mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c70fd7c0e9
commit
e67d7f60d2
@@ -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))
|
if (!gdm_tty_ready(gdm))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
if (!len)
|
while (remain) {
|
||||||
return 0;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
size_t sending_len = min(MUX_TX_MAX_SIZE, remain);
|
size_t sending_len = min(MUX_TX_MAX_SIZE, remain);
|
||||||
gdm->tty_dev->send_func(gdm->tty_dev->priv_dev,
|
gdm->tty_dev->send_func(gdm->tty_dev->priv_dev,
|
||||||
(void *)(buf + sent_len),
|
(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);
|
gdm);
|
||||||
sent_len += sending_len;
|
sent_len += sending_len;
|
||||||
remain -= sending_len;
|
remain -= sending_len;
|
||||||
if (remain <= 0)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
|
|||||||
Reference in New Issue
Block a user