2023-11-21 09:24:54

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 00/17] tty: small cleanups and fixes

This is a series to fix/clean up some obvious issues I revealed during
u8+size_t conversions (to be posted later).

Cc: "David S. Miller" <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Jan Kara <[email protected]>
Cc: Laurentiu Tudor <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Matt Turner <[email protected]>
Cc: [email protected]
Cc: Paolo Abeni <[email protected]>
Cc: Richard Henderson <[email protected]>

Jiri Slaby (SUSE) (17):
tty: deprecate tty_write_message()
tty: remove unneeded mbz from tiocsti()
tty: fix tty_operations types in documentation
tty: move locking docs out of Returns for functions in tty.h
tty: amiserial: return from receive_chars() without goto
tty: amiserial: use bool and rename overrun flag in receive_chars()
tty: ehv_bytecha: use memcpy_and_pad() in local_ev_byte_channel_send()
tty: goldfish: drop unneeded temporary variables
tty: hso: don't emit load/unload info to the log
tty: hso: don't initialize global serial_table
tty: hvc_console: use flexible array for outbuf
tty: nozomi: remove unused debugging DUMP()
tty: srmcons: use 'buf' directly in srmcons_do_write()
tty: srmcons: use 'count' directly in srmcons_do_write()
tty: srmcons: make srmcons_do_write() return void
tty: srmcons: switch need_cr to bool
tty: srmcons: make 'str_cr' const and non-array

arch/alpha/kernel/srmcons.c | 29 +++++++++++++----------------
drivers/net/usb/hso.c | 11 -----------
drivers/tty/amiserial.c | 10 ++++------
drivers/tty/ehv_bytechan.c | 7 +++++--
drivers/tty/goldfish.c | 7 ++-----
drivers/tty/hvc/hvc_console.c | 4 +---
drivers/tty/hvc/hvc_console.h | 2 +-
drivers/tty/nozomi.c | 18 ------------------
drivers/tty/tty_io.c | 8 ++++++--
include/linux/tty.h | 12 +++++++-----
include/linux/tty_driver.h | 5 ++---
11 files changed, 41 insertions(+), 72 deletions(-)

--
2.42.1


2023-11-21 09:24:55

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 16/17] tty: srmcons: switch need_cr to bool

'need_cr' is a flag, so type it properly to be a 'bool'. Move the
declaration into the loop too. That ensures the variable is initialized
properly even if the code was moved somehow.

Signed-off-by: Jiri Slaby (SUSE) <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: Matt Turner <[email protected]>
Cc: [email protected]
---
arch/alpha/kernel/srmcons.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c
index 32bc098de7da..c6b821afbfd3 100644
--- a/arch/alpha/kernel/srmcons.c
+++ b/arch/alpha/kernel/srmcons.c
@@ -94,17 +94,16 @@ srmcons_do_write(struct tty_port *port, const char *buf, int count)
static char str_cr[1] = "\r";
size_t c;
srmcons_result result;
- int need_cr;

while (count > 0) {
- need_cr = 0;
+ bool need_cr = false;
/*
* Break it up into reasonable size chunks to allow a chance
* for input to get in
*/
for (c = 0; c < min_t(size_t, 128U, count) && !need_cr; c++)
if (buf[c] == '\n')
- need_cr = 1;
+ need_cr = true;

while (c > 0) {
result.as_long = callback_puts(0, buf, c);
@@ -122,7 +121,7 @@ srmcons_do_write(struct tty_port *port, const char *buf, int count)
while (need_cr) {
result.as_long = callback_puts(0, str_cr, 1);
if (result.bits.c > 0)
- need_cr = 0;
+ need_cr = false;
}
}
}
--
2.42.1

2023-11-21 09:25:00

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 13/17] tty: srmcons: use 'buf' directly in srmcons_do_write()

There is no need to have a separate iterator ('cur') through 'buf' in
srmcons_do_write(). 'buf' can be used directly which simplifies the code
a bit.

Signed-off-by: Jiri Slaby (SUSE) <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: Matt Turner <[email protected]>
Cc: [email protected]
---
arch/alpha/kernel/srmcons.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c
index d6139dbae4ac..b68c5af083cd 100644
--- a/arch/alpha/kernel/srmcons.c
+++ b/arch/alpha/kernel/srmcons.c
@@ -94,24 +94,23 @@ srmcons_do_write(struct tty_port *port, const char *buf, int count)
static char str_cr[1] = "\r";
long c, remaining = count;
srmcons_result result;
- char *cur;
int need_cr;

- for (cur = (char *)buf; remaining > 0; ) {
+ while (remaining > 0) {
need_cr = 0;
/*
* Break it up into reasonable size chunks to allow a chance
* for input to get in
*/
for (c = 0; c < min_t(long, 128L, remaining) && !need_cr; c++)
- if (cur[c] == '\n')
+ if (buf[c] == '\n')
need_cr = 1;

while (c > 0) {
- result.as_long = callback_puts(0, cur, c);
+ result.as_long = callback_puts(0, buf, c);
c -= result.bits.c;
remaining -= result.bits.c;
- cur += result.bits.c;
+ buf += result.bits.c;

/*
* Check for pending input iff a tty port was provided
--
2.42.1

2023-11-21 17:47:56

by Richard Henderson

[permalink] [raw]
Subject: Re: [PATCH 13/17] tty: srmcons: use 'buf' directly in srmcons_do_write()

On 11/21/23 03:22, Jiri Slaby (SUSE) wrote:
> There is no need to have a separate iterator ('cur') through 'buf' in
> srmcons_do_write(). 'buf' can be used directly which simplifies the code
> a bit.
>
> Signed-off-by: Jiri Slaby (SUSE) <[email protected]>
> Cc: Richard Henderson <[email protected]>
> Cc: Ivan Kokshaysky <[email protected]>
> Cc: Matt Turner <[email protected]>
> Cc: [email protected]
> ---
> arch/alpha/kernel/srmcons.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson <[email protected]>


r~

2023-11-21 17:49:16

by Richard Henderson

[permalink] [raw]
Subject: Re: [PATCH 16/17] tty: srmcons: switch need_cr to bool

On 11/21/23 03:22, Jiri Slaby (SUSE) wrote:
> 'need_cr' is a flag, so type it properly to be a 'bool'. Move the
> declaration into the loop too. That ensures the variable is initialized
> properly even if the code was moved somehow.
>
> Signed-off-by: Jiri Slaby (SUSE) <[email protected]>
> Cc: Richard Henderson <[email protected]>
> Cc: Ivan Kokshaysky <[email protected]>
> Cc: Matt Turner <[email protected]>
> Cc: [email protected]
> ---
> arch/alpha/kernel/srmcons.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <[email protected]>

r~

2023-11-23 20:25:15

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 00/17] tty: small cleanups and fixes

On Tue, Nov 21, 2023 at 10:22:41AM +0100, Jiri Slaby (SUSE) wrote:
> This is a series to fix/clean up some obvious issues I revealed during
> u8+size_t conversions (to be posted later).

I applied most of these except the last few, as I think you were going
to reorder them, right?

thanks,

greg k-h

2023-11-27 09:31:06

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH 00/17] tty: small cleanups and fixes

On 23. 11. 23, 21:19, Greg KH wrote:
> On Tue, Nov 21, 2023 at 10:22:41AM +0100, Jiri Slaby (SUSE) wrote:
>> This is a series to fix/clean up some obvious issues I revealed during
>> u8+size_t conversions (to be posted later).
>
> I applied most of these except the last few, as I think you were going
> to reorder them, right?

Yes, great. I will rebase and see/resend what is missing.

thanks,
--
js
suse labs