From: Nuno Sa via B4 Relay <devnull+nuno.sa.analog.com@kernel.org>
To: linux-iio@vger.kernel.org
Cc: Michael Hennerich <Michael.Hennerich@analog.com>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 2/8] iio: adc: ad9467: don't ignore error codes
Date: Tue, 05 Dec 2023 18:06:42 +0100 [thread overview]
Message-ID: <20231205-iio-backend-prep-v1-2-7c9bc18d612b@analog.com> (raw)
In-Reply-To: <20231205-iio-backend-prep-v1-0-7c9bc18d612b@analog.com>
From: Nuno Sa <nuno.sa@analog.com>
Make sure functions that return errors are not ignored.
Fixes: ad6797120238 ("iio: adc: ad9467: add support AD9467 ADC")
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---
drivers/iio/adc/ad9467.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c
index 5ecf486bf5d1..0f2dce730a0a 100644
--- a/drivers/iio/adc/ad9467.c
+++ b/drivers/iio/adc/ad9467.c
@@ -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;
--
2.43.0
next prev parent reply other threads:[~2023-12-05 17:06 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-05 17:06 [PATCH 0/8] iio: ad9467 and axi-adc cleanups Nuno Sa via B4 Relay
2023-12-05 17:06 ` [PATCH 1/8] iio: adc: ad9467: fix reset gpio handling Nuno Sa via B4 Relay
2023-12-06 18:03 ` Jonathan Cameron
2023-12-07 9:02 ` Nuno Sá
2023-12-06 22:09 ` David Lechner
2023-12-07 9:04 ` Nuno Sá
2023-12-05 17:06 ` Nuno Sa via B4 Relay [this message]
2023-12-06 22:14 ` [PATCH 2/8] iio: adc: ad9467: don't ignore error codes David Lechner
2023-12-05 17:06 ` [PATCH 3/8] iio: adc: ad9467: add mutex to struct ad9467_state Nuno Sa via B4 Relay
2023-12-06 22:27 ` David Lechner
2023-12-07 9:10 ` Nuno Sá
2023-12-05 17:06 ` [PATCH 4/8] iio: adc: ad9467: fix scale setting Nuno Sa via B4 Relay
2023-12-06 23:01 ` David Lechner
2023-12-07 9:21 ` Nuno Sá
2023-12-07 10:02 ` Nuno Sá
2023-12-10 11:27 ` Jonathan Cameron
2023-12-11 9:32 ` Nuno Sá
2023-12-05 17:06 ` [PATCH 5/8] iio: adc: ad9467: use spi_get_device_match_data() Nuno Sa via B4 Relay
2023-12-06 23:03 ` David Lechner
2023-12-05 17:06 ` [PATCH 6/8] iio: adc: ad9467: use chip_info variables instead of array Nuno Sa via B4 Relay
2023-12-06 23:10 ` David Lechner
2023-12-05 17:06 ` [PATCH 7/8] iio: adc: ad9467: use the more common !val NULL check Nuno Sa via B4 Relay
2023-12-06 23:11 ` David Lechner
2023-12-05 17:06 ` [PATCH 8/8] iio: adc: adi-axi-adc: convert to regmap Nuno Sa via B4 Relay
2023-12-06 18:05 ` Jonathan Cameron
2023-12-06 23:18 ` David Lechner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231205-iio-backend-prep-v1-2-7c9bc18d612b@analog.com \
--to=devnull+nuno.sa.analog.com@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox