Skip to contentSkip to conversation

i2c: xiic: Correct return value check for xiic_reinit()

PATCH Applied Daniel Scally 4 participants 4 messages Sep 20, 2023 – Sep 22, 2023

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

PATCH 1/1 i2c: xiic: Correct return value check for xiic_reinit()

The error paths for xiic_reinit() return negative values on failure and 0 on success - this error message therefore is triggered on _success_ rather than failure. Correct the condition so it's only shown on failure as intended.

Fixes 8fa9c9388053 ("i2c: xiic: return value of xiic_reinit")
---
 drivers/i2c/busses/i2c-xiic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-xiic.c +1 -1
index b3bb97762c85..71391b590ada 100644
@@ -710,7 +710,7 @@ static irqreturn_t xiic_process(int irq, void *dev_id)
 		 * reset the IP instead of just flush fifos
 		 */
 		ret = xiic_reinit(i2c);
-		if (!ret)
+		if (ret < 0)
 			dev_dbg(i2c->adap.dev.parent, "reinit failed\n");
 
 		if (i2c->rx_msg) {
Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · Daniel Scally

The error paths for xiic_reinit() return negative values on failure and 0 on success - this error message therefore is triggered on _success_ rather than failure. Correct the condition so it's only shown on failure as intended.

Fixes 8fa9c9388053 ("i2c: xiic: return value of xiic_reinit")
---
  drivers/i2c/busses/i2c-xiic.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-xiic.c +0 -0
index b3bb97762c85..71391b590ada 100644

drivers/i2c/busses/i2c-xiic.c static irqreturn_t xiic_process(int irq, void *dev_id) · line 716

Quoted 8 lines
drivers/i2c/busses/i2c-xiic.c +1 -1
@@ -710,7 +710,7 @@ static irqreturn_t xiic_process(int irq, void *dev_id)
  		 * reset the IP instead of just flush fifos
  		 */
  		ret = xiic_reinit(i2c);
-		if (!ret)
+		if (ret < 0)
  			dev_dbg(i2c->adap.dev.parent, "reinit failed\n");
 
  		if (i2c->rx_msg) {

It would be interesting to know how origin patch was tested. Anyway

Thanks,
Michal

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Daniel Scally

Hi Daniel,

[...]

drivers/i2c/busses/i2c-xiic.c static irqreturn_t xiic_process(int irq, void *dev_id) · line 714

Quoted 7 lines
drivers/i2c/busses/i2c-xiic.c +1 -1
@@ -710,7 +710,7 @@ static irqreturn_t xiic_process(int irq, void *dev_id)
 		 * reset the IP instead of just flush fifos
 		 */
 		ret = xiic_reinit(i2c);
-		if (!ret)
+		if (ret < 0)
 			dev_dbg(i2c->adap.dev.parent, "reinit failed\n");

this should be a dev_warn(), but it's anyway out of the scope of this patch.

Andi

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Applied
#3 lore raw
In reply to Daniel Scally
Quoted 7 lines · Daniel Scally

The error paths for xiic_reinit() return negative values on failure and 0 on success - this error message therefore is triggered on _success_ rather than failure. Correct the condition so it's only shown on failure as intended.

Fixes 8fa9c9388053 ("i2c: xiic: return value of xiic_reinit")

Applied to for-current, thanks!