Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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) <jirislaby@kernel.org>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Cc: linux-staging@lists.linux.dev
Link: https://lore.kernel.org/r/20230810103900.19353-1-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
e67d7f60 c70fd7c0

+1 -6
+1 -6
drivers/staging/gdm724x/gdm_tty.c
··· 158 158 if (!gdm_tty_ready(gdm)) 159 159 return -ENODEV; 160 160 161 - if (!len) 162 - return 0; 163 - 164 - while (1) { 161 + while (remain) { 165 162 size_t sending_len = min(MUX_TX_MAX_SIZE, remain); 166 163 gdm->tty_dev->send_func(gdm->tty_dev->priv_dev, 167 164 (void *)(buf + sent_len), ··· 168 171 gdm); 169 172 sent_len += sending_len; 170 173 remain -= sending_len; 171 - if (remain <= 0) 172 - break; 173 174 } 174 175 175 176 return len;