2023-10-03 07:40:03

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH] gpio: aspeed: fix the GPIO number passed to pinctrl_gpio_set_config()

From: Bartosz Golaszewski <[email protected]>

pinctrl_gpio_set_config() expects the GPIO number from the global GPIO
numberspace, not the controller-relative offset, which needs to be added
to the chip base.

Fixes: 5ae4cb94b313 ("gpio: aspeed: Add debounce support")
Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/gpio/gpio-aspeed.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
index da33bbbdacb9..58f107194fda 100644
--- a/drivers/gpio/gpio-aspeed.c
+++ b/drivers/gpio/gpio-aspeed.c
@@ -973,7 +973,7 @@ static int aspeed_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
else if (param == PIN_CONFIG_BIAS_DISABLE ||
param == PIN_CONFIG_BIAS_PULL_DOWN ||
param == PIN_CONFIG_DRIVE_STRENGTH)
- return pinctrl_gpio_set_config(offset, config);
+ return pinctrl_gpio_set_config(chip->base + offset, config);
else if (param == PIN_CONFIG_DRIVE_OPEN_DRAIN ||
param == PIN_CONFIG_DRIVE_OPEN_SOURCE)
/* Return -ENOTSUPP to trigger emulation, as per datasheet */
--
2.39.2


2023-10-03 08:55:17

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH] gpio: aspeed: fix the GPIO number passed to pinctrl_gpio_set_config()

On Tue, Oct 03, 2023 at 09:39:26AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> pinctrl_gpio_set_config() expects the GPIO number from the global GPIO
> numberspace, not the controller-relative offset, which needs to be added
> to the chip base.

Right, because it has no clue what chip this offset is related to.
Reviewed-by: Andy Shevchenko <[email protected]>

--
With Best Regards,
Andy Shevchenko


2023-10-05 01:12:46

by Andrew Jeffery

[permalink] [raw]
Subject: Re: [PATCH] gpio: aspeed: fix the GPIO number passed to pinctrl_gpio_set_config()

On Tue, 2023-10-03 at 09:39 +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> pinctrl_gpio_set_config() expects the GPIO number from the global GPIO
> numberspace, not the controller-relative offset, which needs to be added
> to the chip base.
>
> Fixes: 5ae4cb94b313 ("gpio: aspeed: Add debounce support")
> Signed-off-by: Bartosz Golaszewski <[email protected]>

Reviewed-by: Andrew Jeffery <[email protected]>

Thanks!

> ---
> drivers/gpio/gpio-aspeed.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
> index da33bbbdacb9..58f107194fda 100644
> --- a/drivers/gpio/gpio-aspeed.c
> +++ b/drivers/gpio/gpio-aspeed.c
> @@ -973,7 +973,7 @@ static int aspeed_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> else if (param == PIN_CONFIG_BIAS_DISABLE ||
> param == PIN_CONFIG_BIAS_PULL_DOWN ||
> param == PIN_CONFIG_DRIVE_STRENGTH)
> - return pinctrl_gpio_set_config(offset, config);
> + return pinctrl_gpio_set_config(chip->base + offset, config);
> else if (param == PIN_CONFIG_DRIVE_OPEN_DRAIN ||
> param == PIN_CONFIG_DRIVE_OPEN_SOURCE)
> /* Return -ENOTSUPP to trigger emulation, as per datasheet */

2023-10-05 14:28:55

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH] gpio: aspeed: fix the GPIO number passed to pinctrl_gpio_set_config()

On Tue, Oct 3, 2023 at 9:39 AM Bartosz Golaszewski <[email protected]> wrote:
>
> From: Bartosz Golaszewski <[email protected]>
>
> pinctrl_gpio_set_config() expects the GPIO number from the global GPIO
> numberspace, not the controller-relative offset, which needs to be added
> to the chip base.
>
> Fixes: 5ae4cb94b313 ("gpio: aspeed: Add debounce support")
> Signed-off-by: Bartosz Golaszewski <[email protected]>
> ---
> drivers/gpio/gpio-aspeed.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
> index da33bbbdacb9..58f107194fda 100644
> --- a/drivers/gpio/gpio-aspeed.c
> +++ b/drivers/gpio/gpio-aspeed.c
> @@ -973,7 +973,7 @@ static int aspeed_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> else if (param == PIN_CONFIG_BIAS_DISABLE ||
> param == PIN_CONFIG_BIAS_PULL_DOWN ||
> param == PIN_CONFIG_DRIVE_STRENGTH)
> - return pinctrl_gpio_set_config(offset, config);
> + return pinctrl_gpio_set_config(chip->base + offset, config);
> else if (param == PIN_CONFIG_DRIVE_OPEN_DRAIN ||
> param == PIN_CONFIG_DRIVE_OPEN_SOURCE)
> /* Return -ENOTSUPP to trigger emulation, as per datasheet */
> --
> 2.39.2
>

Queued for fixes.

Bart