All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] iio: sx9500: couple of bug fixes
@ 2015-06-30 11:20 Vlad Dogaru
  2015-06-30 11:20 ` [PATCH 1/2] iio: sx9500: rework error handling of raw readings Vlad Dogaru
  2015-06-30 11:20 ` [PATCH 2/2] iio: sx9500: fix bug in compensation code Vlad Dogaru
  0 siblings, 2 replies; 7+ messages in thread
From: Vlad Dogaru @ 2015-06-30 11:20 UTC (permalink / raw)
  To: linux-iio, jic23, knaack.h; +Cc: Vlad Dogaru

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(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] iio: sx9500: rework error handling of raw readings
  2015-06-30 11:20 [PATCH 0/2] iio: sx9500: couple of bug fixes Vlad Dogaru
@ 2015-06-30 11:20 ` Vlad Dogaru
  2015-07-01 18:39   ` Hartmut Knaack
  2015-06-30 11:20 ` [PATCH 2/2] iio: sx9500: fix bug in compensation code Vlad Dogaru
  1 sibling, 1 reply; 7+ messages in thread
From: Vlad Dogaru @ 2015-06-30 11:20 UTC (permalink / raw)
  To: linux-iio, jic23, knaack.h; +Cc: Vlad Dogaru

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>
---
 drivers/iio/proximity/sx9500.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index 2042e37..ba1cbbe 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:
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] iio: sx9500: fix bug in compensation code
  2015-06-30 11:20 [PATCH 0/2] iio: sx9500: couple of bug fixes Vlad Dogaru
  2015-06-30 11:20 ` [PATCH 1/2] iio: sx9500: rework error handling of raw readings Vlad Dogaru
@ 2015-06-30 11:20 ` Vlad Dogaru
  2015-07-01 18:42   ` Hartmut Knaack
  1 sibling, 1 reply; 7+ messages in thread
From: Vlad Dogaru @ 2015-06-30 11:20 UTC (permalink / raw)
  To: linux-iio, jic23, knaack.h; +Cc: Vlad Dogaru

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 <knaack.h@gmx.de>
Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
---
 drivers/iio/proximity/sx9500.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index ba1cbbe..798b973 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -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;
 }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] iio: sx9500: rework error handling of raw readings
  2015-06-30 11:20 ` [PATCH 1/2] iio: sx9500: rework error handling of raw readings Vlad Dogaru
@ 2015-07-01 18:39   ` Hartmut Knaack
  2015-07-05 13:02     ` Jonathan Cameron
  0 siblings, 1 reply; 7+ messages in thread
From: Hartmut Knaack @ 2015-07-01 18:39 UTC (permalink / raw)
  To: Vlad Dogaru, linux-iio, jic23

Vlad Dogaru schrieb am 30.06.2015 um 13:20:
> 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>
> ---
>  drivers/iio/proximity/sx9500.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
> index 2042e37..ba1cbbe 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:
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] iio: sx9500: fix bug in compensation code
  2015-06-30 11:20 ` [PATCH 2/2] iio: sx9500: fix bug in compensation code Vlad Dogaru
@ 2015-07-01 18:42   ` Hartmut Knaack
  2015-07-05 13:04     ` Jonathan Cameron
  0 siblings, 1 reply; 7+ messages in thread
From: Hartmut Knaack @ 2015-07-01 18:42 UTC (permalink / raw)
  To: Vlad Dogaru, linux-iio, jic23

Vlad Dogaru schrieb am 30.06.2015 um 13:20:
> 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 <knaack.h@gmx.de>
> Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
Acked-by: Hartmut Knaack <knaack.h@gmx.de>
> ---
>  drivers/iio/proximity/sx9500.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
> index ba1cbbe..798b973 100644
> --- a/drivers/iio/proximity/sx9500.c
> +++ b/drivers/iio/proximity/sx9500.c
> @@ -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;
>  }
>  
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] iio: sx9500: rework error handling of raw readings
  2015-07-01 18:39   ` Hartmut Knaack
@ 2015-07-05 13:02     ` Jonathan Cameron
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2015-07-05 13:02 UTC (permalink / raw)
  To: Hartmut Knaack, Vlad Dogaru, linux-iio

On 01/07/15 19:39, Hartmut Knaack wrote:
> Vlad Dogaru schrieb am 30.06.2015 um 13:20:
>> 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>
Applied to the fixes-for-4.2 branch of iio.git

Thanks,

Jonathan
>> ---
>>  drivers/iio/proximity/sx9500.c | 16 +++++++++-------
>>  1 file changed, 9 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
>> index 2042e37..ba1cbbe 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:
>>
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] iio: sx9500: fix bug in compensation code
  2015-07-01 18:42   ` Hartmut Knaack
@ 2015-07-05 13:04     ` Jonathan Cameron
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2015-07-05 13:04 UTC (permalink / raw)
  To: Hartmut Knaack, Vlad Dogaru, linux-iio

On 01/07/15 19:42, Hartmut Knaack wrote:
> Vlad Dogaru schrieb am 30.06.2015 um 13:20:
>> 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 <knaack.h@gmx.de>
>> Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
> Acked-by: Hartmut Knaack <knaack.h@gmx.de>
Applied to the fixes-for-4.2 branch of iio.git

Thanks,

Jonathan
>> ---
>>  drivers/iio/proximity/sx9500.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
>> index ba1cbbe..798b973 100644
>> --- a/drivers/iio/proximity/sx9500.c
>> +++ b/drivers/iio/proximity/sx9500.c
>> @@ -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;
>>  }
>>  
>>
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-07-05 13:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-30 11:20 [PATCH 0/2] iio: sx9500: couple of bug fixes Vlad Dogaru
2015-06-30 11:20 ` [PATCH 1/2] iio: sx9500: rework error handling of raw readings Vlad Dogaru
2015-07-01 18:39   ` Hartmut Knaack
2015-07-05 13:02     ` Jonathan Cameron
2015-06-30 11:20 ` [PATCH 2/2] iio: sx9500: fix bug in compensation code Vlad Dogaru
2015-07-01 18:42   ` Hartmut Knaack
2015-07-05 13:04     ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.