[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAHN=yabQB5jYDd9iQ7s1dMWTScRf3c_zuNtXL8U283+vvenfNA@mail.gmail.com>
Date: Tue, 14 Jan 2025 16:44:33 +0100
From: work work <lakabd.work@...il.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: mark.tomlinson@...iedtelesis.co.nz, brgl@...ev.pl,
linus.walleij@...aro.org, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org, Abderrahim LAKBIR <abderrahim.lakbir@...ia.fr>
Subject: Re: [PATCH] gpio: pca953x: Improve interrupt support
Le mar. 14 janv. 2025 à 10:37, Andy Shevchenko
<andy.shevchenko@...il.com> a écrit :
>
> On Tue, Jan 14, 2025 at 12:03 AM lakabd <lakabd.work@...il.com> wrote:
> >
....
> > + /* Store irq_mask for later use when checking pending IRQs */
> > + bitmap_or(chip->unmasked_interrupts, chip->unmasked_interrupts, chip->irq_mask, gc->ngpio);
>
> This solution has a flaw. Where is any code that clears this new
> bitmap? The code starts with 0 (obviously) and step by step it gets
> saturated to all-1s.
>
Yes indeed, and actually the new bitmap is not necessary at all
because what we need does already exist which is chip->irq_mask (I
noticed it just now!).
chip->irq_mask is updated whenever a pin is masked or unmasked via
pca953x_irq_mask() and pca953x_irq_unmask().
The solution should look like this:
diff --git a/gpio-pca953x.c b/gpio-pca953x.c
index 272febc..29e8c20 100644
--- a/gpio-pca953x.c
+++ b/gpio-pca953x.c
@@ -842,11 +842,6 @@ static bool pca953x_irq_pending(struct
pca953x_chip *chip, unsigned long *pendin
int ret;
if (chip->driver_data & PCA_PCAL) {
- /* Read the current interrupt status from the device */
- ret = pca953x_read_regs(chip, PCAL953X_INT_STAT, trigger);
- if (ret)
- return false;
-
/* Check latched inputs and clear interrupt status */
ret = pca953x_read_regs(chip, chip->regs->input, cur_stat);
if (ret)
@@ -855,7 +850,7 @@ static bool pca953x_irq_pending(struct
pca953x_chip *chip, unsigned long *pendin
/* Apply filter for rising/falling edge selection */
bitmap_replace(new_stat, chip->irq_trig_fall, chip->irq_trig_raise,
cur_stat, gc->ngpio);
- bitmap_and(pending, new_stat, trigger, gc->ngpio);
+ bitmap_and(pending, new_stat, chip->irq_mask, gc->ngpio);
return !bitmap_empty(pending, gc->ngpio);
}
--
Best Regards
Abderrahim LAKBIR
Powered by blists - more mailing lists