linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpiolib: cdev: clear debounce period if line set to output
@ 2021-01-21 14:10 Kent Gibson
  2021-01-22 22:49 ` Linus Walleij
  2021-01-27 14:51 ` Bartosz Golaszewski
  0 siblings, 2 replies; 3+ messages in thread
From: Kent Gibson @ 2021-01-21 14:10 UTC (permalink / raw)
  To: linux-kernel, linux-gpio, bgolaszewski, linus.walleij; +Cc: Kent Gibson

When set_config changes a line from input to output debounce is
implicitly disabled, as debounce makes no sense for outputs, but the
debounce period is not being cleared and is still reported in the
line info.

So clear the debounce period when the debouncer is stopped in
edge_detector_stop().

Fixed: 65cff7047640 ("gpiolib: cdev: support setting debounce")
Signed-off-by: Kent Gibson <warthog618@gmail.com>
---
 drivers/gpio/gpiolib-cdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
index 12b679ca552c..3551aaf5a361 100644
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -776,6 +776,8 @@ static void edge_detector_stop(struct line *line)
 	cancel_delayed_work_sync(&line->work);
 	WRITE_ONCE(line->sw_debounced, 0);
 	WRITE_ONCE(line->eflags, 0);
+	if (line->desc)
+		WRITE_ONCE(line->desc->debounce_period_us, 0);
 	/* do not change line->level - see comment in debounced_value() */
 }
 
-- 
2.30.0


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

* Re: [PATCH] gpiolib: cdev: clear debounce period if line set to output
  2021-01-21 14:10 [PATCH] gpiolib: cdev: clear debounce period if line set to output Kent Gibson
@ 2021-01-22 22:49 ` Linus Walleij
  2021-01-27 14:51 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2021-01-22 22:49 UTC (permalink / raw)
  To: Kent Gibson; +Cc: linux-kernel, open list:GPIO SUBSYSTEM, Bartosz Golaszewski

On Thu, Jan 21, 2021 at 3:11 PM Kent Gibson <warthog618@gmail.com> wrote:

> When set_config changes a line from input to output debounce is
> implicitly disabled, as debounce makes no sense for outputs, but the
> debounce period is not being cleared and is still reported in the
> line info.
>
> So clear the debounce period when the debouncer is stopped in
> edge_detector_stop().
>
> Fixed: 65cff7047640 ("gpiolib: cdev: support setting debounce")
> Signed-off-by: Kent Gibson <warthog618@gmail.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH] gpiolib: cdev: clear debounce period if line set to output
  2021-01-21 14:10 [PATCH] gpiolib: cdev: clear debounce period if line set to output Kent Gibson
  2021-01-22 22:49 ` Linus Walleij
@ 2021-01-27 14:51 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2021-01-27 14:51 UTC (permalink / raw)
  To: Kent Gibson; +Cc: LKML, linux-gpio, Linus Walleij

On Thu, Jan 21, 2021 at 3:11 PM Kent Gibson <warthog618@gmail.com> wrote:
>
> When set_config changes a line from input to output debounce is
> implicitly disabled, as debounce makes no sense for outputs, but the
> debounce period is not being cleared and is still reported in the
> line info.
>
> So clear the debounce period when the debouncer is stopped in
> edge_detector_stop().
>
> Fixed: 65cff7047640 ("gpiolib: cdev: support setting debounce")

The actual hash for this commit is 65cff7046406 - I fixed that locally.

Patch applied for fixes, thanks!

Bartosz

> Signed-off-by: Kent Gibson <warthog618@gmail.com>
> ---
>  drivers/gpio/gpiolib-cdev.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> index 12b679ca552c..3551aaf5a361 100644
> --- a/drivers/gpio/gpiolib-cdev.c
> +++ b/drivers/gpio/gpiolib-cdev.c
> @@ -776,6 +776,8 @@ static void edge_detector_stop(struct line *line)
>         cancel_delayed_work_sync(&line->work);
>         WRITE_ONCE(line->sw_debounced, 0);
>         WRITE_ONCE(line->eflags, 0);
> +       if (line->desc)
> +               WRITE_ONCE(line->desc->debounce_period_us, 0);
>         /* do not change line->level - see comment in debounced_value() */
>  }
>
> --
> 2.30.0
>

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

end of thread, other threads:[~2021-01-27 15:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21 14:10 [PATCH] gpiolib: cdev: clear debounce period if line set to output Kent Gibson
2021-01-22 22:49 ` Linus Walleij
2021-01-27 14:51 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).