iio: sx9500: couple of bug fixes
cover iio: sx9500: couple of bug fixes
Spotted by Hartmut during a review of an already applied patch. Once again, thanks for the feedback.
Vlad Dogaru (2):
iio: sx9500: rework error handling of raw readings
iio: sx9500: fix bug in compensation code
drivers/iio/proximity/sx9500.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 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.
--- drivers/iio/proximity/sx9500.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/iio/proximity/sx9500.c +9 -7
@@ -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:
Signature · 1 line
1.9.1
PATCH 2/2 iio: sx9500: fix bug in compensation code
In reply to Vlad DogaruThe initial compensation was mistakingly toggling an extra bit in the control register. Fix this and make sure it's less likely to happen by introducing an additional macro.
--- drivers/iio/proximity/sx9500.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/proximity/sx9500.c +3 -3
@@ -80,6 +80,7 @@#define SX9500_COMPSTAT_MASK GENMASK(3, 0)#define SX9500_NUM_CHANNELS 4 +#define SX9500_CHAN_MASK GENMASK(SX9500_NUM_CHANNELS - 1, 0)struct sx9500_data {struct mutex mutex;
@@ -802,8 +803,7 @@ static int sx9500_init_compensation(struct iio_dev *indio_dev)unsigned int val; ret =regmap_update_bits (data->regmap,SX9500_REG_PROX_CTRL0 , -GENMASK (SX9500_NUM_CHANNELS ,0 ), -GENMASK (SX9500_NUM_CHANNELS ,0 )); +SX9500_CHAN_MASK ,SX9500_CHAN_MASK );if (ret <0 )return ret;
@@ -823,7 +823,7 @@ static int sx9500_init_compensation(struct iio_dev *indio_dev) out:regmap_update_bits (data->regmap,SX9500_REG_PROX_CTRL0 , -GENMASK (SX9500_NUM_CHANNELS ,0 ),0 ); +SX9500_CHAN_MASK ,0 );return ret; }
Signature · 1 line
1.9.1
Re: [PATCH 1/2] iio: sx9500: rework error handling of raw readings
In reply to Vlad DogaruVlad Dogaru schrieb am 30.06.2015 um 13:20:
Quoted 5 lines
Fix error handling so that we can power the chip down even if a raw read fails.
Reported-by Hartmut Knaack <[email protected]>Signed-off-by Vlad Dogaru <[email protected]>
Quoted 46 lines
--- drivers/iio/proximity/sx9500.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)drivers/iio/proximity/sx9500.c +9
-7@@ -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:
Re: [PATCH 2/2] iio: sx9500: fix bug in compensation code
In reply to Vlad DogaruVlad Dogaru schrieb am 30.06.2015 um 13:20:
Quoted 6 lines
The initial compensation was mistakingly toggling an extra bit in the control register. Fix this and make sure it's less likely to happen by introducing an additional macro.
Reported-by Hartmut Knaack <[email protected]>Signed-off-by Vlad Dogaru <[email protected]>
Quoted 36 lines
--- drivers/iio/proximity/sx9500.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iio/proximity/sx9500.c +3
-3@@ -80,6 +80,7 @@#define SX9500_COMPSTAT_MASK GENMASK(3, 0)#define SX9500_NUM_CHANNELS 4 +#define SX9500_CHAN_MASK GENMASK(SX9500_NUM_CHANNELS - 1, 0)struct sx9500_data {struct mutex mutex;@@ -802,8 +803,7 @@ static int sx9500_init_compensation(struct iio_dev *indio_dev)unsigned int val; ret =regmap_update_bits (data->regmap,SX9500_REG_PROX_CTRL0 , -GENMASK (SX9500_NUM_CHANNELS ,0 ), -GENMASK (SX9500_NUM_CHANNELS ,0 )); +SX9500_CHAN_MASK ,SX9500_CHAN_MASK );if (ret <0 )return ret;@@ -823,7 +823,7 @@ static int sx9500_init_compensation(struct iio_dev *indio_dev) out:regmap_update_bits (data->regmap,SX9500_REG_PROX_CTRL0 , -GENMASK (SX9500_NUM_CHANNELS ,0 ),0 ); +SX9500_CHAN_MASK ,0 );return ret; }
Re: [PATCH 1/2] iio: sx9500: rework error handling of raw readings
In reply to Hartmut KnaackQuoted 7 lines · Hartmut Knaack
Vlad Dogaru schrieb am 30.06.2015 um 13:20:
Quoted 5 lines
Fix error handling so that we can power the chip down even if a raw read fails.
Reported-by Hartmut Knaack <[email protected]>Signed-off-by Vlad Dogaru <[email protected]>Acked-by Hartmut Knaack <[email protected]>
Applied to the fixes-for-4.2 branch of iio.git
Thanks,
Jonathan
Quoted 47 lines
Quoted 46 lines
--- drivers/iio/proximity/sx9500.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)drivers/iio/proximity/sx9500.c +9
-7@@ -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:
Re: [PATCH 2/2] iio: sx9500: fix bug in compensation code
In reply to Hartmut KnaackQuoted 8 lines · Hartmut Knaack
Vlad Dogaru schrieb am 30.06.2015 um 13:20:
Quoted 6 lines
The initial compensation was mistakingly toggling an extra bit in the control register. Fix this and make sure it's less likely to happen by introducing an additional macro.
Reported-by Hartmut Knaack <[email protected]>Signed-off-by Vlad Dogaru <[email protected]>Acked-by Hartmut Knaack <[email protected]>
Applied to the fixes-for-4.2 branch of iio.git
Thanks,
Jonathan
Quoted 37 lines
Quoted 36 lines
--- drivers/iio/proximity/sx9500.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iio/proximity/sx9500.c +3
-3@@ -80,6 +80,7 @@#define SX9500_COMPSTAT_MASK GENMASK(3, 0)#define SX9500_NUM_CHANNELS 4 +#define SX9500_CHAN_MASK GENMASK(SX9500_NUM_CHANNELS - 1, 0)struct sx9500_data {struct mutex mutex;@@ -802,8 +803,7 @@ static int sx9500_init_compensation(struct iio_dev *indio_dev)unsigned int val; ret =regmap_update_bits (data->regmap,SX9500_REG_PROX_CTRL0 , -GENMASK (SX9500_NUM_CHANNELS ,0 ), -GENMASK (SX9500_NUM_CHANNELS ,0 )); +SX9500_CHAN_MASK ,SX9500_CHAN_MASK );if (ret <0 )return ret;@@ -823,7 +823,7 @@ static int sx9500_init_compensation(struct iio_dev *indio_dev) out:regmap_update_bits (data->regmap,SX9500_REG_PROX_CTRL0 , -GENMASK (SX9500_NUM_CHANNELS ,0 ),0 ); +SX9500_CHAN_MASK ,0 );return ret; }