power: supply: cpcap-charger: fix incorrect return value check
authorPan Bian <bianpan2016@163.com>
Sun, 12 Nov 2017 15:52:02 +0000 (23:52 +0800)
committerSebastian Reichel <sebastian.reichel@collabora.co.uk>
Mon, 13 Nov 2017 10:56:12 +0000 (11:56 +0100)
Function platform_get_irq_byname() returns a negative error code on
failure, and a zero or positive number on success. However, in function
cpcap_usb_init_irq(), positive IRQ numbers are also taken as error
cases. Use "if (irq < 0)" instead of "if (!irq)" to validate the return
value of platform_get_irq_byname().

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
drivers/power/supply/cpcap-charger.c

index 11a07633de6cd81abb55dc0ce17ae7e8e6691294..e4905bef26637aa567c01ed2cf018dc948a3ecaf 100644 (file)
@@ -484,7 +484,7 @@ static int cpcap_usb_init_irq(struct platform_device *pdev,
        int irq, error;
 
        irq = platform_get_irq_byname(pdev, name);
-       if (!irq)
+       if (irq < 0)
                return -ENODEV;
 
        error = devm_request_threaded_irq(ddata->dev, irq, NULL,