]> git.baikalelectronics.ru Git - kernel.git/commitdiff
gpiolib: acpi: Convert ACPI value of debounce to microseconds
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 7 Mar 2022 11:56:23 +0000 (13:56 +0200)
committerBartosz Golaszewski <brgl@bgdev.pl>
Mon, 7 Mar 2022 14:25:27 +0000 (15:25 +0100)
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: 8dcb7a15a585 ("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>
drivers/gpio/gpiolib-acpi.c
drivers/gpio/gpiolib.c

index c0f6a25c327944b26489f24f72ac41a768291a9b..a5495ad31c9ce6ad8b523fadeba6b83a3e9403a1 100644 (file)
@@ -307,7 +307,8 @@ static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip,
        if (IS_ERR(desc))
                return desc;
 
-       ret = gpio_set_debounce_timeout(desc, agpio->debounce_timeout);
+       /* ACPI uses hundredths of milliseconds units */
+       ret = gpio_set_debounce_timeout(desc, agpio->debounce_timeout * 10);
        if (ret)
                dev_warn(chip->parent,
                         "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
                        if (ret < 0)
                                return ret;
 
-                       ret = gpio_set_debounce_timeout(desc, info.debounce);
+                       /* ACPI uses hundredths of milliseconds units */
+                       ret = gpio_set_debounce_timeout(desc, info.debounce * 10);
                        if (ret)
                                return ret;
 
index 005642068c0b5a666fe1c1a82fddd6258d0ddc23..defb7c464b875301ae7866d2652e4369a762f412 100644 (file)
@@ -2217,6 +2217,16 @@ static int gpio_set_bias(struct gpio_desc *desc)
        return gpio_set_config_with_argument_optional(desc, bias, arg);
 }
 
+/**
+ * gpio_set_debounce_timeout() - Set debounce timeout
+ * @desc:      GPIO descriptor to set the debounce timeout
+ * @debounce:  Debounce timeout in microseconds
+ *
+ * The function calls the certain GPIO driver to set debounce timeout
+ * in the hardware.
+ *
+ * Returns 0 on success, or negative error code otherwise.
+ */
 int gpio_set_debounce_timeout(struct gpio_desc *desc, unsigned int debounce)
 {
        return gpio_set_config_with_argument_optional(desc,