2022-05-02 16:11:30

by Puyou Lu

[permalink] [raw]
Subject: [PATCH] gpio: pca953x: update irq_stat even when irq is not enabled (irq_mask not set).

From: Puyou Lu <[email protected]>

When one port's input state get inverted (eg. from low to hight) after
pca953x_irq_setup but before setting irq_mask (by some other driver such as
"gpio-keys"), the next inversion of this port (eg. from hight to low) will not
triggered any more (because irq_stat is not updated at the first time). Issue
should be fixed after this commit.

Signed-off-by: Puyou Lu <[email protected]>
---
drivers/gpio/gpio-pca953x.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index d2fe76f3f34f..8726921a1129 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -762,11 +762,11 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, unsigned long *pendin
bitmap_xor(cur_stat, new_stat, old_stat, gc->ngpio);
bitmap_and(trigger, cur_stat, chip->irq_mask, gc->ngpio);

+ bitmap_copy(chip->irq_stat, new_stat, gc->ngpio);
+
if (bitmap_empty(trigger, gc->ngpio))
return false;

- bitmap_copy(chip->irq_stat, new_stat, gc->ngpio);
-
bitmap_and(cur_stat, chip->irq_trig_fall, old_stat, gc->ngpio);
bitmap_and(old_stat, chip->irq_trig_raise, new_stat, gc->ngpio);
bitmap_or(new_stat, old_stat, cur_stat, gc->ngpio);
--
2.17.1


2022-05-06 09:26:46

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH] gpio: pca953x: update irq_stat even when irq is not enabled (irq_mask not set).

On Sun, May 1, 2022 at 11:22 AM Puyou Lu <[email protected]> wrote:
>
> From: Puyou Lu <[email protected]>
>
> When one port's input state get inverted (eg. from low to hight) after
> pca953x_irq_setup but before setting irq_mask (by some other driver such as
> "gpio-keys"), the next inversion of this port (eg. from hight to low) will not
> triggered any more (because irq_stat is not updated at the first time). Issue
> should be fixed after this commit.
>
> Signed-off-by: Puyou Lu <[email protected]>
> ---
> drivers/gpio/gpio-pca953x.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index d2fe76f3f34f..8726921a1129 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -762,11 +762,11 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, unsigned long *pendin
> bitmap_xor(cur_stat, new_stat, old_stat, gc->ngpio);
> bitmap_and(trigger, cur_stat, chip->irq_mask, gc->ngpio);
>
> + bitmap_copy(chip->irq_stat, new_stat, gc->ngpio);
> +
> if (bitmap_empty(trigger, gc->ngpio))
> return false;
>
> - bitmap_copy(chip->irq_stat, new_stat, gc->ngpio);
> -
> bitmap_and(cur_stat, chip->irq_trig_fall, old_stat, gc->ngpio);
> bitmap_and(old_stat, chip->irq_trig_raise, new_stat, gc->ngpio);
> bitmap_or(new_stat, old_stat, cur_stat, gc->ngpio);
> --
> 2.17.1
>

This needs to Cc stable and a fixes tag.

Bart