tty: type unifications -- part I.
Subsystems (42)
Jiri Slaby (SUSE)
maintainercover tty: type unifications -- part I.
Currently, the tty layer ops and functions use various types for same things:
* characters and flags: unsigned char, char are used on a random basis,
* counts: int, unsigned int, size_t are used, again more-or-less randomly.
This makes it rather hard to remember where each type is required and it also makes the code harder to follow. Also the code has to do min_t() on many places simply because the variables hold the same kind of data, but of different type.
This is the first part of the series to unify the types:
* make characters and flags 'u8'. This is what the hardware expects and what feeds the tty layer with. Since we compile with -funsigned-char, char and unsigned char are the same types on all platforms. So there is no actual change in type.
* make sizes/counts 'size_t'. This is what comes from the VFS layer and some tty functions already operate on this. So instead of using "shorter" (in term of bytes on 64bit) unsigned int, stick to size_t and promote it to most places.
More cleanup and spreading will be done in tty_buffer, n_tty, and likely other places later.
Patches 1-8 are cleanups only. The rest (the real switch) depends on those.
Jiri Slaby (SUSE) (36):
tty: xtensa/iss: drop unneeded tty_operations hooks
tty: ldisc: document that ldops are optional
tty: remove dummy tty_ldisc_ops::poll() implementations
tty: n_null: remove optional ldops
tty: change tty_write_lock()'s ndelay parameter to bool
tty: tty_port: rename 'disc' to 'ld'
tty: drop tty_debug_wait_until_sent()
tty: make tty_change_softcar() more understandable
tty: make tty_port_client_operations operate with u8
tty: make counts in tty_port_client_operations hooks size_t
tty: switch receive_buf() counts to size_t
tty: switch count in tty_ldisc_receive_buf() to size_t
tty: can327: unify error paths in can327_ldisc_rx()
tty: can327, move overflow test inside can327_ldisc_rx()'s loop
tty: make tty_ldisc_ops::*buf*() hooks operate on size_t
tty: use u8 for chars
tty: use u8 for flags
misc: ti-st: make st_recv() conforming to tty_ldisc_ops::receive_buf()
tty: make char_buf_ptr()/flag_buf_ptr()'s offset unsigned
tty: tty_buffer: make all offsets unsigned
tty: don't pass write() to do_tty_write()
tty: rename and de-inline do_tty_write()
tty: use min() in iterate_tty_write()
tty: use ssize_t for iterate_tty_read() returned type
tty: switch size and count types in iterate_tty_read() to size_t
tty: use min() for size computation in iterate_tty_read()
tty: propagate u8 data to tty_operations::write()
tty: propagate u8 data to tty_operations::put_char()
tty: make tty_operations::write()'s count size_t
tty: audit: unify to u8
tty: ldops: unify to u8
tty: hvc: convert counts to size_t
tty: vcc: convert counts to size_t
tty: gdm724x: convert counts to size_t
tty: hso: simplify hso_serial_write()
tty: rfcomm: convert counts to size_t
arch/alpha/kernel/srmcons.c | 5 +- arch/m68k/emu/nfcon.c | 8 +-- arch/sparc/include/asm/vio.h | 2 +- arch/um/drivers/line.c | 2 +- arch/um/drivers/line.h | 3 +- arch/xtensa/platforms/iss/console.c | 27 +-------- drivers/accessibility/speakup/spk_ttyio.c | 5 +- drivers/bluetooth/hci_ldisc.c | 15 ++--- drivers/char/ttyprintk.c | 5 +- drivers/input/serio/serport.c | 8 +-- drivers/ipack/devices/ipoctal.c | 7 +-- drivers/isdn/capi/capi.c | 8 +-- drivers/misc/bcm-vk/bcm_vk_tty.c | 5 +- drivers/misc/ti-st/st_core.c | 11 ++-- drivers/misc/ti-st/st_kim.c | 6 +- drivers/mmc/core/sdio_uart.c | 4 +- drivers/net/caif/caif_serial.c | 2 +- drivers/net/can/can327.c | 39 ++++++------- drivers/net/can/slcan/slcan-core.c | 5 +- drivers/net/hamradio/6pack.c | 4 +- drivers/net/hamradio/mkiss.c | 4 +- drivers/net/mctp/mctp-serial.c | 5 +- drivers/net/ppp/ppp_async.c | 26 +++------ drivers/net/ppp/ppp_synctty.c | 26 +++------ drivers/net/slip/slip.c | 4 +- drivers/net/usb/hso.c | 20 +++---- drivers/s390/char/con3215.c | 6 +- drivers/s390/char/con3270.c | 6 +- drivers/s390/char/sclp_tty.c | 10 ++-- drivers/s390/char/sclp_vt220.c | 6 +- drivers/staging/gdm724x/gdm_tty.c | 14 ++--- drivers/staging/greybus/uart.c | 3 +- drivers/tty/amiserial.c | 4 +- drivers/tty/ehv_bytechan.c | 4 +- drivers/tty/goldfish.c | 7 +-- drivers/tty/hvc/hvc_console.c | 4 +- drivers/tty/hvc/hvcs.c | 10 ++-- drivers/tty/hvc/hvsi.c | 14 ++--- drivers/tty/ipwireless/hardware.c | 2 +- drivers/tty/ipwireless/tty.c | 4 +- drivers/tty/mips_ejtag_fdc.c | 6 +- drivers/tty/moxa.c | 8 +-- drivers/tty/mxser.c | 4 +- drivers/tty/n_gsm.c | 14 ++--- drivers/tty/n_hdlc.c | 12 ++-- drivers/tty/n_null.c | 25 +-------- drivers/tty/n_tty.c | 59 ++++++++++---------- drivers/tty/nozomi.c | 6 +- drivers/tty/pty.c | 2 +- drivers/tty/rpmsg_tty.c | 5 +- drivers/tty/serdev/serdev-ttyport.c | 4 +- drivers/tty/serial/kgdb_nmi.c | 3 +- drivers/tty/serial/serial_core.c | 5 +- drivers/tty/synclink_gt.c | 13 ++--- drivers/tty/tty.h | 8 +-- drivers/tty/tty_audit.c | 6 +- drivers/tty/tty_buffer.c | 35 ++++++------ drivers/tty/tty_io.c | 46 +++++++--------- drivers/tty/tty_ioctl.c | 18 ++---- drivers/tty/tty_port.c | 34 ++++++------ drivers/tty/ttynull.c | 4 +- drivers/tty/vcc.c | 18 +++--- drivers/tty/vt/selection.c | 2 +- drivers/tty/vt/vt.c | 6 +- drivers/usb/class/cdc-acm.c | 8 +-- drivers/usb/gadget/function/u_serial.c | 6 +- drivers/usb/host/xhci-dbgtty.c | 7 +-- drivers/usb/serial/usb-serial.c | 5 +- include/linux/ti_wilink_st.h | 2 +- include/linux/tty_buffer.h | 18 +++--- include/linux/tty_driver.h | 9 ++- include/linux/tty_flip.h | 22 ++++---- include/linux/tty_ldisc.h | 67 +++++++++++++++-------- include/linux/tty_port.h | 7 ++- net/bluetooth/rfcomm/tty.c | 9 +-- net/nfc/nci/uart.c | 15 ++--- sound/soc/codecs/cx20442.c | 4 +- sound/soc/ti/ams-delta.c | 2 +- 78 files changed, 381 insertions(+), 493 deletions(-)
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 1/36 tty: xtensa/iss: drop unneeded tty_operations hooks
All ::flush_chars(), ::hangup(), and ::wait_until_sent() from struct tty_operations are optional. There is no need to provide them with empty bodies.
tty_operations::put_char() needs not be provided if it is the same as tty_operations::write(tty, &ch, 1).
So drop all of them.
--- arch/xtensa/platforms/iss/console.c | 24 ------------------------ 1 file changed, 24 deletions(-)
arch/xtensa/platforms/iss/console.c +0 -24
@@ -82,32 +82,12 @@ static void rs_poll(struct timer_list *unused)mod_timer (&serial_timer, jiffies +SERIAL_TIMER_VALUE ); } - -static int rs_put_char (struct tty_struct *tty,unsigned char ch) -{ -return rs_write (tty, &ch,1 ); -} - -static void rs_flush_chars (struct tty_struct *tty) -{ -} -static unsigned int rs_write_room (struct tty_struct *tty) {/* Let's say iss can always accept 2K characters.. */ return 2 *1024 ; } -static void rs_hangup (struct tty_struct *tty) -{ -/* Stub, once again.. */ -} - -static void rs_wait_until_sent (struct tty_struct *tty,int timeout) -{ -/* Stub, once again.. */ -} -static int rs_proc_show (struct seq_file *m,void *v) {seq_printf (m,"serinfo:1.0 driver:0.1\n" );
@@ -118,11 +98,7 @@ static const struct tty_operations serial_ops = { .open = rs_open, .close = rs_close, .write = rs_write, - .put_char = rs_put_char, - .flush_chars = rs_flush_chars, .write_room = rs_write_room, - .hangup = rs_hangup, - .wait_until_sent = rs_wait_until_sent, .proc_show = rs_proc_show, };
Signature · 1 line
2.41.0
Re: [PATCH 01/36] tty: xtensa/iss: drop unneeded tty_operations hooks
Quoted 8 lines · Jiri Slaby (SUSE)
All ::flush_chars(), ::hangup(), and ::wait_until_sent() from struct
tty_operationsare optional. There is no need to provide them with empty bodies.
tty_operations::put_char()needs not be provided if it is the same astty_operations::write(tty, &ch, 1).
Quoted 8 lines
So drop all of them.
Signed-off-by Jiri Slaby (SUSE) <[email protected]>Cc Chris Zankel <[email protected]>Cc Max Filippov <[email protected]>--- arch/xtensa/platforms/iss/console.c | 24 ------------------------ 1 file changed, 24 deletions(-)
Signature · 2 lines
Thanks. -- Max
Jiri Slaby (SUSE)
maintainerPATCH 2/36 tty: ldisc: document that ldops are optional
In reply to Jiri Slaby (SUSE)There is no need to provide any hook in struct tty_ldisc_ops. Document that and write down that read/write return EIO in that case. The rest is simply ignored.
--- include/linux/tty_ldisc.h | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
include/linux/tty_ldisc.h +25 -5
@@ -71,7 +71,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* call to @receive_buf(). Returning an error will prevent the ldisc from * being attached. * -* Can sleep. +* Optional. Can sleep. * * @close: [TTY] ``void ()(struct tty_struct *tty)`` *
@@ -80,7 +80,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* changed to use a new line discipline. At the point of execution no * further users will enter the ldisc code for this tty. * -* Can sleep. +* Optional. Can sleep. * * @flush_buffer: [TTY] ``void ()(struct tty_struct *tty)`` *
@@ -88,6 +88,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* input characters it may have queued to be delivered to the user mode * process. It may be called at any point between open and close. * +* Optional. +* * @read: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file, * unsigned char *buf, size_t nr)`` *
@@ -97,7 +99,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* an %EIO error. Multiple read calls may occur in parallel and the ldisc * must deal with serialization issues. * -* Can sleep. +* Optional: %EIO unless provided. Can sleep. * * @write: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file, * const unsigned char *buf, size_t nr)``
@@ -108,7 +110,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* characters first. If this function is not defined, the user will * receive an %EIO error. * -* Can sleep. +* Optional: %EIO unless provided. Can sleep. * * @ioctl: [TTY] ``int ()(struct tty_struct *tty, unsigned int cmd, * unsigned long arg)``
@@ -120,6 +122,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* discpline. So a low-level driver can "grab" an ioctl request before * the line discpline has a chance to see it. * +* Optional. +* * @compat_ioctl: [TTY] ``int ()(struct tty_struct *tty, unsigned int cmd, * unsigned long arg)`` *
@@ -130,11 +134,15 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* a pointer to wordsize-sensitive structure belongs here, but most of * ldiscs will happily leave it %NULL. * +* Optional. +* * @set_termios: [TTY] ``void ()(struct tty_struct *tty, const struct ktermios *old)`` * * This function notifies the line discpline that a change has been made * to the termios structure. * +* Optional. +* * @poll: [TTY] ``int ()(struct tty_struct *tty, struct file *file, * struct poll_table_struct *wait)`` *
@@ -142,6 +150,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* device. It is solely the responsibility of the line discipline to * handle poll requests. * +* Optional. +* * @hangup: [TTY] ``void ()(struct tty_struct *tty)`` * * Called on a hangup. Tells the discipline that it should cease I/O to
@@ -149,7 +159,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* but should wait until any pending driver I/O is completed. No further * calls into the ldisc code will occur. * -* Can sleep. +* Optional. Can sleep. * * @receive_buf: [DRV] ``void ()(struct tty_struct *tty, * const unsigned char *cp, const char *fp, int count)``
@@ -161,6 +171,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* character was received with a parity error, etc. @fp may be %NULL to * indicate all data received is %TTY_NORMAL. * +* Optional. +* * @write_wakeup: [DRV] ``void ()(struct tty_struct *tty)`` * * This function is called by the low-level tty driver to signal that line
@@ -170,11 +182,15 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* send, please arise a tasklet or workqueue to do the real data transfer. * Do not send data in this hook, it may lead to a deadlock. * +* Optional. +* * @dcd_change: [DRV] ``void ()(struct tty_struct *tty, bool active)`` * * Tells the discipline that the DCD pin has changed its status. Used * exclusively by the %N_PPS (Pulse-Per-Second) line discipline. * +* Optional. +* * @receive_buf2: [DRV] ``int ()(struct tty_struct *tty, * const unsigned char *cp, const char *fp, int count)`` *
@@ -186,6 +202,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* indicate all data received is %TTY_NORMAL. If assigned, prefer this * function for automatic flow control. * +* Optional. +* * @lookahead_buf: [DRV] ``void ()(struct tty_struct *tty, * const unsigned char *cp, const char *fp, int count)`` *
@@ -198,6 +216,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* same characters (e.g. by skipping the actions for high-priority * characters already handled by ->lookahead_buf()). * +* Optional. +* * @owner: module containting this ldisc (for reference counting) * * This structure defines the interface between the tty line discipline
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 3/36 tty: remove dummy tty_ldisc_ops::poll() implementations
In reply to Jiri Slaby (SUSE)tty_ldisc_ops::poll() is optional and needs not be provided. It is equal to returning 0. So remove all those from the code.
--- drivers/bluetooth/hci_ldisc.c | 7 ------- drivers/net/ppp/ppp_async.c | 8 -------- drivers/net/ppp/ppp_synctty.c | 8 -------- net/nfc/nci/uart.c | 7 ------- 4 files changed, 30 deletions(-)
drivers/bluetooth/hci_ldisc.c +0 -7
@@ -819,12 +819,6 @@ static ssize_t hci_uart_tty_write(struct tty_struct *tty, struct file *file,return 0 ; } -static __poll_t hci_uart_tty_poll (struct tty_struct *tty, -struct file *filp,poll_table *wait) -{ -return 0 ; -} -static struct tty_ldisc_ops hci_uart_ldisc = { .owner =THIS_MODULE , .num =N_HCI ,
@@ -835,7 +829,6 @@ static struct tty_ldisc_ops hci_uart_ldisc = { .write = hci_uart_tty_write, .ioctl = hci_uart_tty_ioctl, .compat_ioctl = hci_uart_tty_ioctl, - .poll = hci_uart_tty_poll, .receive_buf = hci_uart_tty_receive, .write_wakeup = hci_uart_tty_wakeup, };
drivers/net/ppp/ppp_async.c +0 -8
@@ -328,13 +328,6 @@ ppp_asynctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)return err; } -/* No kernel lock - fine */ -static __poll_t -ppp_asynctty_poll (struct tty_struct *tty,struct file *file,poll_table *wait) -{ -return 0 ; -} -/* May sleep, don't call from interrupt level or with interrupts disabled */ static void ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
@@ -378,7 +371,6 @@ static struct tty_ldisc_ops ppp_ldisc = { .read = ppp_asynctty_read, .write = ppp_asynctty_write, .ioctl = ppp_asynctty_ioctl, - .poll = ppp_asynctty_poll, .receive_buf = ppp_asynctty_receive, .write_wakeup = ppp_asynctty_wakeup, };
drivers/net/ppp/ppp_synctty.c +0 -8
@@ -321,13 +321,6 @@ ppp_synctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)return err; } -/* No kernel lock - fine */ -static __poll_t -ppp_sync_poll (struct tty_struct *tty,struct file *file,poll_table *wait) -{ -return 0 ; -} -/* May sleep, don't call from interrupt level or with interrupts disabled */ static void ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
@@ -371,7 +364,6 @@ static struct tty_ldisc_ops ppp_sync_ldisc = { .read = ppp_sync_read, .write = ppp_sync_write, .ioctl = ppp_synctty_ioctl, - .poll = ppp_sync_poll, .receive_buf = ppp_sync_receive, .write_wakeup = ppp_sync_wakeup, };
net/nfc/nci/uart.c +0 -7
@@ -357,12 +357,6 @@ static ssize_t nci_uart_tty_write(struct tty_struct *tty, struct file *file,return 0 ; } -static __poll_t nci_uart_tty_poll (struct tty_struct *tty, -struct file *filp,poll_table *wait) -{ -return 0 ; -} -static int nci_uart_send (struct nci_uart *nu,struct sk_buff *skb) {/* Queue TX packet */
@@ -435,7 +429,6 @@ static struct tty_ldisc_ops nci_uart_ldisc = { .close = nci_uart_tty_close, .read = nci_uart_tty_read, .write = nci_uart_tty_write, - .poll = nci_uart_tty_poll, .receive_buf = nci_uart_tty_receive, .write_wakeup = nci_uart_tty_wakeup, .ioctl = nci_uart_tty_ioctl,
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 4/36 tty: n_null: remove optional ldops
In reply to Jiri Slaby (SUSE)Only tty_ldisc_ops::read() and ::write() of n_null behave differently than the default ldops implementations. They return %EOPNOTSUPP instead of %EIO. So keep only those two and remove the rest ldops as they are superfluous.
--- drivers/tty/n_null.c | 18 ------------------ 1 file changed, 18 deletions(-)
drivers/tty/n_null.c +0 -18
@@ -10,15 +10,6 @@* Copyright (C) Intel 2017 */ -static int n_null_open (struct tty_struct *tty) -{ -return 0 ; -} - -static void n_null_close (struct tty_struct *tty) -{ -} -static ssize_t n_null_read (struct tty_struct *tty,struct file *file,unsigned char *buf,size_t nr,void **cookie,unsigned long offset)
@@ -32,21 +23,12 @@ static ssize_t n_null_write(struct tty_struct *tty, struct file *file,return -EOPNOTSUPP ; } -static void n_null_receivebuf (struct tty_struct *tty, -const unsigned char *cp,const char *fp, -int cnt) -{ -} -static struct tty_ldisc_ops null_ldisc = { .owner =THIS_MODULE , .num =N_NULL , .name ="n_null" , - .open = n_null_open, - .close = n_null_close, .read = n_null_read, .write = n_null_write, - .receive_buf = n_null_receivebuf };static int __init n_null_init (void )
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 5/36 tty: change tty_write_lock()'s ndelay parameter to bool
In reply to Jiri Slaby (SUSE)It's a yes-no parameter, so convert it to bool to be obvious.
--- drivers/tty/tty.h | 2 +- drivers/tty/tty_io.c | 6 +++--- drivers/tty/tty_ioctl.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/tty/tty.h +1 -1
@@ -63,7 +63,7 @@ int tty_check_change(struct tty_struct *tty);void __stop_tty (struct tty_struct *tty);void __start_tty (struct tty_struct *tty);void tty_write_unlock (struct tty_struct *tty); -int tty_write_lock (struct tty_struct *tty,int ndelay); +int tty_write_lock (struct tty_struct *tty,bool ndelay);void tty_vhangup_session (struct tty_struct *tty);void tty_open_proc_set_tty (struct file *filp,struct tty_struct *tty);int tty_signal_session_leader (struct tty_struct *tty,int exit_session);
drivers/tty/tty_io.c +3 -3
@@ -946,7 +946,7 @@ void tty_write_unlock(struct tty_struct *tty)wake_up_interruptible_poll (&tty->write_wait,EPOLLOUT ); } -int tty_write_lock (struct tty_struct *tty,int ndelay) +int tty_write_lock (struct tty_struct *tty,bool ndelay) {if (!mutex_trylock (&tty->atomic_write_lock)) {if (ndelay)
@@ -1160,7 +1160,7 @@ int tty_send_xchar(struct tty_struct *tty, char ch)return 0 ; } -if (tty_write_lock (tty,0 ) <0 ) +if (tty_write_lock (tty, false) <0 )return -ERESTARTSYS ;down_read (&tty->termios_rwsem);
@@ -2486,7 +2486,7 @@ static int send_break(struct tty_struct *tty, unsigned int duration) retval = tty->ops->break_ctl (tty, duration); else {/* Do the work ourselves */ -if (tty_write_lock (tty,0 ) <0 ) +if (tty_write_lock (tty, false) <0 )return -EINTR ; retval = tty->ops->break_ctl (tty,-1 );if (retval)
drivers/tty/tty_ioctl.c +1 -1
@@ -507,7 +507,7 @@ static int set_termios(struct tty_struct *tty, void __user *arg, int opt)if (retval <0 )return retval; -if (tty_write_lock (tty,0 ) <0 ) +if (tty_write_lock (tty, false) <0 ) goto retry_write_wait;/* Racing writer? */
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 6/36 tty: tty_port: rename 'disc' to 'ld'
In reply to Jiri Slaby (SUSE)Line discipline variables are named 'ld' all over the tty code. Rename these in tty_port, so that it is easier to grep for the code (namely for "ld->ops").
--- drivers/tty/tty_port.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/tty/tty_port.c +11 -11
@@ -26,19 +26,19 @@ static int tty_port_default_receive_buf(struct tty_port *port, {int ret;struct tty_struct *tty; -struct tty_ldisc *disc; +struct tty_ldisc *ld; tty =READ_ONCE (port->itty);if (!tty)return 0 ; - disc =tty_ldisc_ref (tty); -if (!disc) + ld =tty_ldisc_ref (tty); +if (!ld)return 0 ; - ret =tty_ldisc_receive_buf (disc, p, (char *)f, count); + ret =tty_ldisc_receive_buf (ld, p, (char *)f, count); -tty_ldisc_deref (disc); +tty_ldisc_deref (ld);return ret; }
@@ -47,20 +47,20 @@ static void tty_port_default_lookahead_buf(struct tty_port *port, const unsigned const unsigned char *f, unsigned int count) {struct tty_struct *tty; -struct tty_ldisc *disc; +struct tty_ldisc *ld; tty =READ_ONCE (port->itty);if (!tty)return ; - disc =tty_ldisc_ref (tty); -if (!disc) + ld =tty_ldisc_ref (tty); +if (!ld)return ; -if (disc->ops->lookahead_buf) - disc->ops->lookahead_buf (disc->tty, p, f, count); +if (ld->ops->lookahead_buf) + ld->ops->lookahead_buf (ld->tty, p, f, count); -tty_ldisc_deref (disc); +tty_ldisc_deref (ld); }static void tty_port_default_wakeup (struct tty_port *port)
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 7/36 tty: drop tty_debug_wait_until_sent()
In reply to Jiri Slaby (SUSE)It's a nop for everyone as TTY_DEBUG_WAIT_UNTIL_SENT is never set. Provided, we have better debugging/printout mechanisms nowadays, remove this mechanism.
--- drivers/tty/tty_ioctl.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/tty/tty_ioctl.c +0 -10
@@ -28,14 +28,6 @@#include <asm/io.h> #include <linux/uaccess.h> -#undef TTY_DEBUG_WAIT_UNTIL_SENT - -#ifdef TTY_DEBUG_WAIT_UNTIL_SENT -# define tty_debug_wait_until_sent(tty, f, args...) tty_debug(tty, f, ##args) -#else -# define tty_debug_wait_until_sent(tty, f, args...) do {} while (0) -#endif -#undef DEBUG/*
@@ -198,8 +190,6 @@ int tty_unthrottle_safe(struct tty_struct *tty)void tty_wait_until_sent (struct tty_struct *tty,long timeout) { -tty_debug_wait_until_sent (tty,"wait until sent, timeout=%ld\n" , timeout); -if (!timeout) timeout =MAX_SCHEDULE_TIMEOUT ;
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 8/36 tty: make tty_change_softcar() more understandable
In reply to Jiri Slaby (SUSE)* rename 'arg' to 'enable' as that is what it means.
* make 'bit' a tcflag_t, not int, as that is what cflags are.
--- drivers/tty/tty_ioctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/tty/tty_ioctl.c +3 -3
@@ -737,17 +737,17 @@ static int set_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars)/** * tty_change_softcar - carrier change ioctl helper * @tty: tty to update -* @arg: enable/disable CLOCAL +* @enable: enable/disable CLOCAL * * Perform a change to the CLOCAL state and call into the driver * layer to make it visible. All done with the termios rwsem */ -static int tty_change_softcar (struct tty_struct *tty,int arg) +static int tty_change_softcar (struct tty_struct *tty,bool enable) {int ret =0 ; -int bit = arg ?CLOCAL :0 ;struct ktermios old; +tcflag_t bit = enable ?CLOCAL :0 ;down_write (&tty->termios_rwsem); old = tty->termios;
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 9/36 tty: make tty_port_client_operations operate with u8
In reply to Jiri Slaby (SUSE)The parameters are already unsigned chars. So make them explicitly u8s, as the rest is going to be unified to u8 eventually too.
--- drivers/tty/serdev/serdev-ttyport.c | 4 ++-- drivers/tty/tty_buffer.c | 4 ++-- drivers/tty/tty_port.c | 9 ++++----- include/linux/tty_port.h | 7 ++++--- 4 files changed, 12 insertions(+), 12 deletions(-)
drivers/tty/serdev/serdev-ttyport.c +2 -2
@@ -22,8 +22,8 @@ struct serport {* Callback functions from the tty port. */ -static int ttyport_receive_buf (struct tty_port *port,const unsigned char *cp, -const unsigned char *fp,size_t count) +static int ttyport_receive_buf (struct tty_port *port,const u8 *cp, +const u8 *fp,size_t count) {struct serdev_controller *ctrl = port->client_data;struct serport *serport =serdev_controller_get_drvdata (ctrl);
drivers/tty/tty_buffer.c +2 -2
@@ -505,8 +505,8 @@ static void lookahead_bufs(struct tty_port *port, struct tty_buffer *head)static int receive_buf (struct tty_port *port,struct tty_buffer *head,int count) { -unsigned char *p =char_buf_ptr (head, head->read); -const char *f =NULL ; +u8 *p =char_buf_ptr (head, head->read); +const u8 *f =NULL ;int n;if (head->flags)
drivers/tty/tty_port.c +4 -5
@@ -20,9 +20,8 @@#include <linux/serdev.h> #include "tty.h" -static int tty_port_default_receive_buf (struct tty_port *port, -const unsigned char *p, -const unsigned char *f,size_t count) +static int tty_port_default_receive_buf (struct tty_port *port,const u8 *p, +const u8 *f,size_t count) {int ret;struct tty_struct *tty;
@@ -43,8 +42,8 @@ static int tty_port_default_receive_buf(struct tty_port *port,return ret; } -static void tty_port_default_lookahead_buf (struct tty_port *port,const unsigned char *p, -const unsigned char *f,unsigned int count) +static void tty_port_default_lookahead_buf (struct tty_port *port,const u8 *p, +const u8 *f,unsigned int count) {struct tty_struct *tty;struct tty_ldisc *ld;
include/linux/tty_port.h +4 -3
@@ -39,9 +39,10 @@ struct tty_port_operations { };struct tty_port_client_operations { -int (*receive_buf)(struct tty_port *port,const unsigned char *,const unsigned char *,size_t ); -void (*lookahead_buf)(struct tty_port *port,const unsigned char *cp, -const unsigned char *fp,unsigned int count); +int (*receive_buf)(struct tty_port *port,const u8 *cp,const u8 *fp, +size_t count); +void (*lookahead_buf)(struct tty_port *port,const u8 *cp, +const u8 *fp,unsigned int count);void (*write_wakeup)(struct tty_port *port); };
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 10/36 tty: make counts in tty_port_client_operations hooks size_t
In reply to Jiri Slaby (SUSE)The counts in tty_port_client_operations hooks' are currently represented by all 'int', 'unsigned int', and 'size_t'. Unify them all to unsigned 'size_t' for clarity. Note that size_t is used already in tty_buffer.c. So, eventually, it is spread for counts everywhere and this is the beginning.
So the two changes namely:
* ::receive_buf() is called from tty_ldisc_receive_buf(). And that expects values ">= 0" from ::receive_buf(), so switch its rettype to size_t is fine. tty_ldisc_receive_buf() types will be changed separately.
* ::lookahead_buf()'s count comes from lookahead_bufs() and is already 'unsigned int'.
--- drivers/tty/serdev/serdev-ttyport.c | 4 ++-- drivers/tty/tty_port.c | 11 +++++------ include/linux/tty_port.h | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-)
drivers/tty/serdev/serdev-ttyport.c +2 -2
@@ -22,8 +22,8 @@ struct serport {* Callback functions from the tty port. */ -static int ttyport_receive_buf (struct tty_port *port,const u8 *cp, -const u8 *fp,size_t count) +static size_t ttyport_receive_buf (struct tty_port *port,const u8 *cp, +const u8 *fp,size_t count) {struct serdev_controller *ctrl = port->client_data;struct serport *serport =serdev_controller_get_drvdata (ctrl);
drivers/tty/tty_port.c +5 -6
@@ -20,10 +20,9 @@#include <linux/serdev.h> #include "tty.h" -static int tty_port_default_receive_buf (struct tty_port *port,const u8 *p, -const u8 *f,size_t count) +static size_t tty_port_default_receive_buf (struct tty_port *port,const u8 *p, +const u8 *f,size_t count) { -int ret;struct tty_struct *tty;struct tty_ldisc *ld;
@@ -35,15 +34,15 @@ static int tty_port_default_receive_buf(struct tty_port *port, const u8 *p,if (!ld)return 0 ; - ret =tty_ldisc_receive_buf (ld, p, (char *)f, count); + count =tty_ldisc_receive_buf (ld, p, (char *)f, count);tty_ldisc_deref (ld); -return ret; +return count; }static void tty_port_default_lookahead_buf (struct tty_port *port,const u8 *p, -const u8 *f,unsigned int count) +const u8 *f,size_t count) {struct tty_struct *tty;struct tty_ldisc *ld;
include/linux/tty_port.h +3 -3
@@ -39,10 +39,10 @@ struct tty_port_operations { };struct tty_port_client_operations { -int (*receive_buf)(struct tty_port *port,const u8 *cp,const u8 *fp, -size_t count); +size_t (*receive_buf)(struct tty_port *port,const u8 *cp,const u8 *fp, +size_t count);void (*lookahead_buf)(struct tty_port *port,const u8 *cp, -const u8 *fp,unsigned int count); +const u8 *fp,size_t count);void (*write_wakeup)(struct tty_port *port); };
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 11/36 tty: switch receive_buf() counts to size_t
In reply to Jiri Slaby (SUSE)'size_t' is what receive_buf() expects and returns while handling count. So switch to 'size_t'.
This renders both local 'count' and 'rcvd' in flush_to_ldisc() to be size_t too.
--- drivers/tty/tty_buffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/tty/tty_buffer.c +4 -4
@@ -502,12 +502,12 @@ static void lookahead_bufs(struct tty_port *port, struct tty_buffer *head) } } -static int -receive_buf (struct tty_port *port,struct tty_buffer *head,int count) +static size_t +receive_buf (struct tty_port *port,struct tty_buffer *head,size_t count) {u8 *p =char_buf_ptr (head, head->read);const u8 *f =NULL ; -int n; +size_t n;if (head->flags) f =flag_buf_ptr (head, head->read);
@@ -539,7 +539,7 @@ static void flush_to_ldisc(struct work_struct *work)while (1 ) {struct tty_buffer *head = buf->head;struct tty_buffer *next; -int count, rcvd; +size_t count, rcvd;/* Ldisc or user is trying to gain exclusive access */ if (atomic_read (&buf->priority))
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 12/36 tty: switch count in tty_ldisc_receive_buf() to size_t
In reply to Jiri Slaby (SUSE)It comes from both paste_selection() and tty_port_default_receive_buf() as unsigned (int and size_t respectively). Switch to size_t to converge to that eventually.
Return the count as size_t too (the two callers above expect that).
Switch paste_selection()'s type of 'count' too, so that the returned and passed type match.
--- drivers/tty/tty_buffer.c | 6 +++--- drivers/tty/vt/selection.c | 2 +- include/linux/tty_flip.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/tty/tty_buffer.c +3 -3
@@ -450,13 +450,13 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string);* * Returns: the number of bytes processed. */ -int tty_ldisc_receive_buf (struct tty_ldisc *ld,const unsigned char *p, -const char *f,int count) +size_t tty_ldisc_receive_buf (struct tty_ldisc *ld,const unsigned char *p, +const char *f,size_t count) {if (ld->ops->receive_buf2) count = ld->ops->receive_buf2 (ld->tty, p, f, count);else { - count =min_t (int, count, ld->tty->receive_room); + count =min_t (size_t, count, ld->tty->receive_room);if (count && ld->ops->receive_buf) ld->ops->receive_buf (ld->tty, p, f, count); }
drivers/tty/vt/selection.c +1 -1
@@ -376,7 +376,7 @@ int paste_selection(struct tty_struct *tty) {struct vc_data *vc = tty->driver_data;int pasted =0 ; -unsigned int count; +size_t count;struct tty_ldisc *ld;DECLARE_WAITQUEUE (wait, current);int ret =0 ;
include/linux/tty_flip.h +2 -2
@@ -41,8 +41,8 @@ static inline int tty_insert_flip_string(struct tty_port *port,return tty_insert_flip_string_fixed_flag (port, chars,TTY_NORMAL , size); } -int tty_ldisc_receive_buf (struct tty_ldisc *ld,const unsigned char *p, -const char *f,int count); +size_t tty_ldisc_receive_buf (struct tty_ldisc *ld,const unsigned char *p, +const char *f,size_t count);void tty_buffer_lock_exclusive (struct tty_port *port);void tty_buffer_unlock_exclusive (struct tty_port *port);
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 13/36 tty: can327: unify error paths in can327_ldisc_rx()
In reply to Jiri Slaby (SUSE)Create a label with can327_uart_side_failure() and spin unlock. And jump there from all three fail paths.
--- drivers/net/can/can327.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
drivers/net/can/can327.c +8 -14
@@ -905,11 +905,7 @@ static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp,if (fp && *fp++) {netdev_err (elm->dev,"Error in received character stream. Check your wiring." ); - -can327_uart_side_failure (elm); - -spin_unlock_bh (&elm->lock); -return ; + goto uart_failure; }/* Ignore NUL characters, which the PIC microcontroller may
@@ -925,10 +921,7 @@ static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp,netdev_err (elm->dev,"Received illegal character %02x.\n" , *cp); -can327_uart_side_failure (elm); - -spin_unlock_bh (&elm->lock); -return ; + goto uart_failure; } elm->rxbuf[elm->rxfill++] = *cp;
@@ -941,15 +934,16 @@ static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp,netdev_err (elm->dev,"Receive buffer overflowed. Bad chip or wiring? count = %i" , count); - -can327_uart_side_failure (elm); - -spin_unlock_bh (&elm->lock); -return ; + goto uart_failure; }can327_parse_rxbuf (elm, first_new_char_idx);spin_unlock_bh (&elm->lock); + +return ; +uart_failure: +can327_uart_side_failure (elm); +spin_unlock_bh (&elm->lock); }/* Write out remaining transmit buffer.
Signature · 1 line
2.41.0
Re: [PATCH 13/36] tty: can327: unify error paths in can327_ldisc_rx()
Thank you for simplifying this!
In case you're re-sending this series, may I ask for one empty line between the final "return;" and the new label "uart_failure:"?
Jiri Slaby (SUSE)
maintainerPATCH 14/36 tty: can327, move overflow test inside can327_ldisc_rx()'s loop
In reply to Jiri Slaby (SUSE)The 'count' is going to be unsigned and the 'count >= 0' test would be always true then. Move the condition to the loop where this is easier to check.
It looks as is easier to follow after all too.
--- drivers/net/can/can327.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/can/can327.c +7 -8
@@ -901,7 +901,13 @@ static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp,*/ first_new_char_idx = elm->rxfill; -while (count-- && elm->rxfill <CAN327_SIZE_RXBUF ) { +while (count--) { +if (elm->rxfill >=CAN327_SIZE_RXBUF ) { +netdev_err (elm->dev, +"Receive buffer overflowed. Bad chip or wiring? count = %i" , + count); + goto uart_failure; + }if (fp && *fp++) {netdev_err (elm->dev,"Error in received character stream. Check your wiring." );
@@ -930,13 +936,6 @@ static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp, cp++; } -if (count >=0 ) { -netdev_err (elm->dev, -"Receive buffer overflowed. Bad chip or wiring? count = %i" , - count); - goto uart_failure; - } -can327_parse_rxbuf (elm, first_new_char_idx);spin_unlock_bh (&elm->lock);
Signature · 1 line
2.41.0
Re: [PATCH 14/36] tty: can327, move overflow test inside can327_ldisc_rx()'s loop
Thanks for this one as well.
Jiri Slaby (SUSE)
maintainerPATCH 15/36 tty: make tty_ldisc_ops::*buf*() hooks operate on size_t
In reply to Jiri Slaby (SUSE)Count passed to tty_ldisc_ops::receive_buf*(), ::lookahead_buf(), and returned from ::receive_buf2() is expected to be size_t. So set it to size_t to unify with the rest of the code.
--- drivers/accessibility/speakup/spk_ttyio.c | 6 +++--- drivers/bluetooth/hci_ldisc.c | 2 +- drivers/input/serio/serport.c | 3 ++- drivers/misc/ti-st/st_core.c | 2 +- drivers/net/caif/caif_serial.c | 2 +- drivers/net/can/can327.c | 4 ++-- drivers/net/can/slcan/slcan-core.c | 2 +- drivers/net/hamradio/6pack.c | 2 +- drivers/net/hamradio/mkiss.c | 2 +- drivers/net/mctp/mctp-serial.c | 2 +- drivers/net/ppp/ppp_async.c | 2 +- drivers/net/ppp/ppp_synctty.c | 2 +- drivers/net/slip/slip.c | 2 +- drivers/tty/n_gsm.c | 2 +- drivers/tty/n_hdlc.c | 4 ++-- drivers/tty/n_tty.c | 14 ++++++++------ include/linux/tty_ldisc.h | 16 ++++++++-------- net/nfc/nci/uart.c | 2 +- sound/soc/codecs/cx20442.c | 2 +- 19 files changed, 38 insertions(+), 35 deletions(-)
drivers/accessibility/speakup/spk_ttyio.c +3 -3
@@ -71,9 +71,9 @@ static void spk_ttyio_ldisc_close(struct tty_struct *tty)kfree (tty->disc_data); } -static int spk_ttyio_receive_buf2 (struct tty_struct *tty, -const unsigned char *cp, -const char *fp,int count) +static size_t spk_ttyio_receive_buf2 (struct tty_struct *tty, +const unsigned char *cp,const char *fp, +size_t count) {struct spk_ldisc_data *ldisc_data = tty->disc_data;struct spk_synth *synth = ldisc_data->synth;
drivers/bluetooth/hci_ldisc.c +1 -1
@@ -599,7 +599,7 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)* Return Value: None */ static void hci_uart_tty_receive (struct tty_struct *tty,const u8 *data, -const char *flags,int count) +const char *flags,size_t count) {struct hci_uart *hu = tty->disc_data;
drivers/input/serio/serport.c +2 -1
@@ -115,7 +115,8 @@ static void serport_ldisc_close(struct tty_struct *tty)*/ static void serport_ldisc_receive (struct tty_struct *tty, -const unsigned char *cp,const char *fp,int count) +const unsigned char *cp,const char *fp, +size_t count) {struct serport *serport = tty->disc_data;unsigned long flags;
drivers/misc/ti-st/st_core.c +1 -1
@@ -792,7 +792,7 @@ static void st_tty_close(struct tty_struct *tty) }static void st_tty_receive (struct tty_struct *tty,const unsigned char *data, -const char *tty_flags,int count) +const char *tty_flags,size_t count) {#ifdef VERBOSE print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE,
drivers/net/caif/caif_serial.c +1 -1
@@ -159,7 +159,7 @@ static inline void debugfs_tx(struct ser_device *ser, const u8 *data, int size)#endif static void ldisc_receive (struct tty_struct *tty,const u8 *data, -const char *flags,int count) +const char *flags,size_t count) {struct sk_buff *skb =NULL ;struct ser_device *ser;
drivers/net/can/can327.c +2 -2
@@ -886,7 +886,7 @@ static bool can327_is_valid_rx_char(u8 c)* functions may be called in parallel. */ static void can327_ldisc_rx (struct tty_struct *tty,const unsigned char *cp, -const char *fp,int count) +const char *fp,size_t count) {struct can327 *elm = tty->disc_data;size_t first_new_char_idx;
@@ -904,7 +904,7 @@ static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp,while (count--) {if (elm->rxfill >=CAN327_SIZE_RXBUF ) {netdev_err (elm->dev, -"Receive buffer overflowed. Bad chip or wiring? count = %i" , +"Receive buffer overflowed. Bad chip or wiring? count = %zu" , count); goto uart_failure; }
drivers/net/can/slcan/slcan-core.c +1 -1
@@ -776,7 +776,7 @@ static const struct net_device_ops slcan_netdev_ops = {*/ static void slcan_receive_buf (struct tty_struct *tty,const unsigned char *cp,const char *fp, -int count) +size_t count) {struct slcan *sl = tty->disc_data;
drivers/net/hamradio/6pack.c +1 -1
@@ -428,7 +428,7 @@ static void sixpack_write_wakeup(struct tty_struct *tty)* and sent on to some IP layer for further processing. */ static void sixpack_receive_buf (struct tty_struct *tty, -const unsigned char *cp,const char *fp,int count) +const unsigned char *cp,const char *fp,size_t count) {struct sixpack *sp;int count1;
drivers/net/hamradio/mkiss.c +1 -1
@@ -875,7 +875,7 @@ static int mkiss_ioctl(struct tty_struct *tty, unsigned int cmd,* and sent on to the AX.25 layer for further processing. */ static void mkiss_receive_buf (struct tty_struct *tty,const unsigned char *cp, -const char *fp,int count) +const char *fp,size_t count) {struct mkiss *ax =mkiss_get (tty);
drivers/net/mctp/mctp-serial.c +1 -1
@@ -392,7 +392,7 @@ static void mctp_serial_push(struct mctp_serial *dev, unsigned char c)static void mctp_serial_tty_receive_buf (struct tty_struct *tty,const unsigned char *c, -const char *f,int len) +const char *f,size_t len) {struct mctp_serial *dev = tty->disc_data;int i;
drivers/net/ppp/ppp_async.c +1 -1
@@ -331,7 +331,7 @@ ppp_asynctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)/* May sleep, don't call from interrupt level or with interrupts disabled */ static void ppp_asynctty_receive (struct tty_struct *tty,const unsigned char *buf, -const char *cflags,int count) +const char *cflags,size_t count) {struct asyncppp *ap =ap_get (tty);unsigned long flags;
drivers/net/ppp/ppp_synctty.c +1 -1
@@ -324,7 +324,7 @@ ppp_synctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)/* May sleep, don't call from interrupt level or with interrupts disabled */ static void ppp_sync_receive (struct tty_struct *tty,const unsigned char *buf, -const char *cflags,int count) +const char *cflags,size_t count) {struct syncppp *ap =sp_get (tty);unsigned long flags;
drivers/net/slip/slip.c +1 -1
@@ -686,7 +686,7 @@ static void sl_setup(struct net_device *dev)*/ static void slip_receive_buf (struct tty_struct *tty,const unsigned char *cp, -const char *fp,int count) +const char *fp,size_t count) {struct slip *sl = tty->disc_data;
drivers/tty/n_gsm.c +1 -1
@@ -3490,7 +3490,7 @@ static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm) }static void gsmld_receive_buf (struct tty_struct *tty,const unsigned char *cp, -const char *fp,int count) +const char *fp,size_t count) {struct gsm_mux *gsm = tty->disc_data;char flags =TTY_NORMAL ;
drivers/tty/n_hdlc.c +2 -2
@@ -370,12 +370,12 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty)* interpreted as one HDLC frame. */ static void n_hdlc_tty_receive (struct tty_struct *tty,const __u8 *data, -const char *flags,int count) +const char *flags,size_t count) { registerstruct n_hdlc *n_hdlc = tty->disc_data; registerstruct n_hdlc_buf *buf; -pr_debug ("%s() called count=%d\n" , __func__, count); +pr_debug ("%s() called count=%zu\n" , __func__, count);if (count > maxframe) {pr_debug ("rx count>maxframesize, data discarded\n" );
drivers/tty/n_tty.c +8 -6
@@ -1480,7 +1480,7 @@ n_tty_receive_char_lnext(struct tty_struct *tty, unsigned char c, char flag)/* Caller must ensure count > 0 */ static void n_tty_lookahead_flow_ctrl (struct tty_struct *tty,const unsigned char *cp, -const unsigned char *fp,unsigned int count) +const unsigned char *fp,size_t count) {struct n_tty_data *ldata = tty->disc_data;unsigned char flag =TTY_NORMAL ;
@@ -1662,12 +1662,13 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,* claims non-exclusive %termios_rwsem * publishes commit_head or canon_head */ -static int +static size_t n_tty_receive_buf_common (struct tty_struct *tty,const unsigned char *cp,const char *fp,int count,int flow) {struct n_tty_data *ldata = tty->disc_data; -int room, n, rcvd =0 , overflow; +size_t rcvd =0 ; +int room, n, overflow;down_read (&tty->termios_rwsem);
@@ -1744,13 +1745,14 @@ n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp, }static void n_tty_receive_buf (struct tty_struct *tty,const unsigned char *cp, -const char *fp,int count) +const char *fp,size_t count) {n_tty_receive_buf_common (tty, cp, fp, count,0 ); } -static int n_tty_receive_buf2 (struct tty_struct *tty,const unsigned char *cp, -const char *fp,int count) +static size_t n_tty_receive_buf2 (struct tty_struct *tty, +const unsigned char *cp,const char *fp, +size_t count) {return n_tty_receive_buf_common (tty, cp, fp, count,1 ); }
include/linux/tty_ldisc.h +8 -8
@@ -162,7 +162,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* Optional. Can sleep. * * @receive_buf: [DRV] ``void ()(struct tty_struct *tty, -* const unsigned char *cp, const char *fp, int count)`` +* const unsigned char *cp, const char *fp, size_t count)`` * * This function is called by the low-level tty driver to send characters * received by the hardware to the line discpline for processing. @cp is
@@ -191,8 +191,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* * Optional. * -* @receive_buf2: [DRV] ``int ()(struct tty_struct *tty, -* const unsigned char *cp, const char *fp, int count)`` +* @receive_buf2: [DRV] ``ssize_t ()(struct tty_struct *tty, +* const unsigned char *cp, const char *fp, size_t count)`` * * This function is called by the low-level tty driver to send characters * received by the hardware to the line discpline for processing. @cp is a
@@ -205,7 +205,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* Optional. * * @lookahead_buf: [DRV] ``void ()(struct tty_struct *tty, -* const unsigned char *cp, const char *fp, int count)`` +* const unsigned char *cp, const char *fp, size_t count)`` * * This function is called by the low-level tty driver for characters * not eaten by ->receive_buf() or ->receive_buf2(). It is useful for
@@ -256,13 +256,13 @@ struct tty_ldisc_ops {* The following routines are called from below. */ void (*receive_buf)(struct tty_struct *tty,const unsigned char *cp, -const char *fp,int count); +const char *fp,size_t count);void (*write_wakeup)(struct tty_struct *tty);void (*dcd_change)(struct tty_struct *tty,bool active); -int (*receive_buf2)(struct tty_struct *tty,const unsigned char *cp, -const char *fp,int count); +size_t (*receive_buf2)(struct tty_struct *tty,const unsigned char *cp, +const char *fp,size_t count);void (*lookahead_buf)(struct tty_struct *tty,const unsigned char *cp, -const unsigned char *fp,unsigned int count); +const unsigned char *fp,size_t count);struct module *owner; };
net/nfc/nci/uart.c +1 -1
@@ -296,7 +296,7 @@ static int nci_uart_default_recv_buf(struct nci_uart *nu, const u8 *data,* Return Value: None */ static void nci_uart_tty_receive (struct tty_struct *tty,const u8 *data, -const char *flags,int count) +const char *flags,size_t count) {struct nci_uart *nu = tty->disc_data;
sound/soc/codecs/cx20442.c +1 -1
@@ -259,7 +259,7 @@ static void v253_hangup(struct tty_struct *tty)/* Line discipline .receive_buf() */ static void v253_receive (struct tty_struct *tty,const unsigned char *cp, -const char *fp,int count) +const char *fp,size_t count) {struct snd_soc_component *component = tty->disc_data;struct cx20442_priv *cx20442;
Signature · 1 line
2.41.0
Re: [PATCH 15/36] tty: make tty_ldisc_ops::*buf*() hooks operate on size_t
Quoted 3 lines · Jiri Slaby (SUSE)
Count passed to tty_ldisc_ops::receive_buf*(), ::lookahead_buf(), and returned from ::receive_buf2() is expected to be
size_t. So set it tosize_tto unify with the rest of the code.
Re: [PATCH 15/36] tty: make tty_ldisc_ops::*buf*() hooks operate on size_t
In reply to Jiri Slaby (SUSE)Jiri Slaby (SUSE)
maintainerPATCH 16/36 tty: use u8 for chars
In reply to Jiri Slaby (SUSE)This makes all those 'unsigned char's an explicit 'u8'. This is part of the continuing unification of chars and flags to be consistent u8.
This approaches tty_port_default_receive_buf(). Flags to be next.
--- drivers/accessibility/speakup/spk_ttyio.c | 5 ++-- drivers/input/serio/serport.c | 5 ++-- drivers/misc/ti-st/st_core.c | 2 +- drivers/net/can/can327.c | 2 +- drivers/net/can/slcan/slcan-core.c | 5 ++-- drivers/net/hamradio/6pack.c | 4 ++-- drivers/net/hamradio/mkiss.c | 2 +- drivers/net/mctp/mctp-serial.c | 3 +-- drivers/net/ppp/ppp_async.c | 8 +++---- drivers/net/ppp/ppp_synctty.c | 11 ++++----- drivers/net/slip/slip.c | 2 +- drivers/tty/n_gsm.c | 2 +- drivers/tty/n_hdlc.c | 2 +- drivers/tty/n_tty.c | 28 +++++++++++------------ drivers/tty/tty.h | 2 +- drivers/tty/tty_buffer.c | 21 ++++++++--------- include/linux/tty_buffer.h | 4 ++-- include/linux/tty_flip.h | 22 ++++++++---------- include/linux/tty_ldisc.h | 18 +++++++-------- sound/soc/codecs/cx20442.c | 4 ++-- sound/soc/ti/ams-delta.c | 2 +- 21 files changed, 73 insertions(+), 81 deletions(-)
drivers/accessibility/speakup/spk_ttyio.c +2 -3
@@ -71,9 +71,8 @@ static void spk_ttyio_ldisc_close(struct tty_struct *tty)kfree (tty->disc_data); } -static size_t spk_ttyio_receive_buf2 (struct tty_struct *tty, -const unsigned char *cp,const char *fp, -size_t count) +static size_t spk_ttyio_receive_buf2 (struct tty_struct *tty,const u8 *cp, +const char *fp,size_t count) {struct spk_ldisc_data *ldisc_data = tty->disc_data;struct spk_synth *synth = ldisc_data->synth;
drivers/input/serio/serport.c +2 -3
@@ -114,9 +114,8 @@ static void serport_ldisc_close(struct tty_struct *tty)* 'interrupt' routine. */ -static void serport_ldisc_receive (struct tty_struct *tty, -const unsigned char *cp,const char *fp, -size_t count) +static void serport_ldisc_receive (struct tty_struct *tty,const u8 *cp, +const char *fp,size_t count) {struct serport *serport = tty->disc_data;unsigned long flags;
drivers/misc/ti-st/st_core.c +1 -1
@@ -791,7 +791,7 @@ static void st_tty_close(struct tty_struct *tty)pr_debug ("%s: done " , __func__); } -static void st_tty_receive (struct tty_struct *tty,const unsigned char *data, +static void st_tty_receive (struct tty_struct *tty,const u8 *data,const char *tty_flags,size_t count) {#ifdef VERBOSE
drivers/net/can/can327.c +1 -1
@@ -885,7 +885,7 @@ static bool can327_is_valid_rx_char(u8 c)* This will not be re-entered while running, but other ldisc * functions may be called in parallel. */ -static void can327_ldisc_rx (struct tty_struct *tty,const unsigned char *cp, +static void can327_ldisc_rx (struct tty_struct *tty,const u8 *cp,const char *fp,size_t count) {struct can327 *elm = tty->disc_data;
drivers/net/can/slcan/slcan-core.c +2 -3
@@ -774,9 +774,8 @@ static const struct net_device_ops slcan_netdev_ops = {* be re-entered while running but other ldisc functions may be called * in parallel */ -static void slcan_receive_buf (struct tty_struct *tty, -const unsigned char *cp,const char *fp, -size_t count) +static void slcan_receive_buf (struct tty_struct *tty,const u8 *cp, +const char *fp,size_t count) {struct slcan *sl = tty->disc_data;
drivers/net/hamradio/6pack.c +2 -2
@@ -427,8 +427,8 @@ static void sixpack_write_wakeup(struct tty_struct *tty)* a block of 6pack data has been received, which can now be decapsulated * and sent on to some IP layer for further processing. */ -static void sixpack_receive_buf (struct tty_struct *tty, -const unsigned char *cp,const char *fp,size_t count) +static void sixpack_receive_buf (struct tty_struct *tty,const u8 *cp, +const char *fp,size_t count) {struct sixpack *sp;int count1;
drivers/net/hamradio/mkiss.c +1 -1
@@ -874,7 +874,7 @@ static int mkiss_ioctl(struct tty_struct *tty, unsigned int cmd,* a block of data has been received, which can now be decapsulated * and sent on to the AX.25 layer for further processing. */ -static void mkiss_receive_buf (struct tty_struct *tty,const unsigned char *cp, +static void mkiss_receive_buf (struct tty_struct *tty,const u8 *cp,const char *fp,size_t count) {struct mkiss *ax =mkiss_get (tty);
drivers/net/mctp/mctp-serial.c +1 -2
@@ -390,8 +390,7 @@ static void mctp_serial_push(struct mctp_serial *dev, unsigned char c) } } -static void mctp_serial_tty_receive_buf (struct tty_struct *tty, -const unsigned char *c, +static void mctp_serial_tty_receive_buf (struct tty_struct *tty,const u8 *c,const char *f,size_t len) {struct mctp_serial *dev = tty->disc_data;
drivers/net/ppp/ppp_async.c +4 -4
@@ -330,8 +330,8 @@ ppp_asynctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)/* May sleep, don't call from interrupt level or with interrupts disabled */ static void -ppp_asynctty_receive (struct tty_struct *tty,const unsigned char *buf, -const char *cflags,size_t count) +ppp_asynctty_receive (struct tty_struct *tty,const u8 *buf,const char *cflags, +size_t count) {struct asyncppp *ap =ap_get (tty);unsigned long flags;
@@ -819,8 +819,8 @@ process_input_packet(struct asyncppp *ap)other ldisc functions but will not be re-entered */ static void -ppp_async_input (struct asyncppp *ap,const unsigned char *buf, -const char *flags,int count) +ppp_async_input (struct asyncppp *ap,const u8 *buf,const char *flags, +int count) {struct sk_buff *skb;int c, i, j, n, s, f;
drivers/net/ppp/ppp_synctty.c +5 -6
@@ -93,8 +93,8 @@ static int ppp_sync_ioctl(struct ppp_channel *chan, unsigned int cmd,static void ppp_sync_process (struct tasklet_struct *t);static int ppp_sync_push (struct syncppp *ap);static void ppp_sync_flush_output (struct syncppp *ap); -static void ppp_sync_input (struct syncppp *ap,const unsigned char *buf, -const char *flags,int count); +static void ppp_sync_input (struct syncppp *ap,const u8 *buf,const char *flags, +int count);static const struct ppp_channel_ops sync_ops = { .start_xmit = ppp_sync_send,
@@ -323,8 +323,8 @@ ppp_synctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)/* May sleep, don't call from interrupt level or with interrupts disabled */ static void -ppp_sync_receive (struct tty_struct *tty,const unsigned char *buf, -const char *cflags,size_t count) +ppp_sync_receive (struct tty_struct *tty,const u8 *buf,const char *cflags, +size_t count) {struct syncppp *ap =sp_get (tty);unsigned long flags;
@@ -655,8 +655,7 @@ ppp_sync_flush_output(struct syncppp *ap)* frame is considered to be in error and is tossed. */ static void -ppp_sync_input (struct syncppp *ap,const unsigned char *buf, -const char *flags,int count) +ppp_sync_input (struct syncppp *ap,const u8 *buf,const char *flags,int count) {struct sk_buff *skb;unsigned char *p;
drivers/net/slip/slip.c +1 -1
@@ -685,7 +685,7 @@ static void sl_setup(struct net_device *dev)* in parallel */ -static void slip_receive_buf (struct tty_struct *tty,const unsigned char *cp, +static void slip_receive_buf (struct tty_struct *tty,const u8 *cp,const char *fp,size_t count) {struct slip *sl = tty->disc_data;
drivers/tty/n_gsm.c +1 -1
@@ -3489,7 +3489,7 @@ static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm) gsm->tty =NULL ; } -static void gsmld_receive_buf (struct tty_struct *tty,const unsigned char *cp, +static void gsmld_receive_buf (struct tty_struct *tty,const u8 *cp,const char *fp,size_t count) {struct gsm_mux *gsm = tty->disc_data;
drivers/tty/n_hdlc.c +1 -1
@@ -369,7 +369,7 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty)* Called by tty low level driver when receive data is available. Data is * interpreted as one HDLC frame. */ -static void n_hdlc_tty_receive (struct tty_struct *tty,const __u8 *data, +static void n_hdlc_tty_receive (struct tty_struct *tty,const u8 *data,const char *flags,size_t count) { registerstruct n_hdlc *n_hdlc = tty->disc_data;
drivers/tty/n_tty.c +14 -14
@@ -1479,7 +1479,7 @@ n_tty_receive_char_lnext(struct tty_struct *tty, unsigned char c, char flag) }/* Caller must ensure count > 0 */ -static void n_tty_lookahead_flow_ctrl (struct tty_struct *tty,const unsigned char *cp, +static void n_tty_lookahead_flow_ctrl (struct tty_struct *tty,const u8 *cp,const unsigned char *fp,size_t count) {struct n_tty_data *ldata = tty->disc_data;
@@ -1500,8 +1500,8 @@ static void n_tty_lookahead_flow_ctrl(struct tty_struct *tty, const unsigned cha }static void -n_tty_receive_buf_real_raw (const struct tty_struct *tty, -const unsigned char *cp,int count) +n_tty_receive_buf_real_raw (const struct tty_struct *tty,const u8 *cp, +int count) {struct n_tty_data *ldata = tty->disc_data;size_t n, head;
@@ -1520,7 +1520,7 @@ n_tty_receive_buf_real_raw(const struct tty_struct *tty, }static void -n_tty_receive_buf_raw (struct tty_struct *tty,const unsigned char *cp, +n_tty_receive_buf_raw (struct tty_struct *tty,const u8 *cp,const char *fp,int count) {struct n_tty_data *ldata = tty->disc_data;
@@ -1537,7 +1537,7 @@ n_tty_receive_buf_raw(struct tty_struct *tty, const unsigned char *cp, }static void -n_tty_receive_buf_closing (struct tty_struct *tty,const unsigned char *cp, +n_tty_receive_buf_closing (struct tty_struct *tty,const u8 *cp,const char *fp,int count,bool lookahead_done) {char flag =TTY_NORMAL ;
@@ -1550,14 +1550,15 @@ n_tty_receive_buf_closing(struct tty_struct *tty, const unsigned char *cp, } } -static void n_tty_receive_buf_standard (struct tty_struct *tty, -const unsigned char *cp,const char *fp,int count,bool lookahead_done) +static void n_tty_receive_buf_standard (struct tty_struct *tty,const u8 *cp, +const char *fp,int count, +bool lookahead_done) {struct n_tty_data *ldata = tty->disc_data;char flag =TTY_NORMAL ;while (count--) { -unsigned char c = *cp++; +u8 c = *cp++;if (fp) flag = *fp++;
@@ -1588,7 +1589,7 @@ static void n_tty_receive_buf_standard(struct tty_struct *tty, } } -static void __receive_buf (struct tty_struct *tty,const unsigned char *cp, +static void __receive_buf (struct tty_struct *tty,const u8 *cp,const char *fp,int count) {struct n_tty_data *ldata = tty->disc_data;
@@ -1663,7 +1664,7 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,* publishes commit_head or canon_head */ static size_t -n_tty_receive_buf_common (struct tty_struct *tty,const unsigned char *cp, +n_tty_receive_buf_common (struct tty_struct *tty,const u8 *cp,const char *fp,int count,int flow) {struct n_tty_data *ldata = tty->disc_data;
@@ -1744,15 +1745,14 @@ n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp,return rcvd; } -static void n_tty_receive_buf (struct tty_struct *tty,const unsigned char *cp, +static void n_tty_receive_buf (struct tty_struct *tty,const u8 *cp,const char *fp,size_t count) {n_tty_receive_buf_common (tty, cp, fp, count,0 ); } -static size_t n_tty_receive_buf2 (struct tty_struct *tty, -const unsigned char *cp,const char *fp, -size_t count) +static size_t n_tty_receive_buf2 (struct tty_struct *tty,const u8 *cp, +const char *fp,size_t count) {return n_tty_receive_buf_common (tty, cp, fp, count,1 ); }
drivers/tty/tty.h +1 -1
@@ -115,6 +115,6 @@ static inline void tty_audit_tiocsti(const struct tty_struct *tty, char ch)ssize_t redirected_tty_write (struct kiocb *,struct iov_iter *);int tty_insert_flip_string_and_push_buffer (struct tty_port *port, -const unsigned char *chars,size_t cnt); +const u8 *chars,size_t cnt);#endif
drivers/tty/tty_buffer.c +10 -11
@@ -316,8 +316,8 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room);* * Returns: the number added. */ -int tty_insert_flip_string_fixed_flag (struct tty_port *port, -const unsigned char *chars,char flag,size_t size) +int tty_insert_flip_string_fixed_flag (struct tty_port *port,const u8 *chars, +char flag,size_t size) {int copied =0 ;bool flags = flag !=TTY_NORMAL ;
@@ -355,8 +355,8 @@ EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag);* * Returns: the number added. */ -int tty_insert_flip_string_flags (struct tty_port *port, -const unsigned char *chars,const char *flags,size_t size) +int tty_insert_flip_string_flags (struct tty_port *port,const u8 *chars, +const char *flags,size_t size) {int copied =0 ;
@@ -390,7 +390,7 @@ EXPORT_SYMBOL(tty_insert_flip_string_flags);* Queue a single byte @ch to the tty buffering, with an optional flag. This is * the slow path of tty_insert_flip_char(). */ -int __tty_insert_flip_char (struct tty_port *port,unsigned char ch,char flag) +int __tty_insert_flip_char (struct tty_port *port,u8 ch,char flag) {struct tty_buffer *tb;bool flags = flag !=TTY_NORMAL ;
@@ -421,8 +421,7 @@ EXPORT_SYMBOL(__tty_insert_flip_char);* Returns: the length available and buffer pointer (@chars) to the space which * is now allocated and accounted for as ready for normal characters. */ -int tty_prepare_flip_string (struct tty_port *port,unsigned char **chars, -size_t size) +int tty_prepare_flip_string (struct tty_port *port,u8 **chars,size_t size) {int space =__tty_buffer_request_room (port, size, false);
@@ -450,8 +449,8 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string);* * Returns: the number of bytes processed. */ -size_t tty_ldisc_receive_buf (struct tty_ldisc *ld,const unsigned char *p, -const char *f,size_t count) +size_t tty_ldisc_receive_buf (struct tty_ldisc *ld,const u8 *p,const char *f, +size_t count) {if (ld->ops->receive_buf2) count = ld->ops->receive_buf2 (ld->tty, p, f, count);
@@ -489,7 +488,7 @@ static void lookahead_bufs(struct tty_port *port, struct tty_buffer *head) }if (port->client_ops->lookahead_buf) { -unsigned char *p, *f =NULL ; +u8 *p, *f =NULL ; p =char_buf_ptr (head, head->lookahead);if (head->flags)
@@ -620,7 +619,7 @@ EXPORT_SYMBOL(tty_flip_buffer_push);* Returns: the number added. */ int tty_insert_flip_string_and_push_buffer (struct tty_port *port, -const unsigned char *chars,size_t size) +const u8 *chars,size_t size) {struct tty_bufhead *buf = &port->buf;unsigned long flags;
include/linux/tty_buffer.h +2 -2
@@ -22,9 +22,9 @@ struct tty_buffer {unsigned long data[]; }; -static inline unsigned char *char_buf_ptr (struct tty_buffer *b,int ofs) +static inline u8 *char_buf_ptr (struct tty_buffer *b,int ofs) { -return ((unsigned char *)b->data) + ofs; +return ((u8 *)b->data) + ofs; }static inline char *flag_buf_ptr (struct tty_buffer *b,int ofs)
include/linux/tty_flip.h +10 -12
@@ -10,17 +10,15 @@ struct tty_ldisc;int tty_buffer_set_limit (struct tty_port *port,int limit);unsigned int tty_buffer_space_avail (struct tty_port *port);int tty_buffer_request_room (struct tty_port *port,size_t size); -int tty_insert_flip_string_flags (struct tty_port *port, -const unsigned char *chars,const char *flags,size_t size); -int tty_insert_flip_string_fixed_flag (struct tty_port *port, -const unsigned char *chars,char flag,size_t size); -int tty_prepare_flip_string (struct tty_port *port,unsigned char **chars, -size_t size); +int tty_insert_flip_string_flags (struct tty_port *port,const u8 *chars, +const char *flags,size_t size); +int tty_insert_flip_string_fixed_flag (struct tty_port *port,const u8 *chars, +char flag,size_t size); +int tty_prepare_flip_string (struct tty_port *port,u8 **chars,size_t size);void tty_flip_buffer_push (struct tty_port *port); -int __tty_insert_flip_char (struct tty_port *port,unsigned char ch,char flag); +int __tty_insert_flip_char (struct tty_port *port,u8 ch,char flag); -static inline int tty_insert_flip_char (struct tty_port *port, -unsigned char ch,char flag) +static inline int tty_insert_flip_char (struct tty_port *port,u8 ch,char flag) {struct tty_buffer *tb = port->buf.tail;int change;
@@ -36,13 +34,13 @@ static inline int tty_insert_flip_char(struct tty_port *port, }static inline int tty_insert_flip_string (struct tty_port *port, -const unsigned char *chars,size_t size) +const u8 *chars,size_t size) {return tty_insert_flip_string_fixed_flag (port, chars,TTY_NORMAL , size); } -size_t tty_ldisc_receive_buf (struct tty_ldisc *ld,const unsigned char *p, -const char *f,size_t count); +size_t tty_ldisc_receive_buf (struct tty_ldisc *ld,const u8 *p,const char *f, +size_t count);void tty_buffer_lock_exclusive (struct tty_port *port);void tty_buffer_unlock_exclusive (struct tty_port *port);
include/linux/tty_ldisc.h +9 -9
@@ -161,8 +161,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* * Optional. Can sleep. * -* @receive_buf: [DRV] ``void ()(struct tty_struct *tty, -* const unsigned char *cp, const char *fp, size_t count)`` +* @receive_buf: [DRV] ``void ()(struct tty_struct *tty, const u8 *cp, +* const char *fp, size_t count)`` * * This function is called by the low-level tty driver to send characters * received by the hardware to the line discpline for processing. @cp is
@@ -191,8 +191,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* * Optional. * -* @receive_buf2: [DRV] ``ssize_t ()(struct tty_struct *tty, -* const unsigned char *cp, const char *fp, size_t count)`` +* @receive_buf2: [DRV] ``ssize_t ()(struct tty_struct *tty, const u8 *cp, +* const char *fp, size_t count)`` * * This function is called by the low-level tty driver to send characters * received by the hardware to the line discpline for processing. @cp is a
@@ -204,8 +204,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* * Optional. * -* @lookahead_buf: [DRV] ``void ()(struct tty_struct *tty, -* const unsigned char *cp, const char *fp, size_t count)`` +* @lookahead_buf: [DRV] ``void ()(struct tty_struct *tty, const u8 *cp, +* const char *fp, size_t count)`` * * This function is called by the low-level tty driver for characters * not eaten by ->receive_buf() or ->receive_buf2(). It is useful for
@@ -255,13 +255,13 @@ struct tty_ldisc_ops {/* * The following routines are called from below. */ -void (*receive_buf)(struct tty_struct *tty,const unsigned char *cp, +void (*receive_buf)(struct tty_struct *tty,const u8 *cp,const char *fp,size_t count);void (*write_wakeup)(struct tty_struct *tty);void (*dcd_change)(struct tty_struct *tty,bool active); -size_t (*receive_buf2)(struct tty_struct *tty,const unsigned char *cp, +size_t (*receive_buf2)(struct tty_struct *tty,const u8 *cp,const char *fp,size_t count); -void (*lookahead_buf)(struct tty_struct *tty,const unsigned char *cp, +void (*lookahead_buf)(struct tty_struct *tty,const u8 *cp,const unsigned char *fp,size_t count);struct module *owner;
sound/soc/codecs/cx20442.c +2 -2
@@ -258,8 +258,8 @@ static void v253_hangup(struct tty_struct *tty) }/* Line discipline .receive_buf() */ -static void v253_receive (struct tty_struct *tty,const unsigned char *cp, -const char *fp,size_t count) +static void v253_receive (struct tty_struct *tty,const u8 *cp,const char *fp, +size_t count) {struct snd_soc_component *component = tty->disc_data;struct cx20442_priv *cx20442;
sound/soc/ti/ams-delta.c +1 -1
@@ -336,7 +336,7 @@ static void cx81801_hangup(struct tty_struct *tty) }/* Line discipline .receive_buf() */ -static void cx81801_receive (struct tty_struct *tty,const unsigned char *cp, +static void cx81801_receive (struct tty_struct *tty,const u8 *cp,const char *fp,int count) {struct snd_soc_component *component = tty->disc_data;
Signature · 1 line
2.41.0
Re: [PATCH 16/36] tty: use u8 for chars
Quoted 2 lines · Jiri Slaby (SUSE)
This makes all those 'unsigned char's an explicit 'u8'. This is part of the continuing unification of chars and flags to be consistent u8.
Re: [PATCH 16/36] tty: use u8 for chars
In reply to Jiri Slaby (SUSE)Quoted 57 lines · Jiri Slaby (SUSE)
This makes all those 'unsigned char's an explicit 'u8'. This is part of the continuing unification of chars and flags to be consistent u8.
This approaches
tty_port_default_receive_buf(). Flags to be next.Signed-off-by Jiri Slaby (SUSE) <[email protected]>Cc William Hubbs <[email protected]>Cc Chris Brannon <[email protected]>Cc Kirk Reiser <[email protected]>Cc Samuel Thibault <[email protected]>Cc Dmitry Torokhov <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Max Staudt <[email protected]>Cc Wolfgang Grandegger <[email protected]>Cc Marc Kleine-Budde <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Dario Binacchi <[email protected]>Cc Andreas Koensgen <[email protected]>Cc Jeremy Kerr <[email protected]>Cc Matt Johnston <[email protected]>Cc Liam Girdwood <[email protected]>Cc Mark Brown <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Cc Peter Ujfalusi <[email protected]>--- drivers/accessibility/speakup/spk_ttyio.c | 5 ++-- drivers/input/serio/serport.c | 5 ++-- drivers/misc/ti-st/st_core.c | 2 +- drivers/net/can/can327.c | 2 +- drivers/net/can/slcan/slcan-core.c | 5 ++-- drivers/net/hamradio/6pack.c | 4 ++-- drivers/net/hamradio/mkiss.c | 2 +- drivers/net/mctp/mctp-serial.c | 3 +-- drivers/net/ppp/ppp_async.c | 8 +++---- drivers/net/ppp/ppp_synctty.c | 11 ++++----- drivers/net/slip/slip.c | 2 +- drivers/tty/n_gsm.c | 2 +- drivers/tty/n_hdlc.c | 2 +- drivers/tty/n_tty.c | 28 +++++++++++------------ drivers/tty/tty.h | 2 +- drivers/tty/tty_buffer.c | 21 ++++++++--------- include/linux/tty_buffer.h | 4 ++-- include/linux/tty_flip.h | 22 ++++++++---------- include/linux/tty_ldisc.h | 18 +++++++-------- sound/soc/codecs/cx20442.c | 4 ++-- sound/soc/ti/ams-delta.c | 2 +- 21 files changed, 73 insertions(+), 81 deletions(-)include/linux/tty_buffer.h +0
-0
include/linux/tty_buffer.h struct tty_buffer { · line 28
Quoted 9 lines
include/linux/tty_buffer.h +2
-2@@ -22,9 +22,9 @@ struct tty_buffer {unsigned long data[]; }; -static inline unsigned char *char_buf_ptr (struct tty_buffer *b,int ofs) +static inline u8 *char_buf_ptr (struct tty_buffer *b,int ofs) { -return ((unsigned char *)b->data) + ofs; +return ((u8 *)b->data) + ofs; }
Any particular reason why b->data is left unsigned long?
Signature · 1 line
i.
Jiri Slaby
maintainerRe: [PATCH 16/36] tty: use u8 for chars
Quoted 6 lines · Ilpo Järvinen
Quoted 4 lines · Jiri Slaby (SUSE)
This makes all those 'unsigned char's an explicit 'u8'. This is part of the continuing unification of chars and flags to be consistent u8.
This approaches
tty_port_default_receive_buf(). Flags to be next.
...>> diff --git a/include/linux/tty_buffer.h b/include/linux/tty_buffer.h
Quoted 7 lines
Quoted 7 lines
index
6ceb2789e6c8..6f2966b15093100644include/linux/tty_buffer.h +0
-0@@ -22,9 +22,9 @@ struct tty_buffer {unsigned long data[]; };
Quoted 8 lines
include/linux/tty_buffer.h struct tty_buffer { · line 28
Quoted 6 lines
include/linux/tty_buffer.h +2
-2-static inline unsigned char *char_buf_ptr (struct tty_buffer *b,int ofs) +static inline u8 *char_buf_ptr (struct tty_buffer *b,int ofs) { -return ((unsigned char *)b->data) + ofs; +return ((u8 *)b->data) + ofs; }Any particular reason why
b->datais left unsigned long?
I am dumb not mentioning it in 00/36, see my e-mail there.
thanks,
Signature · 2 lines
js suse labs
Re: [PATCH 16/36] tty: use u8 for chars
In reply to Ilpo JärvinenQuoted 1 line · Ilpo Järvinen
On Thu, 10 Aug 2023, Jiri Slaby (SUSE) wrote:
...
Quoted 4 lines
Quoted 4 lines
include/linux/tty_buffer.h +0
-0@@ -22,9 +22,9 @@ struct tty_buffer {unsigned long data[]; };
Quoted 8 lines
include/linux/tty_buffer.h struct tty_buffer { · line 28
Quoted 6 lines
include/linux/tty_buffer.h +2
-2-static inline unsigned char *char_buf_ptr (struct tty_buffer *b,int ofs) +static inline u8 *char_buf_ptr (struct tty_buffer *b,int ofs) { -return ((unsigned char *)b->data) + ofs; +return ((u8 *)b->data) + ofs; }Any particular reason why
b->datais left unsigned long?
It might be the performance issue due to unaligned accesses on some architectures. But I'm just speculating...
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 16/36] tty: use u8 for chars
In reply to Jiri Slaby (SUSE)Jiri Slaby (SUSE)
maintainerPATCH 17/36 tty: use u8 for flags
In reply to Jiri Slaby (SUSE)This makes all those 'char's an explicit 'u8'. This is part of the continuing unification of chars and flags to be consistent u8.
This approaches tty_port_default_receive_buf().
Note that we do not change signedness as we compile with -funsigned-char.
--- drivers/accessibility/speakup/spk_ttyio.c | 2 +- drivers/bluetooth/hci_ldisc.c | 2 +- drivers/input/serio/serport.c | 2 +- drivers/misc/ti-st/st_core.c | 2 +- drivers/net/caif/caif_serial.c | 2 +- drivers/net/can/can327.c | 2 +- drivers/net/can/slcan/slcan-core.c | 2 +- drivers/net/hamradio/6pack.c | 2 +- drivers/net/hamradio/mkiss.c | 2 +- drivers/net/mctp/mctp-serial.c | 2 +- drivers/net/ppp/ppp_async.c | 7 +++--- drivers/net/ppp/ppp_synctty.c | 6 ++--- drivers/net/slip/slip.c | 4 ++-- drivers/tty/n_gsm.c | 2 +- drivers/tty/n_hdlc.c | 2 +- drivers/tty/n_tty.c | 28 +++++++++++------------ drivers/tty/tty_buffer.c | 8 +++---- drivers/tty/tty_port.c | 2 +- include/linux/tty_buffer.h | 4 ++-- include/linux/tty_flip.h | 10 ++++---- include/linux/tty_ldisc.h | 12 +++++----- net/nfc/nci/uart.c | 2 +- sound/soc/codecs/cx20442.c | 2 +- 23 files changed, 54 insertions(+), 55 deletions(-)
drivers/accessibility/speakup/spk_ttyio.c +1 -1
@@ -72,7 +72,7 @@ static void spk_ttyio_ldisc_close(struct tty_struct *tty) }static size_t spk_ttyio_receive_buf2 (struct tty_struct *tty,const u8 *cp, -const char *fp,size_t count) +const u8 *fp,size_t count) {struct spk_ldisc_data *ldisc_data = tty->disc_data;struct spk_synth *synth = ldisc_data->synth;
drivers/bluetooth/hci_ldisc.c +1 -1
@@ -599,7 +599,7 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)* Return Value: None */ static void hci_uart_tty_receive (struct tty_struct *tty,const u8 *data, -const char *flags,size_t count) +const u8 *flags,size_t count) {struct hci_uart *hu = tty->disc_data;
drivers/input/serio/serport.c +1 -1
@@ -115,7 +115,7 @@ static void serport_ldisc_close(struct tty_struct *tty)*/ static void serport_ldisc_receive (struct tty_struct *tty,const u8 *cp, -const char *fp,size_t count) +const u8 *fp,size_t count) {struct serport *serport = tty->disc_data;unsigned long flags;
drivers/misc/ti-st/st_core.c +1 -1
@@ -792,7 +792,7 @@ static void st_tty_close(struct tty_struct *tty) }static void st_tty_receive (struct tty_struct *tty,const u8 *data, -const char *tty_flags,size_t count) +const u8 *tty_flags,size_t count) {#ifdef VERBOSE print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE,
drivers/net/caif/caif_serial.c +1 -1
@@ -159,7 +159,7 @@ static inline void debugfs_tx(struct ser_device *ser, const u8 *data, int size)#endif static void ldisc_receive (struct tty_struct *tty,const u8 *data, -const char *flags,size_t count) +const u8 *flags,size_t count) {struct sk_buff *skb =NULL ;struct ser_device *ser;
drivers/net/can/can327.c +1 -1
@@ -886,7 +886,7 @@ static bool can327_is_valid_rx_char(u8 c)* functions may be called in parallel. */ static void can327_ldisc_rx (struct tty_struct *tty,const u8 *cp, -const char *fp,size_t count) +const u8 *fp,size_t count) {struct can327 *elm = tty->disc_data;size_t first_new_char_idx;
drivers/net/can/slcan/slcan-core.c +1 -1
@@ -775,7 +775,7 @@ static const struct net_device_ops slcan_netdev_ops = {* in parallel */ static void slcan_receive_buf (struct tty_struct *tty,const u8 *cp, -const char *fp,size_t count) +const u8 *fp,size_t count) {struct slcan *sl = tty->disc_data;
drivers/net/hamradio/6pack.c +1 -1
@@ -428,7 +428,7 @@ static void sixpack_write_wakeup(struct tty_struct *tty)* and sent on to some IP layer for further processing. */ static void sixpack_receive_buf (struct tty_struct *tty,const u8 *cp, -const char *fp,size_t count) +const u8 *fp,size_t count) {struct sixpack *sp;int count1;
drivers/net/hamradio/mkiss.c +1 -1
@@ -875,7 +875,7 @@ static int mkiss_ioctl(struct tty_struct *tty, unsigned int cmd,* and sent on to the AX.25 layer for further processing. */ static void mkiss_receive_buf (struct tty_struct *tty,const u8 *cp, -const char *fp,size_t count) +const u8 *fp,size_t count) {struct mkiss *ax =mkiss_get (tty);
drivers/net/mctp/mctp-serial.c +1 -1
@@ -391,7 +391,7 @@ static void mctp_serial_push(struct mctp_serial *dev, unsigned char c) }static void mctp_serial_tty_receive_buf (struct tty_struct *tty,const u8 *c, -const char *f,size_t len) +const u8 *f,size_t len) {struct mctp_serial *dev = tty->disc_data;int i;
drivers/net/ppp/ppp_async.c +3 -4
@@ -98,7 +98,7 @@ static int ppp_async_send(struct ppp_channel *chan, struct sk_buff *skb);static int ppp_async_push (struct asyncppp *ap);static void ppp_async_flush_output (struct asyncppp *ap);static void ppp_async_input (struct asyncppp *ap,const unsigned char *buf, -const char *flags,int count); +const u8 *flags,int count);static int ppp_async_ioctl (struct ppp_channel *chan,unsigned int cmd,unsigned long arg);static void ppp_async_process (struct tasklet_struct *t);
@@ -330,7 +330,7 @@ ppp_asynctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)/* May sleep, don't call from interrupt level or with interrupts disabled */ static void -ppp_asynctty_receive (struct tty_struct *tty,const u8 *buf,const char *cflags, +ppp_asynctty_receive (struct tty_struct *tty,const u8 *buf,const u8 *cflags,size_t count) {struct asyncppp *ap =ap_get (tty);
@@ -819,8 +819,7 @@ process_input_packet(struct asyncppp *ap)other ldisc functions but will not be re-entered */ static void -ppp_async_input (struct asyncppp *ap,const u8 *buf,const char *flags, -int count) +ppp_async_input (struct asyncppp *ap,const u8 *buf,const u8 *flags,int count) {struct sk_buff *skb;int c, i, j, n, s, f;
drivers/net/ppp/ppp_synctty.c +3 -3
@@ -93,7 +93,7 @@ static int ppp_sync_ioctl(struct ppp_channel *chan, unsigned int cmd,static void ppp_sync_process (struct tasklet_struct *t);static int ppp_sync_push (struct syncppp *ap);static void ppp_sync_flush_output (struct syncppp *ap); -static void ppp_sync_input (struct syncppp *ap,const u8 *buf,const char *flags, +static void ppp_sync_input (struct syncppp *ap,const u8 *buf,const u8 *flags,int count);static const struct ppp_channel_ops sync_ops = {
@@ -323,7 +323,7 @@ ppp_synctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)/* May sleep, don't call from interrupt level or with interrupts disabled */ static void -ppp_sync_receive (struct tty_struct *tty,const u8 *buf,const char *cflags, +ppp_sync_receive (struct tty_struct *tty,const u8 *buf,const u8 *cflags,size_t count) {struct syncppp *ap =sp_get (tty);
@@ -655,7 +655,7 @@ ppp_sync_flush_output(struct syncppp *ap)* frame is considered to be in error and is tossed. */ static void -ppp_sync_input (struct syncppp *ap,const u8 *buf,const char *flags,int count) +ppp_sync_input (struct syncppp *ap,const u8 *buf,const u8 *flags,int count) {struct sk_buff *skb;unsigned char *p;
drivers/net/slip/slip.c +2 -2
@@ -685,8 +685,8 @@ static void sl_setup(struct net_device *dev)* in parallel */ -static void slip_receive_buf (struct tty_struct *tty,const u8 *cp, -const char *fp,size_t count) +static void slip_receive_buf (struct tty_struct *tty,const u8 *cp,const u8 *fp, +size_t count) {struct slip *sl = tty->disc_data;
drivers/tty/n_gsm.c +1 -1
@@ -3490,7 +3490,7 @@ static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm) }static void gsmld_receive_buf (struct tty_struct *tty,const u8 *cp, -const char *fp,size_t count) +const u8 *fp,size_t count) {struct gsm_mux *gsm = tty->disc_data;char flags =TTY_NORMAL ;
drivers/tty/n_hdlc.c +1 -1
@@ -370,7 +370,7 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty)* interpreted as one HDLC frame. */ static void n_hdlc_tty_receive (struct tty_struct *tty,const u8 *data, -const char *flags,size_t count) +const u8 *flags,size_t count) { registerstruct n_hdlc *n_hdlc = tty->disc_data; registerstruct n_hdlc_buf *buf;
drivers/tty/n_tty.c +14 -14
@@ -1480,7 +1480,7 @@ n_tty_receive_char_lnext(struct tty_struct *tty, unsigned char c, char flag)/* Caller must ensure count > 0 */ static void n_tty_lookahead_flow_ctrl (struct tty_struct *tty,const u8 *cp, -const unsigned char *fp,size_t count) +const u8 *fp,size_t count) {struct n_tty_data *ldata = tty->disc_data;unsigned char flag =TTY_NORMAL ;
@@ -1520,11 +1520,11 @@ n_tty_receive_buf_real_raw(const struct tty_struct *tty, const u8 *cp, }static void -n_tty_receive_buf_raw (struct tty_struct *tty,const u8 *cp, -const char *fp,int count) +n_tty_receive_buf_raw (struct tty_struct *tty,const u8 *cp,const u8 *fp, +int count) {struct n_tty_data *ldata = tty->disc_data; -char flag =TTY_NORMAL ; +u8 flag =TTY_NORMAL ;while (count--) {if (fp)
@@ -1537,8 +1537,8 @@ n_tty_receive_buf_raw(struct tty_struct *tty, const u8 *cp, }static void -n_tty_receive_buf_closing (struct tty_struct *tty,const u8 *cp, -const char *fp,int count,bool lookahead_done) +n_tty_receive_buf_closing (struct tty_struct *tty,const u8 *cp,const u8 *fp, +int count,bool lookahead_done) {char flag =TTY_NORMAL ;
@@ -1551,11 +1551,11 @@ n_tty_receive_buf_closing(struct tty_struct *tty, const u8 *cp, }static void n_tty_receive_buf_standard (struct tty_struct *tty,const u8 *cp, -const char *fp,int count, +const u8 *fp,int count,bool lookahead_done) {struct n_tty_data *ldata = tty->disc_data; -char flag =TTY_NORMAL ; +u8 flag =TTY_NORMAL ;while (count--) {u8 c = *cp++;
@@ -1589,8 +1589,8 @@ static void n_tty_receive_buf_standard(struct tty_struct *tty, const u8 *cp, } } -static void __receive_buf (struct tty_struct *tty,const u8 *cp, -const char *fp,int count) +static void __receive_buf (struct tty_struct *tty,const u8 *cp,const u8 *fp, +int count) {struct n_tty_data *ldata = tty->disc_data;bool preops =I_ISTRIP (tty) || (I_IUCLC (tty) &&L_IEXTEN (tty));
@@ -1664,8 +1664,8 @@ static void __receive_buf(struct tty_struct *tty, const u8 *cp,* publishes commit_head or canon_head */ static size_t -n_tty_receive_buf_common (struct tty_struct *tty,const u8 *cp, -const char *fp,int count,int flow) +n_tty_receive_buf_common (struct tty_struct *tty,const u8 *cp,const u8 *fp, +int count,int flow) {struct n_tty_data *ldata = tty->disc_data;size_t rcvd =0 ;
@@ -1746,13 +1746,13 @@ n_tty_receive_buf_common(struct tty_struct *tty, const u8 *cp, }static void n_tty_receive_buf (struct tty_struct *tty,const u8 *cp, -const char *fp,size_t count) +const u8 *fp,size_t count) {n_tty_receive_buf_common (tty, cp, fp, count,0 ); }static size_t n_tty_receive_buf2 (struct tty_struct *tty,const u8 *cp, -const char *fp,size_t count) +const u8 *fp,size_t count) {return n_tty_receive_buf_common (tty, cp, fp, count,1 ); }
drivers/tty/tty_buffer.c +4 -4
@@ -317,7 +317,7 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room);* Returns: the number added. */ int tty_insert_flip_string_fixed_flag (struct tty_port *port,const u8 *chars, -char flag,size_t size) +u8 flag,size_t size) {int copied =0 ;bool flags = flag !=TTY_NORMAL ;
@@ -356,7 +356,7 @@ EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag);* Returns: the number added. */ int tty_insert_flip_string_flags (struct tty_port *port,const u8 *chars, -const char *flags,size_t size) +const u8 *flags,size_t size) {int copied =0 ;
@@ -390,7 +390,7 @@ EXPORT_SYMBOL(tty_insert_flip_string_flags);* Queue a single byte @ch to the tty buffering, with an optional flag. This is * the slow path of tty_insert_flip_char(). */ -int __tty_insert_flip_char (struct tty_port *port,u8 ch,char flag) +int __tty_insert_flip_char (struct tty_port *port,u8 ch,u8 flag) {struct tty_buffer *tb;bool flags = flag !=TTY_NORMAL ;
@@ -449,7 +449,7 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string);* * Returns: the number of bytes processed. */ -size_t tty_ldisc_receive_buf (struct tty_ldisc *ld,const u8 *p,const char *f, +size_t tty_ldisc_receive_buf (struct tty_ldisc *ld,const u8 *p,const u8 *f,size_t count) {if (ld->ops->receive_buf2)
drivers/tty/tty_port.c +1 -1
@@ -34,7 +34,7 @@ static size_t tty_port_default_receive_buf(struct tty_port *port, const u8 *p,if (!ld)return 0 ; - count =tty_ldisc_receive_buf (ld, p, (char *)f, count); + count =tty_ldisc_receive_buf (ld, p, f, count);tty_ldisc_deref (ld);
include/linux/tty_buffer.h +2 -2
@@ -27,9 +27,9 @@ static inline u8 *char_buf_ptr(struct tty_buffer *b, int ofs)return ((u8 *)b->data) + ofs; } -static inline char *flag_buf_ptr (struct tty_buffer *b,int ofs) +static inline u8 *flag_buf_ptr (struct tty_buffer *b,int ofs) { -return (char *)char_buf_ptr (b, ofs) + b->size; +return char_buf_ptr (b, ofs) + b->size; }struct tty_bufhead {
include/linux/tty_flip.h +5 -5
@@ -11,14 +11,14 @@ int tty_buffer_set_limit(struct tty_port *port, int limit);unsigned int tty_buffer_space_avail (struct tty_port *port);int tty_buffer_request_room (struct tty_port *port,size_t size);int tty_insert_flip_string_flags (struct tty_port *port,const u8 *chars, -const char *flags,size_t size); +const u8 *flags,size_t size);int tty_insert_flip_string_fixed_flag (struct tty_port *port,const u8 *chars, -char flag,size_t size); +u8 flag,size_t size);int tty_prepare_flip_string (struct tty_port *port,u8 **chars,size_t size);void tty_flip_buffer_push (struct tty_port *port); -int __tty_insert_flip_char (struct tty_port *port,u8 ch,char flag); +int __tty_insert_flip_char (struct tty_port *port,u8 ch,u8 flag); -static inline int tty_insert_flip_char (struct tty_port *port,u8 ch,char flag) +static inline int tty_insert_flip_char (struct tty_port *port,u8 ch,u8 flag) {struct tty_buffer *tb = port->buf.tail;int change;
@@ -39,7 +39,7 @@ static inline int tty_insert_flip_string(struct tty_port *port,return tty_insert_flip_string_fixed_flag (port, chars,TTY_NORMAL , size); } -size_t tty_ldisc_receive_buf (struct tty_ldisc *ld,const u8 *p,const char *f, +size_t tty_ldisc_receive_buf (struct tty_ldisc *ld,const u8 *p,const u8 *f,size_t count);void tty_buffer_lock_exclusive (struct tty_port *port);
include/linux/tty_ldisc.h +6 -6
@@ -162,7 +162,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* Optional. Can sleep. * * @receive_buf: [DRV] ``void ()(struct tty_struct *tty, const u8 *cp, -* const char *fp, size_t count)`` +* const u8 *fp, size_t count)`` * * This function is called by the low-level tty driver to send characters * received by the hardware to the line discpline for processing. @cp is
@@ -192,7 +192,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* Optional. * * @receive_buf2: [DRV] ``ssize_t ()(struct tty_struct *tty, const u8 *cp, -* const char *fp, size_t count)`` +* const u8 *fp, size_t count)`` * * This function is called by the low-level tty driver to send characters * received by the hardware to the line discpline for processing. @cp is a
@@ -205,7 +205,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* Optional. * * @lookahead_buf: [DRV] ``void ()(struct tty_struct *tty, const u8 *cp, -* const char *fp, size_t count)`` +* const u8 *fp, size_t count)`` * * This function is called by the low-level tty driver for characters * not eaten by ->receive_buf() or ->receive_buf2(). It is useful for
@@ -256,13 +256,13 @@ struct tty_ldisc_ops {* The following routines are called from below. */ void (*receive_buf)(struct tty_struct *tty,const u8 *cp, -const char *fp,size_t count); +const u8 *fp,size_t count);void (*write_wakeup)(struct tty_struct *tty);void (*dcd_change)(struct tty_struct *tty,bool active);size_t (*receive_buf2)(struct tty_struct *tty,const u8 *cp, -const char *fp,size_t count); +const u8 *fp,size_t count);void (*lookahead_buf)(struct tty_struct *tty,const u8 *cp, -const unsigned char *fp,size_t count); +const u8 *fp,size_t count);struct module *owner; };
net/nfc/nci/uart.c +1 -1
@@ -296,7 +296,7 @@ static int nci_uart_default_recv_buf(struct nci_uart *nu, const u8 *data,* Return Value: None */ static void nci_uart_tty_receive (struct tty_struct *tty,const u8 *data, -const char *flags,size_t count) +const u8 *flags,size_t count) {struct nci_uart *nu = tty->disc_data;
sound/soc/codecs/cx20442.c +1 -1
@@ -258,7 +258,7 @@ static void v253_hangup(struct tty_struct *tty) }/* Line discipline .receive_buf() */ -static void v253_receive (struct tty_struct *tty,const u8 *cp,const char *fp, +static void v253_receive (struct tty_struct *tty,const u8 *cp,const u8 *fp,size_t count) {struct snd_soc_component *component = tty->disc_data;
Signature · 1 line
2.41.0
Re: [PATCH 17/36] tty: use u8 for flags
Quoted 4 lines · Jiri Slaby (SUSE)
This makes all those 'char's an explicit 'u8'. This is part of the continuing unification of chars and flags to be consistent u8.
This approaches
tty_port_default_receive_buf().
Re: [PATCH 17/36] tty: use u8 for flags
In reply to Jiri Slaby (SUSE)Jiri Slaby (SUSE)
maintainerPATCH 18/36 misc: ti-st: make st_recv() conforming to tty_ldisc_ops::receive_buf()
In reply to Jiri Slaby (SUSE)That is change data type to u8 and count to unsigned int. And propagate to both hooks (st_kim_recv() and kim_int_recv()).
--- drivers/misc/ti-st/st_core.c | 7 +++---- drivers/misc/ti-st/st_kim.c | 6 +++--- include/linux/ti_wilink_st.h | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-)
drivers/misc/ti-st/st_core.c +3 -4
@@ -21,7 +21,7 @@* st_kim_recv during registration to receive fw download responses * st_int_recv after registration to receive proto stack responses */ -static void (*st_recv) (void *,const unsigned char *,long ); +static void (*st_recv)(void *disc_data,const u8 *ptr,size_t count);/********************************************************************/ static void add_channel_to_table(struct st_data_s *st_gdata,
@@ -223,8 +223,7 @@ static inline void st_wakeup_ack(struct st_data_s *st_gdata,* HCI-Events, ACL, SCO, 4 types of HCI-LL PM packets * CH-8 packets from FM, CH-9 packets from GPS cores. */ -static void st_int_recv (void *disc_data, -const unsigned char *ptr,long count) +static void st_int_recv (void *disc_data,const u8 *ptr,size_t count) {struct st_proto_s *proto;unsigned short payload_len =0 ;
@@ -239,7 +238,7 @@ static void st_int_recv(void *disc_data,return ; } -pr_debug ("count %ld rx_state %ld" +pr_debug ("count %zu rx_state %ld" "rx_count %ld" , count, st_gdata->rx_state, st_gdata->rx_count);
drivers/misc/ti-st/st_kim.c +3 -3
@@ -127,8 +127,8 @@ static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len)* have been observed to come in bursts of different * tty_receive and hence the logic */ -static void kim_int_recv (struct kim_data_s *kim_gdata, -const unsigned char *ptr,long count) +static void kim_int_recv (struct kim_data_s *kim_gdata,const u8 *ptr, +size_t count) {int len =0 ;unsigned char *plen;
@@ -417,7 +417,7 @@ static long download_firmware(struct kim_data_s *kim_gdata)* 1. response to read local version * 2. during send/recv's of firmware download */ -void st_kim_recv (void *disc_data,const unsigned char *data,long count) +void st_kim_recv (void *disc_data,const u8 *data,size_t count) {struct st_data_s *st_gdata = (struct st_data_s *)disc_data;struct kim_data_s *kim_gdata = st_gdata->kim_data;
include/linux/ti_wilink_st.h +1 -1
@@ -271,7 +271,7 @@ long st_kim_stop(void *);void st_kim_complete (void *);void kim_st_list_protocols (struct st_data_s *,void *); -void st_kim_recv (void *,const unsigned char *,long ); +void st_kim_recv (void *disc_data,const u8 *data,size_t count);/*
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 19/36 tty: make char_buf_ptr()/flag_buf_ptr()'s offset unsigned
In reply to Jiri Slaby (SUSE)The offset is meant from the beginning of data, so unsigned. Make it as such for clarity. All struct tty_buffer's members should be unsigned too -- see the next patch.
--- include/linux/tty_buffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/tty_buffer.h +2 -2
@@ -22,12 +22,12 @@ struct tty_buffer {unsigned long data[]; }; -static inline u8 *char_buf_ptr (struct tty_buffer *b,int ofs) +static inline u8 *char_buf_ptr (struct tty_buffer *b,unsigned int ofs) {return ((u8 *)b->data) + ofs; } -static inline u8 *flag_buf_ptr (struct tty_buffer *b,int ofs) +static inline u8 *flag_buf_ptr (struct tty_buffer *b,unsigned int ofs) {return char_buf_ptr (b, ofs) + b->size; }
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 20/36 tty: tty_buffer: make all offsets unsigned
In reply to Jiri Slaby (SUSE)All these are supposed/expected to be unsigned as they are either counts or offsets. So switch to unsigned for clarity.
--- include/linux/tty_buffer.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
include/linux/tty_buffer.h +5 -5
@@ -12,11 +12,11 @@ struct tty_buffer {struct tty_buffer *next;struct llist_node free; }; -int used; -int size; -int commit; -int lookahead;/* Lazy update on recv, can become less than "read" */ -int read; +unsigned int used; +unsigned int size; +unsigned int commit; +unsigned int lookahead;/* Lazy update on recv, can become less than "read" */ +unsigned int read;bool flags;/* Data points here */ unsigned long data[];
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 21/36 tty: don't pass write() to do_tty_write()
In reply to Jiri Slaby (SUSE)write() passed to do_tty_write() is always ld->ops->write(). Instead, align with iterate_tty_read() and pass the whole ld instead. This makes the code easier to follow as it is clear what the write is. And also the function signature is more readable.
--- drivers/tty/tty_io.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/tty/tty_io.c +4 -7
@@ -961,11 +961,8 @@ int tty_write_lock(struct tty_struct *tty, bool ndelay)* Split writes up in sane blocksizes to avoid * denial-of-service type attacks */ -static inline ssize_t do_tty_write ( -ssize_t (*write)(struct tty_struct *,struct file *,const unsigned char *,size_t ), -struct tty_struct *tty, -struct file *file, -struct iov_iter *from) +static inline ssize_t do_tty_write (struct tty_ldisc *ld,struct tty_struct *tty, +struct file *file,struct iov_iter *from) {size_t count =iov_iter_count (from);ssize_t ret, written =0 ;
@@ -1022,7 +1019,7 @@ static inline ssize_t do_tty_write(if (copy_from_iter (tty->write_buf, size, from) != size)break ; - ret =write (tty, file, tty->write_buf, size); + ret = ld->ops->write (tty, file, tty->write_buf, size);if (ret <=0 )break ;
@@ -1093,7 +1090,7 @@ static ssize_t file_tty_write(struct file *file, struct kiocb *iocb, struct iov_if (!ld->ops->write) ret = -EIO ;else - ret =do_tty_write (ld->ops->write, tty, file, from); + ret =do_tty_write (ld, tty, file, from);tty_ldisc_deref (ld);return ret; }
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 22/36 tty: rename and de-inline do_tty_write()
In reply to Jiri Slaby (SUSE)Make do_tty_write()'s name sound similar to iterate_tty_read(). They both do similar things, so there is no reason for so distinct names. The new name is therefore iterate_tty_write().
Drop the unnedeed inline modifier too. Let the compiler decide.
--- drivers/tty/tty_io.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/tty/tty_io.c +3 -3
@@ -961,8 +961,8 @@ int tty_write_lock(struct tty_struct *tty, bool ndelay)* Split writes up in sane blocksizes to avoid * denial-of-service type attacks */ -static inline ssize_t do_tty_write (struct tty_ldisc *ld,struct tty_struct *tty, -struct file *file,struct iov_iter *from) +static ssize_t iterate_tty_write (struct tty_ldisc *ld,struct tty_struct *tty, +struct file *file,struct iov_iter *from) {size_t count =iov_iter_count (from);ssize_t ret, written =0 ;
@@ -1090,7 +1090,7 @@ static ssize_t file_tty_write(struct file *file, struct kiocb *iocb, struct iov_if (!ld->ops->write) ret = -EIO ;else - ret =do_tty_write (ld, tty, file, from); + ret =iterate_tty_write (ld, tty, file, from);tty_ldisc_deref (ld);return ret; }
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 23/36 tty: use min() in iterate_tty_write()
In reply to Jiri Slaby (SUSE)It simplifies the code. The "price" is we have to unify 'chunk' to be size_t the same as 'count' is. But that change is actually correct.
--- drivers/tty/tty_io.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/tty/tty_io.c +2 -6
@@ -964,9 +964,8 @@ int tty_write_lock(struct tty_struct *tty, bool ndelay)static ssize_t iterate_tty_write (struct tty_ldisc *ld,struct tty_struct *tty,struct file *file,struct iov_iter *from) { -size_t count =iov_iter_count (from); +size_t chunk, count =iov_iter_count (from);ssize_t ret, written =0 ; -unsigned int chunk; ret =tty_write_lock (tty, file->f_flags &O_NDELAY );if (ret <0 )
@@ -1010,10 +1009,7 @@ static ssize_t iterate_tty_write(struct tty_ldisc *ld, struct tty_struct *tty,/* Do the write .. */ for (;;) { -size_t size = count; - -if (size > chunk) - size = chunk; +size_t size =min (chunk, count); ret = -EFAULT ;if (copy_from_iter (tty->write_buf, size, from) != size)
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 24/36 tty: use ssize_t for iterate_tty_read() returned type
In reply to Jiri Slaby (SUSE)tty_read() is supposed to return ssize_t. It takes the return value from iterate_tty_read(). That currently returns int. On the top of that, iterate_tty_write() already returns ssize_t. So switch iterate_tty_read() to ssize_t too, so that all three are consistent.
This means 'i' in tty_read() changes its type too. And while changing that, rename this generic 'i' to more dedicated 'ret'.
--- drivers/tty/tty_io.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/tty/tty_io.c +8 -8
@@ -843,13 +843,13 @@ static void tty_update_time(struct tty_struct *tty, bool mtime)* data or clears the cookie. The cookie may be something that the * ldisc maintains state for and needs to free. */ -static int iterate_tty_read (struct tty_ldisc *ld,struct tty_struct *tty, -struct file *file,struct iov_iter *to) +static ssize_t iterate_tty_read (struct tty_ldisc *ld,struct tty_struct *tty, +struct file *file,struct iov_iter *to) { -int retval =0 ;void *cookie =NULL ;unsigned long offset =0 ;char kernel_buf[64 ]; +ssize_t retval =0 ;size_t count =iov_iter_count (to); do {
@@ -912,11 +912,11 @@ static int iterate_tty_read(struct tty_ldisc *ld, struct tty_struct *tty,*/ static ssize_t tty_read (struct kiocb *iocb,struct iov_iter *to) { -int i;struct file *file = iocb->ki_filp;struct inode *inode =file_inode (file);struct tty_struct *tty =file_tty (file);struct tty_ldisc *ld; +ssize_t ret;if (tty_paranoia_check (tty, inode,"tty_read" ))return -EIO ;
@@ -929,15 +929,15 @@ static ssize_t tty_read(struct kiocb *iocb, struct iov_iter *to) ld =tty_ldisc_ref_wait (tty);if (!ld)return hung_up_tty_read (iocb, to); - i = -EIO ; + ret = -EIO ;if (ld->ops->read) - i =iterate_tty_read (ld, tty, file, to); + ret =iterate_tty_read (ld, tty, file, to);tty_ldisc_deref (ld); -if (i >0 ) +if (ret >0 )tty_update_time (tty, false); -return i; +return ret; }void tty_write_unlock (struct tty_struct *tty)
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 25/36 tty: switch size and count types in iterate_tty_read() to size_t
In reply to Jiri Slaby (SUSE)ld->ops->read() returns ssize_t. copy_to_iter() returns size_t. So switch the variables ('size' and 'copied', respectively) to the corresponding types.
This allows for use of min() in the next patch.
--- drivers/tty/tty_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/tty_io.c +2 -2
@@ -850,10 +850,10 @@ static ssize_t iterate_tty_read(struct tty_ldisc *ld, struct tty_struct *tty,unsigned long offset =0 ;char kernel_buf[64 ];ssize_t retval =0 ; -size_t count =iov_iter_count (to); +size_t copied, count =iov_iter_count (to); do { - int size, copied; + ssize_t size; size = count > sizeof(kernel_buf) ? sizeof(kernel_buf) : count; size = ld->ops->read(tty, file, kernel_buf, size, &cookie, offset);
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 26/36 tty: use min() for size computation in iterate_tty_read()
In reply to Jiri Slaby (SUSE)The computation is more obvious with min().
--- drivers/tty/tty_io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/tty_io.c +1 -2
@@ -853,9 +853,8 @@ static ssize_t iterate_tty_read(struct tty_ldisc *ld, struct tty_struct *tty,size_t copied, count =iov_iter_count (to); do { - ssize_t size; + ssize_t size = min(count, sizeof(kernel_buf)); - size = count > sizeof(kernel_buf) ? sizeof(kernel_buf) : count; size = ld->ops->read(tty, file, kernel_buf, size, &cookie, offset); if (!size) break;
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 27/36 tty: propagate u8 data to tty_operations::write()
In reply to Jiri Slaby (SUSE)Data are now typed as u8. Propagate this change to tty_operations::write().
--- arch/alpha/kernel/srmcons.c | 3 +-- arch/m68k/emu/nfcon.c | 3 +-- arch/um/drivers/line.c | 2 +- arch/um/drivers/line.h | 3 +-- arch/xtensa/platforms/iss/console.c | 3 +-- drivers/char/ttyprintk.c | 5 ++--- drivers/ipack/devices/ipoctal.c | 6 ++---- drivers/isdn/capi/capi.c | 3 +-- drivers/misc/bcm-vk/bcm_vk_tty.c | 4 +--- drivers/mmc/core/sdio_uart.c | 3 +-- drivers/net/usb/hso.c | 3 +-- drivers/s390/char/con3215.c | 3 +-- drivers/s390/char/con3270.c | 3 +-- drivers/s390/char/sclp_tty.c | 2 +- drivers/s390/char/sclp_vt220.c | 2 +- drivers/staging/gdm724x/gdm_tty.c | 3 +-- drivers/staging/greybus/uart.c | 3 +-- drivers/tty/amiserial.c | 2 +- drivers/tty/ehv_bytechan.c | 3 +-- drivers/tty/goldfish.c | 6 ++---- drivers/tty/hvc/hvc_console.c | 2 +- drivers/tty/hvc/hvcs.c | 3 +-- drivers/tty/hvc/hvsi.c | 3 +-- drivers/tty/ipwireless/hardware.c | 2 +- drivers/tty/ipwireless/tty.c | 3 +-- drivers/tty/mips_ejtag_fdc.c | 4 ++-- drivers/tty/moxa.c | 8 +++----- drivers/tty/mxser.c | 2 +- drivers/tty/n_gsm.c | 3 +-- drivers/tty/nozomi.c | 5 ++--- drivers/tty/pty.c | 2 +- drivers/tty/serial/kgdb_nmi.c | 2 +- drivers/tty/serial/serial_core.c | 3 +-- drivers/tty/synclink_gt.c | 7 +++---- drivers/tty/ttynull.c | 3 +-- drivers/tty/vcc.c | 3 +-- drivers/tty/vt/vt.c | 4 ++-- drivers/usb/class/cdc-acm.c | 3 +-- drivers/usb/gadget/function/u_serial.c | 2 +- drivers/usb/host/xhci-dbgtty.c | 4 +--- drivers/usb/serial/usb-serial.c | 3 +-- include/linux/tty_driver.h | 3 +-- net/bluetooth/rfcomm/tty.c | 2 +- 43 files changed, 53 insertions(+), 88 deletions(-)
arch/alpha/kernel/srmcons.c +1 -2
@@ -130,8 +130,7 @@ srmcons_do_write(struct tty_port *port, const char *buf, int count) }static int -srmcons_write (struct tty_struct *tty, -const unsigned char *buf,int count) +srmcons_write (struct tty_struct *tty,const u8 *buf,int count) {unsigned long flags;
arch/m68k/emu/nfcon.c +1 -2
@@ -70,8 +70,7 @@ static void nfcon_tty_close(struct tty_struct *tty, struct file *filp) { } -static int nfcon_tty_write (struct tty_struct *tty,const unsigned char *buf, -int count) +static int nfcon_tty_write (struct tty_struct *tty,const u8 *buf,int count) {nfputs (buf, count);return count;
arch/um/drivers/line.c +1 -1
@@ -184,7 +184,7 @@ void line_flush_chars(struct tty_struct *tty)line_flush_buffer (tty); } -int line_write (struct tty_struct *tty,const unsigned char *buf,int len) +int line_write (struct tty_struct *tty,const u8 *buf,int len) {struct line *line = tty->driver_data;unsigned long flags;
arch/um/drivers/line.h +1 -2
@@ -64,8 +64,7 @@ extern void line_cleanup(struct tty_struct *tty);extern void line_hangup (struct tty_struct *tty);extern int line_setup (char **conf,unsigned nlines,char **def,char *init,char *name); -extern int line_write (struct tty_struct *tty,const unsigned char *buf, -int len); +extern int line_write (struct tty_struct *tty,const u8 *buf,int len);extern unsigned int line_chars_in_buffer (struct tty_struct *tty);extern void line_flush_buffer (struct tty_struct *tty);extern void line_flush_chars (struct tty_struct *tty);
arch/xtensa/platforms/iss/console.c +1 -2
@@ -52,8 +52,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) } -static int rs_write (struct tty_struct * tty, -const unsigned char *buf,int count) +static int rs_write (struct tty_struct * tty,const u8 *buf,int count) {/* see drivers/char/serialX.c to reference original version */
drivers/char/ttyprintk.c +2 -3
@@ -51,7 +51,7 @@ static void tpk_flush(void) } } -static int tpk_printk (const unsigned char *buf,int count) +static int tpk_printk (const u8 *buf,int count) {int i;
@@ -103,8 +103,7 @@ static void tpk_close(struct tty_struct *tty, struct file *filp)/* * TTY operations write function. */ -static int tpk_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int tpk_write (struct tty_struct *tty,const u8 *buf,int count) {struct ttyprintk_port *tpkp = tty->driver_data;unsigned long flags;
drivers/ipack/devices/ipoctal.c +2 -4
@@ -437,8 +437,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr, }static inline int ipoctal_copy_write_buffer (struct ipoctal_channel *channel, -const unsigned char *buf, -int count) +const u8 *buf,int count) {unsigned long flags;int i;
@@ -459,8 +458,7 @@ static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel,return i; } -static int ipoctal_write_tty (struct tty_struct *tty, -const unsigned char *buf,int count) +static int ipoctal_write_tty (struct tty_struct *tty,const u8 *buf,int count) {struct ipoctal_channel *channel = tty->driver_data;unsigned int char_copied;
drivers/isdn/capi/capi.c +1 -2
@@ -1077,8 +1077,7 @@ static void capinc_tty_close(struct tty_struct *tty, struct file *filp)tty_port_close (&mp->port, tty, filp); } -static int capinc_tty_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int capinc_tty_write (struct tty_struct *tty,const u8 *buf,int count) {struct capiminor *mp = tty->driver_data;struct sk_buff *skb;
drivers/misc/bcm-vk/bcm_vk_tty.c +1 -3
@@ -186,9 +186,7 @@ static void bcm_vk_tty_doorbell(struct bcm_vk *vk, u32 db_val) VK_BAR0_REGSEG_DB_BASE + VK_BAR0_REGSEG_TTY_DB_OFFSET); } -static int bcm_vk_tty_write (struct tty_struct *tty, -const unsigned char *buffer, -int count) +static int bcm_vk_tty_write (struct tty_struct *tty,const u8 *buffer,int count) {int index;struct bcm_vk *vk;
drivers/mmc/core/sdio_uart.c +1 -2
@@ -760,8 +760,7 @@ static void sdio_uart_hangup(struct tty_struct *tty)tty_port_hangup (&port->port); } -static int sdio_uart_write (struct tty_struct *tty,const unsigned char *buf, -int count) +static int sdio_uart_write (struct tty_struct *tty,const u8 *buf,int count) {struct sdio_uart_port *port = tty->driver_data;int ret;
drivers/net/usb/hso.c +1 -2
@@ -1322,8 +1322,7 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp) }/* close the requested serial port */ -static int hso_serial_write (struct tty_struct *tty,const unsigned char *buf, -int count) +static int hso_serial_write (struct tty_struct *tty,const u8 *buf,int count) {struct hso_serial *serial = tty->driver_data;int space, tx_bytes;
drivers/s390/char/con3215.c +1 -2
@@ -1021,8 +1021,7 @@ static unsigned int tty3215_write_room(struct tty_struct *tty)/* * String write routine for 3215 ttys */ -static int tty3215_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int tty3215_write (struct tty_struct *tty,const u8 *buf,int count) {handle_write (tty->driver_data, buf, count);return count;
drivers/s390/char/con3270.c +1 -2
@@ -1803,8 +1803,7 @@ static void tty3270_do_write(struct tty3270 *tp, struct tty_struct *tty,/* * String write routine for 3270 ttys */ -static int tty3270_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int tty3270_write (struct tty_struct *tty,const u8 *buf,int count) {struct tty3270 *tp;
drivers/s390/char/sclp_tty.c +1 -1
@@ -230,7 +230,7 @@ static int sclp_tty_write_string(const unsigned char *str, int count, int may_fa* routine will return the number of characters actually accepted for writing. */ static int -sclp_tty_write (struct tty_struct *tty,const unsigned char *buf,int count) +sclp_tty_write (struct tty_struct *tty,const u8 *buf,int count) {if (sclp_tty_chars_count >0 ) {sclp_tty_write_string (sclp_tty_chars, sclp_tty_chars_count,0 );
drivers/s390/char/sclp_vt220.c +1 -1
@@ -463,7 +463,7 @@ __sclp_vt220_write(const unsigned char *buf, int count, int do_schedule,* number of characters actually accepted for writing. */ static int -sclp_vt220_write (struct tty_struct *tty,const unsigned char *buf,int count) +sclp_vt220_write (struct tty_struct *tty,const u8 *buf,int count) {return __sclp_vt220_write (buf, count,1 ,0 ,1 ); }
drivers/staging/gdm724x/gdm_tty.c +1 -2
@@ -149,8 +149,7 @@ static void gdm_tty_send_complete(void *arg)tty_port_tty_wakeup (&gdm->port); } -static int gdm_tty_write (struct tty_struct *tty,const unsigned char *buf, -int len) +static int gdm_tty_write (struct tty_struct *tty,const u8 *buf,int len) {struct gdm *gdm = tty->driver_data;int remain = len;
drivers/staging/greybus/uart.c +1 -2
@@ -427,8 +427,7 @@ static void gb_tty_hangup(struct tty_struct *tty)tty_port_hangup (&gb_tty->port); } -static int gb_tty_write (struct tty_struct *tty,const unsigned char *buf, -int count) +static int gb_tty_write (struct tty_struct *tty,const u8 *buf,int count) {struct gb_tty *gb_tty = tty->driver_data;
drivers/tty/amiserial.c +1 -1
@@ -741,7 +741,7 @@ static void rs_flush_chars(struct tty_struct *tty)local_irq_restore (flags); } -static int rs_write (struct tty_struct * tty,const unsigned char *buf,int count) +static int rs_write (struct tty_struct * tty,const u8 *buf,int count) {int c, ret =0 ;struct serial_state *info = tty->driver_data;
drivers/tty/ehv_bytechan.c +1 -2
@@ -466,8 +466,7 @@ static irqreturn_t ehv_bc_tty_tx_isr(int irq, void *data)* ehv_bc_tty_write_room() will never lie, so the tty layer will never send us * too much data. */ -static int ehv_bc_tty_write (struct tty_struct *ttys,const unsigned char *s, -int count) +static int ehv_bc_tty_write (struct tty_struct *ttys,const u8 *s,int count) {struct ehv_bc_data *bc = ttys->driver_data;unsigned long flags;
drivers/tty/goldfish.c +2 -4
@@ -125,8 +125,7 @@ static void goldfish_tty_rw(struct goldfish_tty *qtty, } } -static void goldfish_tty_do_write (int line,const char *buf, -unsigned int count) +static void goldfish_tty_do_write (int line,const u8 *buf,unsigned int count) {struct goldfish_tty *qtty = &goldfish_ttys[line];unsigned long address = (unsigned long )(void *)buf;
@@ -186,8 +185,7 @@ static void goldfish_tty_hangup(struct tty_struct *tty)tty_port_hangup (tty->port); } -static int goldfish_tty_write (struct tty_struct *tty,const unsigned char *buf, -int count) +static int goldfish_tty_write (struct tty_struct *tty,const u8 *buf,int count) {goldfish_tty_do_write (tty->index, buf, count);return count;
drivers/tty/hvc/hvc_console.c +1 -1
@@ -496,7 +496,7 @@ static int hvc_push(struct hvc_struct *hp)return n; } -static int hvc_write (struct tty_struct *tty,const unsigned char *buf,int count) +static int hvc_write (struct tty_struct *tty,const u8 *buf,int count) {struct hvc_struct *hp = tty->driver_data;unsigned long flags;
drivers/tty/hvc/hvcs.c +1 -2
@@ -1257,8 +1257,7 @@ static void hvcs_hangup(struct tty_struct * tty)* tty_hangup will allow hvcs_write time to complete execution before it * terminates our device. */ -static int hvcs_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int hvcs_write (struct tty_struct *tty,const u8 *buf,int count) {struct hvcs_struct *hvcsd = tty->driver_data;unsigned int unit_address;
drivers/tty/hvc/hvsi.c +1 -2
@@ -904,8 +904,7 @@ static unsigned int hvsi_chars_in_buffer(struct tty_struct *tty)return hp->n_outbuf; } -static int hvsi_write (struct tty_struct *tty, -const unsigned char *source,int count) +static int hvsi_write (struct tty_struct *tty,const u8 *source,int count) {struct hvsi_struct *hp = tty->driver_data;unsigned long flags;
drivers/tty/ipwireless/hardware.c +1 -1
@@ -1292,7 +1292,7 @@ static void *alloc_ctrl_packet(int header_size, }int ipwireless_send_packet (struct ipw_hardware *hw,unsigned int channel_idx, -const unsigned char *data,unsigned int length, +const u8 *data,unsigned int length,void (*callback) (void *cb,unsigned int length),void *callback_data) {
drivers/tty/ipwireless/tty.c +1 -2
@@ -186,8 +186,7 @@ static void ipw_write_packet_sent_callback(void *callback_data, tty->tx_bytes_queued -= packet_length; } -static int ipw_write (struct tty_struct *linux_tty, -const unsigned char *buf,int count) +static int ipw_write (struct tty_struct *linux_tty,const u8 *buf,int count) {struct ipw_tty *tty = linux_tty->driver_data;int room, ret;
drivers/tty/mips_ejtag_fdc.c +2 -2
@@ -796,8 +796,8 @@ static void mips_ejtag_fdc_tty_hangup(struct tty_struct *tty)tty_port_hangup (tty->port); } -static int mips_ejtag_fdc_tty_write (struct tty_struct *tty, -const unsigned char *buf,int total) +static int mips_ejtag_fdc_tty_write (struct tty_struct *tty,const u8 *buf, +int total) {int count, block;struct mips_ejtag_fdc_tty_port *dport = tty->driver_data;
drivers/tty/moxa.c +3 -5
@@ -487,7 +487,7 @@ module_param(ttymajor, int, 0);*/ static int moxa_open (struct tty_struct *,struct file *);static void moxa_close (struct tty_struct *,struct file *); -static int moxa_write (struct tty_struct *,const unsigned char *,int ); +static int moxa_write (struct tty_struct *,const u8 *,int );static unsigned int moxa_write_room (struct tty_struct *);static void moxa_flush_buffer (struct tty_struct *);static unsigned int moxa_chars_in_buffer (struct tty_struct *);
@@ -1499,8 +1499,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)tty_port_close (&ch->port, tty, filp); } -static int moxa_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int moxa_write (struct tty_struct *tty,const u8 *buf,int count) {struct moxa_port *ch = tty->driver_data;unsigned long flags;
@@ -2164,8 +2163,7 @@ static int MoxaPortLineStatus(struct moxa_port *port)return val; } -static int MoxaPortWriteData (struct tty_struct *tty, -const unsigned char *buffer,int len) +static int MoxaPortWriteData (struct tty_struct *tty,const u8 *buffer,int len) {struct moxa_port *port = tty->driver_data;void __iomem *baseAddr, *ofsAddr, *ofs;
drivers/tty/mxser.c +1 -1
@@ -901,7 +901,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)tty_port_close (tty->port, tty, filp); } -static int mxser_write (struct tty_struct *tty,const unsigned char *buf,int count) +static int mxser_write (struct tty_struct *tty,const u8 *buf,int count) {struct mxser_port *info = tty->driver_data;unsigned long flags;
drivers/tty/n_gsm.c +1 -2
@@ -4256,8 +4256,7 @@ static void gsmtty_hangup(struct tty_struct *tty)gsm_dlci_begin_close (dlci); } -static int gsmtty_write (struct tty_struct *tty,const unsigned char *buf, -int len) +static int gsmtty_write (struct tty_struct *tty,const u8 *buf,int len) {int sent;struct gsm_dlci *dlci = tty->driver_data;
drivers/tty/nozomi.c +2 -3
@@ -1599,8 +1599,7 @@ static void ntty_hangup(struct tty_struct *tty)* called when the userspace process writes to the tty (/dev/noz*). * Data is inserted into a fifo, which is then read and transferred to the modem. */ -static int ntty_write (struct tty_struct *tty,const unsigned char *buffer, -int count) +static int ntty_write (struct tty_struct *tty,const u8 *buffer,int count) {int rval = -EINVAL ;struct nozomi *dc =get_dc_by_tty (tty);
@@ -1610,7 +1609,7 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer,if (!dc || !port)return -ENODEV ; - rval =kfifo_in (&port->fifo_ul, (unsigned char *)buffer, count); + rval =kfifo_in (&port->fifo_ul, buffer, count);spin_lock_irqsave (&dc->spin_mutex, flags);/* CTS is only valid on the modem channel */
drivers/tty/pty.c +1 -1
@@ -108,7 +108,7 @@ static void pty_unthrottle(struct tty_struct *tty)* the other side of the pty/tty pair. */ -static int pty_write (struct tty_struct *tty,const unsigned char *buf,int c) +static int pty_write (struct tty_struct *tty,const u8 *buf,int c) {struct tty_struct *to = tty->link;
drivers/tty/serial/kgdb_nmi.c +1 -1
@@ -304,7 +304,7 @@ static unsigned int kgdb_nmi_tty_write_room(struct tty_struct *tty)return 2048 ; } -static int kgdb_nmi_tty_write (struct tty_struct *tty,const unchar *buf,int c) +static int kgdb_nmi_tty_write (struct tty_struct *tty,const u8 *buf,int c) {int i;
drivers/tty/serial/serial_core.c +1 -2
@@ -580,8 +580,7 @@ static void uart_flush_chars(struct tty_struct *tty)uart_start (tty); } -static int uart_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int uart_write (struct tty_struct *tty,const u8 *buf,int count) {struct uart_state *state = tty->driver_data;struct uart_port *port;
drivers/tty/synclink_gt.c +3 -4
@@ -431,7 +431,7 @@ static void tx_set_idle(struct slgt_info *info);static unsigned int tbuf_bytes (struct slgt_info *info);static void reset_tbufs (struct slgt_info *info);static void tdma_reset (struct slgt_info *info); -static bool tx_load (struct slgt_info *info,const char *buf,unsigned int count); +static bool tx_load (struct slgt_info *info,const u8 *buf,unsigned int count);static void get_gtsignals (struct slgt_info *info);static void set_gtsignals (struct slgt_info *info);
@@ -745,8 +745,7 @@ static void update_tx_timer(struct slgt_info *info) } } -static int write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int write (struct tty_struct *tty,const u8 *buf,int count) {int ret =0 ;struct slgt_info *info = tty->driver_data;
@@ -4767,7 +4766,7 @@ static unsigned int tbuf_bytes(struct slgt_info *info)* load data into transmit DMA buffer ring and start transmitter if needed * return true if data accepted, otherwise false (buffers full) */ -static bool tx_load (struct slgt_info *info,const char *buf,unsigned int size) +static bool tx_load (struct slgt_info *info,const u8 *buf,unsigned int size) {unsigned short count;unsigned int i;
drivers/tty/ttynull.c +1 -2
@@ -29,8 +29,7 @@ static void ttynull_hangup(struct tty_struct *tty)tty_port_hangup (&ttynull_port); } -static int ttynull_write (struct tty_struct *tty,const unsigned char *buf, -int count) +static int ttynull_write (struct tty_struct *tty,const u8 *buf,int count) {return count; }
drivers/tty/vcc.c +1 -2
@@ -804,8 +804,7 @@ static void vcc_hangup(struct tty_struct *tty)tty_port_hangup (tty->port); } -static int vcc_write (struct tty_struct *tty,const unsigned char *buf, -int count) +static int vcc_write (struct tty_struct *tty,const u8 *buf,int count) {struct vcc_port *port;struct vio_vcc *pkt;
drivers/tty/vt/vt.c +2 -2
@@ -2845,7 +2845,7 @@ static int vc_con_write_normal(struct vc_data *vc, int tc, int c, }/* acquires console_lock */ -static int do_con_write (struct tty_struct *tty,const unsigned char *buf,int count) +static int do_con_write (struct tty_struct *tty,const u8 *buf,int count) {struct vc_draw_region draw = { .x =-1 ,
@@ -3238,7 +3238,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)* /dev/ttyN handling */ -static int con_write (struct tty_struct *tty,const unsigned char *buf,int count) +static int con_write (struct tty_struct *tty,const u8 *buf,int count) {int retval;
drivers/usb/class/cdc-acm.c +1 -2
@@ -789,8 +789,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp)tty_port_close (&acm->port, tty, filp); } -static int acm_tty_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int acm_tty_write (struct tty_struct *tty,const u8 *buf,int count) {struct acm *acm = tty->driver_data;int stat;
drivers/usb/gadget/function/u_serial.c +1 -1
@@ -734,7 +734,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)spin_unlock_irq (&port->port_lock); } -static int gs_write (struct tty_struct *tty,const unsigned char *buf,int count) +static int gs_write (struct tty_struct *tty,const u8 *buf,int count) {struct gs_port *port = tty->driver_data;unsigned long flags;
drivers/usb/host/xhci-dbgtty.c +1 -3
@@ -208,9 +208,7 @@ static void dbc_tty_close(struct tty_struct *tty, struct file *file)tty_port_close (&port->port, tty, file); } -static int dbc_tty_write (struct tty_struct *tty, -const unsigned char *buf, -int count) +static int dbc_tty_write (struct tty_struct *tty,const u8 *buf,int count) {struct dbc_port *port = tty->driver_data;unsigned long flags;
drivers/usb/serial/usb-serial.c +1 -2
@@ -361,8 +361,7 @@ static void serial_cleanup(struct tty_struct *tty)module_put (owner); } -static int serial_write (struct tty_struct *tty,const unsigned char *buf, -int count) +static int serial_write (struct tty_struct *tty,const u8 *buf,int count) {struct usb_serial_port *port = tty->driver_data;int retval = -ENODEV ;
include/linux/tty_driver.h +1 -2
@@ -356,8 +356,7 @@ struct tty_operations {void (*close)(struct tty_struct * tty,struct file * filp);void (*shutdown)(struct tty_struct *tty);void (*cleanup)(struct tty_struct *tty); -int (*write)(struct tty_struct * tty, -const unsigned char *buf,int count); +int (*write)(struct tty_struct *tty,const u8 *buf,int count);int (*put_char)(struct tty_struct *tty,unsigned char ch);void (*flush_chars)(struct tty_struct *tty);unsigned int (*write_room)(struct tty_struct *tty);
net/bluetooth/rfcomm/tty.c +1 -1
@@ -779,7 +779,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)tty_port_close (&dev->port, tty, filp); } -static int rfcomm_tty_write (struct tty_struct *tty,const unsigned char *buf,int count) +static int rfcomm_tty_write (struct tty_struct *tty,const u8 *buf,int count) {struct rfcomm_dev *dev = tty->driver_data;struct rfcomm_dlc *dlc = dev->dlc;
Signature · 1 line
2.41.0
Alexander Gordeev
maintainerRe: [PATCH 27/36] tty: propagate u8 data to tty_operations::write()
On Thu, Aug 10, 2023 at 11:15:01AM +0200, Jiri Slaby (SUSE) wrote:
Hi Jiri,
Quoted 2 lines
Data are now typed as u8. Propagate this change to
tty_operations::write().
...
Quoted 4 lines
drivers/s390/char/con3215.c | 3 +-- drivers/s390/char/con3270.c | 3 +-- drivers/s390/char/sclp_tty.c | 2 +- drivers/s390/char/sclp_vt220.c | 2 +-
...
Quoted 46 lines
drivers/s390/char/con3215.c +1
-2@@ -1021,8 +1021,7 @@ static unsigned int tty3215_write_room(struct tty_struct *tty)/* * String write routine for 3215 ttys */ -static int tty3215_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int tty3215_write (struct tty_struct *tty,const u8 *buf,int count) {handle_write (tty->driver_data, buf, count);return count;drivers/s390/char/con3270.c +1
-2@@ -1803,8 +1803,7 @@ static void tty3270_do_write(struct tty3270 *tp, struct tty_struct *tty,/* * String write routine for 3270 ttys */ -static int tty3270_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int tty3270_write (struct tty_struct *tty,const u8 *buf,int count) {struct tty3270 *tp;drivers/s390/char/sclp_tty.c +1
-1@@ -230,7 +230,7 @@ static int sclp_tty_write_string(const unsigned char *str, int count, int may_fa* routine will return the number of characters actually accepted for writing. */ static int -sclp_tty_write (struct tty_struct *tty,const unsigned char *buf,int count) +sclp_tty_write (struct tty_struct *tty,const u8 *buf,int count) {if (sclp_tty_chars_count >0 ) {sclp_tty_write_string (sclp_tty_chars, sclp_tty_chars_count,0 );drivers/s390/char/sclp_vt220.c +0
-0
drivers/s390/char/sclp_vt220.c __sclp_vt220_write(const unsigned char *buf, int count, int do_schedule, · line 469
Quoted 8 lines
drivers/s390/char/sclp_vt220.c +1
-1@@ -463,7 +463,7 @@ __sclp_vt220_write(const unsigned char *buf, int count, int do_schedule,* number of characters actually accepted for writing. */ static int -sclp_vt220_write (struct tty_struct *tty,const unsigned char *buf,int count) +sclp_vt220_write (struct tty_struct *tty,const u8 *buf,int count) {return __sclp_vt220_write (buf, count,1 ,0 ,1 ); }
...
In this and following patch it is only ::write() (and other) callbacks switched to u8, while the called internal functions stay with old types.
Do you plan to follow with part II etc, or it is archs/drivers that are expected to sort it out eventually?
(I speak for s390, but the other affected archs are in the same boat I guess).
Thanks!
Jiri Slaby
maintainerRe: [PATCH 27/36] tty: propagate u8 data to tty_operations::write()
Hi,
Quoted 68 lines · Alexander Gordeev
On Thu, Aug 10, 2023 at 11:15:01AM +0200, Jiri Slaby (SUSE) wrote:
Hi Jiri,
Quoted 2 lines
Data are now typed as u8. Propagate this change to
tty_operations::write()....
Quoted 4 lines
drivers/s390/char/con3215.c | 3 +-- drivers/s390/char/con3270.c | 3 +-- drivers/s390/char/sclp_tty.c | 2 +- drivers/s390/char/sclp_vt220.c | 2 +-...
Quoted 54 lines
drivers/s390/char/con3215.c +1
-2@@ -1021,8 +1021,7 @@ static unsigned int tty3215_write_room(struct tty_struct *tty)/* * String write routine for 3215 ttys */ -static int tty3215_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int tty3215_write (struct tty_struct *tty,const u8 *buf,int count) {handle_write (tty->driver_data, buf, count);return count;drivers/s390/char/con3270.c +1
-2@@ -1803,8 +1803,7 @@ static void tty3270_do_write(struct tty3270 *tp, struct tty_struct *tty,/* * String write routine for 3270 ttys */ -static int tty3270_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int tty3270_write (struct tty_struct *tty,const u8 *buf,int count) {struct tty3270 *tp;drivers/s390/char/sclp_tty.c +1
-1@@ -230,7 +230,7 @@ static int sclp_tty_write_string(const unsigned char *str, int count, int may_fa* routine will return the number of characters actually accepted for writing. */ static int -sclp_tty_write (struct tty_struct *tty,const unsigned char *buf,int count) +sclp_tty_write (struct tty_struct *tty,const u8 *buf,int count) {if (sclp_tty_chars_count >0 ) {sclp_tty_write_string (sclp_tty_chars, sclp_tty_chars_count,0 );drivers/s390/char/sclp_vt220.c +1
-1@@ -463,7 +463,7 @@ __sclp_vt220_write(const unsigned char *buf, int count, int do_schedule,* number of characters actually accepted for writing. */ static int -sclp_vt220_write (struct tty_struct *tty,const unsigned char *buf,int count) +sclp_vt220_write (struct tty_struct *tty,const u8 *buf,int count) {return __sclp_vt220_write (buf, count,1 ,0 ,1 ); }...
Quoted 5 lines
In this and following patch it is only ::write() (and other) callbacks switched to u8, while the called internal functions stay with old types.
Do you plan to follow with part II etc, or it is archs/drivers that are expected to sort it out eventually?
Yes, I would say something like part V. would do the job -- at least that's my plan. Slowly propagating from the tty core to leafs (drivers).
Quoted 1 line
(I speak for s390, but the other affected archs are in the same boat I guess).
thanks,
Signature · 2 lines
js suse labs
Re: [PATCH 27/36] tty: propagate u8 data to tty_operations::write()
In reply to Jiri Slaby (SUSE)Quoted 7 lines · Jiri Slaby (SUSE)
Data are now typed as u8. Propagate this change to
tty_operations::write().Signed-off-by Jiri Slaby (SUSE) <[email protected]>arch/m68k/emu/nfcon.c | 3 +-- drivers/tty/amiserial.c | 2 +-
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH 27/36] tty: propagate u8 data to tty_operations::write()
In reply to Jiri Slaby (SUSE)On Thu, Aug 10, 2023 at 11:15:01AM +0200, Jiri Slaby (SUSE) wrote:
...
Quoted 5 lines
drivers/s390/char/con3215.c | 3 +-- drivers/s390/char/con3270.c | 3 +-- drivers/s390/char/sclp_tty.c | 2 +- drivers/s390/char/sclp_vt220.c | 2 +- drivers/staging/gdm724x/gdm_tty.c | 3 +--
...
Quoted 46 lines
drivers/s390/char/con3215.c +1
-2@@ -1021,8 +1021,7 @@ static unsigned int tty3215_write_room(struct tty_struct *tty)/* * String write routine for 3215 ttys */ -static int tty3215_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int tty3215_write (struct tty_struct *tty,const u8 *buf,int count) {handle_write (tty->driver_data, buf, count);return count;drivers/s390/char/con3270.c +1
-2@@ -1803,8 +1803,7 @@ static void tty3270_do_write(struct tty3270 *tp, struct tty_struct *tty,/* * String write routine for 3270 ttys */ -static int tty3270_write (struct tty_struct *tty, -const unsigned char *buf,int count) +static int tty3270_write (struct tty_struct *tty,const u8 *buf,int count) {struct tty3270 *tp;drivers/s390/char/sclp_tty.c +1
-1@@ -230,7 +230,7 @@ static int sclp_tty_write_string(const unsigned char *str, int count, int may_fa* routine will return the number of characters actually accepted for writing. */ static int -sclp_tty_write (struct tty_struct *tty,const unsigned char *buf,int count) +sclp_tty_write (struct tty_struct *tty,const u8 *buf,int count) {if (sclp_tty_chars_count >0 ) {sclp_tty_write_string (sclp_tty_chars, sclp_tty_chars_count,0 );drivers/s390/char/sclp_vt220.c +0
-0
drivers/s390/char/sclp_vt220.c __sclp_vt220_write(const unsigned char *buf, int count, int do_schedule, · line 469
Quoted 8 lines
drivers/s390/char/sclp_vt220.c +1
-1@@ -463,7 +463,7 @@ __sclp_vt220_write(const unsigned char *buf, int count, int do_schedule,* number of characters actually accepted for writing. */ static int -sclp_vt220_write (struct tty_struct *tty,const unsigned char *buf,int count) +sclp_vt220_write (struct tty_struct *tty,const u8 *buf,int count) {return __sclp_vt220_write (buf, count,1 ,0 ,1 ); }
For s390 part:
Jiri Slaby (SUSE)
maintainerPATCH 28/36 tty: propagate u8 data to tty_operations::put_char()
In reply to Jiri Slaby (SUSE)Data are now typed as u8. Propagate this change to tty_operations::put_char().
--- arch/m68k/emu/nfcon.c | 4 ++-- drivers/isdn/capi/capi.c | 2 +- drivers/s390/char/con3215.c | 2 +- drivers/s390/char/con3270.c | 2 +- drivers/s390/char/sclp_tty.c | 6 +++--- drivers/s390/char/sclp_vt220.c | 2 +- drivers/tty/amiserial.c | 2 +- drivers/tty/mxser.c | 2 +- drivers/tty/serial/serial_core.c | 2 +- drivers/tty/synclink_gt.c | 4 ++-- drivers/tty/vt/vt.c | 2 +- drivers/usb/gadget/function/u_serial.c | 2 +- drivers/usb/host/xhci-dbgtty.c | 2 +- include/linux/tty_driver.h | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-)
arch/m68k/emu/nfcon.c +2 -2
@@ -76,9 +76,9 @@ static int nfcon_tty_write(struct tty_struct *tty, const u8 *buf, int count)return count; } -static int nfcon_tty_put_char (struct tty_struct *tty,unsigned char ch) +static int nfcon_tty_put_char (struct tty_struct *tty,u8 ch) { -char temp[2 ] = { ch,0 }; +u8 temp[2 ] = { ch,0 };nf_call (stderr_id,virt_to_phys (temp));return 1 ;
drivers/isdn/capi/capi.c +1 -1
@@ -1111,7 +1111,7 @@ static int capinc_tty_write(struct tty_struct *tty, const u8 *buf, int count)return count; } -static int capinc_tty_put_char (struct tty_struct *tty,unsigned char ch) +static int capinc_tty_put_char (struct tty_struct *tty,u8 ch) {struct capiminor *mp = tty->driver_data;bool invoke_send = false;
drivers/s390/char/con3215.c +1 -1
@@ -1030,7 +1030,7 @@ static int tty3215_write(struct tty_struct *tty, const u8 *buf, int count)/* * Put character routine for 3215 ttys */ -static int tty3215_put_char (struct tty_struct *tty,unsigned char ch) +static int tty3215_put_char (struct tty_struct *tty,u8 ch) {struct raw3215_info *raw = tty->driver_data;
drivers/s390/char/con3270.c +1 -1
@@ -1821,7 +1821,7 @@ static int tty3270_write(struct tty_struct *tty, const u8 *buf, int count)/* * Put single characters to the ttys character buffer */ -static int tty3270_put_char (struct tty_struct *tty,unsigned char ch) +static int tty3270_put_char (struct tty_struct *tty,u8 ch) {struct tty3270 *tp;
drivers/s390/char/sclp_tty.c +3 -3
@@ -48,7 +48,7 @@ static struct sclp_buffer *sclp_ttybuf;static struct timer_list sclp_tty_timer;static struct tty_port sclp_port; -static unsigned char sclp_tty_chars[SCLP_TTY_BUF_SIZE ]; +static u8 sclp_tty_chars[SCLP_TTY_BUF_SIZE ];static unsigned short int sclp_tty_chars_count;struct tty_driver *sclp_tty_driver;
@@ -168,7 +168,7 @@ sclp_tty_timeout(struct timer_list *unused)/* * Write a string to the sclp tty. */ -static int sclp_tty_write_string (const unsigned char *str,int count,int may_fail) +static int sclp_tty_write_string (const u8 *str,int count,int may_fail) {unsigned long flags;void *page;
@@ -250,7 +250,7 @@ sclp_tty_write(struct tty_struct *tty, const u8 *buf, int count)* sclp_write() without final '\n' - will be written. */ static int -sclp_tty_put_char (struct tty_struct *tty,unsigned char ch) +sclp_tty_put_char (struct tty_struct *tty,u8 ch) { sclp_tty_chars[sclp_tty_chars_count++] = ch;if (ch =='\n' || sclp_tty_chars_count >=SCLP_TTY_BUF_SIZE ) {
drivers/s390/char/sclp_vt220.c +1 -1
@@ -579,7 +579,7 @@ sclp_vt220_close(struct tty_struct *tty, struct file *filp)* done stuffing characters into the driver. */ static int -sclp_vt220_put_char (struct tty_struct *tty,unsigned char ch) +sclp_vt220_put_char (struct tty_struct *tty,u8 ch) {return __sclp_vt220_write (&ch,1 ,0 ,0 ,1 ); }
drivers/tty/amiserial.c +1 -1
@@ -696,7 +696,7 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,local_irq_restore (flags); } -static int rs_put_char (struct tty_struct *tty,unsigned char ch) +static int rs_put_char (struct tty_struct *tty,u8 ch) {struct serial_state *info;unsigned long flags;
drivers/tty/mxser.c +1 -1
@@ -920,7 +920,7 @@ static int mxser_write(struct tty_struct *tty, const u8 *buf, int count)return written; } -static int mxser_put_char (struct tty_struct *tty,unsigned char ch) +static int mxser_put_char (struct tty_struct *tty,u8 ch) {struct mxser_port *info = tty->driver_data;unsigned long flags;
drivers/tty/serial/serial_core.c +1 -1
@@ -551,7 +551,7 @@ uart_get_divisor(struct uart_port *port, unsigned int baud) }EXPORT_SYMBOL (uart_get_divisor); -static int uart_put_char (struct tty_struct *tty,unsigned char c) +static int uart_put_char (struct tty_struct *tty,u8 c) {struct uart_state *state = tty->driver_data;struct uart_port *port;
drivers/tty/synclink_gt.c +2 -2
@@ -780,7 +780,7 @@ static int write(struct tty_struct *tty, const u8 *buf, int count)return ret; } -static int put_char (struct tty_struct *tty,unsigned char ch) +static int put_char (struct tty_struct *tty,u8 ch) {struct slgt_info *info = tty->driver_data;unsigned long flags;
@@ -788,7 +788,7 @@ static int put_char(struct tty_struct *tty, unsigned char ch)if (sanity_check (info, tty->name,"put_char" ))return 0 ; -DBGINFO (("%s put_char(%d)\n" , info->device_name, ch)); +DBGINFO (("%s put_char(%u)\n" , info->device_name, ch));if (!info->tx_buf)return 0 ;spin_lock_irqsave (&info->lock,flags);
drivers/tty/vt/vt.c +1 -1
@@ -3248,7 +3248,7 @@ static int con_write(struct tty_struct *tty, const u8 *buf, int count)return retval; } -static int con_put_char (struct tty_struct *tty,unsigned char ch) +static int con_put_char (struct tty_struct *tty,u8 ch) {return do_con_write (tty, &ch,1 ); }
drivers/usb/gadget/function/u_serial.c +1 -1
@@ -753,7 +753,7 @@ static int gs_write(struct tty_struct *tty, const u8 *buf, int count)return count; } -static int gs_put_char (struct tty_struct *tty,unsigned char ch) +static int gs_put_char (struct tty_struct *tty,u8 ch) {struct gs_port *port = tty->driver_data;unsigned long flags;
drivers/usb/host/xhci-dbgtty.c +1 -1
@@ -222,7 +222,7 @@ static int dbc_tty_write(struct tty_struct *tty, const u8 *buf, int count)return count; } -static int dbc_tty_put_char (struct tty_struct *tty,unsigned char ch) +static int dbc_tty_put_char (struct tty_struct *tty,u8 ch) {struct dbc_port *port = tty->driver_data;unsigned long flags;
include/linux/tty_driver.h +1 -1
@@ -357,7 +357,7 @@ struct tty_operations {void (*shutdown)(struct tty_struct *tty);void (*cleanup)(struct tty_struct *tty);int (*write)(struct tty_struct *tty,const u8 *buf,int count); -int (*put_char)(struct tty_struct *tty,unsigned char ch); +int (*put_char)(struct tty_struct *tty,u8 ch);void (*flush_chars)(struct tty_struct *tty);unsigned int (*write_room)(struct tty_struct *tty);unsigned int (*chars_in_buffer)(struct tty_struct *tty);
Signature · 1 line
2.41.0
Re: [PATCH 28/36] tty: propagate u8 data to tty_operations::put_char()
Quoted 7 lines · Jiri Slaby (SUSE)
Data are now typed as u8. Propagate this change to
tty_operations::put_char().Signed-off-by Jiri Slaby (SUSE) <[email protected]>arch/m68k/emu/nfcon.c | 4 ++-- drivers/tty/amiserial.c | 2 +-
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH 28/36] tty: propagate u8 data to tty_operations::put_char()
In reply to Jiri Slaby (SUSE)On Thu, Aug 10, 2023 at 11:15:02AM +0200, Jiri Slaby (SUSE) wrote:
...
Quoted 4 lines
drivers/s390/char/con3215.c | 2 +- drivers/s390/char/con3270.c | 2 +- drivers/s390/char/sclp_tty.c | 6 +++--- drivers/s390/char/sclp_vt220.c | 2 +-
...
Quoted 62 lines
drivers/s390/char/con3215.c +1
-1@@ -1030,7 +1030,7 @@ static int tty3215_write(struct tty_struct *tty, const u8 *buf, int count)/* * Put character routine for 3215 ttys */ -static int tty3215_put_char (struct tty_struct *tty,unsigned char ch) +static int tty3215_put_char (struct tty_struct *tty,u8 ch) {struct raw3215_info *raw = tty->driver_data;drivers/s390/char/con3270.c +1
-1@@ -1821,7 +1821,7 @@ static int tty3270_write(struct tty_struct *tty, const u8 *buf, int count)/* * Put single characters to the ttys character buffer */ -static int tty3270_put_char (struct tty_struct *tty,unsigned char ch) +static int tty3270_put_char (struct tty_struct *tty,u8 ch) {struct tty3270 *tp;drivers/s390/char/sclp_tty.c +3
-3@@ -48,7 +48,7 @@ static struct sclp_buffer *sclp_ttybuf;static struct timer_list sclp_tty_timer;static struct tty_port sclp_port; -static unsigned char sclp_tty_chars[SCLP_TTY_BUF_SIZE ]; +static u8 sclp_tty_chars[SCLP_TTY_BUF_SIZE ];static unsigned short int sclp_tty_chars_count;struct tty_driver *sclp_tty_driver;@@ -168,7 +168,7 @@ sclp_tty_timeout(struct timer_list *unused)/* * Write a string to the sclp tty. */ -static int sclp_tty_write_string (const unsigned char *str,int count,int may_fail) +static int sclp_tty_write_string (const u8 *str,int count,int may_fail) {unsigned long flags;void *page;@@ -250,7 +250,7 @@ sclp_tty_write(struct tty_struct *tty, const u8 *buf, int count)* sclp_write() without final '\n' - will be written. */ static int -sclp_tty_put_char (struct tty_struct *tty,unsigned char ch) +sclp_tty_put_char (struct tty_struct *tty,u8 ch) { sclp_tty_chars[sclp_tty_chars_count++] = ch;if (ch =='\n' || sclp_tty_chars_count >=SCLP_TTY_BUF_SIZE ) {drivers/s390/char/sclp_vt220.c +0
-0
drivers/s390/char/sclp_vt220.c sclp_vt220_close(struct tty_struct *tty, struct file *filp) · line 585
Quoted 8 lines
drivers/s390/char/sclp_vt220.c +1
-1@@ -579,7 +579,7 @@ sclp_vt220_close(struct tty_struct *tty, struct file *filp)* done stuffing characters into the driver. */ static int -sclp_vt220_put_char (struct tty_struct *tty,unsigned char ch) +sclp_vt220_put_char (struct tty_struct *tty,u8 ch) {return __sclp_vt220_write (&ch,1 ,0 ,0 ,1 ); }
For s390 part:
Thanks!
Jiri Slaby (SUSE)
maintainerPATCH 29/36 tty: make tty_operations::write()'s count size_t
In reply to Jiri Slaby (SUSE)Unify with the rest of the code. Use size_t for counts and ssize_t for retval.
--- arch/alpha/kernel/srmcons.c | 4 ++-- arch/m68k/emu/nfcon.c | 3 ++- arch/um/drivers/line.c | 2 +- arch/um/drivers/line.h | 2 +- arch/xtensa/platforms/iss/console.c | 2 +- drivers/char/ttyprintk.c | 2 +- drivers/ipack/devices/ipoctal.c | 3 ++- drivers/isdn/capi/capi.c | 5 +++-- drivers/misc/bcm-vk/bcm_vk_tty.c | 3 ++- drivers/mmc/core/sdio_uart.c | 3 ++- drivers/net/usb/hso.c | 3 ++- drivers/s390/char/con3215.c | 3 ++- drivers/s390/char/con3270.c | 3 ++- drivers/s390/char/sclp_tty.c | 4 ++-- drivers/s390/char/sclp_vt220.c | 4 ++-- drivers/staging/gdm724x/gdm_tty.c | 2 +- drivers/staging/greybus/uart.c | 2 +- drivers/tty/amiserial.c | 2 +- drivers/tty/ehv_bytechan.c | 3 ++- drivers/tty/goldfish.c | 3 ++- drivers/tty/hvc/hvc_console.c | 2 +- drivers/tty/hvc/hvcs.c | 5 +++-- drivers/tty/hvc/hvsi.c | 3 ++- drivers/tty/ipwireless/tty.c | 3 ++- drivers/tty/mips_ejtag_fdc.c | 6 +++--- drivers/tty/moxa.c | 4 ++-- drivers/tty/mxser.c | 2 +- drivers/tty/n_gsm.c | 2 +- drivers/tty/nozomi.c | 3 ++- drivers/tty/pty.c | 2 +- drivers/tty/rpmsg_tty.c | 5 +++-- drivers/tty/serial/kgdb_nmi.c | 3 ++- drivers/tty/serial/serial_core.c | 2 +- drivers/tty/synclink_gt.c | 4 ++-- drivers/tty/ttynull.c | 3 ++- drivers/tty/vcc.c | 5 +++-- drivers/tty/vt/vt.c | 2 +- drivers/usb/class/cdc-acm.c | 7 ++++--- drivers/usb/gadget/function/u_serial.c | 4 ++-- drivers/usb/host/xhci-dbgtty.c | 3 ++- drivers/usb/serial/usb-serial.c | 4 ++-- include/linux/tty_driver.h | 6 +++--- net/bluetooth/rfcomm/tty.c | 5 +++-- 43 files changed, 82 insertions(+), 61 deletions(-)
arch/alpha/kernel/srmcons.c +2 -2
@@ -129,8 +129,8 @@ srmcons_do_write(struct tty_port *port, const char *buf, int count)return count; } -static int -srmcons_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t +srmcons_write (struct tty_struct *tty,const u8 *buf,size_t count) {unsigned long flags;
arch/m68k/emu/nfcon.c +2 -1
@@ -70,7 +70,8 @@ static void nfcon_tty_close(struct tty_struct *tty, struct file *filp) { } -static int nfcon_tty_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t nfcon_tty_write (struct tty_struct *tty,const u8 *buf, +size_t count) {nfputs (buf, count);return count;
arch/um/drivers/line.c +1 -1
@@ -184,7 +184,7 @@ void line_flush_chars(struct tty_struct *tty)line_flush_buffer (tty); } -int line_write (struct tty_struct *tty,const u8 *buf,int len) +ssize_t line_write (struct tty_struct *tty,const u8 *buf,size_t len) {struct line *line = tty->driver_data;unsigned long flags;
arch/um/drivers/line.h +1 -1
@@ -64,7 +64,7 @@ extern void line_cleanup(struct tty_struct *tty);extern void line_hangup (struct tty_struct *tty);extern int line_setup (char **conf,unsigned nlines,char **def,char *init,char *name); -extern int line_write (struct tty_struct *tty,const u8 *buf,int len); +extern ssize_t line_write (struct tty_struct *tty,const u8 *buf,size_t len);extern unsigned int line_chars_in_buffer (struct tty_struct *tty);extern void line_flush_buffer (struct tty_struct *tty);extern void line_flush_chars (struct tty_struct *tty);
arch/xtensa/platforms/iss/console.c +1 -1
@@ -52,7 +52,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) } -static int rs_write (struct tty_struct * tty,const u8 *buf,int count) +static ssize_t rs_write (struct tty_struct * tty,const u8 *buf,size_t count) {/* see drivers/char/serialX.c to reference original version */
drivers/char/ttyprintk.c +1 -1
@@ -103,7 +103,7 @@ static void tpk_close(struct tty_struct *tty, struct file *filp)/* * TTY operations write function. */ -static int tpk_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t tpk_write (struct tty_struct *tty,const u8 *buf,size_t count) {struct ttyprintk_port *tpkp = tty->driver_data;unsigned long flags;
drivers/ipack/devices/ipoctal.c +2 -1
@@ -458,7 +458,8 @@ static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel,return i; } -static int ipoctal_write_tty (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t ipoctal_write_tty (struct tty_struct *tty,const u8 *buf, +size_t count) {struct ipoctal_channel *channel = tty->driver_data;unsigned int char_copied;
drivers/isdn/capi/capi.c +3 -2
@@ -1077,12 +1077,13 @@ static void capinc_tty_close(struct tty_struct *tty, struct file *filp)tty_port_close (&mp->port, tty, filp); } -static int capinc_tty_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t capinc_tty_write (struct tty_struct *tty,const u8 *buf, +size_t count) {struct capiminor *mp = tty->driver_data;struct sk_buff *skb; -pr_debug ("capinc_tty_write(count=%d)\n" , count); +pr_debug ("capinc_tty_write(count=%zu)\n" , count);spin_lock_bh (&mp->outlock); skb = mp->outskb;
drivers/misc/bcm-vk/bcm_vk_tty.c +2 -1
@@ -186,7 +186,8 @@ static void bcm_vk_tty_doorbell(struct bcm_vk *vk, u32 db_val) VK_BAR0_REGSEG_DB_BASE + VK_BAR0_REGSEG_TTY_DB_OFFSET); } -static int bcm_vk_tty_write (struct tty_struct *tty,const u8 *buffer,int count) +static ssize_t bcm_vk_tty_write (struct tty_struct *tty,const u8 *buffer, +size_t count) {int index;struct bcm_vk *vk;
drivers/mmc/core/sdio_uart.c +2 -1
@@ -760,7 +760,8 @@ static void sdio_uart_hangup(struct tty_struct *tty)tty_port_hangup (&port->port); } -static int sdio_uart_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t sdio_uart_write (struct tty_struct *tty,const u8 *buf, +size_t count) {struct sdio_uart_port *port = tty->driver_data;int ret;
drivers/net/usb/hso.c +2 -1
@@ -1322,7 +1322,8 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp) }/* close the requested serial port */ -static int hso_serial_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t hso_serial_write (struct tty_struct *tty,const u8 *buf, +size_t count) {struct hso_serial *serial = tty->driver_data;int space, tx_bytes;
drivers/s390/char/con3215.c +2 -1
@@ -1021,7 +1021,8 @@ static unsigned int tty3215_write_room(struct tty_struct *tty)/* * String write routine for 3215 ttys */ -static int tty3215_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t tty3215_write (struct tty_struct *tty,const u8 *buf, +size_t count) {handle_write (tty->driver_data, buf, count);return count;
drivers/s390/char/con3270.c +2 -1
@@ -1803,7 +1803,8 @@ static void tty3270_do_write(struct tty3270 *tp, struct tty_struct *tty,/* * String write routine for 3270 ttys */ -static int tty3270_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t tty3270_write (struct tty_struct *tty,const u8 *buf, +size_t count) {struct tty3270 *tp;
drivers/s390/char/sclp_tty.c +2 -2
@@ -229,8 +229,8 @@ static int sclp_tty_write_string(const u8 *str, int count, int may_fail)* tty device. The characters may come from user space or kernel space. This * routine will return the number of characters actually accepted for writing. */ -static int -sclp_tty_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t +sclp_tty_write (struct tty_struct *tty,const u8 *buf,size_t count) {if (sclp_tty_chars_count >0 ) {sclp_tty_write_string (sclp_tty_chars, sclp_tty_chars_count,0 );
drivers/s390/char/sclp_vt220.c +2 -2
@@ -462,8 +462,8 @@ __sclp_vt220_write(const unsigned char *buf, int count, int do_schedule,* user space or kernel space. This routine will return the * number of characters actually accepted for writing. */ -static int -sclp_vt220_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t +sclp_vt220_write (struct tty_struct *tty,const u8 *buf,size_t count) {return __sclp_vt220_write (buf, count,1 ,0 ,1 ); }
drivers/staging/gdm724x/gdm_tty.c +1 -1
@@ -149,7 +149,7 @@ static void gdm_tty_send_complete(void *arg)tty_port_tty_wakeup (&gdm->port); } -static int gdm_tty_write (struct tty_struct *tty,const u8 *buf,int len) +static ssize_t gdm_tty_write (struct tty_struct *tty,const u8 *buf,size_t len) {struct gdm *gdm = tty->driver_data;int remain = len;
drivers/staging/greybus/uart.c +1 -1
@@ -427,7 +427,7 @@ static void gb_tty_hangup(struct tty_struct *tty)tty_port_hangup (&gb_tty->port); } -static int gb_tty_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t gb_tty_write (struct tty_struct *tty,const u8 *buf,size_t count) {struct gb_tty *gb_tty = tty->driver_data;
drivers/tty/amiserial.c +1 -1
@@ -741,7 +741,7 @@ static void rs_flush_chars(struct tty_struct *tty)local_irq_restore (flags); } -static int rs_write (struct tty_struct * tty,const u8 *buf,int count) +static ssize_t rs_write (struct tty_struct * tty,const u8 *buf,size_t count) {int c, ret =0 ;struct serial_state *info = tty->driver_data;
drivers/tty/ehv_bytechan.c +2 -1
@@ -466,7 +466,8 @@ static irqreturn_t ehv_bc_tty_tx_isr(int irq, void *data)* ehv_bc_tty_write_room() will never lie, so the tty layer will never send us * too much data. */ -static int ehv_bc_tty_write (struct tty_struct *ttys,const u8 *s,int count) +static ssize_t ehv_bc_tty_write (struct tty_struct *ttys,const u8 *s, +size_t count) {struct ehv_bc_data *bc = ttys->driver_data;unsigned long flags;
drivers/tty/goldfish.c +2 -1
@@ -185,7 +185,8 @@ static void goldfish_tty_hangup(struct tty_struct *tty)tty_port_hangup (tty->port); } -static int goldfish_tty_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t goldfish_tty_write (struct tty_struct *tty,const u8 *buf, +size_t count) {goldfish_tty_do_write (tty->index, buf, count);return count;
drivers/tty/hvc/hvc_console.c +1 -1
@@ -496,7 +496,7 @@ static int hvc_push(struct hvc_struct *hp)return n; } -static int hvc_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t hvc_write (struct tty_struct *tty,const u8 *buf,size_t count) {struct hvc_struct *hp = tty->driver_data;unsigned long flags;
drivers/tty/hvc/hvcs.c +3 -2
@@ -1257,7 +1257,7 @@ static void hvcs_hangup(struct tty_struct * tty)* tty_hangup will allow hvcs_write time to complete execution before it * terminates our device. */ -static int hvcs_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t hvcs_write (struct tty_struct *tty,const u8 *buf,size_t count) {struct hvcs_struct *hvcsd = tty->driver_data;unsigned int unit_address;
@@ -1299,7 +1299,8 @@ static int hvcs_write(struct tty_struct *tty, const u8 *buf, int count) unit_address = hvcsd->vdev->unit_address;while (count >0 ) { - tosend =min (count, (HVCS_BUFF_LEN - hvcsd->chars_in_buffer)); + tosend =min_t (unsigned, count, + (HVCS_BUFF_LEN - hvcsd->chars_in_buffer));/* * No more space, this probably means that the last call to * hvcs_write() didn't succeed and the buffer was filled up.
drivers/tty/hvc/hvsi.c +2 -1
@@ -904,7 +904,8 @@ static unsigned int hvsi_chars_in_buffer(struct tty_struct *tty)return hp->n_outbuf; } -static int hvsi_write (struct tty_struct *tty,const u8 *source,int count) +static ssize_t hvsi_write (struct tty_struct *tty,const u8 *source, +size_t count) {struct hvsi_struct *hp = tty->driver_data;unsigned long flags;
drivers/tty/ipwireless/tty.c +2 -1
@@ -186,7 +186,8 @@ static void ipw_write_packet_sent_callback(void *callback_data, tty->tx_bytes_queued -= packet_length; } -static int ipw_write (struct tty_struct *linux_tty,const u8 *buf,int count) +static ssize_t ipw_write (struct tty_struct *linux_tty,const u8 *buf, +size_t count) {struct ipw_tty *tty = linux_tty->driver_data;int room, ret;
drivers/tty/mips_ejtag_fdc.c +3 -3
@@ -796,8 +796,8 @@ static void mips_ejtag_fdc_tty_hangup(struct tty_struct *tty)tty_port_hangup (tty->port); } -static int mips_ejtag_fdc_tty_write (struct tty_struct *tty,const u8 *buf, -int total) +static ssize_t mips_ejtag_fdc_tty_write (struct tty_struct *tty,const u8 *buf, +size_t total) {int count, block;struct mips_ejtag_fdc_tty_port *dport = tty->driver_data;
@@ -816,7 +816,7 @@ static int mips_ejtag_fdc_tty_write(struct tty_struct *tty, const u8 *buf,*/ spin_lock (&dport->xmit_lock);/* Work out how many bytes we can write to the xmit buffer */ - total =min (total, (int )(priv->xmit_size - dport->xmit_cnt)); + total =min_t (size_t, total, priv->xmit_size - dport->xmit_cnt);atomic_add (total, &priv->xmit_total); dport->xmit_cnt += total;/* Write the actual bytes (may need splitting if it wraps) */
drivers/tty/moxa.c +2 -2
@@ -487,7 +487,7 @@ module_param(ttymajor, int, 0);*/ static int moxa_open (struct tty_struct *,struct file *);static void moxa_close (struct tty_struct *,struct file *); -static int moxa_write (struct tty_struct *,const u8 *,int ); +static ssize_t moxa_write (struct tty_struct *,const u8 *,size_t );static unsigned int moxa_write_room (struct tty_struct *);static void moxa_flush_buffer (struct tty_struct *);static unsigned int moxa_chars_in_buffer (struct tty_struct *);
@@ -1499,7 +1499,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)tty_port_close (&ch->port, tty, filp); } -static int moxa_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t moxa_write (struct tty_struct *tty,const u8 *buf,size_t count) {struct moxa_port *ch = tty->driver_data;unsigned long flags;
drivers/tty/mxser.c +1 -1
@@ -901,7 +901,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)tty_port_close (tty->port, tty, filp); } -static int mxser_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t mxser_write (struct tty_struct *tty,const u8 *buf,size_t count) {struct mxser_port *info = tty->driver_data;unsigned long flags;
drivers/tty/n_gsm.c +1 -1
@@ -4256,7 +4256,7 @@ static void gsmtty_hangup(struct tty_struct *tty)gsm_dlci_begin_close (dlci); } -static int gsmtty_write (struct tty_struct *tty,const u8 *buf,int len) +static ssize_t gsmtty_write (struct tty_struct *tty,const u8 *buf,size_t len) {int sent;struct gsm_dlci *dlci = tty->driver_data;
drivers/tty/nozomi.c +2 -1
@@ -1599,7 +1599,8 @@ static void ntty_hangup(struct tty_struct *tty)* called when the userspace process writes to the tty (/dev/noz*). * Data is inserted into a fifo, which is then read and transferred to the modem. */ -static int ntty_write (struct tty_struct *tty,const u8 *buffer,int count) +static ssize_t ntty_write (struct tty_struct *tty,const u8 *buffer, +size_t count) {int rval = -EINVAL ;struct nozomi *dc =get_dc_by_tty (tty);
drivers/tty/pty.c +1 -1
@@ -108,7 +108,7 @@ static void pty_unthrottle(struct tty_struct *tty)* the other side of the pty/tty pair. */ -static int pty_write (struct tty_struct *tty,const u8 *buf,int c) +static ssize_t pty_write (struct tty_struct *tty,const u8 *buf,size_t c) {struct tty_struct *to = tty->link;
drivers/tty/rpmsg_tty.c +3 -2
@@ -73,7 +73,8 @@ static void rpmsg_tty_close(struct tty_struct *tty, struct file *filp)return tty_port_close (tty->port, tty, filp); } -static int rpmsg_tty_write (struct tty_struct *tty,const u8 *buf,int len) +static ssize_t rpmsg_tty_write (struct tty_struct *tty,const u8 *buf, +size_t len) {struct rpmsg_tty_port *cport = tty->driver_data;struct rpmsg_device *rpdev;
@@ -86,7 +87,7 @@ static int rpmsg_tty_write(struct tty_struct *tty, const u8 *buf, int len)if (msg_max_size <0 )return msg_max_size; - msg_size =min (len, msg_max_size); + msg_size = min_t(unsigned int, len, msg_max_size);/* * Use rpmsg_trysend instead of rpmsg_send to send the message so the caller is not
drivers/tty/serial/kgdb_nmi.c +2 -1
@@ -304,7 +304,8 @@ static unsigned int kgdb_nmi_tty_write_room(struct tty_struct *tty)return 2048 ; } -static int kgdb_nmi_tty_write (struct tty_struct *tty,const u8 *buf,int c) +static ssize_t kgdb_nmi_tty_write (struct tty_struct *tty,const u8 *buf, +size_t c) {int i;
drivers/tty/serial/serial_core.c +1 -1
@@ -580,7 +580,7 @@ static void uart_flush_chars(struct tty_struct *tty)uart_start (tty); } -static int uart_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t uart_write (struct tty_struct *tty,const u8 *buf,size_t count) {struct uart_state *state = tty->driver_data;struct uart_port *port;
drivers/tty/synclink_gt.c +2 -2
@@ -745,7 +745,7 @@ static void update_tx_timer(struct slgt_info *info) } } -static int write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t write (struct tty_struct *tty,const u8 *buf,size_t count) {int ret =0 ;struct slgt_info *info = tty->driver_data;
@@ -754,7 +754,7 @@ static int write(struct tty_struct *tty, const u8 *buf, int count)if (sanity_check (info, tty->name,"write" ))return -EIO ; -DBGINFO (("%s write count=%d\n" , info->device_name, count)); +DBGINFO (("%s write count=%zu\n" , info->device_name, count));if (!info->tx_buf || (count > info->max_frame_size))return -EIO ;
drivers/tty/ttynull.c +2 -1
@@ -29,7 +29,8 @@ static void ttynull_hangup(struct tty_struct *tty)tty_port_hangup (&ttynull_port); } -static int ttynull_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t ttynull_write (struct tty_struct *tty,const u8 *buf, +size_t count) {return count; }
drivers/tty/vcc.c +3 -2
@@ -804,7 +804,7 @@ static void vcc_hangup(struct tty_struct *tty)tty_port_hangup (tty->port); } -static int vcc_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t vcc_write (struct tty_struct *tty,const u8 *buf,size_t count) {struct vcc_port *port;struct vio_vcc *pkt;
@@ -826,7 +826,8 @@ static int vcc_write(struct tty_struct *tty, const u8 *buf, int count)while (count >0 ) {/* Minimum of data to write and space available */ - tosend =min (count, (VCC_BUFF_LEN - port->chars_in_buffer)); + tosend =min_t (size_t, count, + (VCC_BUFF_LEN - port->chars_in_buffer));if (!tosend)break ;
drivers/tty/vt/vt.c +1 -1
@@ -3238,7 +3238,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)* /dev/ttyN handling */ -static int con_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t con_write (struct tty_struct *tty,const u8 *buf,size_t count) {int retval;
drivers/usb/class/cdc-acm.c +4 -3
@@ -789,7 +789,8 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp)tty_port_close (&acm->port, tty, filp); } -static int acm_tty_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t acm_tty_write (struct tty_struct *tty,const u8 *buf, +size_t count) {struct acm *acm = tty->driver_data;int stat;
@@ -800,7 +801,7 @@ static int acm_tty_write(struct tty_struct *tty, const u8 *buf, int count)if (!count)return 0 ; -dev_vdbg (&acm->data->dev,"%d bytes from tty layer\n" , count); +dev_vdbg (&acm->data->dev,"%zu bytes from tty layer\n" , count);spin_lock_irqsave (&acm->write_lock, flags); wbn =acm_wb_alloc (acm);
@@ -817,7 +818,7 @@ static int acm_tty_write(struct tty_struct *tty, const u8 *buf, int count) } count = (count > acm->writesize) ? acm->writesize : count; -dev_vdbg (&acm->data->dev,"writing %d bytes\n" , count); +dev_vdbg (&acm->data->dev,"writing %zu bytes\n" , count);memcpy (wb->buf, buf, count); wb->len = count;
drivers/usb/gadget/function/u_serial.c +2 -2
@@ -734,12 +734,12 @@ static void gs_close(struct tty_struct *tty, struct file *file)spin_unlock_irq (&port->port_lock); } -static int gs_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t gs_write (struct tty_struct *tty,const u8 *buf,size_t count) {struct gs_port *port = tty->driver_data;unsigned long flags; -pr_vdebug ("gs_write: ttyGS%d (%p) writing %d bytes\n" , +pr_vdebug ("gs_write: ttyGS%d (%p) writing %zu bytes\n" , port->port_num, tty, count);spin_lock_irqsave (&port->port_lock, flags);
drivers/usb/host/xhci-dbgtty.c +2 -1
@@ -208,7 +208,8 @@ static void dbc_tty_close(struct tty_struct *tty, struct file *file)tty_port_close (&port->port, tty, file); } -static int dbc_tty_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t dbc_tty_write (struct tty_struct *tty,const u8 *buf, +size_t count) {struct dbc_port *port = tty->driver_data;unsigned long flags;
drivers/usb/serial/usb-serial.c +2 -2
@@ -361,7 +361,7 @@ static void serial_cleanup(struct tty_struct *tty)module_put (owner); } -static int serial_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t serial_write (struct tty_struct *tty,const u8 *buf,size_t count) {struct usb_serial_port *port = tty->driver_data;int retval = -ENODEV ;
@@ -369,7 +369,7 @@ static int serial_write(struct tty_struct *tty, const u8 *buf, int count)if (port->serial->dev->state ==USB_STATE_NOTATTACHED ) goto exit; -dev_dbg (&port->dev,"%s - %d byte(s)\n" , __func__, count); +dev_dbg (&port->dev,"%s - %zu byte(s)\n" , __func__, count); retval = port->serial->type->write (tty, port, buf, count);if (retval <0 )
include/linux/tty_driver.h +3 -3
@@ -72,8 +72,8 @@ struct serial_struct;* is closed for the last time freeing up the resources. This is * actually the second part of shutdown for routines that might sleep. * -* @write: ``int ()(struct tty_struct *tty, const unsigned char *buf, -* int count)`` +* @write: ``ssize_t ()(struct tty_struct *tty, const unsigned char *buf, +* size_t count)`` * * This routine is called by the kernel to write a series (@count) of * characters (@buf) to the @tty device. The characters may come from
@@ -356,7 +356,7 @@ struct tty_operations {void (*close)(struct tty_struct * tty,struct file * filp);void (*shutdown)(struct tty_struct *tty);void (*cleanup)(struct tty_struct *tty); -int (*write)(struct tty_struct *tty,const u8 *buf,int count); +ssize_t (*write)(struct tty_struct *tty,const u8 *buf,size_t count);int (*put_char)(struct tty_struct *tty,u8 ch);void (*flush_chars)(struct tty_struct *tty);unsigned int (*write_room)(struct tty_struct *tty);
net/bluetooth/rfcomm/tty.c +3 -2
@@ -779,14 +779,15 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)tty_port_close (&dev->port, tty, filp); } -static int rfcomm_tty_write (struct tty_struct *tty,const u8 *buf,int count) +static ssize_t rfcomm_tty_write (struct tty_struct *tty,const u8 *buf, +size_t count) {struct rfcomm_dev *dev = tty->driver_data;struct rfcomm_dlc *dlc = dev->dlc;struct sk_buff *skb;int sent =0 , size; -BT_DBG ("tty %p count %d" , tty, count); +BT_DBG ("tty %p count %zu" , tty, count);while (count) { size =min_t (uint, count, dlc->mtu);
Signature · 1 line
2.41.0
Re: [PATCH 29/36] tty: make tty_operations::write()'s count size_t
Quoted 7 lines · Jiri Slaby (SUSE)
Unify with the rest of the code. Use
size_tfor counts andssize_tfor retval.Signed-off-by Jiri Slaby (SUSE) <[email protected]>arch/m68k/emu/nfcon.c | 3 ++- drivers/tty/amiserial.c | 2 +-
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Jiri Slaby (SUSE)
maintainerPATCH 30/36 tty: audit: unify to u8
In reply to Jiri Slaby (SUSE)Somewhere, we use 'char', somewhere 'unsigned char'. Unify to 'u8' as the rest of the tty layer does.
--- drivers/tty/tty.h | 4 ++-- drivers/tty/tty_audit.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/tty/tty.h +2 -2
@@ -101,13 +101,13 @@ extern int tty_ldisc_autoload;#ifdef CONFIG_AUDIT void tty_audit_add_data (const struct tty_struct *tty,const void *data,size_t size); -void tty_audit_tiocsti (const struct tty_struct *tty,char ch); +void tty_audit_tiocsti (const struct tty_struct *tty,u8 ch);#else static inline void tty_audit_add_data (const struct tty_struct *tty,const void *data,size_t size) { } -static inline void tty_audit_tiocsti (const struct tty_struct *tty,char ch) +static inline void tty_audit_tiocsti (const struct tty_struct *tty,u8 ch) { }#endif
drivers/tty/tty_audit.c +3 -3
@@ -17,7 +17,7 @@ struct tty_audit_buf {dev_t dev;/* The TTY which the data is from */ bool icanon;size_t valid; -unsigned char *data;/* Allocated size N_TTY_BUF_SIZE */ +u8 *data;/* Allocated size N_TTY_BUF_SIZE */ };static struct tty_audit_buf *tty_audit_buf_ref (void )
@@ -59,7 +59,7 @@ static void tty_audit_buf_free(struct tty_audit_buf *buf) }static void tty_audit_log (const char *description,dev_t dev, -const unsigned char *data,size_t size) +const u8 *data,size_t size) {struct audit_buffer *ab;pid_t pid =task_pid_nr (current);
@@ -134,7 +134,7 @@ void tty_audit_fork(struct signal_struct *sig)/* * tty_audit_tiocsti - Log TIOCSTI */ -void tty_audit_tiocsti (const struct tty_struct *tty,char ch) +void tty_audit_tiocsti (const struct tty_struct *tty,u8 ch) {dev_t dev;
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 31/36 tty: ldops: unify to u8
In reply to Jiri Slaby (SUSE)Some hooks in struct tty_ldisc_ops still reference buffers by 'unsigned char'. Unify to 'u8' as the rest of the tty layer does.
--- drivers/bluetooth/hci_ldisc.c | 6 +++--- drivers/input/serio/serport.c | 4 ++-- drivers/net/ppp/ppp_async.c | 9 ++++----- drivers/net/ppp/ppp_synctty.c | 7 +++---- drivers/tty/n_gsm.c | 7 +++---- drivers/tty/n_hdlc.c | 6 +++--- drivers/tty/n_null.c | 7 +++---- drivers/tty/n_tty.c | 11 +++++------ include/linux/tty_ldisc.h | 13 ++++++------- net/nfc/nci/uart.c | 6 +++--- 10 files changed, 35 insertions(+), 41 deletions(-)
drivers/bluetooth/hci_ldisc.c +3 -3
@@ -807,14 +807,14 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, unsigned int cmd,* We don't provide read/write/poll interface for user space. */ static ssize_t hci_uart_tty_read (struct tty_struct *tty,struct file *file, -unsigned char *buf,size_t nr, -void **cookie,unsigned long offset) +u8 *buf,size_t nr,void **cookie, +unsigned long offset) {return 0 ; }static ssize_t hci_uart_tty_write (struct tty_struct *tty,struct file *file, -const unsigned char *data,size_t count) +const u8 *data,size_t count) {return 0 ; }
drivers/input/serio/serport.c +2 -2
@@ -158,8 +158,8 @@ static void serport_ldisc_receive(struct tty_struct *tty, const u8 *cp,*/ static ssize_t serport_ldisc_read (struct tty_struct * tty,struct file * file, -unsigned char *kbuf,size_t nr, -void **cookie,unsigned long offset) +u8 *kbuf,size_t nr,void **cookie, +unsigned long offset) {struct serport *serport = tty->disc_data;struct serio *serio;
drivers/net/ppp/ppp_async.c +4 -5
@@ -257,9 +257,8 @@ static void ppp_asynctty_hangup(struct tty_struct *tty)* Pppd reads and writes packets via /dev/ppp instead. */ static ssize_t -ppp_asynctty_read (struct tty_struct *tty,struct file *file, -unsigned char *buf,size_t count, -void **cookie,unsigned long offset) +ppp_asynctty_read (struct tty_struct *tty,struct file *file,u8 *buf, +size_t count,void **cookie,unsigned long offset) {return -EAGAIN ; }
@@ -269,8 +268,8 @@ ppp_asynctty_read(struct tty_struct *tty, struct file *file,* from the ppp generic stuff. */ static ssize_t -ppp_asynctty_write (struct tty_struct *tty,struct file *file, -const unsigned char *buf,size_t count) +ppp_asynctty_write (struct tty_struct *tty,struct file *file,const u8 *buf, +size_t count) {return -EAGAIN ; }
drivers/net/ppp/ppp_synctty.c +3 -4
@@ -255,8 +255,7 @@ static void ppp_sync_hangup(struct tty_struct *tty)* Pppd reads and writes packets via /dev/ppp instead. */ static ssize_t -ppp_sync_read (struct tty_struct *tty,struct file *file, -unsigned char *buf,size_t count, +ppp_sync_read (struct tty_struct *tty,struct file *file,u8 *buf,size_t count,void **cookie,unsigned long offset) {return -EAGAIN ;
@@ -267,8 +266,8 @@ ppp_sync_read(struct tty_struct *tty, struct file *file,* from the ppp generic stuff. */ static ssize_t -ppp_sync_write (struct tty_struct *tty,struct file *file, -const unsigned char *buf,size_t count) +ppp_sync_write (struct tty_struct *tty,struct file *file,const u8 *buf, +size_t count) {return -EAGAIN ; }
drivers/tty/n_gsm.c +3 -4
@@ -3638,9 +3638,8 @@ static void gsmld_write_wakeup(struct tty_struct *tty)* This code must be sure never to sleep through a hangup. */ -static ssize_t gsmld_read (struct tty_struct *tty,struct file *file, -unsigned char *buf,size_t nr, -void **cookie,unsigned long offset) +static ssize_t gsmld_read (struct tty_struct *tty,struct file *file,u8 *buf, +size_t nr,void **cookie,unsigned long offset) {return -EOPNOTSUPP ; }
@@ -3660,7 +3659,7 @@ static ssize_t gsmld_read(struct tty_struct *tty, struct file *file,*/ static ssize_t gsmld_write (struct tty_struct *tty,struct file *file, -const unsigned char *buf,size_t nr) +const u8 *buf,size_t nr) {struct gsm_mux *gsm = tty->disc_data;unsigned long flags;
drivers/tty/n_hdlc.c +3 -3
@@ -425,8 +425,8 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const u8 *data,* Returns the number of bytes returned or error code. */ static ssize_t n_hdlc_tty_read (struct tty_struct *tty,struct file *file, -__u8 *kbuf,size_t nr, -void **cookie,unsigned long offset) +u8 *kbuf,size_t nr,void **cookie, +unsigned long offset) {struct n_hdlc *n_hdlc = tty->disc_data;int ret =0 ;
@@ -518,7 +518,7 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,* Returns the number of bytes written (or error code). */ static ssize_t n_hdlc_tty_write (struct tty_struct *tty,struct file *file, -const unsigned char *data,size_t count) +const u8 *data,size_t count) {struct n_hdlc *n_hdlc = tty->disc_data;int error =0 ;
drivers/tty/n_null.c +3 -4
@@ -10,15 +10,14 @@* Copyright (C) Intel 2017 */ -static ssize_t n_null_read (struct tty_struct *tty,struct file *file, -unsigned char *buf,size_t nr, -void **cookie,unsigned long offset) +static ssize_t n_null_read (struct tty_struct *tty,struct file *file,u8 *buf, +size_t nr,void **cookie,unsigned long offset) {return -EOPNOTSUPP ; }static ssize_t n_null_write (struct tty_struct *tty,struct file *file, -const unsigned char *buf,size_t nr) +const u8 *buf,size_t nr) {return -EOPNOTSUPP ; }
drivers/tty/n_tty.c +5 -6
@@ -2128,12 +2128,11 @@ static int job_control(struct tty_struct *tty, struct file *file)* claims non-exclusive termios_rwsem; * publishes read_tail */ -static ssize_t n_tty_read (struct tty_struct *tty,struct file *file, -unsigned char *kbuf,size_t nr, -void **cookie,unsigned long offset) +static ssize_t n_tty_read (struct tty_struct *tty,struct file *file,u8 *kbuf, +size_t nr,void **cookie,unsigned long offset) {struct n_tty_data *ldata = tty->disc_data; -unsigned char *kb = kbuf; +u8 *kb = kbuf;DEFINE_WAIT_FUNC (wait, woken_wake_function);int c;int minimum, time;
@@ -2332,9 +2331,9 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,*/ static ssize_t n_tty_write (struct tty_struct *tty,struct file *file, -const unsigned char *buf,size_t nr) +const u8 *buf,size_t nr) { -const unsigned char *b = buf; +const u8 *b = buf;DEFINE_WAIT_FUNC (wait, woken_wake_function);int c;ssize_t retval =0 ;
include/linux/tty_ldisc.h +6 -7
@@ -90,8 +90,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* * Optional. * -* @read: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file, -* unsigned char *buf, size_t nr)`` +* @read: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file, u8 *buf, +* size_t nr)`` * * This function is called when the user requests to read from the @tty. * The line discipline will return whatever characters it has buffered up
@@ -102,7 +102,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,* Optional: %EIO unless provided. Can sleep. * * @write: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file, -* const unsigned char *buf, size_t nr)`` +* const u8 *buf, size_t nr)`` * * This function is called when the user requests to write to the @tty. * The line discipline will deliver the characters to the low-level tty
@@ -238,11 +238,10 @@ struct tty_ldisc_ops {int (*open)(struct tty_struct *tty);void (*close)(struct tty_struct *tty);void (*flush_buffer)(struct tty_struct *tty); -ssize_t (*read)(struct tty_struct *tty,struct file *file, -unsigned char *buf,size_t nr, -void **cookie,unsigned long offset); +ssize_t (*read)(struct tty_struct *tty,struct file *file,u8 *buf, +size_t nr,void **cookie,unsigned long offset);ssize_t (*write)(struct tty_struct *tty,struct file *file, -const unsigned char *buf,size_t nr); +const u8 *buf,size_t nr);int (*ioctl)(struct tty_struct *tty,unsigned int cmd,unsigned long arg); int (*compat_ioctl)(struct tty_struct *tty, unsigned int cmd,
net/nfc/nci/uart.c +3 -3
@@ -345,14 +345,14 @@ static int nci_uart_tty_ioctl(struct tty_struct *tty, unsigned int cmd,/* We don't provide read/write/poll interface for user space. */ static ssize_t nci_uart_tty_read (struct tty_struct *tty,struct file *file, -unsigned char *buf,size_t nr, -void **cookie,unsigned long offset) +u8 *buf,size_t nr,void **cookie, +unsigned long offset) {return 0 ; }static ssize_t nci_uart_tty_write (struct tty_struct *tty,struct file *file, -const unsigned char *data,size_t count) +const u8 *data,size_t count) {return 0 ; }
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 32/36 tty: hvc: convert counts to size_t
In reply to Jiri Slaby (SUSE)Unify the type of tty_operations::write() counters with the 'count' parameter. I.e. use size_t for them.
--- drivers/tty/hvc/hvc_console.c | 2 +- drivers/tty/hvc/hvcs.c | 6 +++--- drivers/tty/hvc/hvsi.c | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/tty/hvc/hvc_console.c +1 -1
@@ -500,7 +500,7 @@ static ssize_t hvc_write(struct tty_struct *tty, const u8 *buf, size_t count) {struct hvc_struct *hp = tty->driver_data;unsigned long flags; -int rsize, written =0 ; +size_t rsize, written =0 ;/* This write was probably executed during a tty close. */ if (!hp)
drivers/tty/hvc/hvcs.c +3 -3
@@ -1263,8 +1263,8 @@ static ssize_t hvcs_write(struct tty_struct *tty, const u8 *buf, size_t count)unsigned int unit_address;const unsigned char *charbuf;unsigned long flags; -int total_sent =0 ; -int tosend =0 ; +size_t total_sent =0 ; +size_t tosend =0 ;int result =0 ;/*
@@ -1299,7 +1299,7 @@ static ssize_t hvcs_write(struct tty_struct *tty, const u8 *buf, size_t count) unit_address = hvcsd->vdev->unit_address;while (count >0 ) { - tosend =min_t (unsigned, count, + tosend =min_t (size_t, count, (HVCS_BUFF_LEN - hvcsd->chars_in_buffer));/* * No more space, this probably means that the last call to
drivers/tty/hvc/hvsi.c +5 -5
@@ -909,8 +909,8 @@ static ssize_t hvsi_write(struct tty_struct *tty, const u8 *source, {struct hvsi_struct *hp = tty->driver_data;unsigned long flags; -int total =0 ; -int origcount = count; +size_t total =0 ; +size_t origcount = count;spin_lock_irqsave (&hp->lock, flags);
@@ -928,7 +928,7 @@ static ssize_t hvsi_write(struct tty_struct *tty, const u8 *source,* will see there is no room in outbuf and return. */ while ((count >0 ) && (hvsi_write_room (tty) >0 )) { -int chunksize =min_t (int, count,hvsi_write_room (tty)); +size_t chunksize =min_t (size_t, count,hvsi_write_room (tty));BUG_ON (hp->n_outbuf <0 );memcpy (hp->outbuf + hp->n_outbuf, source, chunksize);
@@ -952,8 +952,8 @@ static ssize_t hvsi_write(struct tty_struct *tty, const u8 *source,spin_unlock_irqrestore (&hp->lock, flags);if (total != origcount) -pr_debug ("%s: wanted %i, only wrote %i\n" , __func__, origcount, - total); +pr_debug ("%s: wanted %zu, only wrote %zu\n" , __func__, + origcount, total);return total; }
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 33/36 tty: vcc: convert counts to size_t
In reply to Jiri Slaby (SUSE)Unify the type of tty_operations::write() counters with the 'count' parameter. I.e. use size_t for them.
This includes changing vcc_port::chars_in_buffer to size_t to keep min() and avoid min_t().
--- arch/sparc/include/asm/vio.h | 2 +- drivers/tty/vcc.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
arch/sparc/include/asm/vio.h +1 -1
@@ -284,7 +284,7 @@ struct vio_dring_state {struct ldc_trans_cookie cookies[VIO_MAX_RING_COOKIES ]; }; -#define VIO_TAG_SIZE ((int)sizeof(struct vio_msg_tag)) +#define VIO_TAG_SIZE (sizeof(struct vio_msg_tag))#define VIO_VCC_MTU_SIZE (LDC_PACKET_SIZE - VIO_TAG_SIZE)struct vio_vcc {
drivers/tty/vcc.c +6 -6
@@ -36,7 +36,7 @@ struct vcc_port {* and guarantee that any characters that the driver accepts will * be eventually sent, either immediately or later. */ -int chars_in_buffer; +size_t chars_in_buffer;struct vio_vcc buffer;struct timer_list rx_timer;
@@ -385,7 +385,7 @@ static void vcc_tx_timer(struct timer_list *t)struct vcc_port *port =from_timer (port, t, tx_timer);struct vio_vcc *pkt;unsigned long flags; -int tosend =0 ; +size_t tosend =0 ;int rv;spin_lock_irqsave (&port->lock, flags);
@@ -809,8 +809,8 @@ static ssize_t vcc_write(struct tty_struct *tty, const u8 *buf, size_t count)struct vcc_port *port;struct vio_vcc *pkt;unsigned long flags; -int total_sent =0 ; -int tosend =0 ; +size_t total_sent =0 ; +size_t tosend =0 ;int rv = -EINVAL ; port =vcc_get_ne (tty->index);
@@ -847,7 +847,7 @@ static ssize_t vcc_write(struct tty_struct *tty, const u8 *buf, size_t count)* hypervisor actually took it because we have it buffered. */ rv =ldc_write (port->vio.lp, pkt, (VIO_TAG_SIZE + tosend)); -vccdbg ("VCC: write: ldc_write(%d)=%d\n" , +vccdbg ("VCC: write: ldc_write(%zu)=%d\n" , (VIO_TAG_SIZE + tosend), rv); total_sent += tosend;
@@ -864,7 +864,7 @@ static ssize_t vcc_write(struct tty_struct *tty, const u8 *buf, size_t count)vcc_put (port, false); -vccdbg ("VCC: write: total=%d rv=%d" , total_sent, rv); +vccdbg ("VCC: write: total=%zu rv=%d" , total_sent, rv);return total_sent ? total_sent : rv; }
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 34/36 tty: gdm724x: convert counts to size_t
In reply to Jiri Slaby (SUSE)Unify the type of tty_operations::write() counters with the 'count' parameter. I.e. use size_t for them.
This includes changing constants to UL to keep min() and avoid min_t().
--- drivers/staging/gdm724x/gdm_tty.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/gdm724x/gdm_tty.c +5 -6
@@ -17,9 +17,9 @@#define GDM_TTY_MAJOR 0#define GDM_TTY_MINOR 32 -#define WRITE_SIZE 2048 +#define WRITE_SIZE 2048UL -#define MUX_TX_MAX_SIZE 2048 +#define MUX_TX_MAX_SIZE 2048ULstatic inline bool gdm_tty_ready (struct gdm *gdm) {
@@ -152,9 +152,8 @@ static void gdm_tty_send_complete(void *arg)static ssize_t gdm_tty_write (struct tty_struct *tty,const u8 *buf,size_t len) {struct gdm *gdm = tty->driver_data; -int remain = len; -int sent_len =0 ; -int sending_len =0 ; +size_t remain = len; +size_t sent_len =0 ;if (!gdm_tty_ready (gdm))return -ENODEV ;
@@ -163,7 +162,7 @@ static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len)return 0 ;while (1 ) { - 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, (void *)(buf + sent_len), sending_len,
Signature · 1 line
2.41.0
Re: [PATCH 34/36] tty: gdm724x: convert counts to size_t
Quoted 28 lines · Jiri Slaby (SUSE)
Unify the type of
tty_operations::write()counters with the 'count' parameter. I.e. usesize_tfor them.This includes changing constants to UL to keep
min()and avoidmin_t().Signed-off-by Jiri Slaby (SUSE) <[email protected]>--- drivers/staging/gdm724x/gdm_tty.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/staging/gdm724x/gdm_tty.c +2
-2@@ -17,9 +17,9 @@#define GDM_TTY_MAJOR 0#define GDM_TTY_MINOR 32 -#define WRITE_SIZE 2048 +#define WRITE_SIZE 2048UL -#define MUX_TX_MAX_SIZE 2048 +#define MUX_TX_MAX_SIZE 2048ULstatic inline bool gdm_tty_ready (struct gdm *gdm) {
drivers/staging/gdm724x/gdm_tty.c static void gdm_tty_send_complete(void *arg) · line 155
Quoted 7 lines
drivers/staging/gdm724x/gdm_tty.c +1
-3@@ -152,9 +152,8 @@ static void gdm_tty_send_complete(void *arg)static ssize_t gdm_tty_write (struct tty_struct *tty,const u8 *buf,size_t len) {struct gdm *gdm = tty->driver_data; -int remain = len; -int sent_len =0 ; -int sending_len =0 ; +size_t remain = len;
We later check if remain <= 0. It still works because remain could never be negative, but now it's even less necessary to check for negatives, I guess.
regards,
dan carpenter
Jiri Slaby
maintainerRe: [PATCH 34/36] tty: gdm724x: convert counts to size_t
Quoted 26 lines · Dan Carpenter
Quoted 25 lines · Jiri Slaby (SUSE)
Unify the type of
tty_operations::write()counters with the 'count' parameter. I.e. usesize_tfor them.This includes changing constants to UL to keep
min()and avoidmin_t().Signed-off-by Jiri Slaby (SUSE) <[email protected]>--- drivers/staging/gdm724x/gdm_tty.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/staging/gdm724x/gdm_tty.c +2
-2@@ -17,9 +17,9 @@#define GDM_TTY_MAJOR 0#define GDM_TTY_MINOR 32 -#define WRITE_SIZE 2048 +#define WRITE_SIZE 2048UL -#define MUX_TX_MAX_SIZE 2048 +#define MUX_TX_MAX_SIZE 2048UL
Quoted 14 lines
drivers/staging/gdm724x/gdm_tty.c static void gdm_tty_send_complete(void *arg) · line 155
Quoted 10 lines
drivers/staging/gdm724x/gdm_tty.c +1
-3static inline bool gdm_tty_ready (struct gdm *gdm) {@@ -152,9 +152,8 @@ static void gdm_tty_send_complete(void *arg)static ssize_t gdm_tty_write (struct tty_struct *tty,const u8 *buf,size_t len) {struct gdm *gdm = tty->driver_data; -int remain = len; -int sent_len =0 ; -int sending_len =0 ; +size_t remain = len;We later check if remain <= 0. It still works because remain could never be negative, but now it's even less necessary to check for negatives, I guess.
You're right. The whole loop should be now:
while (remain) {
...
}
Even without the preceding 'if'.
thanks,
Signature · 2 lines
js suse labs
Jiri Slaby (SUSE)
maintainerPATCH 1/1 tty: gdm724x: simplify gdm_tty_write()
In reply to Dan Carpenterlen 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.
--- drivers/staging/gdm724x/gdm_tty.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/staging/gdm724x/gdm_tty.c +1 -6
@@ -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;
Signature · 1 line
2.41.0
Re: [PATCH 34-and-three-quarters/36] tty: gdm724x: simplify gdm_tty_write()
Quoted 7 lines · Jiri Slaby (SUSE)
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) <[email protected]>Reported-by Dan Carpenter <[email protected]>
I guess Suggested-by would be more appropriate since there's no problem being fixed here.
Quoted 1 line
Signature · 1 line
i.
Quoted 30 lines
--- drivers/staging/gdm724x/gdm_tty.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/staging/gdm724x/gdm_tty.c +1
-6@@ -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;
Re: [PATCH 34/36] tty: gdm724x: convert counts to size_t
In reply to Jiri Slaby (SUSE)Quoted 4 lines · Jiri Slaby (SUSE)
Unify the type of
tty_operations::write()counters with the 'count' parameter. I.e. usesize_tfor them.This includes changing constants to UL to keep
min()and avoidmin_t().
This patch appears to cause a warning/error on 32-bit architectures now due to this part of the change, as size_t is 'unsigned int' there:
In file included from include/linux/kernel.h:27,
from drivers/staging/gdm724x/gdm_tty.c:6:
drivers/staging/gdm724x/gdm_tty.c: In function 'gdm_tty_write':
include/linux/minmax.h:21:35: error: comparison of distinct pointer types lacks a cast [-Werror]
21 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
| ^~
include/linux/minmax.h:27:18: note: in expansion of macro '__typecheck'
27 | (__typecheck(x, y) && __no_side_effects(x, y))
| ^~~~~~~~~~~
include/linux/minmax.h:37:31: note: in expansion of macro '__safe_cmp'
37 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~
include/linux/minmax.h:68:25: note: in expansion of macro '__careful_cmp'
68 | #define min(x, y) __careful_cmp(x, y, <)
| ^~~~~~~~~~~~~
drivers/staging/gdm724x/gdm_tty.c:162:38: note: in expansion of macro 'min'
162 | size_t sending_len = min(MUX_TX_MAX_SIZE, remain);
| ^~~cc1: all warnings being treated as errors
Quoted 46 lines
Signed-off-by Jiri Slaby (SUSE) <[email protected]>--- drivers/staging/gdm724x/gdm_tty.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/staging/gdm724x/gdm_tty.c +5
-6@@ -17,9 +17,9 @@#define GDM_TTY_MAJOR 0#define GDM_TTY_MINOR 32 -#define WRITE_SIZE 2048 +#define WRITE_SIZE 2048UL -#define MUX_TX_MAX_SIZE 2048 +#define MUX_TX_MAX_SIZE 2048ULstatic inline bool gdm_tty_ready (struct gdm *gdm) {@@ -152,9 +152,8 @@ static void gdm_tty_send_complete(void *arg)static ssize_t gdm_tty_write (struct tty_struct *tty,const u8 *buf,size_t len) {struct gdm *gdm = tty->driver_data; -int remain = len; -int sent_len =0 ; -int sending_len =0 ; +size_t remain = len; +size_t sent_len =0 ;if (!gdm_tty_ready (gdm))return -ENODEV ;@@ -163,7 +162,7 @@ static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len)return 0 ;while (1 ) { - 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, (void *)(buf + sent_len), sending_len,Signature · 1 line
2.41.0
Jiri Slaby
maintainerRe: [PATCH 34/36] tty: gdm724x: convert counts to size_t
Quoted 8 lines · Nathan Chancellor
Quoted 4 lines · Jiri Slaby (SUSE)
Unify the type of
tty_operations::write()counters with the 'count' parameter. I.e. usesize_tfor them.This includes changing constants to UL to keep
min()and avoidmin_t().This patch appears to cause a warning/error on 32-bit architectures now due to this part of the change, as
size_tis 'unsigned int' there:
Right, this is my brain fart thinking ulong is the same as size_t everywhere. No, size_t is uint on 32bit.
I will fix this -- kernel build bot seems to be slow -- it didn't find the issue out in my queue, nor in tty-testing.
thanks,
Signature · 2 lines
js suse labs
RE: [PATCH 34/36] tty: gdm724x: convert counts to size_t
From: Jiri Slaby
Quoted 9 lines
Sent: Wednesday, August 16, 2023 7:47 AM
Quoted 6 lines · Nathan Chancellor
Quoted 4 lines · Jiri Slaby (SUSE)
Unify the type of
tty_operations::write()counters with the 'count' parameter. I.e. usesize_tfor them.This includes changing constants to UL to keep
min()and avoidmin_t().
Quoted 8 lines
Quoted 2 lines
This patch appears to cause a warning/error on 32-bit architectures now due to this part of the change, as
size_tis 'unsigned int' there:Right, this is my brain fart thinking ulong is the same as
size_teverywhere. No,size_tis uint on 32bit.I will fix this -- kernel build bot seems to be slow -- it didn't find the issue out in my queue, nor in tty-testing.
'Vote up' my patches to minmax.h that make this all work. Then it won't care provided both values have the same signedness. (or, with patch 5, are non-negative 31bit compile time constants.)
Pretty much the only other patch is casting the constants to (size_t).
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Jiri Slaby
maintainerRe: [PATCH 34/36] tty: gdm724x: convert counts to size_t
Quoted 16 lines · David Laight
From: Jiri Slaby
Quoted 15 lines
Sent: Wednesday, August 16, 2023 7:47 AM
Quoted 8 lines · Nathan Chancellor
Quoted 4 lines · Jiri Slaby (SUSE)
Unify the type of
tty_operations::write()counters with the 'count' parameter. I.e. usesize_tfor them.This includes changing constants to UL to keep
min()and avoidmin_t().This patch appears to cause a warning/error on 32-bit architectures now due to this part of the change, as
size_tis 'unsigned int' there:Right, this is my brain fart thinking ulong is the same as
size_teverywhere. No,size_tis uint on 32bit.
Quoted 6 lines
Quoted 2 lines
I will fix this -- kernel build bot seems to be slow -- it didn't find the issue out in my queue, nor in tty-testing.
'Vote up' my patches to
minmax.hthat make this all work. Then it won't care provided both values have the same signedness. (or, with patch 5, are non-negative 31bit compile time constants.)
Oh yeah, that [1] looks great. Why should one care in min(4096, sizeof()) after all…
So what's the current status of those?
[1] https://lore.kernel.org/all/[email protected]/
thanks,
Signature · 2 lines
js suse labs
RE: [PATCH 34/36] tty: gdm724x: convert counts to size_t
From: Jiri Slaby
Quoted 1 line
Sent: Wednesday, August 16, 2023 9:59 AM
...
Quoted 8 lines
Quoted 3 lines
'Vote up' my patches to
minmax.hthat make this all work. Then it won't care provided both values have the same signedness. (or, with patch 5, are non-negative 31bit compile time constants.)Oh yeah, that [1] looks great. Why should one care in
min(4096, sizeof())after all…So what's the current status of those?
Waiting... :-(
The only comment is from Linus who really doesn't like the idea that min(signed_var, 4u) should be the same as min(signed_var, 4). I think he is ok with min(unsigned_var, 4) though.
The min_t(u16,...) I quoted from the console buffer code is a real bug that was identified by someone else last week.
Really min_t() is just an accident waiting to happen.
David
Quoted 8 lines
[1]
https://lore.kernel.org/all/[email protected]/thanks,
--
js
suse labs
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Jiri Slaby (SUSE)
maintainerPATCH 35/36 tty: hso: simplify hso_serial_write()
In reply to Jiri Slaby (SUSE)There is no need for two more variables in hso_serial_write(). Switch to min_t() and eliminate those.
Furthermore, the 'if-goto' is superfluous as memcpy() of zero count is a nop. So is addition of zero. So remove the 'if-goto' completely.
--- drivers/net/usb/hso.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/net/usb/hso.c +5 -11
@@ -1326,7 +1326,6 @@ static ssize_t hso_serial_write(struct tty_struct *tty, const u8 *buf, size_t count) {struct hso_serial *serial = tty->driver_data; -int space, tx_bytes;unsigned long flags;/* sanity check */
@@ -1337,21 +1336,16 @@ static ssize_t hso_serial_write(struct tty_struct *tty, const u8 *buf,spin_lock_irqsave (&serial->serial_lock, flags); - space = serial->tx_data_length - serial->tx_buffer_count; - tx_bytes = (count < space) ? count : space; + count =min_t (size_t, serial->tx_data_length - serial->tx_buffer_count, + count); +memcpy (serial->tx_buffer + serial->tx_buffer_count, buf, count); + serial->tx_buffer_count += count; -if (!tx_bytes) - goto out; - -memcpy (serial->tx_buffer + serial->tx_buffer_count, buf, tx_bytes); - serial->tx_buffer_count += tx_bytes; - -out:spin_unlock_irqrestore (&serial->serial_lock, flags);hso_kick_transmit (serial);/* done */ -return tx_bytes; +return count; }/* how much room is there for writing */
Signature · 1 line
2.41.0
Jiri Slaby (SUSE)
maintainerPATCH 36/36 tty: rfcomm: convert counts to size_t
In reply to Jiri Slaby (SUSE)Unify the type of tty_operations::write() counters with the 'count' parameter. I.e. use size_t for them.
--- net/bluetooth/rfcomm/tty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/rfcomm/tty.c +2 -2
@@ -785,12 +785,12 @@ static ssize_t rfcomm_tty_write(struct tty_struct *tty, const u8 *buf,struct rfcomm_dev *dev = tty->driver_data;struct rfcomm_dlc *dlc = dev->dlc;struct sk_buff *skb; -int sent =0 , size; +size_t sent =0 , size;BT_DBG ("tty %p count %zu" , tty, count);while (count) { - size =min_t (uint, count, dlc->mtu); + size =min_t (size_t, count, dlc->mtu); skb =rfcomm_wmalloc (dev, size +RFCOMM_SKB_RESERVE ,GFP_ATOMIC );if (!skb)
Signature · 1 line
2.41.0
Quoted 21 lines · Jiri Slaby (SUSE)
Currently, the tty layer ops and functions use various types for same things:
* characters and flags: unsigned char, char are used on a random basis,
* counts: int, unsigned int,size_tare used, again more-or-less randomly.This makes it rather hard to remember where each type is required and it also makes the code harder to follow. Also the code has to do
min_t()on many places simply because the variables hold the same kind of data, but of different type.This is the first part of the series to unify the types:
* make characters and flags 'u8'. This is what the hardware expects and what feeds the tty layer with. Since we compile with -funsigned-char, char and unsigned char are the same types on all platforms. So there is no actual change in type.
* make sizes/counts 'size_t'. This is what comes from the VFS layer and some tty functions already operate on this. So instead of using "shorter" (in term of bytes on 64bit) unsigned int, stick tosize_tand promote it to most places.
Quoted 5 lines
More cleanup and spreading will be done in
tty_buffer,n_tty, and likely other places later.Patches 1-8 are cleanups only. The rest (the real switch) depends on those.
Yeah, very much needed change and step into the right direction!
It's a bit tedious to review all this and comment a particular subchange but e.g. n_tty_receive_buf_common() still seems to still have int count which I think fall into the same call chain about size/count (probably most related change is #15). Note though that it also has room which I think can actually become negative so it might not be as straightforward search and replace like some other parts are.
At least for patches #1-#14,
Quoted 119 lines
Jiri Slaby (SUSE) (36):
tty: xtensa/iss: drop unneededtty_operationshooks
tty: ldisc: document that ldops are optional
tty: remove dummytty_ldisc_ops::poll()implementations
tty:n_null: remove optional ldops
tty: change tty_write_lock()'s ndelay parameter to bool
tty:tty_port: rename 'disc' to 'ld'
tty: droptty_debug_wait_until_sent()
tty: maketty_change_softcar()more understandable
tty: maketty_port_client_operationsoperate with u8
tty: make counts intty_port_client_operationshookssize_t
tty: switchreceive_buf()counts tosize_t
tty: switch count intty_ldisc_receive_buf()tosize_t
tty: can327: unify error paths incan327_ldisc_rx()
tty: can327, move overflow test inside can327_ldisc_rx()'s loop
tty: make tty_ldisc_ops::*buf*() hooks operate onsize_t
tty: use u8 for chars
tty: use u8 for flags
misc: ti-st: makest_recv()conforming totty_ldisc_ops::receive_buf()
tty: make char_buf_ptr()/flag_buf_ptr()'s offset unsigned
tty:tty_buffer: make all offsets unsigned
tty: don't passwrite()todo_tty_write()
tty: rename and de-inlinedo_tty_write()
tty: usemin()initerate_tty_write()
tty: usessize_tforiterate_tty_read()returned type
tty: switch size and count types initerate_tty_read()tosize_t
tty: usemin()for size computation initerate_tty_read()
tty: propagate u8 data totty_operations::write()
tty: propagate u8 data totty_operations::put_char()
tty: make tty_operations::write()'s countsize_t
tty: audit: unify to u8
tty: ldops: unify to u8
tty: hvc: convert counts tosize_t
tty: vcc: convert counts tosize_t
tty: gdm724x: convert counts tosize_t
tty: hso: simplifyhso_serial_write()
tty: rfcomm: convert counts tosize_tarch/alpha/kernel/srmcons.c | 5 +- arch/m68k/emu/nfcon.c | 8 +-- arch/sparc/include/asm/vio.h | 2 +- arch/um/drivers/line.c | 2 +- arch/um/drivers/line.h | 3 +- arch/xtensa/platforms/iss/console.c | 27 +-------- drivers/accessibility/speakup/spk_ttyio.c | 5 +- drivers/bluetooth/hci_ldisc.c | 15 ++--- drivers/char/ttyprintk.c | 5 +- drivers/input/serio/serport.c | 8 +-- drivers/ipack/devices/ipoctal.c | 7 +-- drivers/isdn/capi/capi.c | 8 +-- drivers/misc/bcm-vk/bcm_vk_tty.c | 5 +- drivers/misc/ti-st/st_core.c | 11 ++-- drivers/misc/ti-st/st_kim.c | 6 +- drivers/mmc/core/sdio_uart.c | 4 +- drivers/net/caif/caif_serial.c | 2 +- drivers/net/can/can327.c | 39 ++++++------- drivers/net/can/slcan/slcan-core.c | 5 +- drivers/net/hamradio/6pack.c | 4 +- drivers/net/hamradio/mkiss.c | 4 +- drivers/net/mctp/mctp-serial.c | 5 +- drivers/net/ppp/ppp_async.c | 26 +++------ drivers/net/ppp/ppp_synctty.c | 26 +++------ drivers/net/slip/slip.c | 4 +- drivers/net/usb/hso.c | 20 +++---- drivers/s390/char/con3215.c | 6 +- drivers/s390/char/con3270.c | 6 +- drivers/s390/char/sclp_tty.c | 10 ++-- drivers/s390/char/sclp_vt220.c | 6 +- drivers/staging/gdm724x/gdm_tty.c | 14 ++--- drivers/staging/greybus/uart.c | 3 +- drivers/tty/amiserial.c | 4 +- drivers/tty/ehv_bytechan.c | 4 +- drivers/tty/goldfish.c | 7 +-- drivers/tty/hvc/hvc_console.c | 4 +- drivers/tty/hvc/hvcs.c | 10 ++-- drivers/tty/hvc/hvsi.c | 14 ++--- drivers/tty/ipwireless/hardware.c | 2 +- drivers/tty/ipwireless/tty.c | 4 +- drivers/tty/mips_ejtag_fdc.c | 6 +- drivers/tty/moxa.c | 8 +-- drivers/tty/mxser.c | 4 +- drivers/tty/n_gsm.c | 14 ++--- drivers/tty/n_hdlc.c | 12 ++-- drivers/tty/n_null.c | 25 +-------- drivers/tty/n_tty.c | 59 ++++++++++---------- drivers/tty/nozomi.c | 6 +- drivers/tty/pty.c | 2 +- drivers/tty/rpmsg_tty.c | 5 +- drivers/tty/serdev/serdev-ttyport.c | 4 +- drivers/tty/serial/kgdb_nmi.c | 3 +- drivers/tty/serial/serial_core.c | 5 +- drivers/tty/synclink_gt.c | 13 ++--- drivers/tty/tty.h | 8 +-- drivers/tty/tty_audit.c | 6 +- drivers/tty/tty_buffer.c | 35 ++++++------ drivers/tty/tty_io.c | 46 +++++++--------- drivers/tty/tty_ioctl.c | 18 ++---- drivers/tty/tty_port.c | 34 ++++++------ drivers/tty/ttynull.c | 4 +- drivers/tty/vcc.c | 18 +++--- drivers/tty/vt/selection.c | 2 +- drivers/tty/vt/vt.c | 6 +- drivers/usb/class/cdc-acm.c | 8 +-- drivers/usb/gadget/function/u_serial.c | 6 +- drivers/usb/host/xhci-dbgtty.c | 7 +-- drivers/usb/serial/usb-serial.c | 5 +- include/linux/ti_wilink_st.h | 2 +- include/linux/tty_buffer.h | 18 +++--- include/linux/tty_driver.h | 9 ++- include/linux/tty_flip.h | 22 ++++---- include/linux/tty_ldisc.h | 67 +++++++++++++++-------- include/linux/tty_port.h | 7 ++- net/bluetooth/rfcomm/tty.c | 9 +-- net/nfc/nci/uart.c | 15 ++--- sound/soc/codecs/cx20442.c | 4 +- sound/soc/ti/ams-delta.c | 2 +- 78 files changed, 381 insertions(+), 493 deletions(-)
Signature · 1 line
i.
Jiri Slaby
maintainerQuoted 29 lines · Ilpo Järvinen
Quoted 21 lines · Jiri Slaby (SUSE)
Currently, the tty layer ops and functions use various types for same things:
* characters and flags: unsigned char, char are used on a random basis,
* counts: int, unsigned int,size_tare used, again more-or-less randomly.This makes it rather hard to remember where each type is required and it also makes the code harder to follow. Also the code has to do
min_t()on many places simply because the variables hold the same kind of data, but of different type.This is the first part of the series to unify the types:
* make characters and flags 'u8'. This is what the hardware expects and what feeds the tty layer with. Since we compile with -funsigned-char, char and unsigned char are the same types on all platforms. So there is no actual change in type.
* make sizes/counts 'size_t'. This is what comes from the VFS layer and some tty functions already operate on this. So instead of using "shorter" (in term of bytes on 64bit) unsigned int, stick tosize_tand promote it to most places.Quoted 5 lines
More cleanup and spreading will be done in
tty_buffer,n_tty, and likely other places later.Patches 1-8 are cleanups only. The rest (the real switch) depends on those.
Quoted 8 lines
Yeah, very much needed change and step into the right direction!
It's a bit tedious to review all this and comment a particular subchange but e.g.
n_tty_receive_buf_common()still seems to still have int count which I think fall into the same call chain about size/count (probably most related change is #15). Note though that it also has room which I think can actually become negative so it might not be as straightforward search and replace like some other parts are.
----
Yes, sorry, my bad -- I forgot to elaborate on why this is "part I." and what is going to be part II., III., ...
So yeah, I have more in my queue which is growing a lot. I had to cut it at some point as I was losing myself in all the changes already. So I flushed this "part I.". It is only a minimalistic change in the core and necessary changes in drivers' hooks. Parts II. and on will spread this more, of course. Ideally, to every single loop in every driver ;) (in long-term).
I still have a bunch of changes for tty_buffer and n_tty in my queue. As soon as I rebase on the today's -next which is already supposed to contain this part I., I will send part II. with these changes. I could have merged those II. changes to some earlier I. patches. At first, I actually did try, but the patches were growing with more and more dependencies, so I stopped this approach. Instead, I separated the changes per the core/ldisc/drivers. The parts are self-contained, despite it might look like the changes are incomplete (i.e. not everything is changed everywhere). After all, I wanted to avoid one hundred+ patches series.
thanks,
Signature · 2 lines
js suse labs
Quoted 53 lines · Jiri Slaby
Quoted 29 lines · Ilpo Järvinen
Quoted 21 lines · Jiri Slaby (SUSE)
Currently, the tty layer ops and functions use various types for same things:
* characters and flags: unsigned char, char are used on a random basis,
* counts: int, unsigned int,size_tare used, again more-or-less randomly.This makes it rather hard to remember where each type is required and it also makes the code harder to follow. Also the code has to do
min_t()on many places simply because the variables hold the same kind of data, but of different type.This is the first part of the series to unify the types:
* make characters and flags 'u8'. This is what the hardware expects and what feeds the tty layer with. Since we compile with -funsigned-char, char and unsigned char are the same types on all platforms. So there is no actual change in type.
* make sizes/counts 'size_t'. This is what comes from the VFS layer and some tty functions already operate on this. So instead of using "shorter" (in term of bytes on 64bit) unsigned int, stick tosize_tand promote it to most places.Quoted 5 lines
More cleanup and spreading will be done in
tty_buffer,n_tty, and likely other places later.Patches 1-8 are cleanups only. The rest (the real switch) depends on those.
Quoted 8 lines
Yeah, very much needed change and step into the right direction!
It's a bit tedious to review all this and comment a particular subchange but e.g.
n_tty_receive_buf_common()still seems to still have int count which I think fall into the same call chain about size/count (probably most related change is #15). Note though that it also has room which I think can actually become negative so it might not be as straightforward search and replace like some other parts are.----
Yes, sorry, my bad -- I forgot to elaborate on why this is "part I." and what is going to be part II., III., ...
So yeah, I have more in my queue which is growing a lot. I had to cut it at some point as I was losing myself in all the changes already. So I flushed this "part I.". It is only a minimalistic change in the core and necessary changes in drivers' hooks. Parts II. and on will spread this more, of course. Ideally, to every single loop in every driver ;) (in long-term).
Quoted 9 lines
I still have a bunch of changes for
tty_bufferandn_ttyin my queue. As soon as I rebase on the today's -next which is already supposed to contain this part I., I will send part II. with these changes. I could have merged those II. changes to some earlier I. patches. At first, I actually did try, but the patches were growing with more and more dependencies, so I stopped this approach. Instead, I separated the changes per the core/ldisc/drivers. The parts are self-contained, despite it might look like the changes are incomplete (i.e. not everything is changed everywhere). After all, I wanted to avoid one hundred+ patches series.
Yeah, right. Very much understandable. I realized you probably had more patches somewhere due to "Part I" designation but I couldn't check so I just noted the things that I came up during the review.
Signature · 1 line
i.