All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Record interrupt status when an IRQ is masked
@ 2019-07-20 11:31 Tomasz Kazimierz Motyl
  2019-07-20 19:42 ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Tomasz Kazimierz Motyl @ 2019-07-20 11:31 UTC (permalink / raw)
  To: linus.walleij, bgolaszewski, linux-gpio
  Cc: butterfly_tm666, Tomasz Kazimierz Motyl

 When one changes the state of any input pins of a PCA9555 chip before
 setting up the IRQ mask through i.e. SysFS e.g. echo "both" >
 /sys/class/gpio/gpioXYZ/edge the epoll_wait shall not exit on the subsequent
 change of the GPIO state. The reason behind it is that the IRQ status is not
 being saved when the IRQ is masked.

---
 drivers/gpio/gpio-pca953x.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 7e76830b3368..088bef902156 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -716,13 +716,16 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending)
 		trigger[i] = (cur_stat[i] ^ old_stat[i]) & chip->irq_mask[i];
 		if (trigger[i])
 			trigger_seen = true;
+
+    /* We want the current status recorded in the chip->irq stat regardless the
+     * chip->irq_mask setting in order to have a change detected when the interrupt
+     * mask gets changed i.e. echo "both" > /sys/class/gpioXYZ/edge */
+    chip->irq_stat[i] = cur_stat[i];
 	}
 
 	if (!trigger_seen)
 		return false;
 
-	memcpy(chip->irq_stat, cur_stat, NBANK(chip));
-
 	for (i = 0; i < NBANK(chip); i++) {
 		pending[i] = (old_stat[i] & chip->irq_trig_fall[i]) |
 			(cur_stat[i] & chip->irq_trig_raise[i]);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Record interrupt status when an IRQ is masked
  2019-07-20 11:31 [PATCH] Record interrupt status when an IRQ is masked Tomasz Kazimierz Motyl
@ 2019-07-20 19:42 ` Linus Walleij
  2019-10-18  9:18   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2019-07-20 19:42 UTC (permalink / raw)
  To: Tomasz Kazimierz Motyl, Geert Uytterhoeven, Andy Shevchenko,
	Thomas Petazzoni, Marek Vasut
  Cc: Bartosz Golaszewski, open list:GPIO SUBSYSTEM, butterfly_tm666,
	Tomasz Kazimierz Motyl

Looping in some experts on PCA953xx by top posting, sorry.

Linus Walleij

On Sat, Jul 20, 2019 at 1:32 PM Tomasz Kazimierz Motyl
<tomasz.motyl666@gmail.com> wrote:
>
>  When one changes the state of any input pins of a PCA9555 chip before
>  setting up the IRQ mask through i.e. SysFS e.g. echo "both" >
>  /sys/class/gpio/gpioXYZ/edge the epoll_wait shall not exit on the subsequent
>  change of the GPIO state. The reason behind it is that the IRQ status is not
>  being saved when the IRQ is masked.
>
> ---
>  drivers/gpio/gpio-pca953x.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index 7e76830b3368..088bef902156 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -716,13 +716,16 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending)
>                 trigger[i] = (cur_stat[i] ^ old_stat[i]) & chip->irq_mask[i];
>                 if (trigger[i])
>                         trigger_seen = true;
> +
> +    /* We want the current status recorded in the chip->irq stat regardless the
> +     * chip->irq_mask setting in order to have a change detected when the interrupt
> +     * mask gets changed i.e. echo "both" > /sys/class/gpioXYZ/edge */
> +    chip->irq_stat[i] = cur_stat[i];
>         }
>
>         if (!trigger_seen)
>                 return false;
>
> -       memcpy(chip->irq_stat, cur_stat, NBANK(chip));
> -
>         for (i = 0; i < NBANK(chip); i++) {
>                 pending[i] = (old_stat[i] & chip->irq_trig_fall[i]) |
>                         (cur_stat[i] & chip->irq_trig_raise[i]);
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Record interrupt status when an IRQ is masked
  2019-07-20 19:42 ` Linus Walleij
@ 2019-10-18  9:18   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2019-10-18  9:18 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Tomasz Kazimierz Motyl, Geert Uytterhoeven, Thomas Petazzoni,
	Marek Vasut, Bartosz Golaszewski, open list:GPIO SUBSYSTEM,
	butterfly_tm666, Tomasz Kazimierz Motyl

On Sat, Jul 20, 2019 at 09:42:35PM +0200, Linus Walleij wrote:
> Looping in some experts on PCA953xx by top posting, sorry.

NP.

I would like to have my conversion patch be applied first. It will improve
reading of this change I suppose.

P.S. My patch still needs a bit of work, so, I'll send new version.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-18  9:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-20 11:31 [PATCH] Record interrupt status when an IRQ is masked Tomasz Kazimierz Motyl
2019-07-20 19:42 ` Linus Walleij
2019-10-18  9:18   ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.