Re: [PATCH] of/irq: handle irq_of_parse_and_map() errors

From
Christophe Leroy <hidden>
Date
2024-09-03 16:56:44
Also in
linux-i2c, lkml, stable
Reply to
Ma Ke, 2024-08-30

Le 30/08/2024 à 16:21, Ma Ke a écrit :
Zero and negative number is not a valid IRQ for in-kernel code and the
irq_of_parse_and_map() function returns zero on error.  So this check for
valid IRQs should only accept values > 0.
unsigned int irq_of_parse_and_map(struct device_node *node, int index);

I can't see how an 'unsigned int' can be negative.

Christophe
quoted hunk ↗ jump to hunk
Cc: <redacted>
Fixes: f7578496a671 ("of/irq: Use irq_of_parse_and_map()")
Signed-off-by: Ma Ke <redacted>
---
  drivers/i2c/busses/i2c-cpm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
index 4794ec066eb0..41e3c95c0ef7 100644
--- a/drivers/i2c/busses/i2c-cpm.c
+++ b/drivers/i2c/busses/i2c-cpm.c
@@ -435,7 +435,7 @@ static int cpm_i2c_setup(struct cpm_i2c *cpm)
  	init_waitqueue_head(&cpm->i2c_wait);
  
  	cpm->irq = irq_of_parse_and_map(ofdev->dev.of_node, 0);
-	if (!cpm->irq)
+	if (cpm->irq <= 0)
  		return -EINVAL;
  
  	/* Install interrupt handler. */
  
Thread (4 messages) 4 messages, 4 authors, last reply 2024-09-06
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help