]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging:iio:lpc32xx_adc: Fix IRQ check
authorLars-Peter Clausen <lars@metafoo.de>
Wed, 16 Oct 2013 20:45:00 +0000 (21:45 +0100)
committerJonathan Cameron <jic23@kernel.org>
Thu, 17 Oct 2013 22:11:45 +0000 (23:11 +0100)
The test in the lpc32xx_adc driver which checks whether the IRQ number returned
by platform_get_irq() has multiple problems. It accepts 0 even though this is an
invalid IRQ. It also rejects IRQ numbers that are larger or equal than NR_IRQS.
First of all drivers should never need to reference NR_IRQS and secondly with
CONFIG_SPARSE_IRQ NR_IRQS is not the upper limit, so the check might reject
valid IRQ numbers. This patch modifies the check to only test against less or
equal to 0.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Roland Stigge <stigge@antcom.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/adc/lpc32xx_adc.c

index ce7ff3e6cd21e5df63f4a6210ff43b250065ec49..ef0a21d8ce15ce76ea4ae39bb72d0523f3bfc230 100644 (file)
@@ -160,7 +160,7 @@ static int lpc32xx_adc_probe(struct platform_device *pdev)
        }
 
        irq = platform_get_irq(pdev, 0);
-       if ((irq < 0) || (irq >= NR_IRQS)) {
+       if (irq <= 0) {
                dev_err(&pdev->dev, "failed getting interrupt resource\n");
                return -EINVAL;
        }