Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH v2] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper
@ 2026-07-24 16:42 Alex Tran
  2026-07-25 14:01 ` Linus Walleij
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Alex Tran @ 2026-07-24 16:42 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, Alex Tran, Dan Carpenter,
	AKASHI Takahiro, Andy Shevchenko, Bartosz Golaszewski

After successfully configuring gpio pin as output, set the
requested initial output value via the existing gpio set
wrapper, so that the pin is not left at its previous level.

Fixes: 7671f4949a6c ("gpio: gpio-by-pinctrl: add pinctrl based generic GPIO driver")
Signed-off-by: Alex Tran <alex.tran@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..fb8440acb31d 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 = pinctrl_gpio_direction_output(chip, offset);
+	if (ret)
+		return ret;
+
+	return pin_control_gpio_set(chip, offset, val);
+}
+
 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>


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

* Re: [PATCH v2] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper
  2026-07-24 16:42 [PATCH v2] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper Alex Tran
@ 2026-07-25 14:01 ` Linus Walleij
  2026-07-27 11:14 ` Bartosz Golaszewski
  2026-08-06 21:58 ` Andy Shevchenko
  2 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2026-07-25 14:01 UTC (permalink / raw)
  To: Alex Tran
  Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, Dan Carpenter,
	AKASHI Takahiro, Andy Shevchenko, Bartosz Golaszewski

On Fri, Jul 24, 2026 at 6:43 PM Alex Tran <alex.tran@oss.qualcomm.com> wrote:

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

OMG that's an important semantic fix actually, thanks for
finding this Alex!!

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

Yours,
Linus Walleij

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

* Re: [PATCH v2] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper
  2026-07-24 16:42 [PATCH v2] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper Alex Tran
  2026-07-25 14:01 ` Linus Walleij
@ 2026-07-27 11:14 ` Bartosz Golaszewski
  2026-08-06 21:59   ` Andy Shevchenko
  2026-08-06 21:58 ` Andy Shevchenko
  2 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-07-27 11:14 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Alex Tran
  Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, Dan Carpenter,
	AKASHI Takahiro, Andy Shevchenko


On Fri, 24 Jul 2026 09:42:28 -0700, Alex Tran wrote:
> After successfully configuring gpio pin as output, set the
> requested initial output value via the existing gpio set
> wrapper, so that the pin is not left at its previous level.
> 
> 

Applied, thanks!

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

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

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

* Re: [PATCH v2] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper
  2026-07-24 16:42 [PATCH v2] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper Alex Tran
  2026-07-25 14:01 ` Linus Walleij
  2026-07-27 11:14 ` Bartosz Golaszewski
@ 2026-08-06 21:58 ` Andy Shevchenko
  2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-08-06 21:58 UTC (permalink / raw)
  To: Alex Tran
  Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel,
	Dan Carpenter, AKASHI Takahiro, Bartosz Golaszewski

On Fri, Jul 24, 2026 at 09:42:28AM -0700, Alex Tran wrote:
> After successfully configuring gpio pin as output, set the
> requested initial output value via the existing gpio set
> wrapper, so that the pin is not left at its previous level.

...

> +static int pin_control_gpio_direction_output(struct gpio_chip *chip,
> +					     unsigned int offset, int val)
> +{
> +	int ret;
> +
> +	ret = pinctrl_gpio_direction_output(chip, offset);
> +	if (ret)
> +		return ret;
> +
> +	return pin_control_gpio_set(chip, offset, val);
> +}

But this is a wrong order. First we should submit the value and
only _then_ set the direction. This is not glitch-free in such
an order. Granted, not all HW is well implemented.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper
  2026-07-27 11:14 ` Bartosz Golaszewski
@ 2026-08-06 21:59   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-08-06 21:59 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Bartosz Golaszewski, Alex Tran, linux-gpio,
	linux-kernel, Dan Carpenter, AKASHI Takahiro

On Mon, Jul 27, 2026 at 01:14:40PM +0200, Bartosz Golaszewski wrote:
> On Fri, 24 Jul 2026 09:42:28 -0700, Alex Tran wrote:
> > After successfully configuring gpio pin as output, set the
> > requested initial output value via the existing gpio set
> > wrapper, so that the pin is not left at its previous level.
> 
> Applied, thanks!
> 
> [1/1] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper
>       https://git.kernel.org/brgl/c/67ff4bf723c8bd1f1b10450fa3e8f55762418104

Thanks, but see my comment.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-08-06 21:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 16:42 [PATCH v2] gpio: gpio-by-pinctrl: Apply initial value in direction output wrapper Alex Tran
2026-07-25 14:01 ` Linus Walleij
2026-07-27 11:14 ` Bartosz Golaszewski
2026-08-06 21:59   ` Andy Shevchenko
2026-08-06 21:58 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox