Skip to contentSkip to conversation

gpiolib: cdev: clear debounce period if line set to output

PATCH In review Kent Gibson 3 participants 3 messages Jan 21, 2021 – Jan 27, 2021

Subsystems (2)
lore
Share & tools
lore

Kent Gibson

author reviewer
#0 lore raw

PATCH 1/1 gpiolib: cdev: clear debounce period if line set to output

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")

---
 drivers/gpio/gpiolib-cdev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpio/gpiolib-cdev.c +2 -0
index 12b679ca552c..3551aaf5a361 100644
@@ -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() */
 }
 
Signature · 1 line
2.30.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · 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")

Yours,
Linus Walleij

#2 lore raw
In reply to Kent Gibson
Quoted 10 lines · 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")

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

Patch applied for fixes, thanks!

Bartosz

Quoted 21 lines
---
 drivers/gpio/gpiolib-cdev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpio/gpiolib-cdev.c +2 -1
index 12b679ca552c..3551aaf5a361 100644
@@ -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