Skip to content

Commit 660c619

Browse files
andy-shevbrgl
authored andcommitted
gpiolib: acpi: Convert ACPI value of debounce to microseconds
It appears that GPIO ACPI library uses ACPI debounce values directly. However, the GPIO library APIs expect the debounce timeout to be in microseconds. Convert ACPI value of debounce to microseconds. While at it, document this detail where it is appropriate. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215664 Reported-by: Kai-Heng Feng <kai.heng.feng@canonical.com> Fixes: 8dcb7a1 ("gpiolib: acpi: Take into account debounce settings") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
1 parent fc328a7 commit 660c619

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

drivers/gpio/gpiolib-acpi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip,
307307
if (IS_ERR(desc))
308308
return desc;
309309

310-
ret = gpio_set_debounce_timeout(desc, agpio->debounce_timeout);
310+
/* ACPI uses hundredths of milliseconds units */
311+
ret = gpio_set_debounce_timeout(desc, agpio->debounce_timeout * 10);
311312
if (ret)
312313
dev_warn(chip->parent,
313314
"Failed to set debounce-timeout for pin 0x%04X, err %d\n",
@@ -1035,7 +1036,8 @@ int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int ind
10351036
if (ret < 0)
10361037
return ret;
10371038

1038-
ret = gpio_set_debounce_timeout(desc, info.debounce);
1039+
/* ACPI uses hundredths of milliseconds units */
1040+
ret = gpio_set_debounce_timeout(desc, info.debounce * 10);
10391041
if (ret)
10401042
return ret;
10411043

drivers/gpio/gpiolib.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,16 @@ static int gpio_set_bias(struct gpio_desc *desc)
22172217
return gpio_set_config_with_argument_optional(desc, bias, arg);
22182218
}
22192219

2220+
/**
2221+
* gpio_set_debounce_timeout() - Set debounce timeout
2222+
* @desc: GPIO descriptor to set the debounce timeout
2223+
* @debounce: Debounce timeout in microseconds
2224+
*
2225+
* The function calls the certain GPIO driver to set debounce timeout
2226+
* in the hardware.
2227+
*
2228+
* Returns 0 on success, or negative error code otherwise.
2229+
*/
22202230
int gpio_set_debounce_timeout(struct gpio_desc *desc, unsigned int debounce)
22212231
{
22222232
return gpio_set_config_with_argument_optional(desc,

0 commit comments

Comments
 (0)