linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] firmware: turris-mox-rwtm: Fix an error handling path in mox_get_board_info()
@ 2023-02-15  9:30 Christophe JAILLET
  2023-02-17 11:21 ` Marek Behún
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe JAILLET @ 2023-02-15  9:30 UTC (permalink / raw)
  To: Marek Behún, Arnd Bergmann
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

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.

v2:
   - Fix some other wait_for_completion_timeout() calls

---
 drivers/firmware/turris-mox-rwtm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 6ea5789a89e2..d6fc37ba897d 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) {
@@ -236,8 +236,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_ECDSA_PUB_KEY, reply->retval);
 	if (ret == -ENODATA) {
@@ -275,8 +275,8 @@ static int check_get_random_support(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;
 
 	return mox_get_status(MBOX_CMD_GET_RANDOM, rwtm->reply.retval);
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] firmware: turris-mox-rwtm: Fix an error handling path in mox_get_board_info()
  2023-02-15  9:30 [PATCH v2] firmware: turris-mox-rwtm: Fix an error handling path in mox_get_board_info() Christophe JAILLET
@ 2023-02-17 11:21 ` Marek Behún
  2023-07-11 16:44   ` Christophe JAILLET
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Behún @ 2023-02-17 11:21 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: Arnd Bergmann, linux-kernel, kernel-janitors

On Wed, 15 Feb 2023 10:30:02 +0100
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:

> 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.
> 
> v2:
>    - Fix some other wait_for_completion_timeout() calls
> 
> ---
>  drivers/firmware/turris-mox-rwtm.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
> index 6ea5789a89e2..d6fc37ba897d 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) {
> @@ -236,8 +236,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_ECDSA_PUB_KEY, reply->retval);
>  	if (ret == -ENODATA) {
> @@ -275,8 +275,8 @@ static int check_get_random_support(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;
>  
>  	return mox_get_status(MBOX_CMD_GET_RANDOM, rwtm->reply.retval);
>  }

Reviewed-by: Marek Behún <kabel@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] firmware: turris-mox-rwtm: Fix an error handling path in mox_get_board_info()
  2023-02-17 11:21 ` Marek Behún
@ 2023-07-11 16:44   ` Christophe JAILLET
  2023-07-12 11:16     ` Marek Behún
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe JAILLET @ 2023-07-11 16:44 UTC (permalink / raw)
  To: Marek Behún; +Cc: Arnd Bergmann, linux-kernel, kernel-janitors

Le 17/02/2023 à 12:21, Marek Behún a écrit :
> On Wed, 15 Feb 2023 10:30:02 +0100
> Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
> 
>> 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.
>>
>> v2:
>>     - Fix some other wait_for_completion_timeout() calls
>>
>> ---
>>   drivers/firmware/turris-mox-rwtm.c | 12 ++++++------
>>   1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
>> index 6ea5789a89e2..d6fc37ba897d 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) {
>> @@ -236,8 +236,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_ECDSA_PUB_KEY, reply->retval);
>>   	if (ret == -ENODATA) {
>> @@ -275,8 +275,8 @@ static int check_get_random_support(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;
>>   
>>   	return mox_get_status(MBOX_CMD_GET_RANDOM, rwtm->reply.retval);
>>   }
> 
> Reviewed-by: Marek Behún <kabel@kernel.org>
> 

Hi,
polite reminder.

CJ

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] firmware: turris-mox-rwtm: Fix an error handling path in mox_get_board_info()
  2023-07-11 16:44   ` Christophe JAILLET
@ 2023-07-12 11:16     ` Marek Behún
  2023-07-13  8:56       ` Gregory CLEMENT
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Behún @ 2023-07-12 11:16 UTC (permalink / raw)
  To: Grégory Clement
  Cc: Christophe JAILLET, Arnd Bergmann, linux-kernel, kernel-janitors

Gregory, could you take this patch via mvebu?

On Tue, 11 Jul 2023 18:44:36 +0200
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:

> Le 17/02/2023 à 12:21, Marek Behún a écrit :
> > On Wed, 15 Feb 2023 10:30:02 +0100
> > Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
> >   
> >> 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.
> >>
> >> v2:
> >>     - Fix some other wait_for_completion_timeout() calls
> >>
> >> ---
> >>   drivers/firmware/turris-mox-rwtm.c | 12 ++++++------
> >>   1 file changed, 6 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
> >> index 6ea5789a89e2..d6fc37ba897d 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) {
> >> @@ -236,8 +236,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_ECDSA_PUB_KEY, reply->retval);
> >>   	if (ret == -ENODATA) {
> >> @@ -275,8 +275,8 @@ static int check_get_random_support(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;
> >>   
> >>   	return mox_get_status(MBOX_CMD_GET_RANDOM, rwtm->reply.retval);
> >>   }  
> > 
> > Reviewed-by: Marek Behún <kabel@kernel.org>
> >   
> 
> Hi,
> polite reminder.
> 
> CJ


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] firmware: turris-mox-rwtm: Fix an error handling path in mox_get_board_info()
  2023-07-12 11:16     ` Marek Behún
@ 2023-07-13  8:56       ` Gregory CLEMENT
  0 siblings, 0 replies; 5+ messages in thread
From: Gregory CLEMENT @ 2023-07-13  8:56 UTC (permalink / raw)
  To: Marek Behún
  Cc: Christophe JAILLET, Arnd Bergmann, linux-kernel, kernel-janitors

Marek Behún <kabel@kernel.org> writes:

> Gregory, could you take this patch via mvebu?


Yes sure, actually I was not in CC of this series and I don't follow
linux-kernel or kernel-janitors mailing lists. So thanks to having
pointing me the thread.

Applied on mvebu/drivers

Thanks,

Gregory


>
> On Tue, 11 Jul 2023 18:44:36 +0200
> Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
>
>> Le 17/02/2023 à 12:21, Marek Behún a écrit :
>> > On Wed, 15 Feb 2023 10:30:02 +0100
>> > Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
>> >   
>> >> 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.
>> >>
>> >> v2:
>> >>     - Fix some other wait_for_completion_timeout() calls
>> >>
>> >> ---
>> >>   drivers/firmware/turris-mox-rwtm.c | 12 ++++++------
>> >>   1 file changed, 6 insertions(+), 6 deletions(-)
>> >>
>> >> diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
>> >> index 6ea5789a89e2..d6fc37ba897d 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) {
>> >> @@ -236,8 +236,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_ECDSA_PUB_KEY, reply->retval);
>> >>   	if (ret == -ENODATA) {
>> >> @@ -275,8 +275,8 @@ static int check_get_random_support(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;
>> >>   
>> >>   	return mox_get_status(MBOX_CMD_GET_RANDOM, rwtm->reply.retval);
>> >>   }  
>> > 
>> > Reviewed-by: Marek Behún <kabel@kernel.org>
>> >   
>> 
>> Hi,
>> polite reminder.
>> 
>> CJ
>

-- 
Gregory Clement, Bootlin
Embedded Linux and Kernel engineering
http://bootlin.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-07-13  8:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-15  9:30 [PATCH v2] firmware: turris-mox-rwtm: Fix an error handling path in mox_get_board_info() Christophe JAILLET
2023-02-17 11:21 ` Marek Behún
2023-07-11 16:44   ` Christophe JAILLET
2023-07-12 11:16     ` Marek Behún
2023-07-13  8:56       ` Gregory CLEMENT

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).