From: Jiri Slaby (SUSE) Date: Thu, 10 Aug 2023 10:39:00 +0000 (+0200) Subject: tty: gdm724x: simplify gdm_tty_write() X-Git-Tag: v6.6-rc1~101^2~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e67d7f60d2382677c25de10b2e4d8d3717ace91f;p=thirdparty%2Fkernel%2Fstable.git tty: gdm724x: simplify gdm_tty_write() 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) Reported-by: Dan Carpenter Reviewed-by: Ilpo Järvinen Cc: linux-staging@lists.linux.dev Link: https://lore.kernel.org/r/20230810103900.19353-1-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index cbaaa8fa7474a..67d9bf41e8364 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;