Skip to contentSkip to conversation

gpio: aspeed: fix the GPIO number passed to pinctrl_gpio_set_config()

PATCH In review Bartosz Golaszewski 3 participants 4 messages Oct 3, 2023 – Oct 5, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/gpio/gpio-aspeed.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-aspeed.c +1 -1
index da33bbbdacb9..58f107194fda 100644
@@ -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 */
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Bartosz Golaszewski

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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Bartosz Golaszewski
Quoted 8 lines · Bartosz Golaszewski

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")

Thanks!

Quoted 17 lines
---
 drivers/gpio/gpio-aspeed.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-aspeed.c +1 -1
index da33bbbdacb9..58f107194fda 100644
@@ -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 */
#3 lore raw
In reply to Bartosz Golaszewski
Quoted 27 lines · 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")
---
 drivers/gpio/gpio-aspeed.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-aspeed.c +1 -2
index da33bbbdacb9..58f107194fda 100644
@@ -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 */
--
Quoted 2 lines

2.39.2

Queued for fixes.

Bart