Linux-GPIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/2] gpio: max77620: Fixup debounce delays
@ 2019-11-08 16:07 Thierry Reding
  2019-11-08 16:07 ` [PATCH 2/2] gpio: bd70528: Use correct unit for debounce times Thierry Reding
  2019-11-08 20:54 ` [PATCH 1/2] gpio: max77620: Fixup debounce delays Pavel Machek
  0 siblings, 2 replies; 5+ messages in thread
From: Thierry Reding @ 2019-11-08 16:07 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski; +Cc: Pavel Machek, linux-gpio, linux-kernel

From: Thierry Reding <treding@nvidia.com>

When converting milliseconds to microseconds in commit fffa6af94894
("gpio: max77620: Use correct unit for debounce times") some ~1 ms gaps
were introduced between the various ranges supported by the controller.
Fix this by changing the start of each range to the value immediately
following the end of the previous range. This way a debounce time of,
say 8250 us will translate into 16 ms instead of returning an -EINVAL
error.

Typically the debounce delay is only ever set through device tree and
specified in milliseconds, so we can never really hit this issue because
debounce times are always a multiple of 1000 us.

The only notable exception for this is drivers/mmc/host/mmc-spi.c where
the CD GPIO is requested, which passes a 1 us debounce time. According
to a comment preceeding that code this should actually be 1 ms (i.e.
1000 us).

Reported-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpio/gpio-max77620.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-max77620.c b/drivers/gpio/gpio-max77620.c
index c5b64a4ac172..313bd02dd893 100644
--- a/drivers/gpio/gpio-max77620.c
+++ b/drivers/gpio/gpio-max77620.c
@@ -198,13 +198,13 @@ static int max77620_gpio_set_debounce(struct max77620_gpio *mgpio,
 	case 0:
 		val = MAX77620_CNFG_GPIO_DBNC_None;
 		break;
-	case 1000 ... 8000:
+	case 1 ... 8000:
 		val = MAX77620_CNFG_GPIO_DBNC_8ms;
 		break;
-	case 9000 ... 16000:
+	case 8001 ... 16000:
 		val = MAX77620_CNFG_GPIO_DBNC_16ms;
 		break;
-	case 17000 ... 32000:
+	case 16001 ... 32000:
 		val = MAX77620_CNFG_GPIO_DBNC_32ms;
 		break;
 	default:
-- 
2.23.0


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

* [PATCH 2/2] gpio: bd70528: Use correct unit for debounce times
  2019-11-08 16:07 [PATCH 1/2] gpio: max77620: Fixup debounce delays Thierry Reding
@ 2019-11-08 16:07 ` Thierry Reding
  2019-11-12 10:20   ` Bartosz Golaszewski
  2019-11-08 20:54 ` [PATCH 1/2] gpio: max77620: Fixup debounce delays Pavel Machek
  1 sibling, 1 reply; 5+ messages in thread
From: Thierry Reding @ 2019-11-08 16:07 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski; +Cc: Pavel Machek, linux-gpio, linux-kernel

From: Thierry Reding <treding@nvidia.com>

The debounce time passed to gpiod_set_debounce() is specifid in
microseconds, so make sure to use the correct unit when computing the
register values, which denote delays in milliseconds.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpio/gpio-bd70528.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-bd70528.c b/drivers/gpio/gpio-bd70528.c
index d934d23b77c6..d29cbd3c9e53 100644
--- a/drivers/gpio/gpio-bd70528.c
+++ b/drivers/gpio/gpio-bd70528.c
@@ -25,13 +25,13 @@ static int bd70528_set_debounce(struct bd70528_gpio *bdgpio,
 	case 0:
 		val = BD70528_DEBOUNCE_DISABLE;
 		break;
-	case 1 ... 15:
+	case 1 ... 15000:
 		val = BD70528_DEBOUNCE_15MS;
 		break;
-	case 16 ... 30:
+	case 15001 ... 30000:
 		val = BD70528_DEBOUNCE_30MS;
 		break;
-	case 31 ... 50:
+	case 30001 ... 50000:
 		val = BD70528_DEBOUNCE_50MS;
 		break;
 	default:
-- 
2.23.0


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

* Re: [PATCH 1/2] gpio: max77620: Fixup debounce delays
  2019-11-08 16:07 [PATCH 1/2] gpio: max77620: Fixup debounce delays Thierry Reding
  2019-11-08 16:07 ` [PATCH 2/2] gpio: bd70528: Use correct unit for debounce times Thierry Reding
@ 2019-11-08 20:54 ` Pavel Machek
  2019-11-12 10:16   ` Bartosz Golaszewski
  1 sibling, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2019-11-08 20:54 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Linus Walleij, Bartosz Golaszewski, Pavel Machek, linux-gpio,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1934 bytes --]

On Fri 2019-11-08 17:07:46, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> When converting milliseconds to microseconds in commit fffa6af94894
> ("gpio: max77620: Use correct unit for debounce times") some ~1 ms gaps
> were introduced between the various ranges supported by the controller.
> Fix this by changing the start of each range to the value immediately
> following the end of the previous range. This way a debounce time of,
> say 8250 us will translate into 16 ms instead of returning an -EINVAL
> error.
> 
> Typically the debounce delay is only ever set through device tree and
> specified in milliseconds, so we can never really hit this issue because
> debounce times are always a multiple of 1000 us.
> 
> The only notable exception for this is drivers/mmc/host/mmc-spi.c where
> the CD GPIO is requested, which passes a 1 us debounce time. According
> to a comment preceeding that code this should actually be 1 ms (i.e.
> 1000 us).
> 
> Reported-by: Pavel Machek <pavel@denx.de>
> Signed-off-by: Thierry Reding <treding@nvidia.com>

Thanks for doing this!

Acked-by: Pavel Machek <pavel@denx.de>

And I guess this should be cc: stable, as the commit this fixes was
making its way there.

Best regards,
								Pavel


> @@ -198,13 +198,13 @@ static int max77620_gpio_set_debounce(struct max77620_gpio *mgpio,
>  	case 0:
>  		val = MAX77620_CNFG_GPIO_DBNC_None;
>  		break;
> -	case 1000 ... 8000:
> +	case 1 ... 8000:
>  		val = MAX77620_CNFG_GPIO_DBNC_8ms;
>  		break;
> -	case 9000 ... 16000:
> +	case 8001 ... 16000:
>  		val = MAX77620_CNFG_GPIO_DBNC_16ms;
>  		break;
> -	case 17000 ... 32000:
> +	case 16001 ... 32000:
>  		val = MAX77620_CNFG_GPIO_DBNC_32ms;
>  		break;
>  	default:

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH 1/2] gpio: max77620: Fixup debounce delays
  2019-11-08 20:54 ` [PATCH 1/2] gpio: max77620: Fixup debounce delays Pavel Machek
@ 2019-11-12 10:16   ` Bartosz Golaszewski
  0 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2019-11-12 10:16 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Thierry Reding, Linus Walleij, linux-gpio, LKML

pt., 8 lis 2019 o 21:54 Pavel Machek <pavel@denx.de> napisał(a):
>
> On Fri 2019-11-08 17:07:46, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> >
> > When converting milliseconds to microseconds in commit fffa6af94894
> > ("gpio: max77620: Use correct unit for debounce times") some ~1 ms gaps
> > were introduced between the various ranges supported by the controller.
> > Fix this by changing the start of each range to the value immediately
> > following the end of the previous range. This way a debounce time of,
> > say 8250 us will translate into 16 ms instead of returning an -EINVAL
> > error.
> >
> > Typically the debounce delay is only ever set through device tree and
> > specified in milliseconds, so we can never really hit this issue because
> > debounce times are always a multiple of 1000 us.
> >
> > The only notable exception for this is drivers/mmc/host/mmc-spi.c where
> > the CD GPIO is requested, which passes a 1 us debounce time. According
> > to a comment preceeding that code this should actually be 1 ms (i.e.
> > 1000 us).
> >
> > Reported-by: Pavel Machek <pavel@denx.de>
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
>
> Thanks for doing this!
>
> Acked-by: Pavel Machek <pavel@denx.de>
>
> And I guess this should be cc: stable, as the commit this fixes was
> making its way there.
>
> Best regards,
>                                                                 Pavel
>
>
> > @@ -198,13 +198,13 @@ static int max77620_gpio_set_debounce(struct max77620_gpio *mgpio,
> >       case 0:
> >               val = MAX77620_CNFG_GPIO_DBNC_None;
> >               break;
> > -     case 1000 ... 8000:
> > +     case 1 ... 8000:
> >               val = MAX77620_CNFG_GPIO_DBNC_8ms;
> >               break;
> > -     case 9000 ... 16000:
> > +     case 8001 ... 16000:
> >               val = MAX77620_CNFG_GPIO_DBNC_16ms;
> >               break;
> > -     case 17000 ... 32000:
> > +     case 16001 ... 32000:
> >               val = MAX77620_CNFG_GPIO_DBNC_32ms;
> >               break;
> >       default:
>
> --
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

Applied for fixes and marked for stable.

Thanks

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

* Re: [PATCH 2/2] gpio: bd70528: Use correct unit for debounce times
  2019-11-08 16:07 ` [PATCH 2/2] gpio: bd70528: Use correct unit for debounce times Thierry Reding
@ 2019-11-12 10:20   ` Bartosz Golaszewski
  0 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2019-11-12 10:20 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Linus Walleij, Pavel Machek, linux-gpio, LKML

pt., 8 lis 2019 o 17:07 Thierry Reding <thierry.reding@gmail.com> napisał(a):
>
> From: Thierry Reding <treding@nvidia.com>
>
> The debounce time passed to gpiod_set_debounce() is specifid in
> microseconds, so make sure to use the correct unit when computing the
> register values, which denote delays in milliseconds.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/gpio/gpio-bd70528.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-bd70528.c b/drivers/gpio/gpio-bd70528.c
> index d934d23b77c6..d29cbd3c9e53 100644
> --- a/drivers/gpio/gpio-bd70528.c
> +++ b/drivers/gpio/gpio-bd70528.c
> @@ -25,13 +25,13 @@ static int bd70528_set_debounce(struct bd70528_gpio *bdgpio,
>         case 0:
>                 val = BD70528_DEBOUNCE_DISABLE;
>                 break;
> -       case 1 ... 15:
> +       case 1 ... 15000:
>                 val = BD70528_DEBOUNCE_15MS;
>                 break;
> -       case 16 ... 30:
> +       case 15001 ... 30000:
>                 val = BD70528_DEBOUNCE_30MS;
>                 break;
> -       case 31 ... 50:
> +       case 30001 ... 50000:
>                 val = BD70528_DEBOUNCE_50MS;
>                 break;
>         default:
> --
> 2.23.0
>

This fixes commit 18bc64b3aebf ("gpio: Initial support for ROHM
bd70528 GPIO block") present in v5.3 so applied to fixes and marked
for stable.

Bart

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08 16:07 [PATCH 1/2] gpio: max77620: Fixup debounce delays Thierry Reding
2019-11-08 16:07 ` [PATCH 2/2] gpio: bd70528: Use correct unit for debounce times Thierry Reding
2019-11-12 10:20   ` Bartosz Golaszewski
2019-11-08 20:54 ` [PATCH 1/2] gpio: max77620: Fixup debounce delays Pavel Machek
2019-11-12 10:16   ` Bartosz Golaszewski

Linux-GPIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-gpio/0 linux-gpio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-gpio linux-gpio/ https://lore.kernel.org/linux-gpio \
		linux-gpio@vger.kernel.org
	public-inbox-index linux-gpio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-gpio


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git