All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] gpiolib: acpi: Convert ACPI value of debounce to microseconds
@ 2022-03-07 11:56 Andy Shevchenko
  2022-03-07 12:19 ` Kai-Heng Feng
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andy Shevchenko @ 2022-03-07 11:56 UTC (permalink / raw)
  To: Andy Shevchenko, Bartosz Golaszewski, linux-gpio, linux-acpi,
	linux-kernel
  Cc: Mika Westerberg, Linus Walleij, Hans de Goede, Kai-Heng Feng

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>
---
 drivers/gpio/gpiolib-acpi.c |  6 ++++--
 drivers/gpio/gpiolib.c      | 10 ++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index c0f6a25c3279..a5495ad31c9c 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -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;
 
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index f5e7443208d4..f956c533f218 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2223,6 +2223,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,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 1/1] gpiolib: acpi: Convert ACPI value of debounce to microseconds
  2022-03-07 11:56 [PATCH v1 1/1] gpiolib: acpi: Convert ACPI value of debounce to microseconds Andy Shevchenko
@ 2022-03-07 12:19 ` Kai-Heng Feng
  2022-03-07 12:48 ` Bartosz Golaszewski
  2022-03-07 13:56 ` Mika Westerberg
  2 siblings, 0 replies; 7+ messages in thread
From: Kai-Heng Feng @ 2022-03-07 12:19 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Bartosz Golaszewski, linux-gpio, linux-acpi, linux-kernel,
	Mika Westerberg, Linus Walleij, Hans de Goede

On Mon, Mar 7, 2022 at 7:56 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> 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>

This works for me. Thanks!

Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

> ---
>  drivers/gpio/gpiolib-acpi.c |  6 ++++--
>  drivers/gpio/gpiolib.c      | 10 ++++++++++
>  2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index c0f6a25c3279..a5495ad31c9c 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -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;
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index f5e7443208d4..f956c533f218 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -2223,6 +2223,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,
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 1/1] gpiolib: acpi: Convert ACPI value of debounce to microseconds
  2022-03-07 11:56 [PATCH v1 1/1] gpiolib: acpi: Convert ACPI value of debounce to microseconds Andy Shevchenko
  2022-03-07 12:19 ` Kai-Heng Feng
@ 2022-03-07 12:48 ` Bartosz Golaszewski
  2022-03-07 13:48   ` Andy Shevchenko
  2022-03-07 13:56 ` Mika Westerberg
  2 siblings, 1 reply; 7+ messages in thread
From: Bartosz Golaszewski @ 2022-03-07 12:48 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: open list:GPIO SUBSYSTEM, ACPI Devel Maling List,
	Linux Kernel Mailing List, Mika Westerberg, Linus Walleij,
	Hans de Goede, Kai-Heng Feng

On Mon, Mar 7, 2022 at 12:56 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> 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>
> ---
>  drivers/gpio/gpiolib-acpi.c |  6 ++++--
>  drivers/gpio/gpiolib.c      | 10 ++++++++++
>  2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index c0f6a25c3279..a5495ad31c9c 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -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;
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index f5e7443208d4..f956c533f218 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -2223,6 +2223,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,
> --
> 2.34.1
>

Do you have some more stuff coming up for fixes or do you want me to
queue it directly?

Bart

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 1/1] gpiolib: acpi: Convert ACPI value of debounce to microseconds
  2022-03-07 12:48 ` Bartosz Golaszewski
@ 2022-03-07 13:48   ` Andy Shevchenko
  2022-03-07 14:33     ` Bartosz Golaszewski
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2022-03-07 13:48 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: open list:GPIO SUBSYSTEM, ACPI Devel Maling List,
	Linux Kernel Mailing List, Mika Westerberg, Linus Walleij,
	Hans de Goede, Kai-Heng Feng

On Mon, Mar 07, 2022 at 01:48:10PM +0100, Bartosz Golaszewski wrote:
> On Mon, Mar 7, 2022 at 12:56 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > 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.

> Do you have some more stuff coming up for fixes

I don't think so.

> or do you want me to queue it directly?

Yes, please take it directly, thanks!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 1/1] gpiolib: acpi: Convert ACPI value of debounce to microseconds
  2022-03-07 11:56 [PATCH v1 1/1] gpiolib: acpi: Convert ACPI value of debounce to microseconds Andy Shevchenko
  2022-03-07 12:19 ` Kai-Heng Feng
  2022-03-07 12:48 ` Bartosz Golaszewski
@ 2022-03-07 13:56 ` Mika Westerberg
  2 siblings, 0 replies; 7+ messages in thread
From: Mika Westerberg @ 2022-03-07 13:56 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Bartosz Golaszewski, linux-gpio, linux-acpi, linux-kernel,
	Linus Walleij, Hans de Goede, Kai-Heng Feng

On Mon, Mar 07, 2022 at 01:56:23PM +0200, Andy Shevchenko wrote:
> 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>

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 1/1] gpiolib: acpi: Convert ACPI value of debounce to microseconds
  2022-03-07 13:48   ` Andy Shevchenko
@ 2022-03-07 14:33     ` Bartosz Golaszewski
  2022-03-07 16:38       ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Bartosz Golaszewski @ 2022-03-07 14:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: open list:GPIO SUBSYSTEM, ACPI Devel Maling List,
	Linux Kernel Mailing List, Mika Westerberg, Linus Walleij,
	Hans de Goede, Kai-Heng Feng

On Mon, Mar 7, 2022 at 2:49 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Mon, Mar 07, 2022 at 01:48:10PM +0100, Bartosz Golaszewski wrote:
> > On Mon, Mar 7, 2022 at 12:56 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > > 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.
>
> > Do you have some more stuff coming up for fixes
>
> I don't think so.
>
> > or do you want me to queue it directly?
>
> Yes, please take it directly, thanks!
>
> --
> With Best Regards,
> Andy Shevchenko
>
>

Applied, thanks!

Bart

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 1/1] gpiolib: acpi: Convert ACPI value of debounce to microseconds
  2022-03-07 14:33     ` Bartosz Golaszewski
@ 2022-03-07 16:38       ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2022-03-07 16:38 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: open list:GPIO SUBSYSTEM, ACPI Devel Maling List,
	Linux Kernel Mailing List, Mika Westerberg, Linus Walleij,
	Hans de Goede, Kai-Heng Feng

On Mon, Mar 07, 2022 at 03:33:43PM +0100, Bartosz Golaszewski wrote:
> On Mon, Mar 7, 2022 at 2:49 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Mon, Mar 07, 2022 at 01:48:10PM +0100, Bartosz Golaszewski wrote:
> > > On Mon, Mar 7, 2022 at 12:56 PM Andy Shevchenko
> > > <andriy.shevchenko@linux.intel.com> wrote:

...

> > > Do you have some more stuff coming up for fixes
> >
> > I don't think so.

Hmm... As a matter of fact, one small fix is on its way since I noticed during
compilation test of the above.

...

> Applied, thanks!

Thank you!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-03-07 16:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07 11:56 [PATCH v1 1/1] gpiolib: acpi: Convert ACPI value of debounce to microseconds Andy Shevchenko
2022-03-07 12:19 ` Kai-Heng Feng
2022-03-07 12:48 ` Bartosz Golaszewski
2022-03-07 13:48   ` Andy Shevchenko
2022-03-07 14:33     ` Bartosz Golaszewski
2022-03-07 16:38       ` Andy Shevchenko
2022-03-07 13:56 ` Mika Westerberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.