linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/12] gpio: use new GPIO line value setter callbacks
@ 2025-07-07  7:50 Bartosz Golaszewski
  2025-07-07  7:50 ` [PATCH 01/12] gpio: tps65910: " Bartosz Golaszewski
                   ` (12 more replies)
  0 siblings, 13 replies; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07  7:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

Commit 98ce1eb1fd87e ("gpiolib: introduce gpio_chip setters that return
values") added new line setter callbacks to struct gpio_chip. They allow
to indicate failures to callers. We're in the process of converting all
GPIO controllers to using them before removing the old ones. This series
converts another round of GPIO drivers.

To: 

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
Bartosz Golaszewski (12):
      gpio: tps65910: use new GPIO line value setter callbacks
      gpio: tps65912: check the return value of regmap_update_bits()
      gpio: tps65912: use new GPIO line value setter callbacks
      gpio: tps68470: use new GPIO line value setter callbacks
      gpio: tqmx86: use new GPIO line value setter callbacks
      gpio: ts4900: use new GPIO line value setter callbacks
      gpio: twl4030: use new GPIO line value setter callbacks
      gpio: twl6040: use new GPIO line value setter callbacks
      gpio: twl6040: set line value in .direction_out()
      gpio: uniphier: use new GPIO line value setter callbacks
      gpio: viperboard: use new GPIO line value setter callbacks
      gpio: virtio: use new GPIO line value setter callbacks

 drivers/gpio/gpio-tps65910.c   |  21 ++++----
 drivers/gpio/gpio-tps65912.c   |  17 +++---
 drivers/gpio/gpio-tps68470.c   |  14 +++--
 drivers/gpio/gpio-tqmx86.c     |   8 +--
 drivers/gpio/gpio-ts4900.c     |  14 ++---
 drivers/gpio/gpio-twl4030.c    |  23 ++++----
 drivers/gpio/gpio-twl6040.c    |  23 ++++----
 drivers/gpio/gpio-uniphier.c   |  16 +++---
 drivers/gpio/gpio-viperboard.c | 116 ++++++++++++++++++++++-------------------
 drivers/gpio/gpio-virtio.c     |   7 +--
 10 files changed, 144 insertions(+), 115 deletions(-)
---
base-commit: 26ffb3d6f02cd0935fb9fa3db897767beee1cb2a
change-id: 20250703-gpiochip-set-rv-gpio-round4-e3b568fda584

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


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

* [PATCH 01/12] gpio: tps65910: use new GPIO line value setter callbacks
  2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
@ 2025-07-07  7:50 ` Bartosz Golaszewski
  2025-07-07  7:50 ` [PATCH 02/12] gpio: tps65912: check the return value of regmap_update_bits() Bartosz Golaszewski
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07  7:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-tps65910.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-tps65910.c b/drivers/gpio/gpio-tps65910.c
index 187d21580573fb1d896d90642a537a90aced8276..3204f55394cff12dc1b462cdce60342ed1b32fc1 100644
--- a/drivers/gpio/gpio-tps65910.c
+++ b/drivers/gpio/gpio-tps65910.c
@@ -36,18 +36,18 @@ static int tps65910_gpio_get(struct gpio_chip *gc, unsigned offset)
 	return 0;
 }
 
-static void tps65910_gpio_set(struct gpio_chip *gc, unsigned offset,
-			      int value)
+static int tps65910_gpio_set(struct gpio_chip *gc, unsigned int offset,
+			     int value)
 {
 	struct tps65910_gpio *tps65910_gpio = gpiochip_get_data(gc);
 	struct tps65910 *tps65910 = tps65910_gpio->tps65910;
 
 	if (value)
-		regmap_set_bits(tps65910->regmap, TPS65910_GPIO0 + offset,
-						GPIO_SET_MASK);
-	else
-		regmap_clear_bits(tps65910->regmap, TPS65910_GPIO0 + offset,
-						GPIO_SET_MASK);
+		return regmap_set_bits(tps65910->regmap,
+				       TPS65910_GPIO0 + offset, GPIO_SET_MASK);
+
+	return regmap_clear_bits(tps65910->regmap, TPS65910_GPIO0 + offset,
+				 GPIO_SET_MASK);
 }
 
 static int tps65910_gpio_output(struct gpio_chip *gc, unsigned offset,
@@ -55,9 +55,12 @@ static int tps65910_gpio_output(struct gpio_chip *gc, unsigned offset,
 {
 	struct tps65910_gpio *tps65910_gpio = gpiochip_get_data(gc);
 	struct tps65910 *tps65910 = tps65910_gpio->tps65910;
+	int ret;
 
 	/* Set the initial value */
-	tps65910_gpio_set(gc, offset, value);
+	ret = tps65910_gpio_set(gc, offset, value);
+	if (ret)
+		return ret;
 
 	return regmap_set_bits(tps65910->regmap, TPS65910_GPIO0 + offset,
 						GPIO_CFG_MASK);
@@ -136,7 +139,7 @@ static int tps65910_gpio_probe(struct platform_device *pdev)
 	tps65910_gpio->gpio_chip.can_sleep = true;
 	tps65910_gpio->gpio_chip.direction_input = tps65910_gpio_input;
 	tps65910_gpio->gpio_chip.direction_output = tps65910_gpio_output;
-	tps65910_gpio->gpio_chip.set	= tps65910_gpio_set;
+	tps65910_gpio->gpio_chip.set_rv	= tps65910_gpio_set;
 	tps65910_gpio->gpio_chip.get	= tps65910_gpio_get;
 	tps65910_gpio->gpio_chip.parent = &pdev->dev;
 

-- 
2.48.1


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

* [PATCH 02/12] gpio: tps65912: check the return value of regmap_update_bits()
  2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
  2025-07-07  7:50 ` [PATCH 01/12] gpio: tps65910: " Bartosz Golaszewski
@ 2025-07-07  7:50 ` Bartosz Golaszewski
  2025-07-07  7:50 ` [PATCH 03/12] gpio: tps65912: use new GPIO line value setter callbacks Bartosz Golaszewski
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07  7:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

regmap_update_bits() can fail, check its return value like we do
elsewhere in the driver.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-tps65912.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
index fab771cb6a87bf05b1edc3c062f846bea70ca825..bac757c191c2ea0d103eb0577710065611fd79aa 100644
--- a/drivers/gpio/gpio-tps65912.c
+++ b/drivers/gpio/gpio-tps65912.c
@@ -49,10 +49,13 @@ static int tps65912_gpio_direction_output(struct gpio_chip *gc,
 					  unsigned offset, int value)
 {
 	struct tps65912_gpio *gpio = gpiochip_get_data(gc);
+	int ret;
 
 	/* Set the initial value */
-	regmap_update_bits(gpio->tps->regmap, TPS65912_GPIO1 + offset,
-			   GPIO_SET_MASK, value ? GPIO_SET_MASK : 0);
+	ret = regmap_update_bits(gpio->tps->regmap, TPS65912_GPIO1 + offset,
+				 GPIO_SET_MASK, value ? GPIO_SET_MASK : 0);
+	if (ret)
+		return ret;
 
 	return regmap_update_bits(gpio->tps->regmap, TPS65912_GPIO1 + offset,
 				  GPIO_CFG_MASK, GPIO_CFG_MASK);

-- 
2.48.1


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

* [PATCH 03/12] gpio: tps65912: use new GPIO line value setter callbacks
  2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
  2025-07-07  7:50 ` [PATCH 01/12] gpio: tps65910: " Bartosz Golaszewski
  2025-07-07  7:50 ` [PATCH 02/12] gpio: tps65912: check the return value of regmap_update_bits() Bartosz Golaszewski
@ 2025-07-07  7:50 ` Bartosz Golaszewski
  2025-07-07  7:50 ` [PATCH 04/12] gpio: tps68470: " Bartosz Golaszewski
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07  7:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-tps65912.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
index bac757c191c2ea0d103eb0577710065611fd79aa..d586ccfbfc56c17ca18f5c2b04a807305dd66890 100644
--- a/drivers/gpio/gpio-tps65912.c
+++ b/drivers/gpio/gpio-tps65912.c
@@ -76,13 +76,13 @@ static int tps65912_gpio_get(struct gpio_chip *gc, unsigned offset)
 	return 0;
 }
 
-static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset,
-			      int value)
+static int tps65912_gpio_set(struct gpio_chip *gc, unsigned int offset,
+			     int value)
 {
 	struct tps65912_gpio *gpio = gpiochip_get_data(gc);
 
-	regmap_update_bits(gpio->tps->regmap, TPS65912_GPIO1 + offset,
-			   GPIO_SET_MASK, value ? GPIO_SET_MASK : 0);
+	return regmap_update_bits(gpio->tps->regmap, TPS65912_GPIO1 + offset,
+				  GPIO_SET_MASK, value ? GPIO_SET_MASK : 0);
 }
 
 static const struct gpio_chip template_chip = {
@@ -92,7 +92,7 @@ static const struct gpio_chip template_chip = {
 	.direction_input	= tps65912_gpio_direction_input,
 	.direction_output	= tps65912_gpio_direction_output,
 	.get			= tps65912_gpio_get,
-	.set			= tps65912_gpio_set,
+	.set_rv			= tps65912_gpio_set,
 	.base			= -1,
 	.ngpio			= 5,
 	.can_sleep		= true,

-- 
2.48.1


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

* [PATCH 04/12] gpio: tps68470: use new GPIO line value setter callbacks
  2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2025-07-07  7:50 ` [PATCH 03/12] gpio: tps65912: use new GPIO line value setter callbacks Bartosz Golaszewski
@ 2025-07-07  7:50 ` Bartosz Golaszewski
  2025-07-07  7:50 ` [PATCH 05/12] gpio: tqmx86: " Bartosz Golaszewski
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07  7:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-tps68470.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-tps68470.c b/drivers/gpio/gpio-tps68470.c
index 532deaddfd4e2e2f306f3872e746ad4d85925893..3b8805c854f7dbf4ae96fc06afaeb775bbdcacb1 100644
--- a/drivers/gpio/gpio-tps68470.c
+++ b/drivers/gpio/gpio-tps68470.c
@@ -70,8 +70,8 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
 						    GPIO_LINE_DIRECTION_IN;
 }
 
-static void tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset,
-				int value)
+static int tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset,
+			     int value)
 {
 	struct tps68470_gpio_data *tps68470_gpio = gpiochip_get_data(gc);
 	struct regmap *regmap = tps68470_gpio->tps68470_regmap;
@@ -82,7 +82,8 @@ static void tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset,
 		offset -= TPS68470_N_REGULAR_GPIO;
 	}
 
-	regmap_update_bits(regmap, reg, BIT(offset), value ? BIT(offset) : 0);
+	return regmap_update_bits(regmap, reg, BIT(offset),
+				  value ? BIT(offset) : 0);
 }
 
 static int tps68470_gpio_output(struct gpio_chip *gc, unsigned int offset,
@@ -90,9 +91,12 @@ static int tps68470_gpio_output(struct gpio_chip *gc, unsigned int offset,
 {
 	struct tps68470_gpio_data *tps68470_gpio = gpiochip_get_data(gc);
 	struct regmap *regmap = tps68470_gpio->tps68470_regmap;
+	int ret;
 
 	/* Set the initial value */
-	tps68470_gpio_set(gc, offset, value);
+	ret = tps68470_gpio_set(gc, offset, value);
+	if (ret)
+		return ret;
 
 	/* rest are always outputs */
 	if (offset >= TPS68470_N_REGULAR_GPIO)
@@ -138,7 +142,7 @@ static int tps68470_gpio_probe(struct platform_device *pdev)
 	tps68470_gpio->gc.direction_output = tps68470_gpio_output;
 	tps68470_gpio->gc.get = tps68470_gpio_get;
 	tps68470_gpio->gc.get_direction = tps68470_gpio_get_direction;
-	tps68470_gpio->gc.set = tps68470_gpio_set;
+	tps68470_gpio->gc.set_rv = tps68470_gpio_set;
 	tps68470_gpio->gc.can_sleep = true;
 	tps68470_gpio->gc.names = tps68470_names;
 	tps68470_gpio->gc.ngpio = TPS68470_N_GPIO;

-- 
2.48.1


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

* [PATCH 05/12] gpio: tqmx86: use new GPIO line value setter callbacks
  2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
                   ` (3 preceding siblings ...)
  2025-07-07  7:50 ` [PATCH 04/12] gpio: tps68470: " Bartosz Golaszewski
@ 2025-07-07  7:50 ` Bartosz Golaszewski
  2025-07-07 12:32   ` Matthias Schiffer
  2025-07-07  7:50 ` [PATCH 06/12] gpio: ts4900: " Bartosz Golaszewski
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07  7:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-tqmx86.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
index 18f523a15b3c03e083b363a026e751f7367fb080..056799ecce6a256f3438d9fd81ee4677cdd20125 100644
--- a/drivers/gpio/gpio-tqmx86.c
+++ b/drivers/gpio/gpio-tqmx86.c
@@ -93,14 +93,16 @@ static void _tqmx86_gpio_set(struct tqmx86_gpio_data *gpio, unsigned int offset,
 	tqmx86_gpio_write(gpio, bitmap_get_value8(gpio->output, 0), TQMX86_GPIOD);
 }
 
-static void tqmx86_gpio_set(struct gpio_chip *chip, unsigned int offset,
-			    int value)
+static int tqmx86_gpio_set(struct gpio_chip *chip, unsigned int offset,
+			   int value)
 {
 	struct tqmx86_gpio_data *gpio = gpiochip_get_data(chip);
 
 	guard(raw_spinlock_irqsave)(&gpio->spinlock);
 
 	_tqmx86_gpio_set(gpio, offset, value);
+
+	return 0;
 }
 
 static int tqmx86_gpio_direction_input(struct gpio_chip *chip,
@@ -368,7 +370,7 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
 	chip->direction_output = tqmx86_gpio_direction_output;
 	chip->get_direction = tqmx86_gpio_get_direction;
 	chip->get = tqmx86_gpio_get;
-	chip->set = tqmx86_gpio_set;
+	chip->set_rv = tqmx86_gpio_set;
 	chip->ngpio = TQMX86_NGPIO;
 	chip->parent = pdev->dev.parent;
 

-- 
2.48.1


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

* [PATCH 06/12] gpio: ts4900: use new GPIO line value setter callbacks
  2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
                   ` (4 preceding siblings ...)
  2025-07-07  7:50 ` [PATCH 05/12] gpio: tqmx86: " Bartosz Golaszewski
@ 2025-07-07  7:50 ` Bartosz Golaszewski
  2025-07-07  7:50 ` [PATCH 07/12] gpio: twl4030: " Bartosz Golaszewski
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07  7:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-ts4900.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-ts4900.c b/drivers/gpio/gpio-ts4900.c
index 5c806140fdf0d6e60f2225824aa18d393f61b607..35dd2d09b4d441256f01d9ac762dd3a2f0a47352 100644
--- a/drivers/gpio/gpio-ts4900.c
+++ b/drivers/gpio/gpio-ts4900.c
@@ -95,16 +95,16 @@ static int ts4900_gpio_get(struct gpio_chip *chip, unsigned int offset)
 	return !!(reg & priv->input_bit);
 }
 
-static void ts4900_gpio_set(struct gpio_chip *chip, unsigned int offset,
-			    int value)
+static int ts4900_gpio_set(struct gpio_chip *chip, unsigned int offset,
+			   int value)
 {
 	struct ts4900_gpio_priv *priv = gpiochip_get_data(chip);
 
 	if (value)
-		regmap_update_bits(priv->regmap, offset, TS4900_GPIO_OUT,
-				   TS4900_GPIO_OUT);
-	else
-		regmap_update_bits(priv->regmap, offset, TS4900_GPIO_OUT, 0);
+		return regmap_update_bits(priv->regmap, offset,
+					  TS4900_GPIO_OUT, TS4900_GPIO_OUT);
+
+	return regmap_update_bits(priv->regmap, offset, TS4900_GPIO_OUT, 0);
 }
 
 static const struct regmap_config ts4900_regmap_config = {
@@ -119,7 +119,7 @@ static const struct gpio_chip template_chip = {
 	.direction_input	= ts4900_gpio_direction_input,
 	.direction_output	= ts4900_gpio_direction_output,
 	.get			= ts4900_gpio_get,
-	.set			= ts4900_gpio_set,
+	.set_rv			= ts4900_gpio_set,
 	.base			= -1,
 	.can_sleep		= true,
 };

-- 
2.48.1


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

* [PATCH 07/12] gpio: twl4030: use new GPIO line value setter callbacks
  2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
                   ` (5 preceding siblings ...)
  2025-07-07  7:50 ` [PATCH 06/12] gpio: ts4900: " Bartosz Golaszewski
@ 2025-07-07  7:50 ` Bartosz Golaszewski
  2025-07-07  7:50 ` [PATCH 08/12] gpio: twl6040: " Bartosz Golaszewski
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07  7:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-twl4030.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index c5d7825f19c18bfa84083aa5a46e48d174b8fce6..e39e39e3ef85b7c60c1f29f78c11d6eeccec6206 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -120,7 +120,7 @@ static u8 cached_leden;
  * external pullup is needed.  We could also expose the integrated PWM
  * as a LED brightness control; we initialize it as "always on".
  */
-static void twl4030_led_set_value(int led, int value)
+static int twl4030_led_set_value(int led, int value)
 {
 	u8 mask = LEDEN_LEDAON | LEDEN_LEDAPWM;
 
@@ -132,8 +132,8 @@ static void twl4030_led_set_value(int led, int value)
 	else
 		cached_leden |= mask;
 
-	WARN_ON_ONCE(twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
-				      TWL4030_LED_LEDEN_REG));
+	return twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
+				TWL4030_LED_LEDEN_REG);
 }
 
 static int twl4030_set_gpio_direction(int gpio, int is_input)
@@ -278,7 +278,7 @@ static void twl_free(struct gpio_chip *chip, unsigned offset)
 
 	mutex_lock(&priv->mutex);
 	if (offset >= TWL4030_GPIO_MAX) {
-		twl4030_led_set_value(offset - TWL4030_GPIO_MAX, 1);
+		WARN_ON_ONCE(twl4030_led_set_value(offset - TWL4030_GPIO_MAX, 1));
 		goto out;
 	}
 
@@ -334,15 +334,16 @@ static int twl_get(struct gpio_chip *chip, unsigned offset)
 	return ret;
 }
 
-static void twl_set(struct gpio_chip *chip, unsigned offset, int value)
+static int twl_set(struct gpio_chip *chip, unsigned int offset, int value)
 {
 	struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
+	int ret;
 
 	mutex_lock(&priv->mutex);
 	if (offset < TWL4030_GPIO_MAX)
-		twl4030_set_gpio_dataout(offset, value);
+		ret = twl4030_set_gpio_dataout(offset, value);
 	else
-		twl4030_led_set_value(offset - TWL4030_GPIO_MAX, value);
+		ret = twl4030_led_set_value(offset - TWL4030_GPIO_MAX, value);
 
 	if (value)
 		priv->out_state |= BIT(offset);
@@ -350,6 +351,8 @@ static void twl_set(struct gpio_chip *chip, unsigned offset, int value)
 		priv->out_state &= ~BIT(offset);
 
 	mutex_unlock(&priv->mutex);
+
+	return ret;
 }
 
 static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value)
@@ -373,9 +376,7 @@ static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value)
 	priv->direction |= BIT(offset);
 	mutex_unlock(&priv->mutex);
 
-	twl_set(chip, offset, value);
-
-	return ret;
+	return twl_set(chip, offset, value);
 }
 
 static int twl_get_direction(struct gpio_chip *chip, unsigned offset)
@@ -418,7 +419,7 @@ static const struct gpio_chip template_chip = {
 	.direction_output	= twl_direction_out,
 	.get_direction		= twl_get_direction,
 	.get			= twl_get,
-	.set			= twl_set,
+	.set_rv			= twl_set,
 	.to_irq			= twl_to_irq,
 	.can_sleep		= true,
 };

-- 
2.48.1


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

* [PATCH 08/12] gpio: twl6040: use new GPIO line value setter callbacks
  2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
                   ` (6 preceding siblings ...)
  2025-07-07  7:50 ` [PATCH 07/12] gpio: twl4030: " Bartosz Golaszewski
@ 2025-07-07  7:50 ` Bartosz Golaszewski
  2025-07-07  7:50 ` [PATCH 09/12] gpio: twl6040: set line value in .direction_out() Bartosz Golaszewski
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07  7:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-twl6040.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c
index b9171bf66168f054e9eddef8417bef6d8f197f3c..b9c0d54d12f43242444f12a2bd8b6988d1511466 100644
--- a/drivers/gpio/gpio-twl6040.c
+++ b/drivers/gpio/gpio-twl6040.c
@@ -44,7 +44,8 @@ static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
 	return 0;
 }
 
-static void twl6040gpo_set(struct gpio_chip *chip, unsigned offset, int value)
+static int twl6040gpo_set(struct gpio_chip *chip, unsigned int offset,
+			  int value)
 {
 	struct twl6040 *twl6040 = gpiochip_get_data(chip);
 	int ret;
@@ -52,14 +53,14 @@ static void twl6040gpo_set(struct gpio_chip *chip, unsigned offset, int value)
 
 	ret = twl6040_reg_read(twl6040, TWL6040_REG_GPOCTL);
 	if (ret < 0)
-		return;
+		return ret;
 
 	if (value)
 		gpoctl = ret | BIT(offset);
 	else
 		gpoctl = ret & ~BIT(offset);
 
-	twl6040_reg_write(twl6040, TWL6040_REG_GPOCTL, gpoctl);
+	return twl6040_reg_write(twl6040, TWL6040_REG_GPOCTL, gpoctl);
 }
 
 static struct gpio_chip twl6040gpo_chip = {
@@ -68,7 +69,7 @@ static struct gpio_chip twl6040gpo_chip = {
 	.get			= twl6040gpo_get,
 	.direction_output	= twl6040gpo_direction_out,
 	.get_direction		= twl6040gpo_get_direction,
-	.set			= twl6040gpo_set,
+	.set_rv			= twl6040gpo_set,
 	.can_sleep		= true,
 };
 

-- 
2.48.1


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

* [PATCH 09/12] gpio: twl6040: set line value in .direction_out()
  2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
                   ` (7 preceding siblings ...)
  2025-07-07  7:50 ` [PATCH 08/12] gpio: twl6040: " Bartosz Golaszewski
@ 2025-07-07  7:50 ` Bartosz Golaszewski
  2025-07-07  7:50 ` [PATCH 10/12] gpio: uniphier: use new GPIO line value setter callbacks Bartosz Golaszewski
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07  7:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

It's ok for a GPIO controller to be output-only but the .direction_out()
callback must also set the requested line value.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-twl6040.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c
index b9c0d54d12f43242444f12a2bd8b6988d1511466..b2196b62b528cd0a2df2c4a4c4869ad172d6e2cd 100644
--- a/drivers/gpio/gpio-twl6040.c
+++ b/drivers/gpio/gpio-twl6040.c
@@ -37,13 +37,6 @@ static int twl6040gpo_get_direction(struct gpio_chip *chip, unsigned offset)
 	return GPIO_LINE_DIRECTION_OUT;
 }
 
-static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
-				    int value)
-{
-	/* This only drives GPOs, and can't change direction */
-	return 0;
-}
-
 static int twl6040gpo_set(struct gpio_chip *chip, unsigned int offset,
 			  int value)
 {
@@ -63,6 +56,13 @@ static int twl6040gpo_set(struct gpio_chip *chip, unsigned int offset,
 	return twl6040_reg_write(twl6040, TWL6040_REG_GPOCTL, gpoctl);
 }
 
+static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned int offset,
+				    int value)
+{
+	/* This only drives GPOs, and can't change direction */
+	return twl6040gpo_set(chip, offset, value);
+}
+
 static struct gpio_chip twl6040gpo_chip = {
 	.label			= "twl6040",
 	.owner			= THIS_MODULE,

-- 
2.48.1


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

* [PATCH 10/12] gpio: uniphier: use new GPIO line value setter callbacks
  2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
                   ` (8 preceding siblings ...)
  2025-07-07  7:50 ` [PATCH 09/12] gpio: twl6040: set line value in .direction_out() Bartosz Golaszewski
@ 2025-07-07  7:50 ` Bartosz Golaszewski
  2025-07-08  0:30   ` Kunihiko Hayashi
  2025-07-07  7:50 ` [PATCH 11/12] gpio: viperboard: " Bartosz Golaszewski
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07  7:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-uniphier.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
index d738da8718f9cf52286ebf14dd4d0ae60466db2e..8939556f42b60f32dbf7bff315eb5bbb6f062256 100644
--- a/drivers/gpio/gpio-uniphier.c
+++ b/drivers/gpio/gpio-uniphier.c
@@ -138,14 +138,16 @@ static int uniphier_gpio_get(struct gpio_chip *chip, unsigned int offset)
 	return uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DATA);
 }
 
-static void uniphier_gpio_set(struct gpio_chip *chip,
-			      unsigned int offset, int val)
+static int uniphier_gpio_set(struct gpio_chip *chip,
+			     unsigned int offset, int val)
 {
 	uniphier_gpio_offset_write(chip, offset, UNIPHIER_GPIO_PORT_DATA, val);
+
+	return 0;
 }
 
-static void uniphier_gpio_set_multiple(struct gpio_chip *chip,
-				       unsigned long *mask, unsigned long *bits)
+static int uniphier_gpio_set_multiple(struct gpio_chip *chip,
+				      unsigned long *mask, unsigned long *bits)
 {
 	unsigned long i, bank, bank_mask, bank_bits;
 
@@ -156,6 +158,8 @@ static void uniphier_gpio_set_multiple(struct gpio_chip *chip,
 		uniphier_gpio_bank_write(chip, bank, UNIPHIER_GPIO_PORT_DATA,
 					 bank_mask, bank_bits);
 	}
+
+	return 0;
 }
 
 static int uniphier_gpio_to_irq(struct gpio_chip *chip, unsigned int offset)
@@ -382,8 +386,8 @@ static int uniphier_gpio_probe(struct platform_device *pdev)
 	chip->direction_input = uniphier_gpio_direction_input;
 	chip->direction_output = uniphier_gpio_direction_output;
 	chip->get = uniphier_gpio_get;
-	chip->set = uniphier_gpio_set;
-	chip->set_multiple = uniphier_gpio_set_multiple;
+	chip->set_rv = uniphier_gpio_set;
+	chip->set_multiple_rv = uniphier_gpio_set_multiple;
 	chip->to_irq = uniphier_gpio_to_irq;
 	chip->base = -1;
 	chip->ngpio = ngpios;

-- 
2.48.1


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

* [PATCH 11/12] gpio: viperboard: use new GPIO line value setter callbacks
  2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
                   ` (9 preceding siblings ...)
  2025-07-07  7:50 ` [PATCH 10/12] gpio: uniphier: use new GPIO line value setter callbacks Bartosz Golaszewski
@ 2025-07-07  7:50 ` Bartosz Golaszewski
  2025-07-07  7:50 ` [PATCH 12/12] gpio: virtio: " Bartosz Golaszewski
  2025-07-13  8:45 ` [PATCH 00/12] gpio: " Bartosz Golaszewski
  12 siblings, 0 replies; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07  7:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-viperboard.c | 116 ++++++++++++++++++++++-------------------
 1 file changed, 63 insertions(+), 53 deletions(-)

diff --git a/drivers/gpio/gpio-viperboard.c b/drivers/gpio/gpio-viperboard.c
index e55d28a8a66f25dd0949133c4a7f3bca9b5711dc..3eba77f981d3a502b67a0a7cdea51c706d4c3376 100644
--- a/drivers/gpio/gpio-viperboard.c
+++ b/drivers/gpio/gpio-viperboard.c
@@ -128,45 +128,50 @@ static int vprbrd_gpioa_get(struct gpio_chip *chip,
 	return answer;
 }
 
-static void vprbrd_gpioa_set(struct gpio_chip *chip,
-		unsigned int offset, int value)
+static int vprbrd_gpioa_set(struct gpio_chip *chip, unsigned int offset,
+			    int value)
 {
-	int ret;
+	int ret = 0;
 	struct vprbrd_gpio *gpio = gpiochip_get_data(chip);
 	struct vprbrd *vb = gpio->vb;
 	struct vprbrd_gpioa_msg *gamsg = (struct vprbrd_gpioa_msg *)vb->buf;
 
-	if (gpio->gpioa_out & (1 << offset)) {
-		if (value)
-			gpio->gpioa_val |= (1 << offset);
-		else
-			gpio->gpioa_val &= ~(1 << offset);
+	if (!(gpio->gpioa_out & (1 << offset)))
+		return 0;
 
-		mutex_lock(&vb->lock);
+	if (value)
+		gpio->gpioa_val |= (1 << offset);
+	else
+		gpio->gpioa_val &= ~(1 << offset);
 
-		gamsg->cmd = VPRBRD_GPIOA_CMD_SETOUT;
-		gamsg->clk = 0x00;
-		gamsg->offset = offset;
-		gamsg->t1 = 0x00;
-		gamsg->t2 = 0x00;
-		gamsg->invert = 0x00;
-		gamsg->pwmlevel = 0x00;
-		gamsg->outval = value;
-		gamsg->risefall = 0x00;
-		gamsg->answer = 0x00;
-		gamsg->__fill = 0x00;
+	mutex_lock(&vb->lock);
 
-		ret = usb_control_msg(vb->usb_dev,
-			usb_sndctrlpipe(vb->usb_dev, 0),
-			VPRBRD_USB_REQUEST_GPIOA, VPRBRD_USB_TYPE_OUT,
-			0x0000,	0x0000, gamsg,
-			sizeof(struct vprbrd_gpioa_msg), VPRBRD_USB_TIMEOUT_MS);
+	gamsg->cmd = VPRBRD_GPIOA_CMD_SETOUT;
+	gamsg->clk = 0x00;
+	gamsg->offset = offset;
+	gamsg->t1 = 0x00;
+	gamsg->t2 = 0x00;
+	gamsg->invert = 0x00;
+	gamsg->pwmlevel = 0x00;
+	gamsg->outval = value;
+	gamsg->risefall = 0x00;
+	gamsg->answer = 0x00;
+	gamsg->__fill = 0x00;
 
-		mutex_unlock(&vb->lock);
+	ret = usb_control_msg(vb->usb_dev, usb_sndctrlpipe(vb->usb_dev, 0),
+			      VPRBRD_USB_REQUEST_GPIOA, VPRBRD_USB_TYPE_OUT,
+			      0x0000, 0x0000, gamsg,
+			      sizeof(struct vprbrd_gpioa_msg),
+			      VPRBRD_USB_TIMEOUT_MS);
 
-		if (ret != sizeof(struct vprbrd_gpioa_msg))
-			dev_err(chip->parent, "usb error setting pin value\n");
+	mutex_unlock(&vb->lock);
+
+	if (ret != sizeof(struct vprbrd_gpioa_msg)) {
+		dev_err(chip->parent, "usb error setting pin value\n");
+		return -EREMOTEIO;
 	}
+
+	return 0;
 }
 
 static int vprbrd_gpioa_direction_input(struct gpio_chip *chip,
@@ -304,37 +309,42 @@ static int vprbrd_gpiob_get(struct gpio_chip *chip,
 	return (gpio->gpiob_val >> offset) & 0x1;
 }
 
-static void vprbrd_gpiob_set(struct gpio_chip *chip,
-		unsigned int offset, int value)
+static int vprbrd_gpiob_set(struct gpio_chip *chip, unsigned int offset,
+			    int value)
 {
 	int ret;
 	struct vprbrd_gpio *gpio = gpiochip_get_data(chip);
 	struct vprbrd *vb = gpio->vb;
 	struct vprbrd_gpiob_msg *gbmsg = (struct vprbrd_gpiob_msg *)vb->buf;
 
-	if (gpio->gpiob_out & (1 << offset)) {
-		if (value)
-			gpio->gpiob_val |= (1 << offset);
-		else
-			gpio->gpiob_val &= ~(1 << offset);
+	if (!(gpio->gpiob_out & (1 << offset)))
+		return 0;
 
-		mutex_lock(&vb->lock);
+	if (value)
+		gpio->gpiob_val |= (1 << offset);
+	else
+		gpio->gpiob_val &= ~(1 << offset);
 
-		gbmsg->cmd = VPRBRD_GPIOB_CMD_SETVAL;
-		gbmsg->val = cpu_to_be16(value << offset);
-		gbmsg->mask = cpu_to_be16(0x0001 << offset);
+	mutex_lock(&vb->lock);
 
-		ret = usb_control_msg(vb->usb_dev,
-			usb_sndctrlpipe(vb->usb_dev, 0),
-			VPRBRD_USB_REQUEST_GPIOB, VPRBRD_USB_TYPE_OUT,
-			0x0000,	0x0000, gbmsg,
-			sizeof(struct vprbrd_gpiob_msg), VPRBRD_USB_TIMEOUT_MS);
+	gbmsg->cmd = VPRBRD_GPIOB_CMD_SETVAL;
+	gbmsg->val = cpu_to_be16(value << offset);
+	gbmsg->mask = cpu_to_be16(0x0001 << offset);
 
-		mutex_unlock(&vb->lock);
+	ret = usb_control_msg(vb->usb_dev, usb_sndctrlpipe(vb->usb_dev, 0),
+			      VPRBRD_USB_REQUEST_GPIOB, VPRBRD_USB_TYPE_OUT,
+			      0x0000, 0x0000, gbmsg,
+			      sizeof(struct vprbrd_gpiob_msg),
+			      VPRBRD_USB_TIMEOUT_MS);
 
-		if (ret != sizeof(struct vprbrd_gpiob_msg))
-			dev_err(chip->parent, "usb error setting pin value\n");
+	mutex_unlock(&vb->lock);
+
+	if (ret != sizeof(struct vprbrd_gpiob_msg)) {
+		dev_err(chip->parent, "usb error setting pin value\n");
+		return -EREMOTEIO;
 	}
+
+	return 0;
 }
 
 static int vprbrd_gpiob_direction_input(struct gpio_chip *chip,
@@ -370,14 +380,14 @@ static int vprbrd_gpiob_direction_output(struct gpio_chip *chip,
 	mutex_lock(&vb->lock);
 
 	ret = vprbrd_gpiob_setdir(vb, offset, 1);
-	if (ret)
+	if (ret) {
 		dev_err(chip->parent, "usb error setting pin to output\n");
+		return ret;
+	}
 
 	mutex_unlock(&vb->lock);
 
-	vprbrd_gpiob_set(chip, offset, value);
-
-	return ret;
+	return vprbrd_gpiob_set(chip, offset, value);
 }
 
 /* ----- end of gpio b chip ---------------------------------------------- */
@@ -400,7 +410,7 @@ static int vprbrd_gpio_probe(struct platform_device *pdev)
 	vb_gpio->gpioa.base = -1;
 	vb_gpio->gpioa.ngpio = 16;
 	vb_gpio->gpioa.can_sleep = true;
-	vb_gpio->gpioa.set = vprbrd_gpioa_set;
+	vb_gpio->gpioa.set_rv = vprbrd_gpioa_set;
 	vb_gpio->gpioa.get = vprbrd_gpioa_get;
 	vb_gpio->gpioa.direction_input = vprbrd_gpioa_direction_input;
 	vb_gpio->gpioa.direction_output = vprbrd_gpioa_direction_output;
@@ -416,7 +426,7 @@ static int vprbrd_gpio_probe(struct platform_device *pdev)
 	vb_gpio->gpiob.base = -1;
 	vb_gpio->gpiob.ngpio = 16;
 	vb_gpio->gpiob.can_sleep = true;
-	vb_gpio->gpiob.set = vprbrd_gpiob_set;
+	vb_gpio->gpiob.set_rv = vprbrd_gpiob_set;
 	vb_gpio->gpiob.get = vprbrd_gpiob_get;
 	vb_gpio->gpiob.direction_input = vprbrd_gpiob_direction_input;
 	vb_gpio->gpiob.direction_output = vprbrd_gpiob_direction_output;

-- 
2.48.1


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

* [PATCH 12/12] gpio: virtio: use new GPIO line value setter callbacks
  2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
                   ` (10 preceding siblings ...)
  2025-07-07  7:50 ` [PATCH 11/12] gpio: viperboard: " Bartosz Golaszewski
@ 2025-07-07  7:50 ` Bartosz Golaszewski
  2025-07-07  8:29   ` Viresh Kumar
  2025-07-13  8:45 ` [PATCH 00/12] gpio: " Bartosz Golaszewski
  12 siblings, 1 reply; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07  7:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-virtio.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
index ac39da17a29bb844b0dd1e36eaf37670261396e8..92b456475d895912c903ad04a9d101daab5ceb58 100644
--- a/drivers/gpio/gpio-virtio.c
+++ b/drivers/gpio/gpio-virtio.c
@@ -194,11 +194,12 @@ static int virtio_gpio_get(struct gpio_chip *gc, unsigned int gpio)
 	return ret ? ret : value;
 }
 
-static void virtio_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
+static int virtio_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
 {
 	struct virtio_gpio *vgpio = gpiochip_get_data(gc);
 
-	virtio_gpio_req(vgpio, VIRTIO_GPIO_MSG_SET_VALUE, gpio, value, NULL);
+	return virtio_gpio_req(vgpio, VIRTIO_GPIO_MSG_SET_VALUE, gpio, value,
+			       NULL);
 }
 
 /* Interrupt handling */
@@ -565,7 +566,7 @@ static int virtio_gpio_probe(struct virtio_device *vdev)
 	vgpio->gc.direction_input	= virtio_gpio_direction_input;
 	vgpio->gc.direction_output	= virtio_gpio_direction_output;
 	vgpio->gc.get			= virtio_gpio_get;
-	vgpio->gc.set			= virtio_gpio_set;
+	vgpio->gc.set_rv		= virtio_gpio_set;
 	vgpio->gc.ngpio			= ngpio;
 	vgpio->gc.base			= -1; /* Allocate base dynamically */
 	vgpio->gc.label			= dev_name(dev);

-- 
2.48.1


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

* Re: [PATCH 12/12] gpio: virtio: use new GPIO line value setter callbacks
  2025-07-07  7:50 ` [PATCH 12/12] gpio: virtio: " Bartosz Golaszewski
@ 2025-07-07  8:29   ` Viresh Kumar
  0 siblings, 0 replies; 17+ messages in thread
From: Viresh Kumar @ 2025-07-07  8:29 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Kunihiko Hayashi, Masami Hiramatsu, Viresh Kumar,
	linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski

On 07-07-25, 09:50, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> struct gpio_chip now has callbacks for setting line values that return
> an integer, allowing to indicate failures. Convert the driver to using
> them.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  drivers/gpio/gpio-virtio.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

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

* Re: [PATCH 05/12] gpio: tqmx86: use new GPIO line value setter callbacks
  2025-07-07  7:50 ` [PATCH 05/12] gpio: tqmx86: " Bartosz Golaszewski
@ 2025-07-07 12:32   ` Matthias Schiffer
  0 siblings, 0 replies; 17+ messages in thread
From: Matthias Schiffer @ 2025-07-07 12:32 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, linux, linux-arm-kernel, virtualization,
	Bartosz Golaszewski, Linus Walleij, Kunihiko Hayashi,
	Masami Hiramatsu, Viresh Kumar

On Mon, 2025-07-07 at 09:50 +0200, Bartosz Golaszewski wrote:
> 
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> struct gpio_chip now has callbacks for setting line values that return
> an integer, allowing to indicate failures. Convert the driver to using
> them.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Acked-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>

> ---
>  drivers/gpio/gpio-tqmx86.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
> index 18f523a15b3c03e083b363a026e751f7367fb080..056799ecce6a256f3438d9fd81ee4677cdd20125 100644
> --- a/drivers/gpio/gpio-tqmx86.c
> +++ b/drivers/gpio/gpio-tqmx86.c
> @@ -93,14 +93,16 @@ static void _tqmx86_gpio_set(struct tqmx86_gpio_data *gpio, unsigned int offset,
>  	tqmx86_gpio_write(gpio, bitmap_get_value8(gpio->output, 0), TQMX86_GPIOD);
>  }
>  
> -static void tqmx86_gpio_set(struct gpio_chip *chip, unsigned int offset,
> -			    int value)
> +static int tqmx86_gpio_set(struct gpio_chip *chip, unsigned int offset,
> +			   int value)
>  {
>  	struct tqmx86_gpio_data *gpio = gpiochip_get_data(chip);
>  
>  	guard(raw_spinlock_irqsave)(&gpio->spinlock);
>  
>  	_tqmx86_gpio_set(gpio, offset, value);
> +
> +	return 0;
>  }
>  
>  static int tqmx86_gpio_direction_input(struct gpio_chip *chip,
> @@ -368,7 +370,7 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
>  	chip->direction_output = tqmx86_gpio_direction_output;
>  	chip->get_direction = tqmx86_gpio_get_direction;
>  	chip->get = tqmx86_gpio_get;
> -	chip->set = tqmx86_gpio_set;
> +	chip->set_rv = tqmx86_gpio_set;
>  	chip->ngpio = TQMX86_NGPIO;
>  	chip->parent = pdev->dev.parent;
>  
> 

-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/

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

* Re: [PATCH 10/12] gpio: uniphier: use new GPIO line value setter callbacks
  2025-07-07  7:50 ` [PATCH 10/12] gpio: uniphier: use new GPIO line value setter callbacks Bartosz Golaszewski
@ 2025-07-08  0:30   ` Kunihiko Hayashi
  0 siblings, 0 replies; 17+ messages in thread
From: Kunihiko Hayashi @ 2025-07-08  0:30 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Viresh Kumar, Masami Hiramatsu, linux-gpio,
	linux-kernel, linux, linux-arm-kernel, virtualization

Hi Bartosz,

On 2025/07/07 16:50, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> struct gpio_chip now has callbacks for setting line values that return
> an integer, allowing to indicate failures. Convert the driver to using
> them.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>   drivers/gpio/gpio-uniphier.c | 16 ++++++++++------
>   1 file changed, 10 insertions(+), 6 deletions(-)

Looks good to me.

Acked-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>

Thank you,

---
Best Regards
Kunihiko Hayashi

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

* Re: [PATCH 00/12] gpio: use new GPIO line value setter callbacks
  2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
                   ` (11 preceding siblings ...)
  2025-07-07  7:50 ` [PATCH 12/12] gpio: virtio: " Bartosz Golaszewski
@ 2025-07-13  8:45 ` Bartosz Golaszewski
  12 siblings, 0 replies; 17+ messages in thread
From: Bartosz Golaszewski @ 2025-07-13  8:45 UTC (permalink / raw)
  To: Linus Walleij, Kunihiko Hayashi, Masami Hiramatsu, Viresh Kumar,
	Bartosz Golaszewski
  Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, linux,
	linux-arm-kernel, virtualization

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Mon, 07 Jul 2025 09:50:13 +0200, Bartosz Golaszewski wrote:
> Commit 98ce1eb1fd87e ("gpiolib: introduce gpio_chip setters that return
> values") added new line setter callbacks to struct gpio_chip. They allow
> to indicate failures to callers. We're in the process of converting all
> GPIO controllers to using them before removing the old ones. This series
> converts another round of GPIO drivers.
> 
> To:
> 
> [...]

Applied, thanks!

[01/12] gpio: tps65910: use new GPIO line value setter callbacks
        https://git.kernel.org/brgl/linux/c/3e498b3c7b96a17037b5777c56ccff33d3bfbca5
[02/12] gpio: tps65912: check the return value of regmap_update_bits()
        https://git.kernel.org/brgl/linux/c/a0b2a6bbff8c26aafdecd320f38f52c341d5cafa
[03/12] gpio: tps65912: use new GPIO line value setter callbacks
        https://git.kernel.org/brgl/linux/c/22cbcfe36e9724fda06ca873e20777d863445ab8
[04/12] gpio: tps68470: use new GPIO line value setter callbacks
        https://git.kernel.org/brgl/linux/c/e41e51f07b1c8a642fed121d01da37c1c2994f89
[05/12] gpio: tqmx86: use new GPIO line value setter callbacks
        https://git.kernel.org/brgl/linux/c/9ade48906b62fc7c5b999422891408a4f02c255a
[06/12] gpio: ts4900: use new GPIO line value setter callbacks
        https://git.kernel.org/brgl/linux/c/ed8497dc6683cd285ef4335a315d398524c4af52
[07/12] gpio: twl4030: use new GPIO line value setter callbacks
        https://git.kernel.org/brgl/linux/c/0446ce284bebe192be6e0da6e969379dc3dac587
[08/12] gpio: twl6040: use new GPIO line value setter callbacks
        https://git.kernel.org/brgl/linux/c/77ba4640cc1564f29b280040b312688b79039c4c
[09/12] gpio: twl6040: set line value in .direction_out()
        https://git.kernel.org/brgl/linux/c/79880eba2c0feed895e6d2aa8f7e5489d113d653
[10/12] gpio: uniphier: use new GPIO line value setter callbacks
        https://git.kernel.org/brgl/linux/c/42fbbe31634d116a7f6bee75c0ae455bf10a7737
[11/12] gpio: viperboard: use new GPIO line value setter callbacks
        https://git.kernel.org/brgl/linux/c/55e2d1eec110f1278324882714b64465e4e58ced
[12/12] gpio: virtio: use new GPIO line value setter callbacks
        https://git.kernel.org/brgl/linux/c/e502df58b5e3767c00e887744b6eff43b7fde3ea

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

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

end of thread, other threads:[~2025-07-13  8:45 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-07  7:50 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
2025-07-07  7:50 ` [PATCH 01/12] gpio: tps65910: " Bartosz Golaszewski
2025-07-07  7:50 ` [PATCH 02/12] gpio: tps65912: check the return value of regmap_update_bits() Bartosz Golaszewski
2025-07-07  7:50 ` [PATCH 03/12] gpio: tps65912: use new GPIO line value setter callbacks Bartosz Golaszewski
2025-07-07  7:50 ` [PATCH 04/12] gpio: tps68470: " Bartosz Golaszewski
2025-07-07  7:50 ` [PATCH 05/12] gpio: tqmx86: " Bartosz Golaszewski
2025-07-07 12:32   ` Matthias Schiffer
2025-07-07  7:50 ` [PATCH 06/12] gpio: ts4900: " Bartosz Golaszewski
2025-07-07  7:50 ` [PATCH 07/12] gpio: twl4030: " Bartosz Golaszewski
2025-07-07  7:50 ` [PATCH 08/12] gpio: twl6040: " Bartosz Golaszewski
2025-07-07  7:50 ` [PATCH 09/12] gpio: twl6040: set line value in .direction_out() Bartosz Golaszewski
2025-07-07  7:50 ` [PATCH 10/12] gpio: uniphier: use new GPIO line value setter callbacks Bartosz Golaszewski
2025-07-08  0:30   ` Kunihiko Hayashi
2025-07-07  7:50 ` [PATCH 11/12] gpio: viperboard: " Bartosz Golaszewski
2025-07-07  7:50 ` [PATCH 12/12] gpio: virtio: " Bartosz Golaszewski
2025-07-07  8:29   ` Viresh Kumar
2025-07-13  8:45 ` [PATCH 00/12] gpio: " Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).