Skip to contentSkip to conversation

gpio: omap: Enable software fallback for long debounce periods

PATCH In review Ben Hutchings 2 participants 2 messages Aug 11, 2021 – Aug 12, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: omap: Enable software fallback for long debounce periods

omap2_set_gpio_debounce() currently returns -EINVAL if the debounce period is too long to be handled in hardware. gpiolib provides a software fallback, but it is used only if the driver returns -ENOTSUPP.

* Enable the software fallback by using the expected error code
* Downgrade the log message about this from info to debug, since the error is now handled

---
 drivers/gpio/gpio-omap.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpio/gpio-omap.c +4 -4
index ca23f72165ca..93812480dd0a 100644
@@ -190,7 +190,7 @@ static int omap2_set_gpio_debounce(struct gpio_bank *bank, unsigned offset,
 	if (enable) {
 		debounce = DIV_ROUND_UP(debounce, 31) - 1;
 		if ((debounce & OMAP4_GPIO_DEBOUNCINGTIME_MASK) != debounce)
-			return -EINVAL;
+			return -ENOTSUPP;
 	}
 
 	l = BIT(offset);
@@ -887,9 +887,9 @@ static int omap_gpio_debounce(struct gpio_chip *chip, unsigned offset,
 	raw_spin_unlock_irqrestore(&bank->lock, flags);
 
 	if (ret)
-		dev_info(chip->parent,
-			 "Could not set line %u debounce to %u microseconds (%d)",
-			 offset, debounce, ret);
+		dev_dbg(chip->parent,
+			"Could not set line %u debounce to %u microseconds (%d)",
+			offset, debounce, ret);
 
 	return ret;
 }
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Ben Hutchings

omap2_set_gpio_debounce() currently returns -EINVAL if the debounce period is too long to be handled in hardware. gpiolib provides a software fallback, but it is used only if the driver returns -ENOTSUPP.

* Enable the software fallback by using the expected error code
* Downgrade the log message about this from info to debug, since the error is now handled

Looks good to me: