iio: adc: ti-ads7950: use new GPIO line value setter callbacks
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 9 Apr 2025 08:40:42 +0000 (10:40 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 22 Apr 2025 18:10:02 +0000 (19:10 +0100)
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>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250409-gpiochip-set-rv-iio-v2-4-4b36428f39cb@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ti-ads7950.c

index af28672..0356ccf 100644 (file)
@@ -403,10 +403,11 @@ static const struct iio_info ti_ads7950_info = {
        .update_scan_mode       = ti_ads7950_update_scan_mode,
 };
 
-static void ti_ads7950_set(struct gpio_chip *chip, unsigned int offset,
-                          int value)
+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);
 
@@ -416,9 +417,11 @@ static void 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);
-       spi_sync(st->spi, &st->scan_single_msg);
+       ret = spi_sync(st->spi, &st->scan_single_msg);
 
        mutex_unlock(&st->slock);
+
+       return ret;
 }
 
 static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
@@ -499,7 +502,11 @@ static int ti_ads7950_direction_input(struct gpio_chip *chip,
 static int ti_ads7950_direction_output(struct gpio_chip *chip,
                                       unsigned int offset, int value)
 {
-       ti_ads7950_set(chip, offset, value);
+       int ret;
+
+       ret = ti_ads7950_set(chip, offset, value);
+       if (ret)
+               return ret;
 
        return _ti_ads7950_set_direction(chip, offset, 0);
 }
@@ -641,7 +648,7 @@ static int ti_ads7950_probe(struct spi_device *spi)
        st->chip.direction_input = ti_ads7950_direction_input;
        st->chip.direction_output = ti_ads7950_direction_output;
        st->chip.get = ti_ads7950_get;
-       st->chip.set = ti_ads7950_set;
+       st->chip.set_rv = ti_ads7950_set;
 
        ret = gpiochip_add_data(&st->chip, st);
        if (ret) {