[PATCH v3] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper

Alex Tran posted 1 patch 1 month, 2 weeks ago
drivers/gpio/gpio-by-pinctrl.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
[PATCH v3] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper
Posted by Alex Tran 1 month, 2 weeks ago
Apply the requested initial value via the existing gpio set
wrapper, so that the pin is not left at its previous level.
Afterwards, configure the gpio pin as output.

Fixes: 7671f4949a6c ("gpio: gpio-by-pinctrl: add pinctrl based generic GPIO driver")
Signed-off-by: Alex Tran <alex.tran@oss.qualcomm.com>
---
Changes in v3:
- Apply initial value before configuring as output
- Link to v2: https://patch.msgid.link/20260724-gpio-pinctrl-output-set-val-v2-1-cad55d025636@oss.qualcomm.com

Changes in v2:
- Add fixes tag
- Link to v1: https://patch.msgid.link/20260723-gpio-pinctrl-output-set-val-v1-1-ed4477dcd3e1@oss.qualcomm.com

To: Linus Walleij <linusw@kernel.org>
To: Bartosz Golaszewski <brgl@kernel.org>
To: Dan Carpenter <error27@gmail.com>
To: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Cc: linux-gpio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/gpio/gpio-by-pinctrl.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-by-pinctrl.c b/drivers/gpio/gpio-by-pinctrl.c
index 7d7c48ce5163..f54efd635f13 100644
--- a/drivers/gpio/gpio-by-pinctrl.c
+++ b/drivers/gpio/gpio-by-pinctrl.c
@@ -27,12 +27,6 @@ static int pin_control_gpio_get_direction(struct gpio_chip *gc, unsigned int off
 	return GPIO_LINE_DIRECTION_IN;
 }
 
-static int pin_control_gpio_direction_output(struct gpio_chip *chip,
-					     unsigned int offset, int val)
-{
-	return pinctrl_gpio_direction_output(chip, offset);
-}
-
 static int pin_control_gpio_get(struct gpio_chip *chip, unsigned int offset)
 {
 	unsigned long config;
@@ -55,6 +49,18 @@ static int pin_control_gpio_set(struct gpio_chip *chip, unsigned int offset,
 	return pinctrl_gpio_set_config(chip, offset, config);
 }
 
+static int pin_control_gpio_direction_output(struct gpio_chip *chip,
+					     unsigned int offset, int val)
+{
+	int ret;
+
+	ret = pin_control_gpio_set(chip, offset, val);
+	if (ret)
+		return ret;
+
+	return pinctrl_gpio_direction_output(chip, offset);
+}
+
 static int pin_control_gpio_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;

---
base-commit: 4539944e515183668109bdf4d0c3d7d228383d88
change-id: 20260723-gpio-pinctrl-output-set-val-676008568122

Best regards,
--  
Alex Tran <alex.tran@oss.qualcomm.com>
Re: [PATCH v3] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper
Posted by Bartosz Golaszewski 1 month, 2 weeks ago
On Mon, 10 Aug 2026 11:58:17 -0700, Alex Tran wrote:
> Apply the requested initial value via the existing gpio set
> wrapper, so that the pin is not left at its previous level.
> Afterwards, configure the gpio pin as output.
> 
> 

Applied, thanks!

[1/1] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper
      https://git.kernel.org/brgl/c/408866669ce01b8f2111afdea2c13d15a8960bff

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Re: [PATCH v3] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper
Posted by Linus Walleij 1 month, 2 weeks ago
On Mon, Aug 10, 2026 at 8:59 PM Alex Tran <alex.tran@oss.qualcomm.com> wrote:

> Apply the requested initial value via the existing gpio set
> wrapper, so that the pin is not left at its previous level.
> Afterwards, configure the gpio pin as output.
>
> Fixes: 7671f4949a6c ("gpio: gpio-by-pinctrl: add pinctrl based generic GPIO driver")
> Signed-off-by: Alex Tran <alex.tran@oss.qualcomm.com>

Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij
Re: [PATCH v3] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper
Posted by Andy Shevchenko 1 month, 2 weeks ago
On Mon, Aug 10, 2026 at 11:58:17AM -0700, Alex Tran wrote:
> Apply the requested initial value via the existing gpio set

GPIO

> wrapper, so that the pin is not left at its previous level.
> Afterwards, configure the gpio pin as output.

GPIO

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko