diff mbox series

i2c: qup: Add error handling in qup_i2c_xfer_v2()

Message ID 20250519141918.2522-1-vulab@iscas.ac.cn
State New
Headers show
Series i2c: qup: Add error handling in qup_i2c_xfer_v2() | expand

Commit Message

Wentao Liang May 19, 2025, 2:19 p.m. UTC
The qup_i2c_xfer_v2() calls the qup_i2c_change_state() but does
not check its return value. A proper implementation can be
found in qup_i2c_xfer().

Add error handling for qup_i2c_change_state(). If the function
fails, return the error code.

Fixes: 7545c7dba169 ("i2c: qup: reorganization of driver code to remove polling for qup v2")
Cc: stable@vger.kernel.org # v4.17
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/i2c/busses/i2c-qup.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Andi Shyti May 20, 2025, 11:51 a.m. UTC | #1
Hi Mukesh,

...

> > @@ -1588,7 +1588,9 @@ static int qup_i2c_xfer_v2(struct i2c_adapter *adap,
> >   		ret = qup_i2c_bus_active(qup, ONE_BYTE);
> >   	if (!ret)
> > -		qup_i2c_change_state(qup, QUP_RESET_STATE);
> > +		err = qup_i2c_change_state(qup, QUP_RESET_STATE);
> > +	if (err)
> > +		return err;
> Is there an error seen around this ? Expecting this to work as is.
> After an error, what next ? Just return back to framework ?

thanks for chiming in. qup_i2c_change_state() can fail, why
shouldn't we consider the possibility to fail?

Thanks,
Andi
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
index da20b4487c9a..2477f570fe86 100644
--- a/drivers/i2c/busses/i2c-qup.c
+++ b/drivers/i2c/busses/i2c-qup.c
@@ -1538,7 +1538,7 @@  static int qup_i2c_xfer_v2(struct i2c_adapter *adap,
 			   int num)
 {
 	struct qup_i2c_dev *qup = i2c_get_adapdata(adap);
-	int ret, idx = 0;
+	int ret, err, idx = 0;
 
 	qup->bus_err = 0;
 	qup->qup_err = 0;
@@ -1588,7 +1588,9 @@  static int qup_i2c_xfer_v2(struct i2c_adapter *adap,
 		ret = qup_i2c_bus_active(qup, ONE_BYTE);
 
 	if (!ret)
-		qup_i2c_change_state(qup, QUP_RESET_STATE);
+		err = qup_i2c_change_state(qup, QUP_RESET_STATE);
+	if (err)
+		return err;
 
 	if (ret == 0)
 		ret = num;