Commit 0559ef7f authored by Slawomir Stepien's avatar Slawomir Stepien Committed by Jonathan Cameron

staging: iio: adc: ad7280a: handle error from __ad7280_read32()

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: default avatarSlawomir Stepien <sst@poczta.fm>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 57297461
...@@ -256,7 +256,9 @@ static int ad7280_read(struct ad7280_state *st, unsigned int devaddr, ...@@ -256,7 +256,9 @@ static int ad7280_read(struct ad7280_state *st, unsigned int devaddr,
if (ret) if (ret)
return ret; return ret;
__ad7280_read32(st, &tmp); ret = __ad7280_read32(st, &tmp);
if (ret)
return ret;
if (ad7280_check_crc(st, tmp)) if (ad7280_check_crc(st, tmp))
return -EIO; return -EIO;
...@@ -294,7 +296,9 @@ static int ad7280_read_channel(struct ad7280_state *st, unsigned int devaddr, ...@@ -294,7 +296,9 @@ static int ad7280_read_channel(struct ad7280_state *st, unsigned int devaddr,
ad7280_delay(st); ad7280_delay(st);
__ad7280_read32(st, &tmp); ret = __ad7280_read32(st, &tmp);
if (ret)
return ret;
if (ad7280_check_crc(st, tmp)) if (ad7280_check_crc(st, tmp))
return -EIO; return -EIO;
...@@ -327,7 +331,9 @@ static int ad7280_read_all_channels(struct ad7280_state *st, unsigned int cnt, ...@@ -327,7 +331,9 @@ static int ad7280_read_all_channels(struct ad7280_state *st, unsigned int cnt,
ad7280_delay(st); ad7280_delay(st);
for (i = 0; i < cnt; i++) { 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)) if (ad7280_check_crc(st, tmp))
return -EIO; return -EIO;
...@@ -370,7 +376,10 @@ static int ad7280_chain_setup(struct ad7280_state *st) ...@@ -370,7 +376,10 @@ static int ad7280_chain_setup(struct ad7280_state *st)
return ret; return ret;
for (n = 0; n <= AD7280A_MAX_CHAIN; n++) { for (n = 0; n <= AD7280A_MAX_CHAIN; n++) {
__ad7280_read32(st, &val); ret = __ad7280_read32(st, &val);
if (ret)
return ret;
if (val == 0) if (val == 0)
return n - 1; return n - 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment