diff mbox series

iio: light: apds9306: Fix error handing

Message ID 20240625210203.522179-1-muditsharma.info@gmail.com (mailing list archive)
State Accepted
Headers show
Series iio: light: apds9306: Fix error handing | expand

Commit Message

Mudit Sharma June 25, 2024, 9:02 p.m. UTC
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")
Signed-off-by: Mudit Sharma <muditsharma.info@gmail.com>
---
 drivers/iio/light/apds9306.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Subhajit Ghosh June 26, 2024, 12:10 p.m. UTC | #1
On 26/6/24 06:32, Mudit Sharma wrote:
> 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")
> Signed-off-by: Mudit Sharma <muditsharma.info@gmail.com>
> ---
>   drivers/iio/light/apds9306.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c
> index d6627b3e6000..66a063ea3db4 100644
> --- a/drivers/iio/light/apds9306.c
> +++ b/drivers/iio/light/apds9306.c
> @@ -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.

Reviewed-by: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>


Regards,
Subhajit Ghosh
Jonathan Cameron June 29, 2024, 5:52 p.m. UTC | #2
On Wed, 26 Jun 2024 21:40:29 +0930
Subhajit Ghosh <subhajit.ghosh@tweaklogic.com> wrote:

> On 26/6/24 06:32, Mudit Sharma wrote:
> > 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")
> > Signed-off-by: Mudit Sharma <muditsharma.info@gmail.com>
> > ---
> >   drivers/iio/light/apds9306.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c
> > index d6627b3e6000..66a063ea3db4 100644
> > --- a/drivers/iio/light/apds9306.c
> > +++ b/drivers/iio/light/apds9306.c
> > @@ -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.
> 
> Reviewed-by: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,

Jonathan

> 
> 
> Regards,
> Subhajit Ghosh
diff mbox series

Patch

diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c
index d6627b3e6000..66a063ea3db4 100644
--- a/drivers/iio/light/apds9306.c
+++ b/drivers/iio/light/apds9306.c
@@ -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;