Skip to content

Commit e4a77f9

Browse files
Hans de Goedeandy-shev
authored andcommitted
gpiolib: acpi: Make set debounce errors non fatal
Commit 16c0734 ("gpiolib: acpi: Program debounce when finding GPIO") adds a gpio_set_debounce_timeout() call to acpi_find_gpio() and makes acpi_find_gpio() fail if this fails. But gpio_set_debounce_timeout() failing is a somewhat normal occurrence, since not all debounce values are supported on all GPIO/pinctrl chips. Making this an error for example break getting the card-detect GPIO for the micro-sd slot found on many Bay Trail tablets, breaking support for the micro-sd slot on these tablets. acpi_request_own_gpiod() already treats gpio_set_debounce_timeout() failures as non-fatal, just warning about them. Add a acpi_gpio_set_debounce_timeout() helper which wraps gpio_set_debounce_timeout() and warns on failures and replace both existing gpio_set_debounce_timeout() calls with the helper. Since the helper only warns on failures this fixes the card-detect issue. Fixes: 16c0734 ("gpiolib: acpi: Program debounce when finding GPIO") Cc: stable@vger.kernel.org Cc: Mario Limonciello <superm1@kernel.org> Signed-off-by: Hans de Goede <hansg@kernel.org> Acked-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/stable/20250920201200.20611-1-hansg%40kernel.org Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
1 parent 3a86608 commit e4a77f9

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

drivers/gpio/gpiolib-acpi-core.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,19 @@ acpi_gpio_to_gpiod_flags(const struct acpi_resource_gpio *agpio, int polarity)
291291
return GPIOD_ASIS;
292292
}
293293

294+
static void acpi_gpio_set_debounce_timeout(struct gpio_desc *desc,
295+
unsigned int acpi_debounce)
296+
{
297+
int ret;
298+
299+
/* ACPI uses hundredths of milliseconds units */
300+
acpi_debounce *= 10;
301+
ret = gpio_set_debounce_timeout(desc, acpi_debounce);
302+
if (ret)
303+
gpiod_warn(desc, "Failed to set debounce-timeout %u: %d\n",
304+
acpi_debounce, ret);
305+
}
306+
294307
static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip,
295308
struct acpi_resource_gpio *agpio,
296309
unsigned int index,
@@ -300,18 +313,12 @@ static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip,
300313
enum gpiod_flags flags = acpi_gpio_to_gpiod_flags(agpio, polarity);
301314
unsigned int pin = agpio->pin_table[index];
302315
struct gpio_desc *desc;
303-
int ret;
304316

305317
desc = gpiochip_request_own_desc(chip, pin, label, polarity, flags);
306318
if (IS_ERR(desc))
307319
return desc;
308320

309-
/* ACPI uses hundredths of milliseconds units */
310-
ret = gpio_set_debounce_timeout(desc, agpio->debounce_timeout * 10);
311-
if (ret)
312-
dev_warn(chip->parent,
313-
"Failed to set debounce-timeout for pin 0x%04X, err %d\n",
314-
pin, ret);
321+
acpi_gpio_set_debounce_timeout(desc, agpio->debounce_timeout);
315322

316323
return desc;
317324
}
@@ -944,7 +951,6 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
944951
bool can_fallback = acpi_can_fallback_to_crs(adev, con_id);
945952
struct acpi_gpio_info info = {};
946953
struct gpio_desc *desc;
947-
int ret;
948954

949955
desc = __acpi_find_gpio(fwnode, con_id, idx, can_fallback, &info);
950956
if (IS_ERR(desc))
@@ -959,10 +965,7 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
959965
acpi_gpio_update_gpiod_flags(dflags, &info);
960966
acpi_gpio_update_gpiod_lookup_flags(lookupflags, &info);
961967

962-
/* ACPI uses hundredths of milliseconds units */
963-
ret = gpio_set_debounce_timeout(desc, info.debounce * 10);
964-
if (ret)
965-
return ERR_PTR(ret);
968+
acpi_gpio_set_debounce_timeout(desc, info.debounce);
966969

967970
return desc;
968971
}

0 commit comments

Comments
 (0)