public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 linux-serial <linux-serial@vger.kernel.org>,
	 LKML <linux-kernel@vger.kernel.org>,
	 Dan Carpenter <dan.carpenter@linaro.org>,
	linux-staging@lists.linux.dev
Subject: Re: [PATCH 34-and-three-quarters/36] tty: gdm724x: simplify gdm_tty_write()
Date: Fri, 11 Aug 2023 12:11:39 +0300 (EEST)	[thread overview]
Message-ID: <8df438f1-354a-7e2c-53c5-872f32c56a7@linux.intel.com> (raw)
In-Reply-To: <20230810103900.19353-1-jirislaby@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 1533 bytes --]

On Thu, 10 Aug 2023, Jiri Slaby (SUSE) wrote:

> len and remain can never be negative in gdm_tty_write(). So remove such
> a check and move the check of remaining bytes to the loop condition.
> This way, the preceding 'if' is now superfluous too. Fix all that and
> make the code cleaner.
> 
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>

I guess Suggested-by would be more appropriate since there's no problem 
being fixed here.

> Cc: linux-staging@lists.linux.dev

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.



> ---
>  drivers/staging/gdm724x/gdm_tty.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
> index cbaaa8fa7474..67d9bf41e836 100644
> --- a/drivers/staging/gdm724x/gdm_tty.c
> +++ b/drivers/staging/gdm724x/gdm_tty.c
> @@ -158,10 +158,7 @@ static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len)
>  	if (!gdm_tty_ready(gdm))
>  		return -ENODEV;
>  
> -	if (!len)
> -		return 0;
> -
> -	while (1) {
> +	while (remain) {
>  		size_t sending_len = min(MUX_TX_MAX_SIZE, remain);
>  		gdm->tty_dev->send_func(gdm->tty_dev->priv_dev,
>  					(void *)(buf + sent_len),
> @@ -171,8 +168,6 @@ static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len)
>  					gdm);
>  		sent_len += sending_len;
>  		remain -= sending_len;
> -		if (remain <= 0)
> -			break;
>  	}
>  
>  	return len;
> 

  reply	other threads:[~2023-08-11  9:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230810091510.13006-1-jirislaby@kernel.org>
2023-08-10  9:15 ` [PATCH 34/36] tty: gdm724x: convert counts to size_t Jiri Slaby (SUSE)
2023-08-10  9:42   ` Dan Carpenter
2023-08-10 10:08     ` Jiri Slaby
2023-08-10 10:39     ` [PATCH 34-and-three-quarters/36] tty: gdm724x: simplify gdm_tty_write() Jiri Slaby (SUSE)
2023-08-11  9:11       ` Ilpo Järvinen [this message]
2023-08-15 17:22   ` [PATCH 34/36] tty: gdm724x: convert counts to size_t Nathan Chancellor
2023-08-16  6:46     ` Jiri Slaby
2023-08-16  8:40       ` David Laight
2023-08-16  8:58         ` Jiri Slaby
2023-08-16  9:18           ` David Laight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8df438f1-354a-7e2c-53c5-872f32c56a7@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox