iio: adc: ad9467: don't ignore error codes
authorNuno Sa <nuno.sa@analog.com>
Thu, 7 Dec 2023 12:39:25 +0000 (13:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:35:52 +0000 (15:35 -0800)
[ Upstream commit e072e149cfb827e0ab4cafb0547e9658e35393cd ]

Make sure functions that return errors are not ignored.

Fixes: ad6797120238 ("iio: adc: ad9467: add support AD9467 ADC")
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20231207-iio-backend-prep-v2-2-a4a33bc4d70e@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iio/adc/ad9467.c

index 4fb9e48dc782c5b4725555089ee0707096fc0877..d3c98c4eccd3a5f57850b43cb5b23ce15d0c6deb 100644 (file)
@@ -162,9 +162,10 @@ static int ad9467_reg_access(struct adi_axi_adc_conv *conv, unsigned int reg,
 
        if (readval == NULL) {
                ret = ad9467_spi_write(spi, reg, writeval);
-               ad9467_spi_write(spi, AN877_ADC_REG_TRANSFER,
-                                AN877_ADC_TRANSFER_SYNC);
-               return ret;
+               if (ret)
+                       return ret;
+               return ad9467_spi_write(spi, AN877_ADC_REG_TRANSFER,
+                                       AN877_ADC_TRANSFER_SYNC);
        }
 
        ret = ad9467_spi_read(spi, reg);
@@ -272,10 +273,13 @@ static int ad9467_get_scale(struct adi_axi_adc_conv *conv, int *val, int *val2)
        const struct ad9467_chip_info *info1 = to_ad9467_chip_info(info);
        struct ad9467_state *st = adi_axi_adc_conv_priv(conv);
        unsigned int i, vref_val;
+       int ret;
 
-       vref_val = ad9467_spi_read(st->spi, AN877_ADC_REG_VREF);
+       ret = ad9467_spi_read(st->spi, AN877_ADC_REG_VREF);
+       if (ret < 0)
+               return ret;
 
-       vref_val &= info1->vref_mask;
+       vref_val = ret & info1->vref_mask;
 
        for (i = 0; i < info->num_scales; i++) {
                if (vref_val == info->scale_table[i][1])
@@ -296,6 +300,7 @@ static int ad9467_set_scale(struct adi_axi_adc_conv *conv, int val, int val2)
        struct ad9467_state *st = adi_axi_adc_conv_priv(conv);
        unsigned int scale_val[2];
        unsigned int i;
+       int ret;
 
        if (val != 0)
                return -EINVAL;
@@ -305,11 +310,13 @@ static int ad9467_set_scale(struct adi_axi_adc_conv *conv, int val, int val2)
                if (scale_val[0] != val || scale_val[1] != val2)
                        continue;
 
-               ad9467_spi_write(st->spi, AN877_ADC_REG_VREF,
-                                info->scale_table[i][1]);
-               ad9467_spi_write(st->spi, AN877_ADC_REG_TRANSFER,
-                                AN877_ADC_TRANSFER_SYNC);
-               return 0;
+               ret = ad9467_spi_write(st->spi, AN877_ADC_REG_VREF,
+                                      info->scale_table[i][1]);
+               if (ret < 0)
+                       return ret;
+
+               return ad9467_spi_write(st->spi, AN877_ADC_REG_TRANSFER,
+                                       AN877_ADC_TRANSFER_SYNC);
        }
 
        return -EINVAL;