diff options
author | Arturas Moskvinas <arturas.moskvinas@gmail.com> | 2024-02-01 16:14:07 +0200 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2024-02-09 14:32:47 +0100 |
commit | 2c0aafdf4a7c9e6381bcaa7d8aa2e90e42b028d7 (patch) | |
tree | f4c8c0b1b9d6c4eaf65ae12ea4071a443f24d9dc /drivers/pinctrl/pinctrl-mcp23s08.c | |
parent | 8e4cc358223df13c8842e9a71961a00d0652f341 (diff) |
pinctrl: mcp23s08: Check only GPIOs which have interrupts enabled
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>
Link: https://lore.kernel.org/r/20240201141406.32484-2-arturas.moskvinas@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-mcp23s08.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-mcp23s08.c | 15 |
1 files 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 |