linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] hwmon: convert GPIO chips to using new value setters
@ 2025-04-07  7:16 Bartosz Golaszewski
  2025-04-07  7:16 ` [PATCH 1/2] hwmon: (ltc2992) Use new GPIO line value setter callbacks Bartosz Golaszewski
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2025-04-07  7:16 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, Linus Walleij, Bartosz Golaszewski
  Cc: linux-hwmon, linux-kernel, linux-gpio, Bartosz Golaszewski

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. We're in the process of
converting all GPIO drivers to using the new API. This series converts
all the hwmon drivers.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
Bartosz Golaszewski (2):
      hwmon: (ltc2992) Use new GPIO line value setter callbacks
      hwmon: (pmbus/ucd9000) Use new GPIO line value setter callbacks

 drivers/hwmon/ltc2992.c       | 28 +++++++++++++++++++---------
 drivers/hwmon/pmbus/ucd9000.c | 16 +++++++++-------
 2 files changed, 28 insertions(+), 16 deletions(-)
---
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
change-id: 20250331-gpiochip-set-rv-hwmon-6ff74f898034

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


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

* [PATCH 1/2] hwmon: (ltc2992) Use new GPIO line value setter callbacks
  2025-04-07  7:16 [PATCH 0/2] hwmon: convert GPIO chips to using new value setters Bartosz Golaszewski
@ 2025-04-07  7:16 ` Bartosz Golaszewski
  2025-04-07 21:59   ` Guenter Roeck
  2025-04-07  7:16 ` [PATCH 2/2] hwmon: (pmbus/ucd9000) " Bartosz Golaszewski
  2025-04-15  8:31 ` [PATCH 0/2] hwmon: convert GPIO chips to using new value setters Linus Walleij
  2 siblings, 1 reply; 7+ messages in thread
From: Bartosz Golaszewski @ 2025-04-07  7:16 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, Linus Walleij, Bartosz Golaszewski
  Cc: linux-hwmon, linux-kernel, linux-gpio, 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/hwmon/ltc2992.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/hwmon/ltc2992.c b/drivers/hwmon/ltc2992.c
index 541fa09dc6e7..a45a07ca11fe 100644
--- a/drivers/hwmon/ltc2992.c
+++ b/drivers/hwmon/ltc2992.c
@@ -256,33 +256,38 @@ static int ltc2992_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask
 	return 0;
 }
 
-static void ltc2992_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
+static int ltc2992_gpio_set(struct gpio_chip *chip, unsigned int offset,
+			    int value)
 {
 	struct ltc2992_state *st = gpiochip_get_data(chip);
 	unsigned long gpio_ctrl;
-	int reg;
+	int reg, ret;
 
 	mutex_lock(&st->gpio_mutex);
 	reg = ltc2992_read_reg(st, ltc2992_gpio_addr_map[offset].ctrl, 1);
 	if (reg < 0) {
 		mutex_unlock(&st->gpio_mutex);
-		return;
+		return reg;
 	}
 
 	gpio_ctrl = reg;
 	assign_bit(ltc2992_gpio_addr_map[offset].ctrl_bit, &gpio_ctrl, value);
 
-	ltc2992_write_reg(st, ltc2992_gpio_addr_map[offset].ctrl, 1, gpio_ctrl);
+	ret = ltc2992_write_reg(st, ltc2992_gpio_addr_map[offset].ctrl, 1,
+				gpio_ctrl);
 	mutex_unlock(&st->gpio_mutex);
+
+	return ret;
 }
 
-static void ltc2992_gpio_set_multiple(struct gpio_chip *chip, unsigned long *mask,
+static int ltc2992_gpio_set_multiple(struct gpio_chip *chip, unsigned long *mask,
 				      unsigned long *bits)
 {
 	struct ltc2992_state *st = gpiochip_get_data(chip);
 	unsigned long gpio_ctrl_io = 0;
 	unsigned long gpio_ctrl = 0;
 	unsigned int gpio_nr;
+	int ret;
 
 	for_each_set_bit(gpio_nr, mask, LTC2992_GPIO_NR) {
 		if (gpio_nr < 3)
@@ -293,9 +298,14 @@ static void ltc2992_gpio_set_multiple(struct gpio_chip *chip, unsigned long *mas
 	}
 
 	mutex_lock(&st->gpio_mutex);
-	ltc2992_write_reg(st, LTC2992_GPIO_IO_CTRL, 1, gpio_ctrl_io);
-	ltc2992_write_reg(st, LTC2992_GPIO_CTRL, 1, gpio_ctrl);
+	ret = ltc2992_write_reg(st, LTC2992_GPIO_IO_CTRL, 1, gpio_ctrl_io);
+	if (ret)
+		goto out;
+
+	ret = ltc2992_write_reg(st, LTC2992_GPIO_CTRL, 1, gpio_ctrl);
+out:
 	mutex_unlock(&st->gpio_mutex);
+	return ret;
 }
 
 static int ltc2992_config_gpio(struct ltc2992_state *st)
@@ -329,8 +339,8 @@ static int ltc2992_config_gpio(struct ltc2992_state *st)
 	st->gc.ngpio = ARRAY_SIZE(st->gpio_names);
 	st->gc.get = ltc2992_gpio_get;
 	st->gc.get_multiple = ltc2992_gpio_get_multiple;
-	st->gc.set = ltc2992_gpio_set;
-	st->gc.set_multiple = ltc2992_gpio_set_multiple;
+	st->gc.set_rv = ltc2992_gpio_set;
+	st->gc.set_multiple_rv = ltc2992_gpio_set_multiple;
 
 	ret = devm_gpiochip_add_data(&st->client->dev, &st->gc, st);
 	if (ret)

-- 
2.45.2


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

* [PATCH 2/2] hwmon: (pmbus/ucd9000) Use new GPIO line value setter callbacks
  2025-04-07  7:16 [PATCH 0/2] hwmon: convert GPIO chips to using new value setters Bartosz Golaszewski
  2025-04-07  7:16 ` [PATCH 1/2] hwmon: (ltc2992) Use new GPIO line value setter callbacks Bartosz Golaszewski
@ 2025-04-07  7:16 ` Bartosz Golaszewski
  2025-04-07 22:00   ` Guenter Roeck
  2025-04-15  8:31 ` [PATCH 0/2] hwmon: convert GPIO chips to using new value setters Linus Walleij
  2 siblings, 1 reply; 7+ messages in thread
From: Bartosz Golaszewski @ 2025-04-07  7:16 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, Linus Walleij, Bartosz Golaszewski
  Cc: linux-hwmon, linux-kernel, linux-gpio, 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/hwmon/pmbus/ucd9000.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c
index 9b0eadc81a2e..2bc8cccb01fd 100644
--- a/drivers/hwmon/pmbus/ucd9000.c
+++ b/drivers/hwmon/pmbus/ucd9000.c
@@ -212,8 +212,8 @@ static int ucd9000_gpio_get(struct gpio_chip *gc, unsigned int offset)
 	return !!(ret & UCD9000_GPIO_CONFIG_STATUS);
 }
 
-static void ucd9000_gpio_set(struct gpio_chip *gc, unsigned int offset,
-			     int value)
+static int ucd9000_gpio_set(struct gpio_chip *gc, unsigned int offset,
+			    int value)
 {
 	struct i2c_client *client = gpiochip_get_data(gc);
 	int ret;
@@ -222,17 +222,17 @@ static void ucd9000_gpio_set(struct gpio_chip *gc, unsigned int offset,
 	if (ret < 0) {
 		dev_dbg(&client->dev, "failed to read GPIO %d config: %d\n",
 			offset, ret);
-		return;
+		return ret;
 	}
 
 	if (value) {
 		if (ret & UCD9000_GPIO_CONFIG_STATUS)
-			return;
+			return 0;
 
 		ret |= UCD9000_GPIO_CONFIG_STATUS;
 	} else {
 		if (!(ret & UCD9000_GPIO_CONFIG_STATUS))
-			return;
+			return 0;
 
 		ret &= ~UCD9000_GPIO_CONFIG_STATUS;
 	}
@@ -244,7 +244,7 @@ static void ucd9000_gpio_set(struct gpio_chip *gc, unsigned int offset,
 	if (ret < 0) {
 		dev_dbg(&client->dev, "Failed to write GPIO %d config: %d\n",
 			offset, ret);
-		return;
+		return ret;
 	}
 
 	ret &= ~UCD9000_GPIO_CONFIG_ENABLE;
@@ -253,6 +253,8 @@ static void ucd9000_gpio_set(struct gpio_chip *gc, unsigned int offset,
 	if (ret < 0)
 		dev_dbg(&client->dev, "Failed to write GPIO %d config: %d\n",
 			offset, ret);
+
+	return ret;
 }
 
 static int ucd9000_gpio_get_direction(struct gpio_chip *gc,
@@ -362,7 +364,7 @@ static void ucd9000_probe_gpio(struct i2c_client *client,
 	data->gpio.direction_input = ucd9000_gpio_direction_input;
 	data->gpio.direction_output = ucd9000_gpio_direction_output;
 	data->gpio.get = ucd9000_gpio_get;
-	data->gpio.set = ucd9000_gpio_set;
+	data->gpio.set_rv = ucd9000_gpio_set;
 	data->gpio.can_sleep = true;
 	data->gpio.base = -1;
 	data->gpio.parent = &client->dev;

-- 
2.45.2


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

* Re: [PATCH 1/2] hwmon: (ltc2992) Use new GPIO line value setter callbacks
  2025-04-07  7:16 ` [PATCH 1/2] hwmon: (ltc2992) Use new GPIO line value setter callbacks Bartosz Golaszewski
@ 2025-04-07 21:59   ` Guenter Roeck
  2025-04-08  6:52     ` Bartosz Golaszewski
  0 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2025-04-07 21:59 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Jean Delvare, Linus Walleij, linux-hwmon, linux-kernel,
	linux-gpio, Bartosz Golaszewski

On Mon, Apr 07, 2025 at 09:16:16AM +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>

Applied, after fixing the multi-line alignment issue reported by checkpatch.

Guenter

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

* Re: [PATCH 2/2] hwmon: (pmbus/ucd9000) Use new GPIO line value setter callbacks
  2025-04-07  7:16 ` [PATCH 2/2] hwmon: (pmbus/ucd9000) " Bartosz Golaszewski
@ 2025-04-07 22:00   ` Guenter Roeck
  0 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2025-04-07 22:00 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Jean Delvare, Linus Walleij, linux-hwmon, linux-kernel,
	linux-gpio, Bartosz Golaszewski

On Mon, Apr 07, 2025 at 09:16:17AM +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>

Applied.

Thanks,
Guenter

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

* Re: [PATCH 1/2] hwmon: (ltc2992) Use new GPIO line value setter callbacks
  2025-04-07 21:59   ` Guenter Roeck
@ 2025-04-08  6:52     ` Bartosz Golaszewski
  0 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2025-04-08  6:52 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Jean Delvare, Linus Walleij, linux-hwmon, linux-kernel,
	linux-gpio, Bartosz Golaszewski

On Tue, Apr 8, 2025 at 12:00 AM Guenter Roeck <linux@roeck-us.net> wrote:
>
> On Mon, Apr 07, 2025 at 09:16:16AM +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>
>
> Applied, after fixing the multi-line alignment issue reported by checkpatch.
>

Huh, I always run b4 --check, it didn't report anything.

Anyway, thanks!

Bart

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

* Re: [PATCH 0/2] hwmon: convert GPIO chips to using new value setters
  2025-04-07  7:16 [PATCH 0/2] hwmon: convert GPIO chips to using new value setters Bartosz Golaszewski
  2025-04-07  7:16 ` [PATCH 1/2] hwmon: (ltc2992) Use new GPIO line value setter callbacks Bartosz Golaszewski
  2025-04-07  7:16 ` [PATCH 2/2] hwmon: (pmbus/ucd9000) " Bartosz Golaszewski
@ 2025-04-15  8:31 ` Linus Walleij
  2 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2025-04-15  8:31 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Jean Delvare, Guenter Roeck, linux-hwmon, linux-kernel,
	linux-gpio, Bartosz Golaszewski

On Mon, Apr 7, 2025 at 9:16 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> struct gpio_chip now has callbacks for setting line values that return
> an integer, allowing to indicate failures. We're in the process of
> converting all GPIO drivers to using the new API. This series converts
> all the hwmon drivers.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

The series:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

end of thread, other threads:[~2025-04-15  8:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-07  7:16 [PATCH 0/2] hwmon: convert GPIO chips to using new value setters Bartosz Golaszewski
2025-04-07  7:16 ` [PATCH 1/2] hwmon: (ltc2992) Use new GPIO line value setter callbacks Bartosz Golaszewski
2025-04-07 21:59   ` Guenter Roeck
2025-04-08  6:52     ` Bartosz Golaszewski
2025-04-07  7:16 ` [PATCH 2/2] hwmon: (pmbus/ucd9000) " Bartosz Golaszewski
2025-04-07 22:00   ` Guenter Roeck
2025-04-15  8:31 ` [PATCH 0/2] hwmon: convert GPIO chips to using new value setters Linus Walleij

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