Message ID | 1510502480-27117-1-git-send-email-bianpan2016@163.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi, On Mon, Nov 13, 2017 at 12:01:20AM +0800, Pan Bian wrote: > 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 <bianpan2016@163.com> > --- Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> -- Sebastian > drivers/iio/adc/cpcap-adc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c > index 6e419d5..f153e026 100644 > --- a/drivers/iio/adc/cpcap-adc.c > +++ b/drivers/iio/adc/cpcap-adc.c > @@ -1012,7 +1012,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, > -- > 1.9.1 > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
* Sebastian Reichel <sre@kernel.org> [171112 18:30]: > Hi, > > On Mon, Nov 13, 2017 at 12:01:20AM +0800, Pan Bian wrote: > > 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 <bianpan2016@163.com> > > --- > > Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Acked-by: Tony Lindgren <tony@atomide.com> -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, 13 Nov 2017 10:49:03 -0800 Tony Lindgren <tony@atomide.com> wrote: > * Sebastian Reichel <sre@kernel.org> [171112 18:30]: > > Hi, > > > > On Mon, Nov 13, 2017 at 12:01:20AM +0800, Pan Bian wrote: > > > 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 <bianpan2016@163.com> > > > --- > > > > Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> > > Acked-by: Tony Lindgren <tony@atomide.com> Applied to the fixes-togreg branch of iio.git. Thanks, Jonathan -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c index 6e419d5..f153e026 100644 --- a/drivers/iio/adc/cpcap-adc.c +++ b/drivers/iio/adc/cpcap-adc.c @@ -1012,7 +1012,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,
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 <bianpan2016@163.com> --- drivers/iio/adc/cpcap-adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)