From: Sergey Shtylyov <s.shtylyov@omp.ru>
To: <linux-i2c@vger.kernel.org>
Subject: [PATCH v2 3/5] i2c: pmcmsp: fix IRQ check
Date: Sun, 4 Jul 2021 17:41:50 +0300 [thread overview]
Message-ID: <fd0dd13c-2fe7-c954-ff0f-917067c8252c@omp.ru> (raw)
In-Reply-To: <3712e871-bf2f-32c5-f9c2-2968c42087f8@omp.ru>
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() and use polling mode
when platform_get_irq() returns negative error code (or IRQ0)...
Fixes: 1b144df1d7d6 ("i2c: New PMC MSP71xx TWI bus driver")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
Changes in version 2:
- fixed the IRQ validity check, assigning the result of platform_get_irq() call
to the 'rc' variable first;
- merging the code enforcing the polling mode on bad IRQ in one place (after
calling request_irq() and handling its result);
- removed explicit check for the deferred probe, fixed up the patch description
accordingly;
- removed the dashes in the patch subject;
- refreshed the patch.
drivers/i2c/busses/i2c-pmcmsp.c | 8 +++++---
drivers/i2c/busses/i2c-pmcmsp.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
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,9 @@ 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);
+ pmcmsptwi_data.irq = rc;
+ if (rc > 0) {
rc = request_irq(pmcmsptwi_data.irq, &pmcmsptwi_interrupt,
IRQF_SHARED, pldev->name, &pmcmsptwi_data);
if (rc == 0) {
@@ -312,9 +313,14 @@ static int pmcmsptwi_probe(struct platfo
"Could not assign TWI IRQ handler "
"to irq %d (continuing with poll)\n",
pmcmsptwi_data.irq);
- pmcmsptwi_data.irq = 0;
}
}
+ /*
+ * We only get here with a negative rc if either platform_get_irq() or
+ * request_irq() call has failed; we have to enforce the polling mode...
+ */
+ if (rc < 0)
+ pmcmsptwi_data.irq = 0;
init_completion(&pmcmsptwi_data.wait);
mutex_init(&pmcmsptwi_data.lock);
next prev parent reply other threads:[~2021-07-04 14:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-04 14:32 [PATCH v2 0/5] Correctly handle plaform_get_irq()'s result in the i2C drivers Sergey Shtylyov
2021-07-04 14:35 ` [PATCH v2 1/5] i2c: hix5hd2: fix IRQ check Sergey Shtylyov
2021-08-17 20:10 ` Wolfram Sang
2021-07-04 14:38 ` [PATCH v2 2/5] i2c: mt65xx: " Sergey Shtylyov
2021-08-17 20:09 ` Wolfram Sang
2021-08-20 1:46 ` Qii Wang
2021-08-25 21:00 ` Wolfram Sang
2021-07-04 14:41 ` Sergey Shtylyov [this message]
2021-08-17 20:08 ` [PATCH v2 3/5] i2c: pmcmsp: " Wolfram Sang
2021-07-04 14:45 ` [PATCH v2 4/5] i2c: s3c2410: " Sergey Shtylyov
2021-07-05 7:46 ` Krzysztof Kozlowski
2021-08-17 20:08 ` Wolfram Sang
2021-07-04 14:47 ` [PATCH v2 5/5] i2c: xlp9xx: fix main " Sergey Shtylyov
2021-08-17 20:13 ` Wolfram Sang
2021-08-25 21:05 ` Wolfram Sang
2021-08-11 20:12 ` [PATCH v2 0/5] Correctly handle plaform_get_irq()'s result in the i2C drivers Sergey Shtylyov
2021-08-11 20:14 ` Sergey Shtylyov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fd0dd13c-2fe7-c954-ff0f-917067c8252c@omp.ru \
--to=s.shtylyov@omp.ru \
--cc=linux-i2c@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox