diff mbox series

[1/1] media:dvb: check the return value of mb86a16_read()

Message ID 20230715094530.36820-1-ruc_gongyuanjun@163.com
State Accepted
Commit 7b7a3c014ed6bda5c37f7a95ad684796dc26c9a5
Headers show
Series [1/1] media:dvb: check the return value of mb86a16_read() | expand

Commit Message

Yuanjun Gong July 15, 2023, 9:45 a.m. UTC
return an error code if mb86a16_read() gets an unexpected return
value.

Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
---
 drivers/media/dvb-frontends/mb86a16.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Hans Verkuil July 19, 2023, 6:16 a.m. UTC | #1
Hi Yuanjun Gong,

Please add the name of the driver to the subject line:

"media: dvb: mb86a16: check the return value of mb86a16_read()"

On 15/07/2023 11:45, Yuanjun Gong wrote:
> return an error code if mb86a16_read() gets an unexpected return
> value.
> 
> Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
> ---
>  drivers/media/dvb-frontends/mb86a16.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/dvb-frontends/mb86a16.c b/drivers/media/dvb-frontends/mb86a16.c
> index d3e29937cf4c..f04188a72e7a 100644
> --- a/drivers/media/dvb-frontends/mb86a16.c
> +++ b/drivers/media/dvb-frontends/mb86a16.c
> @@ -1487,9 +1487,12 @@ static int mb86a16_set_fe(struct mb86a16_state *state)
>  		}
>  	}
>  
> -	mb86a16_read(state, 0x15, &agcval);
> -	mb86a16_read(state, 0x26, &cnmval);
> -	dprintk(verbose, MB86A16_INFO, 1, "AGC = %02x CNM = %02x", agcval, cnmval);
> +	if (mb86a16_read(state, 0x15, &agcval) != 2 ||	mb86a16_read(state, 0x26, &cnmval) != 2){
> +		dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
> +		ret = -EREMOTEIO;
> +	}
> +	else
> +		dprintk(verbose, MB86A16_INFO, 1, "AGC = %02x CNM = %02x", agcval, cnmval);

And also run 'checkpatch.pl --strict' over your patch and fix the issues it finds.

Thank you!

	Hans

>  
>  	return ret;
>  }
diff mbox series

Patch

diff --git a/drivers/media/dvb-frontends/mb86a16.c b/drivers/media/dvb-frontends/mb86a16.c
index d3e29937cf4c..f04188a72e7a 100644
--- a/drivers/media/dvb-frontends/mb86a16.c
+++ b/drivers/media/dvb-frontends/mb86a16.c
@@ -1487,9 +1487,12 @@  static int mb86a16_set_fe(struct mb86a16_state *state)
 		}
 	}
 
-	mb86a16_read(state, 0x15, &agcval);
-	mb86a16_read(state, 0x26, &cnmval);
-	dprintk(verbose, MB86A16_INFO, 1, "AGC = %02x CNM = %02x", agcval, cnmval);
+	if (mb86a16_read(state, 0x15, &agcval) != 2 ||	mb86a16_read(state, 0x26, &cnmval) != 2){
+		dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+		ret = -EREMOTEIO;
+	}
+	else
+		dprintk(verbose, MB86A16_INFO, 1, "AGC = %02x CNM = %02x", agcval, cnmval);
 
 	return ret;
 }