Skip to contentSkip to conversation

staging:iio:lpc32xx_adc: Fix IRQ check

PATCH Applied Lars-Peter Clausen 2 participants 4 messages Oct 16, 2013 – Oct 17, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 staging:iio:lpc32xx_adc: Fix IRQ check

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.

---
 drivers/staging/iio/adc/lpc32xx_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/lpc32xx_adc.c +1 -1
index ce7ff3e..ef0a21d 100644
@@ -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;
 	}
Signature · 1 line
1.8.0
#1 lore raw

PATCH 2/2 staging:iio:spear_adc: Fix IRQ check

The test in the spear_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.

---
 drivers/staging/iio/adc/spear_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/spear_adc.c +1 -1
index e6555b6..970d9ed 100644
@@ -333,7 +333,7 @@ static int spear_adc_probe(struct platform_device *pdev)
 	}
 
 	irq = platform_get_irq(pdev, 0);
-	if ((irq < 0) || (irq >= NR_IRQS)) {
+	if (irq <= 0) {
 		dev_err(dev, "failed getting interrupt resource\n");
 		ret = -EINVAL;
 		goto errout3;
Signature · 1 line
1.8.0
maintainer Applied
#2 lore raw

Re: [PATCH 2/2] staging:iio:spear_adc: Fix IRQ check

Quoted 11 lines · Lars-Peter Clausen

The test in the spear_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.

Applied to the togreg branch of iio.git

Thanks for dealing with this so quickly.

Jonathan

Quoted 18 lines
---
 drivers/staging/iio/adc/spear_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/spear_adc.c +1 -1
index e6555b6..970d9ed 100644
@@ -333,7 +333,7 @@ static int spear_adc_probe(struct platform_device *pdev)
 	}
 
 	irq = platform_get_irq(pdev, 0);
-	if ((irq < 0) || (irq >= NR_IRQS)) {
+	if (irq <= 0) {
 		dev_err(dev, "failed getting interrupt resource\n");
 		ret = -EINVAL;
 		goto errout3;
maintainer Applied
#3 lore raw
In reply to Lars-Peter Clausen
Quoted 11 lines · Lars-Peter Clausen

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.

Applied to the togreg branch of iio.git

Thanks,

Jonathan

Quoted 18 lines
---
 drivers/staging/iio/adc/lpc32xx_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/lpc32xx_adc.c +1 -1
index ce7ff3e..ef0a21d 100644
@@ -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;
 	}