diff mbox series

[BACKPORT,5.10] gpiolib: cdev: clear debounce period if line set to output

Message ID 20210208233325.6087-1-warthog618@gmail.com
State New
Headers show
Series [BACKPORT,5.10] gpiolib: cdev: clear debounce period if line set to output | expand

Commit Message

Kent Gibson Feb. 8, 2021, 11:33 p.m. UTC
commit 03a58ea5905fdbd93ff9e52e670d802600ba38cd upstream.

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().

Fixes: 65cff7046406 ("gpiolib: cdev: support setting debounce")
Cc: stable@vger.kernel.org
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpiolib-cdev.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Greg KH Feb. 10, 2021, 2:10 p.m. UTC | #1
On Tue, Feb 09, 2021 at 07:33:25AM +0800, Kent Gibson wrote:
> commit 03a58ea5905fdbd93ff9e52e670d802600ba38cd upstream.

> 

> 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().

> 

> Fixes: 65cff7046406 ("gpiolib: cdev: support setting debounce")

> Cc: stable@vger.kernel.org

> Signed-off-by: Kent Gibson <warthog618@gmail.com>

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

> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

> ---

>  drivers/gpio/gpiolib-cdev.c | 2 ++

>  1 file changed, 2 insertions(+)


Now applied, thanks.

greg k-h
diff mbox series

Patch

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
@@ -756,6 +756,8 @@  static void edge_detector_stop(struct line *line)
 	cancel_delayed_work_sync(&line->work);
 	WRITE_ONCE(line->sw_debounced, 0);
 	line->eflags = 0;
+	if (line->desc)
+		WRITE_ONCE(line->desc->debounce_period_us, 0);
 	/* do not change line->level - see comment in debounced_value() */
 }