Skip to contentSkip to conversation

iio: sx9500: couple of bug fixes

PATCH Applied Vlad Dogaru 3 participants 7 messages Jun 30, 2015 – Jul 5, 2015 IIO

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 2042e37..ba1cbbe 100644
@@ -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
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] iio: sx9500: rework error handling of raw readings

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.

Quoted 46 lines
---
 drivers/iio/proximity/sx9500.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/iio/proximity/sx9500.c +9 -7
index 2042e37..ba1cbbe 100644
@@ -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:
maintainer Applied
#3 lore raw

Re: [PATCH 1/2] iio: sx9500: rework error handling of raw readings

Quoted 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.

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
index 2042e37..ba1cbbe 100644
@@ -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:
#4 lore raw

PATCH 2/2 iio: sx9500: fix bug in compensation code

In reply to 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.

---
 drivers/iio/proximity/sx9500.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/proximity/sx9500.c +3 -3
index ba1cbbe..798b973 100644
@@ -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
Acked-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] iio: sx9500: fix bug in compensation code

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.

Quoted 36 lines
---
 drivers/iio/proximity/sx9500.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/proximity/sx9500.c +3 -3
index ba1cbbe..798b973 100644
@@ -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;
 }
 
maintainer Applied
#6 lore raw

Re: [PATCH 2/2] iio: sx9500: fix bug in compensation code

Quoted 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.

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
index ba1cbbe..798b973 100644
@@ -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;
 }