mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 06:10:56 +00:00
staging: iio: adc: ad7280a: handle error from __ad7280_read32()
[ Upstream commit 0559ef7fde
]
Inside __ad7280_read32(), the spi_sync_transfer() can fail with negative
error code. This change will ensure that this error is being passed up
in the call stack, so it can be handled.
Signed-off-by: Slawomir Stepien <sst@poczta.fm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
9b3e959d46
commit
e31bc4df03
1 changed files with 13 additions and 4 deletions
|
@ -250,7 +250,9 @@ static int ad7280_read(struct ad7280_state *st, unsigned int devaddr,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
__ad7280_read32(st, &tmp);
|
||||
ret = __ad7280_read32(st, &tmp);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (ad7280_check_crc(st, tmp))
|
||||
return -EIO;
|
||||
|
@ -288,7 +290,9 @@ static int ad7280_read_channel(struct ad7280_state *st, unsigned int devaddr,
|
|||
|
||||
ad7280_delay(st);
|
||||
|
||||
__ad7280_read32(st, &tmp);
|
||||
ret = __ad7280_read32(st, &tmp);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (ad7280_check_crc(st, tmp))
|
||||
return -EIO;
|
||||
|
@ -321,7 +325,9 @@ static int ad7280_read_all_channels(struct ad7280_state *st, unsigned int cnt,
|
|||
ad7280_delay(st);
|
||||
|
||||
for (i = 0; i < cnt; i++) {
|
||||
__ad7280_read32(st, &tmp);
|
||||
ret = __ad7280_read32(st, &tmp);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (ad7280_check_crc(st, tmp))
|
||||
return -EIO;
|
||||
|
@ -364,7 +370,10 @@ static int ad7280_chain_setup(struct ad7280_state *st)
|
|||
return ret;
|
||||
|
||||
for (n = 0; n <= AD7280A_MAX_CHAIN; n++) {
|
||||
__ad7280_read32(st, &val);
|
||||
ret = __ad7280_read32(st, &val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (val == 0)
|
||||
return n - 1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue