Skip to contentSkip to conversation

iio: light: apds9306: Fix error handing

PATCH Applied Mudit Sharma 3 participants 3 messages Jun 25, 2024 – Jun 29, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: light: apds9306: Fix error handing

The return value of 'iio_gts_find_int_time_by_sel()' is assigned to variable 'intg_old' but value of 'ret' is checked for error. Update to use 'intg_old' for error checking.

Fixes 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor")
---
 drivers/iio/light/apds9306.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/light/apds9306.c +2 -2
index d6627b3e6000..66a063ea3db4 100644
@@ -583,8 +583,8 @@ static int apds9306_intg_time_set(struct apds9306_data *data, int val2)
 		return ret;
 
 	intg_old = iio_gts_find_int_time_by_sel(&data->gts, intg_time_idx);
-	if (ret < 0)
-		return ret;
+	if (intg_old < 0)
+		return intg_old;
 
 	if (intg_old == val2)
 		return 0;
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Mudit Sharma

The return value of 'iio_gts_find_int_time_by_sel()' is assigned to variable 'intg_old' but value of 'ret' is checked for error. Update to use 'intg_old' for error checking.

Fixes 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor")
---
  drivers/iio/light/apds9306.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/light/apds9306.c +0 -0
index d6627b3e6000..66a063ea3db4 100644

drivers/iio/light/apds9306.c static int apds9306_intg_time_set(struct apds9306_data *data, int val2) · line 590

Quoted 10 lines
drivers/iio/light/apds9306.c +2 -2
@@ -583,8 +583,8 @@ static int apds9306_intg_time_set(struct apds9306_data *data, int val2)
  		return ret;
 
  	intg_old = iio_gts_find_int_time_by_sel(&data->gts, intg_time_idx);
-	if (ret < 0)
-		return ret;
+	if (intg_old < 0)
+		return intg_old;
 
  	if (intg_old == val2)
  		return 0;

Hi Mudit,

Good find.
Working well on my target dev board with your changes.

Regards,
Subhajit Ghosh

maintainer Applied
#2 lore raw
Quoted 24 lines · On Wed, 26 Jun 2024 21:40:29 +0930 Subhajit Ghosh…
Quoted 23 lines · Mudit Sharma

The return value of 'iio_gts_find_int_time_by_sel()' is assigned to variable 'intg_old' but value of 'ret' is checked for error. Update to use 'intg_old' for error checking.

Fixes 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor")
---
  drivers/iio/light/apds9306.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/light/apds9306.c +2 -2
index d6627b3e6000..66a063ea3db4 100644
@@ -583,8 +583,8 @@ static int apds9306_intg_time_set(struct apds9306_data *data, int val2)
  		return ret;
 
  	intg_old = iio_gts_find_int_time_by_sel(&data->gts, intg_time_idx);
-	if (ret < 0)
-		return ret;
+	if (intg_old < 0)
+		return intg_old;
 
Quoted 8 lines

drivers/iio/light/apds9306.c static int apds9306_intg_time_set(struct apds9306_data *data, int val2) · line 590

Quoted 2 lines
drivers/iio/light/apds9306.c +0 -0
  	if (intg_old == val2)
  		return 0;  

Hi Mudit,

Good find.
Working well on my target dev board with your changes.

Applied to the fixes-togreg branch of iio.git and marked for stable. Thanks,

Jonathan

Quoted 4 lines

Regards,
Subhajit Ghosh