diff mbox series

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

Message ID 20230920134109.2232769-1-dan.scally@ideasonboard.com
State New
Headers show
Series i2c: xiic: Correct return value check for xiic_reinit() | expand

Commit Message

Dan Scally Sept. 20, 2023, 1:41 p.m. UTC
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")
Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
---
 drivers/i2c/busses/i2c-xiic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michal Simek Sept. 21, 2023, 12:13 p.m. UTC | #1
On 9/20/23 15:41, Daniel Scally wrote:
> 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")
> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
> ---
>   drivers/i2c/busses/i2c-xiic.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
> index b3bb97762c85..71391b590ada 100644
> --- a/drivers/i2c/busses/i2c-xiic.c
> +++ b/drivers/i2c/busses/i2c-xiic.c
> @@ -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
Acked-by: Michal Simek <michal.simek@amd.com>

Thanks,
Michal
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index b3bb97762c85..71391b590ada 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -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) {