diff mbox series

[3/5] i2c: pmcmsp: fix-IRQ-check

Message ID 31a2d0c2-8069-6a73-ef7e-40e1146d5c56@omp.ru
State New
Headers show
Series [1/5] i2c: hix5hd2: fix IRQ check | expand

Commit Message

Sergey Shtylyov June 23, 2021, 8:58 p.m. UTC
The driver's probe() method is written as if platform_get_irq() returns 0
on error, while actually it returns a negative error code (with all the
other values considered valid IRQs).  Rewrite the driver's IRQ checking
code to pass the positive IRQ #s to request_irq(), propagate -EPROBE_DEFER
upstream, and use the polling mode when platform_get_irq() returns negative
error code or 0...

Fixes: 1b144df1d7d6 ("i2c: New PMC MSP71xx TWI bus driver")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

---
 drivers/i2c/busses/i2c-pmcmsp.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

Index: linux/drivers/i2c/busses/i2c-pmcmsp.c
===================================================================
--- linux.orig/drivers/i2c/busses/i2c-pmcmsp.c
+++ linux/drivers/i2c/busses/i2c-pmcmsp.c
@@ -291,8 +291,13 @@  static int pmcmsptwi_probe(struct platfo
 	}
 
 	/* request the irq */
-	pmcmsptwi_data.irq = platform_get_irq(pldev, 0);
-	if (pmcmsptwi_data.irq) {
+	rc = platform_get_irq(pldev, 0);
+	if (rc == -EPROBE_DEFER)
+		return rc;
+	if (rc <= 0) {
+		pmcmsptwi_data.irq = 0;
+	} else {
+		pmcmsptwi_data.irq = rc;
 		rc = request_irq(pmcmsptwi_data.irq, &pmcmsptwi_interrupt,
 				 IRQF_SHARED, pldev->name, &pmcmsptwi_data);
 		if (rc == 0) {