firmware: turris-mox-rwtm: Fix an error handling path in mox_get_board_info()

Message ID 60b29f04b47a60ae6da754034a608aae1eba053a.1676452827.git.christophe.jaillet@wanadoo.fr
State New
Headers
Series firmware: turris-mox-rwtm: Fix an error handling path in mox_get_board_info() |

Commit Message

Christophe JAILLET Feb. 15, 2023, 9:20 a.m. UTC
  wait_for_completion_timeout() returns 0 if timed out, and positive (at
least 1, or number of jiffies left till timeout) if completed.

In case of timeout, return -ETIMEDOUT.

Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only.
---
 drivers/firmware/turris-mox-rwtm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Christophe JAILLET Feb. 15, 2023, 9:21 a.m. UTC | #1
Le 15/02/2023 à 10:20, Christophe JAILLET a écrit :
> wait_for_completion_timeout() returns 0 if timed out, and positive (at
> least 1, or number of jiffies left till timeout) if completed.
> 
> In case of timeout, return -ETIMEDOUT.
> 
> Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only.
> ---
>   drivers/firmware/turris-mox-rwtm.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
> index 6ea5789a89e2..577e87e1c6ee 100644
> --- a/drivers/firmware/turris-mox-rwtm.c
> +++ b/drivers/firmware/turris-mox-rwtm.c
> @@ -200,8 +200,8 @@ static int mox_get_board_info(struct mox_rwtm *rwtm)
>   		return ret;
>   
>   	ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2);
> -	if (ret < 0)
> -		return ret;
> +	if (ret == 0)
> +		return -ETIMEDOUT;
>   
>   	ret = mox_get_status(MBOX_CMD_BOARD_INFO, reply->retval);
>   	if (ret == -ENODATA) {

NACK, some other need to be fixed in the same file.
I'll send a V2.

CJ
  

Patch

diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 6ea5789a89e2..577e87e1c6ee 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -200,8 +200,8 @@  static int mox_get_board_info(struct mox_rwtm *rwtm)
 		return ret;
 
 	ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2);
-	if (ret < 0)
-		return ret;
+	if (ret == 0)
+		return -ETIMEDOUT;
 
 	ret = mox_get_status(MBOX_CMD_BOARD_INFO, reply->retval);
 	if (ret == -ENODATA) {