From: Arturas Moskvinas <arturas.moskvinas@gmail.com>
To: linus.walleij@linaro.org, biju.das.jz@bp.renesas.com,
akaessens@gmail.com, thomas.preston@codethink.co.uk,
andriy.shevchenko@linux.intel.com, preid@electromag.com.au,
u.kleine-koenig@pengutronix.de
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Arturas Moskvinas <arturas.moskvinas@gmail.com>
Subject: [PATCH v2] pinctrl: mcp23s08: Check only GPIOs which have interrupts enabled
Date: Thu, 1 Feb 2024 16:14:07 +0200 [thread overview]
Message-ID: <20240201141406.32484-2-arturas.moskvinas@gmail.com> (raw)
GPINTEN register contains information about GPIOs with enabled
interrupts no need to check other GPIOs for changes.
Signed-off-by: Arturas Moskvinas <arturas.moskvinas@gmail.com>
---
drivers/pinctrl/pinctrl-mcp23s08.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
index 4551575e4e7d..38c3a14c8b58 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08.c
@@ -375,7 +375,8 @@ mcp23s08_direction_output(struct gpio_chip *chip, unsigned offset, int value)
static irqreturn_t mcp23s08_irq(int irq, void *data)
{
struct mcp23s08 *mcp = data;
- int intcap, intcon, intf, i, gpio, gpio_orig, intcap_mask, defval;
+ int intcap, intcon, intf, i, gpio, gpio_orig, intcap_mask, defval, gpinten;
+ unsigned long int enabled_interrupts;
unsigned int child_irq;
bool intf_set, intcap_changed, gpio_bit_changed,
defval_changed, gpio_set;
@@ -395,6 +396,9 @@ static irqreturn_t mcp23s08_irq(int irq, void *data)
if (mcp_read(mcp, MCP_INTCON, &intcon))
goto unlock;
+ if (mcp_read(mcp, MCP_GPINTEN, &gpinten))
+ goto unlock;
+
if (mcp_read(mcp, MCP_DEFVAL, &defval))
goto unlock;
@@ -410,9 +414,12 @@ static irqreturn_t mcp23s08_irq(int irq, void *data)
"intcap 0x%04X intf 0x%04X gpio_orig 0x%04X gpio 0x%04X\n",
intcap, intf, gpio_orig, gpio);
- for (i = 0; i < mcp->chip.ngpio; i++) {
- /* We must check all of the inputs on the chip,
- * otherwise we may not notice a change on >=2 pins.
+ enabled_interrupts = gpinten;
+ for_each_set_bit(i, &enabled_interrupts, mcp->chip.ngpio) {
+ /*
+ * We must check all of the inputs with enabled interrupts
+ * on the chip, otherwise we may not notice a change
+ * on more than one pin.
*
* On at least the mcp23s17, INTCAP is only updated
* one byte at a time(INTCAPA and INTCAPB are
base-commit: 41bccc98fb7931d63d03f326a746ac4d429c1dd3
--
2.43.0
next reply other threads:[~2024-02-01 14:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 14:14 Arturas Moskvinas [this message]
2024-02-01 14:30 ` Andy Shevchenko
2024-02-02 10:40 ` Arturas Moskvinas
2024-02-08 13:46 ` Linus Walleij
2024-02-05 13:56 Andy Shevchenko
2024-02-07 10:50 ` Arturas Moskvinas
2024-02-07 14:48 ` Andy Shevchenko
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=20240201141406.32484-2-arturas.moskvinas@gmail.com \
--to=arturas.moskvinas@gmail.com \
--cc=akaessens@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=preid@electromag.com.au \
--cc=thomas.preston@codethink.co.uk \
--cc=u.kleine-koenig@pengutronix.de \
/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
all inboxes | Powered by JetHome®