* [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift
@ 2026-04-06 4:39 Dmitry Torokhov
2026-04-06 4:39 ` [PATCH v5 1/4] iio: adc: ti-ads7950: switch to using guard() notation Dmitry Torokhov
` (7 more replies)
0 siblings, 8 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2026-04-06 4:39 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner
Cc: Nuno Sá, Andy Shevchenko, Linus Walleij, Bartosz Golaszewski,
linux-iio, linux-kernel, linux-gpio, Jonathan Cameron,
Bartosz Golaszewski
The original reason for this series is to make sure ti_ads7950_get()
returns result in range [0, 1] or a negative error code to comply with
gpiolib requirement.
During review David noticed the fact that the function also clobbers
gpio state. Fixing that lead to adding cleanups using guard() and devm.
---
Changes in v5:
- replace mutex_init() with devm_mutex_init() (Bartosz)
- Link to v4: https://patch.msgid.link/20260329-ti-ads7950-facelift-v4-0-c568c508c49a@gmail.com
Changes in v4:
- rebased on top of latest next
- dropped the 2 already applied patches
- restored inadvertently removed mutex_init() (Andy)
- stopped calling devm_regulator_get_enable_read_voltage() on ACPI
systems as it is guaranteed to fail (David, Jonathan)
- removed call to spi_set_drvdata() since it is not needed anymore (David)
- Link to v3: https://patch.msgid.link/20260305-ti-ads7950-facelift-v3-0-a23fdd1a079e@gmail.com
Changes in v3:
- Added "Fixes" tags
- Picked up reviewed-by tags for #1 and #2
- Dropped the conversion to "error" variables
- Avoid using scoped_guard (per David)
- directly return results of function calls at the end of function (David)
- Split spi_sync() error handling into a new patxch (Andy)
- Switch to using devm_regulator_get_enable_read_voltage() (David)
Changes in v2:
- style fixes in #1 (per David)
- fix to not clobber state (#2, new)
- #3 and #4 (new)
---
Dmitry Torokhov (4):
iio: adc: ti-ads7950: switch to using guard() notation
iio: adc: ti-ads7950: simplify check for spi_setup() failures
iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()
iio: adc: ti-ads7950: complete conversion to using managed resources
drivers/iio/adc/ti-ads7950.c | 197 ++++++++++++++-----------------------------
1 file changed, 64 insertions(+), 133 deletions(-)
---
base-commit: 2febe6e6ee6e34c7754eff3c4d81aa7b0dcb7979
change-id: 20260220-ti-ads7950-facelift-ad8b5390a654
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 1/4] iio: adc: ti-ads7950: switch to using guard() notation
2026-04-06 4:39 [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift Dmitry Torokhov
@ 2026-04-06 4:39 ` Dmitry Torokhov
2026-04-06 4:39 ` [PATCH v5 2/4] iio: adc: ti-ads7950: simplify check for spi_setup() failures Dmitry Torokhov
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2026-04-06 4:39 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner
Cc: Nuno Sá, Andy Shevchenko, Linus Walleij, Bartosz Golaszewski,
linux-iio, linux-kernel, linux-gpio, Jonathan Cameron,
Bartosz Golaszewski
guard() notation allows early returns when encountering errors, making
control flow more obvious. Use it.
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/iio/adc/ti-ads7950.c | 83 +++++++++++++++++---------------------------
1 file changed, 31 insertions(+), 52 deletions(-)
diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
index 028acd42741f..6e9ea9cc33bf 100644
--- a/drivers/iio/adc/ti-ads7950.c
+++ b/drivers/iio/adc/ti-ads7950.c
@@ -299,18 +299,19 @@ static irqreturn_t ti_ads7950_trigger_handler(int irq, void *p)
struct ti_ads7950_state *st = iio_priv(indio_dev);
int ret;
- mutex_lock(&st->slock);
- ret = spi_sync(st->spi, &st->ring_msg);
- if (ret < 0)
- goto out;
-
- iio_push_to_buffers_with_ts_unaligned(indio_dev, &st->rx_buf[2],
- sizeof(*st->rx_buf) *
- TI_ADS7950_MAX_CHAN,
- iio_get_time_ns(indio_dev));
-
-out:
- mutex_unlock(&st->slock);
+ do {
+ guard(mutex)(&st->slock);
+
+ ret = spi_sync(st->spi, &st->ring_msg);
+ if (ret)
+ break;
+
+ iio_push_to_buffers_with_ts_unaligned(indio_dev, &st->rx_buf[2],
+ sizeof(*st->rx_buf) *
+ TI_ADS7950_MAX_CHAN,
+ iio_get_time_ns(indio_dev));
+ } while (0);
+
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
@@ -321,20 +322,16 @@ static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch)
struct ti_ads7950_state *st = iio_priv(indio_dev);
int ret, cmd;
- mutex_lock(&st->slock);
+ guard(mutex)(&st->slock);
+
cmd = TI_ADS7950_MAN_CMD(TI_ADS7950_CR_CHAN(ch));
st->single_tx = cmd;
ret = spi_sync(st->spi, &st->scan_single_msg);
if (ret)
- goto out;
-
- ret = st->single_rx;
-
-out:
- mutex_unlock(&st->slock);
+ return ret;
- return ret;
+ return st->single_rx;
}
static int ti_ads7950_get_range(struct ti_ads7950_state *st)
@@ -400,9 +397,8 @@ static int ti_ads7950_set(struct gpio_chip *chip, unsigned int offset,
int value)
{
struct ti_ads7950_state *st = gpiochip_get_data(chip);
- int ret;
- mutex_lock(&st->slock);
+ guard(mutex)(&st->slock);
if (value)
st->cmd_settings_bitmask |= BIT(offset);
@@ -410,11 +406,8 @@ static int ti_ads7950_set(struct gpio_chip *chip, unsigned int offset,
st->cmd_settings_bitmask &= ~BIT(offset);
st->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);
- ret = spi_sync(st->spi, &st->scan_single_msg);
-
- mutex_unlock(&st->slock);
- return ret;
+ return spi_sync(st->spi, &st->scan_single_msg);
}
static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
@@ -423,13 +416,12 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
bool state;
int ret;
- mutex_lock(&st->slock);
+ guard(mutex)(&st->slock);
/* If set as output, return the output */
if (st->gpio_cmd_settings_bitmask & BIT(offset)) {
state = st->cmd_settings_bitmask & BIT(offset);
- ret = 0;
- goto out;
+ return state;
}
/* GPIO data bit sets SDO bits 12-15 to GPIO input */
@@ -437,7 +429,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
st->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);
ret = spi_sync(st->spi, &st->scan_single_msg);
if (ret)
- goto out;
+ return ret;
state = (st->single_rx >> 12) & BIT(offset);
@@ -446,12 +438,9 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
st->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);
ret = spi_sync(st->spi, &st->scan_single_msg);
if (ret)
- goto out;
-
-out:
- mutex_unlock(&st->slock);
+ return ret;
- return ret ?: state;
+ return state;
}
static int ti_ads7950_get_direction(struct gpio_chip *chip,
@@ -467,9 +456,8 @@ static int _ti_ads7950_set_direction(struct gpio_chip *chip, int offset,
int input)
{
struct ti_ads7950_state *st = gpiochip_get_data(chip);
- int ret = 0;
- mutex_lock(&st->slock);
+ guard(mutex)(&st->slock);
/* Only change direction if needed */
if (input && (st->gpio_cmd_settings_bitmask & BIT(offset)))
@@ -477,15 +465,11 @@ static int _ti_ads7950_set_direction(struct gpio_chip *chip, int offset,
else if (!input && !(st->gpio_cmd_settings_bitmask & BIT(offset)))
st->gpio_cmd_settings_bitmask |= BIT(offset);
else
- goto out;
+ return 0;
st->single_tx = TI_ADS7950_GPIO_CMD_SETTINGS(st);
- ret = spi_sync(st->spi, &st->scan_single_msg);
-
-out:
- mutex_unlock(&st->slock);
- return ret;
+ return spi_sync(st->spi, &st->scan_single_msg);
}
static int ti_ads7950_direction_input(struct gpio_chip *chip,
@@ -508,9 +492,9 @@ static int ti_ads7950_direction_output(struct gpio_chip *chip,
static int ti_ads7950_init_hw(struct ti_ads7950_state *st)
{
- int ret = 0;
+ int ret;
- mutex_lock(&st->slock);
+ guard(mutex)(&st->slock);
/* Settings for Manual/Auto1/Auto2 commands */
/* Default to 5v ref */
@@ -518,17 +502,12 @@ static int ti_ads7950_init_hw(struct ti_ads7950_state *st)
st->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st);
ret = spi_sync(st->spi, &st->scan_single_msg);
if (ret)
- goto out;
+ return ret;
/* Settings for GPIO command */
st->gpio_cmd_settings_bitmask = 0x0;
st->single_tx = TI_ADS7950_GPIO_CMD_SETTINGS(st);
- ret = spi_sync(st->spi, &st->scan_single_msg);
-
-out:
- mutex_unlock(&st->slock);
-
- return ret;
+ return spi_sync(st->spi, &st->scan_single_msg);
}
static int ti_ads7950_probe(struct spi_device *spi)
--
2.53.0.1213.gd9a14994de-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 2/4] iio: adc: ti-ads7950: simplify check for spi_setup() failures
2026-04-06 4:39 [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift Dmitry Torokhov
2026-04-06 4:39 ` [PATCH v5 1/4] iio: adc: ti-ads7950: switch to using guard() notation Dmitry Torokhov
@ 2026-04-06 4:39 ` Dmitry Torokhov
2026-04-06 4:39 ` [PATCH v5 3/4] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage() Dmitry Torokhov
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2026-04-06 4:39 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner
Cc: Nuno Sá, Andy Shevchenko, Linus Walleij, Bartosz Golaszewski,
linux-iio, linux-kernel, linux-gpio, Jonathan Cameron,
Bartosz Golaszewski
spi_setup() specifies that it returns 0 on success or negative error on
failure. Therefore we can simply check for the return code being 0 or
not.
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/iio/adc/ti-ads7950.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
index 6e9ea9cc33bf..c31c706c92a9 100644
--- a/drivers/iio/adc/ti-ads7950.c
+++ b/drivers/iio/adc/ti-ads7950.c
@@ -520,7 +520,7 @@ static int ti_ads7950_probe(struct spi_device *spi)
spi->bits_per_word = 16;
spi->mode |= SPI_CS_WORD;
ret = spi_setup(spi);
- if (ret < 0) {
+ if (ret) {
dev_err(&spi->dev, "Error in spi setup\n");
return ret;
}
--
2.53.0.1213.gd9a14994de-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 3/4] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()
2026-04-06 4:39 [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift Dmitry Torokhov
2026-04-06 4:39 ` [PATCH v5 1/4] iio: adc: ti-ads7950: switch to using guard() notation Dmitry Torokhov
2026-04-06 4:39 ` [PATCH v5 2/4] iio: adc: ti-ads7950: simplify check for spi_setup() failures Dmitry Torokhov
@ 2026-04-06 4:39 ` Dmitry Torokhov
2026-04-06 4:39 ` [PATCH v5 4/4] iio: adc: ti-ads7950: complete conversion to using managed resources Dmitry Torokhov
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2026-04-06 4:39 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner
Cc: Nuno Sá, Andy Shevchenko, Linus Walleij, Bartosz Golaszewski,
linux-iio, linux-kernel, linux-gpio, Jonathan Cameron,
Bartosz Golaszewski
The regulator is enabled for the entire time the driver is bound to the
device, and we only need to access it to fetch voltage, which can be
done at probe time.
Switch to using devm_regulator_get_enable_read_voltage() which
simplifies probing and unbinding code.
Suggested-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/iio/adc/ti-ads7950.c | 48 ++++++++++++--------------------------------
1 file changed, 13 insertions(+), 35 deletions(-)
diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
index c31c706c92a9..0b98c8e7385d 100644
--- a/drivers/iio/adc/ti-ads7950.c
+++ b/drivers/iio/adc/ti-ads7950.c
@@ -334,19 +334,9 @@ static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch)
return st->single_rx;
}
-static int ti_ads7950_get_range(struct ti_ads7950_state *st)
+static unsigned int ti_ads7950_get_range(struct ti_ads7950_state *st)
{
- int vref;
-
- if (st->vref_mv) {
- vref = st->vref_mv;
- } else {
- vref = regulator_get_voltage(st->reg);
- if (vref < 0)
- return vref;
-
- vref /= 1000;
- }
+ unsigned int vref = st->vref_mv;
if (st->cmd_settings_bitmask & TI_ADS7950_CR_RANGE_5V)
vref *= 2;
@@ -375,11 +365,7 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
- ret = ti_ads7950_get_range(st);
- if (ret < 0)
- return ret;
-
- *val = ret;
+ *val = ti_ads7950_get_range(st);
*val2 = (1 << chan->scan_type.realbits) - 1;
return IIO_VAL_FRACTIONAL;
@@ -573,30 +559,25 @@ static int ti_ads7950_probe(struct spi_device *spi)
spi_message_init_with_transfers(&st->scan_single_msg,
st->scan_single_xfer, 3);
- /* Use hard coded value for reference voltage in ACPI case */
- if (ACPI_COMPANION(&spi->dev))
- st->vref_mv = TI_ADS7950_VA_MV_ACPI_DEFAULT;
-
mutex_init(&st->slock);
- st->reg = devm_regulator_get(&spi->dev, "vref");
- if (IS_ERR(st->reg)) {
- ret = dev_err_probe(&spi->dev, PTR_ERR(st->reg),
- "Failed to get regulator \"vref\"\n");
- goto error_destroy_mutex;
- }
+ /* Use hard coded value for reference voltage in ACPI case */
+ if (ACPI_COMPANION(&spi->dev)) {
+ st->vref_mv = TI_ADS7950_VA_MV_ACPI_DEFAULT;
+ } else {
+ ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref");
+ if (ret < 0)
+ return dev_err_probe(&spi->dev, ret,
+ "Failed to get regulator \"vref\"\n");
- ret = regulator_enable(st->reg);
- if (ret) {
- dev_err(&spi->dev, "Failed to enable regulator \"vref\"\n");
- goto error_destroy_mutex;
+ st->vref_mv = ret / 1000;
}
ret = iio_triggered_buffer_setup(indio_dev, NULL,
&ti_ads7950_trigger_handler, NULL);
if (ret) {
dev_err(&spi->dev, "Failed to setup triggered buffer\n");
- goto error_disable_reg;
+ goto error_destroy_mutex;
}
ret = ti_ads7950_init_hw(st);
@@ -636,8 +617,6 @@ static int ti_ads7950_probe(struct spi_device *spi)
iio_device_unregister(indio_dev);
error_cleanup_ring:
iio_triggered_buffer_cleanup(indio_dev);
-error_disable_reg:
- regulator_disable(st->reg);
error_destroy_mutex:
mutex_destroy(&st->slock);
@@ -652,7 +631,6 @@ static void ti_ads7950_remove(struct spi_device *spi)
gpiochip_remove(&st->chip);
iio_device_unregister(indio_dev);
iio_triggered_buffer_cleanup(indio_dev);
- regulator_disable(st->reg);
mutex_destroy(&st->slock);
}
--
2.53.0.1213.gd9a14994de-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 4/4] iio: adc: ti-ads7950: complete conversion to using managed resources
2026-04-06 4:39 [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift Dmitry Torokhov
` (2 preceding siblings ...)
2026-04-06 4:39 ` [PATCH v5 3/4] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage() Dmitry Torokhov
@ 2026-04-06 4:39 ` Dmitry Torokhov
2026-04-07 10:43 ` Bartosz Golaszewski
2026-04-07 12:24 ` [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift Andy Shevchenko
` (3 subsequent siblings)
7 siblings, 1 reply; 10+ messages in thread
From: Dmitry Torokhov @ 2026-04-06 4:39 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner
Cc: Nuno Sá, Andy Shevchenko, Linus Walleij, Bartosz Golaszewski,
linux-iio, linux-kernel, linux-gpio, Jonathan Cameron
All resources that the driver needs have managed API now. Switch to
using them to make code clearer and drop ti_ads7950_remove().
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/iio/adc/ti-ads7950.c | 70 ++++++++++++++------------------------------
1 file changed, 22 insertions(+), 48 deletions(-)
diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
index 0b98c8e7385d..882b280d9e0b 100644
--- a/drivers/iio/adc/ti-ads7950.c
+++ b/drivers/iio/adc/ti-ads7950.c
@@ -506,10 +506,8 @@ static int ti_ads7950_probe(struct spi_device *spi)
spi->bits_per_word = 16;
spi->mode |= SPI_CS_WORD;
ret = spi_setup(spi);
- if (ret) {
- dev_err(&spi->dev, "Error in spi setup\n");
- return ret;
- }
+ if (ret)
+ return dev_err_probe(&spi->dev, ret, "Error in spi setup\n");
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (!indio_dev)
@@ -517,8 +515,6 @@ static int ti_ads7950_probe(struct spi_device *spi)
st = iio_priv(indio_dev);
- spi_set_drvdata(spi, indio_dev);
-
st->spi = spi;
info = spi_get_device_match_data(spi);
@@ -559,7 +555,9 @@ static int ti_ads7950_probe(struct spi_device *spi)
spi_message_init_with_transfers(&st->scan_single_msg,
st->scan_single_xfer, 3);
- mutex_init(&st->slock);
+ ret = devm_mutex_init(&spi->dev, &st->slock);
+ if (ret)
+ return ret;
/* Use hard coded value for reference voltage in ACPI case */
if (ACPI_COMPANION(&spi->dev)) {
@@ -573,24 +571,22 @@ static int ti_ads7950_probe(struct spi_device *spi)
st->vref_mv = ret / 1000;
}
- ret = iio_triggered_buffer_setup(indio_dev, NULL,
- &ti_ads7950_trigger_handler, NULL);
- if (ret) {
- dev_err(&spi->dev, "Failed to setup triggered buffer\n");
- goto error_destroy_mutex;
- }
+ ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL,
+ &ti_ads7950_trigger_handler,
+ NULL);
+ if (ret)
+ return dev_err_probe(&spi->dev, ret,
+ "Failed to setup triggered buffer\n");
ret = ti_ads7950_init_hw(st);
- if (ret) {
- dev_err(&spi->dev, "Failed to init adc chip\n");
- goto error_cleanup_ring;
- }
+ if (ret)
+ return dev_err_probe(&spi->dev, ret,
+ "Failed to init adc chip\n");
- ret = iio_device_register(indio_dev);
- if (ret) {
- dev_err(&spi->dev, "Failed to register iio device\n");
- goto error_cleanup_ring;
- }
+ ret = devm_iio_device_register(&spi->dev, indio_dev);
+ if (ret)
+ return dev_err_probe(&spi->dev, ret,
+ "Failed to register iio device\n");
/* Add GPIO chip */
st->chip.label = dev_name(&st->spi->dev);
@@ -605,33 +601,12 @@ static int ti_ads7950_probe(struct spi_device *spi)
st->chip.get = ti_ads7950_get;
st->chip.set = ti_ads7950_set;
- ret = gpiochip_add_data(&st->chip, st);
- if (ret) {
- dev_err(&spi->dev, "Failed to init GPIOs\n");
- goto error_iio_device;
- }
+ ret = devm_gpiochip_add_data(&spi->dev, &st->chip, st);
+ if (ret)
+ return dev_err_probe(&spi->dev, ret,
+ "Failed to init GPIOs\n");
return 0;
-
-error_iio_device:
- iio_device_unregister(indio_dev);
-error_cleanup_ring:
- iio_triggered_buffer_cleanup(indio_dev);
-error_destroy_mutex:
- mutex_destroy(&st->slock);
-
- return ret;
-}
-
-static void ti_ads7950_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct ti_ads7950_state *st = iio_priv(indio_dev);
-
- gpiochip_remove(&st->chip);
- iio_device_unregister(indio_dev);
- iio_triggered_buffer_cleanup(indio_dev);
- mutex_destroy(&st->slock);
}
static const struct spi_device_id ti_ads7950_id[] = {
@@ -674,7 +649,6 @@ static struct spi_driver ti_ads7950_driver = {
.of_match_table = ads7950_of_table,
},
.probe = ti_ads7950_probe,
- .remove = ti_ads7950_remove,
.id_table = ti_ads7950_id,
};
module_spi_driver(ti_ads7950_driver);
--
2.53.0.1213.gd9a14994de-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v5 4/4] iio: adc: ti-ads7950: complete conversion to using managed resources
2026-04-06 4:39 ` [PATCH v5 4/4] iio: adc: ti-ads7950: complete conversion to using managed resources Dmitry Torokhov
@ 2026-04-07 10:43 ` Bartosz Golaszewski
0 siblings, 0 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2026-04-07 10:43 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Linus Walleij, linux-iio, linux-kernel, linux-gpio,
Jonathan Cameron
On Mon, Apr 6, 2026 at 6:39 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> All resources that the driver needs have managed API now. Switch to
> using them to make code clearer and drop ti_ads7950_remove().
>
> Reviewed-by: David Lechner <dlechner@baylibre.com>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift
2026-04-06 4:39 [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift Dmitry Torokhov
` (3 preceding siblings ...)
2026-04-06 4:39 ` [PATCH v5 4/4] iio: adc: ti-ads7950: complete conversion to using managed resources Dmitry Torokhov
@ 2026-04-07 12:24 ` Andy Shevchenko
2026-04-08 8:02 ` Linus Walleij
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2026-04-07 12:24 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Linus Walleij, Bartosz Golaszewski, linux-iio, linux-kernel,
linux-gpio, Jonathan Cameron, Bartosz Golaszewski
On Sun, Apr 05, 2026 at 09:39:22PM -0700, Dmitry Torokhov wrote:
> The original reason for this series is to make sure ti_ads7950_get()
> returns result in range [0, 1] or a negative error code to comply with
> gpiolib requirement.
>
> During review David noticed the fact that the function also clobbers
> gpio state. Fixing that lead to adding cleanups using guard() and devm.
Now the series LGTM,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Thanks.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift
2026-04-06 4:39 [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift Dmitry Torokhov
` (4 preceding siblings ...)
2026-04-07 12:24 ` [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift Andy Shevchenko
@ 2026-04-08 8:02 ` Linus Walleij
2026-04-11 21:39 ` David Lechner
2026-04-12 18:38 ` Jonathan Cameron
7 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2026-04-08 8:02 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Bartosz Golaszewski, linux-iio, linux-kernel, linux-gpio,
Jonathan Cameron, Bartosz Golaszewski
On Mon, Apr 6, 2026 at 6:39 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> The original reason for this series is to make sure ti_ads7950_get()
> returns result in range [0, 1] or a negative error code to comply with
> gpiolib requirement.
This looks awesome. Thanks for all attention to detail and elegance.
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift
2026-04-06 4:39 [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift Dmitry Torokhov
` (5 preceding siblings ...)
2026-04-08 8:02 ` Linus Walleij
@ 2026-04-11 21:39 ` David Lechner
2026-04-12 18:38 ` Jonathan Cameron
7 siblings, 0 replies; 10+ messages in thread
From: David Lechner @ 2026-04-11 21:39 UTC (permalink / raw)
To: Dmitry Torokhov, Jonathan Cameron
Cc: Nuno Sá, Andy Shevchenko, Linus Walleij, Bartosz Golaszewski,
linux-iio, linux-kernel, linux-gpio, Jonathan Cameron,
Bartosz Golaszewski
On 4/5/26 11:39 PM, Dmitry Torokhov wrote:
> The original reason for this series is to make sure ti_ads7950_get()
> returns result in range [0, 1] or a negative error code to comply with
> gpiolib requirement.
>
> During review David noticed the fact that the function also clobbers
> gpio state. Fixing that lead to adding cleanups using guard() and devm.
>
Tested-by: David Lechner <dlechner@baylibre.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift
2026-04-06 4:39 [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift Dmitry Torokhov
` (6 preceding siblings ...)
2026-04-11 21:39 ` David Lechner
@ 2026-04-12 18:38 ` Jonathan Cameron
7 siblings, 0 replies; 10+ messages in thread
From: Jonathan Cameron @ 2026-04-12 18:38 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: David Lechner, Nuno Sá, Andy Shevchenko, Linus Walleij,
Bartosz Golaszewski, linux-iio, linux-kernel, linux-gpio,
Jonathan Cameron, Bartosz Golaszewski
On Sun, 05 Apr 2026 21:39:22 -0700
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> The original reason for this series is to make sure ti_ads7950_get()
> returns result in range [0, 1] or a negative error code to comply with
> gpiolib requirement.
>
> During review David noticed the fact that the function also clobbers
> gpio state. Fixing that lead to adding cleanups using guard() and devm.
>
Applied to the testing branch of iio.git. I'll rebase that on rc1 once available.
Thanks for persisting with this. Indeed a nice facelift ;)
Jonathan
> ---
> Changes in v5:
> - replace mutex_init() with devm_mutex_init() (Bartosz)
> - Link to v4: https://patch.msgid.link/20260329-ti-ads7950-facelift-v4-0-c568c508c49a@gmail.com
>
> Changes in v4:
> - rebased on top of latest next
> - dropped the 2 already applied patches
> - restored inadvertently removed mutex_init() (Andy)
> - stopped calling devm_regulator_get_enable_read_voltage() on ACPI
> systems as it is guaranteed to fail (David, Jonathan)
> - removed call to spi_set_drvdata() since it is not needed anymore (David)
> - Link to v3: https://patch.msgid.link/20260305-ti-ads7950-facelift-v3-0-a23fdd1a079e@gmail.com
>
> Changes in v3:
>
> - Added "Fixes" tags
> - Picked up reviewed-by tags for #1 and #2
> - Dropped the conversion to "error" variables
> - Avoid using scoped_guard (per David)
> - directly return results of function calls at the end of function (David)
> - Split spi_sync() error handling into a new patxch (Andy)
> - Switch to using devm_regulator_get_enable_read_voltage() (David)
>
> Changes in v2:
>
> - style fixes in #1 (per David)
> - fix to not clobber state (#2, new)
> - #3 and #4 (new)
>
> ---
> Dmitry Torokhov (4):
> iio: adc: ti-ads7950: switch to using guard() notation
> iio: adc: ti-ads7950: simplify check for spi_setup() failures
> iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage()
> iio: adc: ti-ads7950: complete conversion to using managed resources
>
> drivers/iio/adc/ti-ads7950.c | 197 ++++++++++++++-----------------------------
> 1 file changed, 64 insertions(+), 133 deletions(-)
> ---
> base-commit: 2febe6e6ee6e34c7754eff3c4d81aa7b0dcb7979
> change-id: 20260220-ti-ads7950-facelift-ad8b5390a654
>
> Thanks.
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-04-12 18:39 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-06 4:39 [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift Dmitry Torokhov
2026-04-06 4:39 ` [PATCH v5 1/4] iio: adc: ti-ads7950: switch to using guard() notation Dmitry Torokhov
2026-04-06 4:39 ` [PATCH v5 2/4] iio: adc: ti-ads7950: simplify check for spi_setup() failures Dmitry Torokhov
2026-04-06 4:39 ` [PATCH v5 3/4] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage() Dmitry Torokhov
2026-04-06 4:39 ` [PATCH v5 4/4] iio: adc: ti-ads7950: complete conversion to using managed resources Dmitry Torokhov
2026-04-07 10:43 ` Bartosz Golaszewski
2026-04-07 12:24 ` [PATCH v5 0/4] ti-ads7950: fix gpio handling and facelift Andy Shevchenko
2026-04-08 8:02 ` Linus Walleij
2026-04-11 21:39 ` David Lechner
2026-04-12 18:38 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox