summaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorVlad Dogaru <vlad.dogaru@intel.com>2015-06-30 14:20:58 +0300
committerJonathan Cameron <jic23@kernel.org>2015-07-19 11:48:15 +0100
commit498adaeb898c4eff190d598799bd9b0d607ce051 (patch)
treeb4926606100d5a91993177e63cdc4a80d2a0acfe /drivers/iio
parentc99389ad3d80eeef0d0980a17e07f41822bda687 (diff)
downloadblackbird-op-linux-498adaeb898c4eff190d598799bd9b0d607ce051.tar.gz
blackbird-op-linux-498adaeb898c4eff190d598799bd9b0d607ce051.zip
iio: sx9500: rework error handling of raw readings
Fix error handling so that we can power the chip down even if a raw read fails. Reported-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com> Acked-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/proximity/sx9500.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index 01494cd6fa32..21eaa167a784 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -329,27 +329,29 @@ static int sx9500_read_proximity(struct sx9500_data *data,
else
ret = sx9500_wait_for_sample(data);
- if (ret < 0)
- return ret;
-
mutex_lock(&data->mutex);
- ret = sx9500_read_prox_data(data, chan, val);
if (ret < 0)
- goto out;
+ goto out_dec_data_rdy;
- ret = sx9500_dec_chan_users(data, chan->channel);
+ ret = sx9500_read_prox_data(data, chan, val);
if (ret < 0)
- goto out;
+ goto out_dec_data_rdy;
ret = sx9500_dec_data_rdy_users(data);
if (ret < 0)
+ goto out_dec_chan;
+
+ ret = sx9500_dec_chan_users(data, chan->channel);
+ if (ret < 0)
goto out;
ret = IIO_VAL_INT;
goto out;
+out_dec_data_rdy:
+ sx9500_dec_data_rdy_users(data);
out_dec_chan:
sx9500_dec_chan_users(data, chan->channel);
out:
OpenPOWER on IntegriCloud