Skip to content

Commit

Permalink
iio: adc: cpcap: fix incorrect validation
Browse files Browse the repository at this point in the history
Function platform_get_irq_byname() returns a negative error code on
failure, and a zero or positive number on success. However, in function
cpcap_adc_probe(), positive IRQ numbers are also taken as error cases.
Use "if (ddata->irq < 0)" instead of "if (!ddata->irq)" to validate the
return value of platform_get_irq_byname().

Signed-off-by: Pan Bian <[email protected]>
Fixes: 25ec249 ("iio: adc: cpcap: Add minimal support for CPCAP PMIC ADC")
Reviewed-by: Sebastian Reichel <[email protected]>
Acked-by: Tony Lindgren <[email protected]>
Cc: <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
SinkFinder authored and jic23 committed Dec 2, 2017
1 parent 0590cdf commit 81b039e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/iio/adc/cpcap-adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ static int cpcap_adc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, indio_dev);

ddata->irq = platform_get_irq_byname(pdev, "adcdone");
if (!ddata->irq)
if (ddata->irq < 0)
return -ENODEV;

error = devm_request_threaded_irq(&pdev->dev, ddata->irq, NULL,
Expand Down

0 comments on commit 81b039e

Please sign in to comment.