Re: [PATCH v2 2/3] ratp: return 0 bytes written from puts if busy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 31, 2019 at 12:21:42PM +0200, Ahmad Fatoum wrote:
> Prior behavior was to wrongly report all bytes written if enqueueing wasn't
> possible at the time. Instead we should either return 0 or an error code if
> users need to retry. write(2) returns 0 in such cases. Follow suit.
> 
> As no current users run puts in a loop, this has no effect for now.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
> ---
> Changes in v2:
> 	New commit.
> ---
>  common/ratp/ratp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/ratp/ratp.c b/common/ratp/ratp.c
> index 9aea1786d684..8ac7dc98b6f8 100644
> --- a/common/ratp/ratp.c
> +++ b/common/ratp/ratp.c
> @@ -267,7 +267,7 @@ static int ratp_console_puts(struct console_device *cdev, const char *s)
>  	len = strlen(s);
>  
>  	if (ratp_busy(&ctx->ratp))
> -		return len;
> +		return 0;

I'm not sure if this return value is ever used for something useful,
not sure how relevant this is. ratp_busy() however returns true when
it's called from inside the ratp code. This is necessary so that we
don't get stuck in an endless loop. If we start returning 0 for
"no characters sent" how should code evaluating this return value
react? Retrying it until all characters are sent obviously is not an
option.

I think the current behaviour of just returning 'len' is correct.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux