linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/36] tty: type unifications -- part I.
@ 2023-08-10  9:14 Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 01/36] tty: xtensa/iss: drop unneeded tty_operations hooks Jiri Slaby (SUSE)
                   ` (36 more replies)
  0 siblings, 37 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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_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(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 01/36] tty: xtensa/iss: drop unneeded tty_operations hooks
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10 12:37   ` Max Filippov
  2023-08-10  9:14 ` [PATCH 02/36] tty: ldisc: document that ldops are optional Jiri Slaby (SUSE)
                   ` (35 subsequent siblings)
  36 siblings, 1 reply; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Chris Zankel,
	Max Filippov

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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
---
 arch/xtensa/platforms/iss/console.c | 24 ------------------------
 1 file changed, 24 deletions(-)

diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 10b79d3c74e0..b40b73809dd8 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -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,
 };
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 02/36] tty: ldisc: document that ldops are optional
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 01/36] tty: xtensa/iss: drop unneeded tty_operations hooks Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 03/36] tty: remove dummy tty_ldisc_ops::poll() implementations Jiri Slaby (SUSE)
                   ` (34 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 include/linux/tty_ldisc.h | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index 49dc172dedc7..62e089434995 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -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
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 03/36] tty: remove dummy tty_ldisc_ops::poll() implementations
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 01/36] tty: xtensa/iss: drop unneeded tty_operations hooks Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 02/36] tty: ldisc: document that ldops are optional Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 04/36] tty: n_null: remove optional ldops Jiri Slaby (SUSE)
                   ` (33 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Marcel Holtmann,
	Johan Hedberg, Luiz Augusto von Dentz, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Krzysztof Kozlowski

tty_ldisc_ops::poll() is optional and needs not be provided. It is equal
to returning 0. So remove all those from the code.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 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(-)

diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index a76eb98c0047..759472686831 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -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,
 };
diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c
index 15a179631903..f420bddb6a8c 100644
--- a/drivers/net/ppp/ppp_async.c
+++ b/drivers/net/ppp/ppp_async.c
@@ -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,
 };
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index 18283b7b94bc..86dacef84c6c 100644
--- a/drivers/net/ppp/ppp_synctty.c
+++ b/drivers/net/ppp/ppp_synctty.c
@@ -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,
 };
diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c
index 082f94be0996..c8249d95306d 100644
--- a/net/nfc/nci/uart.c
+++ b/net/nfc/nci/uart.c
@@ -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,
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 04/36] tty: n_null: remove optional ldops
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (2 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 03/36] tty: remove dummy tty_ldisc_ops::poll() implementations Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 05/36] tty: change tty_write_lock()'s ndelay parameter to bool Jiri Slaby (SUSE)
                   ` (32 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/n_null.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/drivers/tty/n_null.c b/drivers/tty/n_null.c
index f913b665af72..4a0d8bb2fb4c 100644
--- a/drivers/tty/n_null.c
+++ b/drivers/tty/n_null.c
@@ -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)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 05/36] tty: change tty_write_lock()'s ndelay parameter to bool
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (3 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 04/36] tty: n_null: remove optional ldops Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 06/36] tty: tty_port: rename 'disc' to 'ld' Jiri Slaby (SUSE)
                   ` (31 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE)

It's a yes-no parameter, so convert it to bool to be obvious.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/tty.h       | 2 +-
 drivers/tty/tty_io.c    | 6 +++---
 drivers/tty/tty_ioctl.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h
index 89769a1f1f97..2751ac3946e7 100644
--- a/drivers/tty/tty.h
+++ b/drivers/tty/tty.h
@@ -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);
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index eb4e2e0e300d..54036a20a102 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -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)
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index 2e88b414cf95..e3e1318f53fd 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -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? */
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 06/36] tty: tty_port: rename 'disc' to 'ld'
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (4 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 05/36] tty: change tty_write_lock()'s ndelay parameter to bool Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 07/36] tty: drop tty_debug_wait_until_sent() Jiri Slaby (SUSE)
                   ` (30 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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").

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/tty_port.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index a788a6bf487d..cda33dec73c3 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -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)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 07/36] tty: drop tty_debug_wait_until_sent()
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (5 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 06/36] tty: tty_port: rename 'disc' to 'ld' Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 08/36] tty: make tty_change_softcar() more understandable Jiri Slaby (SUSE)
                   ` (29 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/tty_ioctl.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index e3e1318f53fd..f63e8b1b9e40 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -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;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 08/36] tty: make tty_change_softcar() more understandable
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (6 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 07/36] tty: drop tty_debug_wait_until_sent() Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 09/36] tty: make tty_port_client_operations operate with u8 Jiri Slaby (SUSE)
                   ` (28 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/tty_ioctl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index f63e8b1b9e40..7958bf6d27c4 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 09/36] tty: make tty_port_client_operations operate with u8
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (7 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 08/36] tty: make tty_change_softcar() more understandable Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 10/36] tty: make counts in tty_port_client_operations hooks size_t Jiri Slaby (SUSE)
                   ` (27 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Rob Herring

The parameters are already unsigned chars. So make them explicitly u8s,
as the rest is going to be unified to u8 eventually too.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Rob Herring <robh@kernel.org>
---
 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(-)

diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c
index 8033ef19669c..f69ae27838e3 100644
--- a/drivers/tty/serdev/serdev-ttyport.c
+++ b/drivers/tty/serdev/serdev-ttyport.c
@@ -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);
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 2df86ed90574..42464c37125a 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -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)
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index cda33dec73c3..6bf58980c81d 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -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;
diff --git a/include/linux/tty_port.h b/include/linux/tty_port.h
index edf685a24f7c..726575743367 100644
--- a/include/linux/tty_port.h
+++ b/include/linux/tty_port.h
@@ -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);
 };
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 10/36] tty: make counts in tty_port_client_operations hooks size_t
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (8 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 09/36] tty: make tty_port_client_operations operate with u8 Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 11/36] tty: switch receive_buf() counts to size_t Jiri Slaby (SUSE)
                   ` (26 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Rob Herring

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'.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Rob Herring <robh@kernel.org>
---
 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(-)

diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c
index f69ae27838e3..e3856814ce77 100644
--- a/drivers/tty/serdev/serdev-ttyport.c
+++ b/drivers/tty/serdev/serdev-ttyport.c
@@ -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);
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 6bf58980c81d..7fd171b7c844 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -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;
diff --git a/include/linux/tty_port.h b/include/linux/tty_port.h
index 726575743367..6b367eb17979 100644
--- a/include/linux/tty_port.h
+++ b/include/linux/tty_port.h
@@ -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);
 };
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 11/36] tty: switch receive_buf() counts to size_t
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (9 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 10/36] tty: make counts in tty_port_client_operations hooks size_t Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 12/36] tty: switch count in tty_ldisc_receive_buf() " Jiri Slaby (SUSE)
                   ` (25 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/tty_buffer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 42464c37125a..7182dab60fac 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -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))
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 12/36] tty: switch count in tty_ldisc_receive_buf() to size_t
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (10 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 11/36] tty: switch receive_buf() counts to size_t Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 13/36] tty: can327: unify error paths in can327_ldisc_rx() Jiri Slaby (SUSE)
                   ` (24 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 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(-)

diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 7182dab60fac..56f5732ce47f 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -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);
 	}
diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index 6ef22f01cc51..8967c3a0d916 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -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;
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
index bfaaeee61a05..09c4dbcd0025 100644
--- a/include/linux/tty_flip.h
+++ b/include/linux/tty_flip.h
@@ -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);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 13/36] tty: can327: unify error paths in can327_ldisc_rx()
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (11 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 12/36] tty: switch count in tty_ldisc_receive_buf() " Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-11 21:32   ` Max Staudt
  2023-08-10  9:14 ` [PATCH 14/36] tty: can327, move overflow test inside can327_ldisc_rx()'s loop Jiri Slaby (SUSE)
                   ` (23 subsequent siblings)
  36 siblings, 1 reply; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Max Staudt,
	Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-can

Create a label with can327_uart_side_failure() and spin unlock. And jump
there from all three fail paths.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Max Staudt <max@enpas.org>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: linux-can@vger.kernel.org
---
 drivers/net/can/can327.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/net/can/can327.c b/drivers/net/can/can327.c
index ee8a977acc8d..05e9c035e8f6 100644
--- a/drivers/net/can/can327.c
+++ b/drivers/net/can/can327.c
@@ -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.
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 14/36] tty: can327, move overflow test inside can327_ldisc_rx()'s loop
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (12 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 13/36] tty: can327: unify error paths in can327_ldisc_rx() Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-11 21:34   ` Max Staudt
  2023-08-10  9:14 ` [PATCH 15/36] tty: make tty_ldisc_ops::*buf*() hooks operate on size_t Jiri Slaby (SUSE)
                   ` (22 subsequent siblings)
  36 siblings, 1 reply; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Max Staudt,
	Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-can

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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Max Staudt <max@enpas.org>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: linux-can@vger.kernel.org
---
 drivers/net/can/can327.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/can/can327.c b/drivers/net/can/can327.c
index 05e9c035e8f6..4533dc00f215 100644
--- a/drivers/net/can/can327.c
+++ b/drivers/net/can/can327.c
@@ -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);
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 15/36] tty: make tty_ldisc_ops::*buf*() hooks operate on size_t
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (13 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 14/36] tty: can327, move overflow test inside can327_ldisc_rx()'s loop Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10 12:02   ` Mark Brown
  2023-08-11 21:34   ` Max Staudt
  2023-08-10  9:14 ` [PATCH 16/36] tty: use u8 for chars Jiri Slaby (SUSE)
                   ` (21 subsequent siblings)
  36 siblings, 2 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), William Hubbs,
	Chris Brannon, Kirk Reiser, Samuel Thibault, Marcel Holtmann,
	Johan Hedberg, Luiz Augusto von Dentz, Dmitry Torokhov,
	Arnd Bergmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Max Staudt, Wolfgang Grandegger, Marc Kleine-Budde,
	Dario Binacchi, Andreas Koensgen, Jeremy Kerr, Matt Johnston,
	Krzysztof Kozlowski, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai

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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: William Hubbs <w.d.hubbs@gmail.com>
Cc: Chris Brannon <chris@the-brannons.com>
Cc: Kirk Reiser <kirk@reisers.ca>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Max Staudt <max@enpas.org>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Cc: Andreas Koensgen <ajk@comnets.uni-bremen.de>
Cc: Jeremy Kerr <jk@codeconstruct.com.au>
Cc: Matt Johnston <matt@codeconstruct.com.au>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
---
 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(-)

diff --git a/drivers/accessibility/speakup/spk_ttyio.c b/drivers/accessibility/speakup/spk_ttyio.c
index 5d4bafe118ec..736f622068ce 100644
--- a/drivers/accessibility/speakup/spk_ttyio.c
+++ b/drivers/accessibility/speakup/spk_ttyio.c
@@ -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;
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 759472686831..3473c4b8751a 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -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;
 
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index a5d8953f5904..7fc6155131f8 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -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;
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index 3b2145722bd7..c89024ab3d77 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -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,
diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
index 688075859ae4..feda04dbe837 100644
--- a/drivers/net/caif/caif_serial.c
+++ b/drivers/net/caif/caif_serial.c
@@ -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;
diff --git a/drivers/net/can/can327.c b/drivers/net/can/can327.c
index 4533dc00f215..4bf970df7e84 100644
--- a/drivers/net/can/can327.c
+++ b/drivers/net/can/can327.c
@@ -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;
 		}
diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c
index 371af9d17b14..63371563d8e2 100644
--- a/drivers/net/can/slcan/slcan-core.c
+++ b/drivers/net/can/slcan/slcan-core.c
@@ -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;
 
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 9fb567524220..2089efb0d360 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -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;
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index c251e04ae047..1efab6037c7e 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -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);
 
diff --git a/drivers/net/mctp/mctp-serial.c b/drivers/net/mctp/mctp-serial.c
index 9f9eaf896047..6761f4ff2e7c 100644
--- a/drivers/net/mctp/mctp-serial.c
+++ b/drivers/net/mctp/mctp-serial.c
@@ -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;
diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c
index f420bddb6a8c..79b8fca47edb 100644
--- a/drivers/net/ppp/ppp_async.c
+++ b/drivers/net/ppp/ppp_async.c
@@ -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;
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index 86dacef84c6c..767aca32b315 100644
--- a/drivers/net/ppp/ppp_synctty.c
+++ b/drivers/net/ppp/ppp_synctty.c
@@ -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;
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index 6865d32270e5..39450bf748a5 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -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;
 
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index c7a787f10a9c..2f85877b8ba1 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -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;
diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index 46b09bfb6f3a..ce3c779f5c03 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -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)
 {
 	register struct n_hdlc *n_hdlc = tty->disc_data;
 	register struct 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");
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 0043cc84b91a..ee9b20dcbce6 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -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);
 }
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index 62e089434995..f88529e6a783 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -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;
 };
diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c
index c8249d95306d..c957ca6d2f87 100644
--- a/net/nfc/nci/uart.c
+++ b/net/nfc/nci/uart.c
@@ -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;
 
diff --git a/sound/soc/codecs/cx20442.c b/sound/soc/codecs/cx20442.c
index 43c0cac0ec9e..42cc863cbd53 100644
--- a/sound/soc/codecs/cx20442.c
+++ b/sound/soc/codecs/cx20442.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 16/36] tty: use u8 for chars
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (14 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 15/36] tty: make tty_ldisc_ops::*buf*() hooks operate on size_t Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10 12:04   ` Mark Brown
                     ` (2 more replies)
  2023-08-10  9:14 ` [PATCH 17/36] tty: use u8 for flags Jiri Slaby (SUSE)
                   ` (20 subsequent siblings)
  36 siblings, 3 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), William Hubbs,
	Chris Brannon, Kirk Reiser, Samuel Thibault, Dmitry Torokhov,
	Arnd Bergmann, Max Staudt, Wolfgang Grandegger, Marc Kleine-Budde,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Dario Binacchi, Andreas Koensgen, Jeremy Kerr, Matt Johnston,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Peter Ujfalusi

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) <jirislaby@kernel.org>
Cc: William Hubbs <w.d.hubbs@gmail.com>
Cc: Chris Brannon <chris@the-brannons.com>
Cc: Kirk Reiser <kirk@reisers.ca>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Max Staudt <max@enpas.org>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Cc: Andreas Koensgen <ajk@comnets.uni-bremen.de>
Cc: Jeremy Kerr <jk@codeconstruct.com.au>
Cc: Matt Johnston <matt@codeconstruct.com.au>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Peter Ujfalusi <peter.ujfalusi@gmail.com>
---
 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(-)

diff --git a/drivers/accessibility/speakup/spk_ttyio.c b/drivers/accessibility/speakup/spk_ttyio.c
index 736f622068ce..dd683a079c08 100644
--- a/drivers/accessibility/speakup/spk_ttyio.c
+++ b/drivers/accessibility/speakup/spk_ttyio.c
@@ -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;
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index 7fc6155131f8..8bf79d39964d 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -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;
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index c89024ab3d77..0ce4e46ff161 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -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
diff --git a/drivers/net/can/can327.c b/drivers/net/can/can327.c
index 4bf970df7e84..a054f5fd0d43 100644
--- a/drivers/net/can/can327.c
+++ b/drivers/net/can/can327.c
@@ -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;
diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c
index 63371563d8e2..fe5671dbeb77 100644
--- a/drivers/net/can/slcan/slcan-core.c
+++ b/drivers/net/can/slcan/slcan-core.c
@@ -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;
 
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 2089efb0d360..9a1f2a3f3b4f 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -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;
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 1efab6037c7e..26dbcf49bfa6 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -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);
diff --git a/drivers/net/mctp/mctp-serial.c b/drivers/net/mctp/mctp-serial.c
index 6761f4ff2e7c..5f809a18d308 100644
--- a/drivers/net/mctp/mctp-serial.c
+++ b/drivers/net/mctp/mctp-serial.c
@@ -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;
diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c
index 79b8fca47edb..a661ccdea6ab 100644
--- a/drivers/net/ppp/ppp_async.c
+++ b/drivers/net/ppp/ppp_async.c
@@ -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;
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index 767aca32b315..2a5cf6be9591 100644
--- a/drivers/net/ppp/ppp_synctty.c
+++ b/drivers/net/ppp/ppp_synctty.c
@@ -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;
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index 39450bf748a5..7bfa90724e7b 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -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;
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 2f85877b8ba1..86d89bbbaa16 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -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;
diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index ce3c779f5c03..c86be060baed 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -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)
 {
 	register struct n_hdlc *n_hdlc = tty->disc_data;
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index ee9b20dcbce6..d770007e5215 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -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);
 }
diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h
index 2751ac3946e7..e31cd9f281de 100644
--- a/drivers/tty/tty.h
+++ b/drivers/tty/tty.h
@@ -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
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 56f5732ce47f..9db42e6ed45b 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -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;
diff --git a/include/linux/tty_buffer.h b/include/linux/tty_buffer.h
index 6ceb2789e6c8..6f2966b15093 100644
--- a/include/linux/tty_buffer.h
+++ b/include/linux/tty_buffer.h
@@ -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)
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
index 09c4dbcd0025..a0fcffeaaa25 100644
--- a/include/linux/tty_flip.h
+++ b/include/linux/tty_flip.h
@@ -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);
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index f88529e6a783..5551c4400e59 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -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;
diff --git a/sound/soc/codecs/cx20442.c b/sound/soc/codecs/cx20442.c
index 42cc863cbd53..6d4938e3cbad 100644
--- a/sound/soc/codecs/cx20442.c
+++ b/sound/soc/codecs/cx20442.c
@@ -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;
diff --git a/sound/soc/ti/ams-delta.c b/sound/soc/ti/ams-delta.c
index 1028b5efcfff..371943350fdf 100644
--- a/sound/soc/ti/ams-delta.c
+++ b/sound/soc/ti/ams-delta.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 17/36] tty: use u8 for flags
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (15 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 16/36] tty: use u8 for chars Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10 12:05   ` Mark Brown
  2023-08-11 21:35   ` Max Staudt
  2023-08-10  9:14 ` [PATCH 18/36] misc: ti-st: make st_recv() conforming to tty_ldisc_ops::receive_buf() Jiri Slaby (SUSE)
                   ` (19 subsequent siblings)
  36 siblings, 2 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), William Hubbs,
	Chris Brannon, Kirk Reiser, Samuel Thibault, Marcel Holtmann,
	Johan Hedberg, Luiz Augusto von Dentz, Dmitry Torokhov,
	Arnd Bergmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Max Staudt, Wolfgang Grandegger, Marc Kleine-Budde,
	Dario Binacchi, Andreas Koensgen, Jeremy Kerr, Matt Johnston,
	Krzysztof Kozlowski, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai

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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: William Hubbs <w.d.hubbs@gmail.com>
Cc: Chris Brannon <chris@the-brannons.com>
Cc: Kirk Reiser <kirk@reisers.ca>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Max Staudt <max@enpas.org>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Cc: Andreas Koensgen <ajk@comnets.uni-bremen.de>
Cc: Jeremy Kerr <jk@codeconstruct.com.au>
Cc: Matt Johnston <matt@codeconstruct.com.au>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
---
 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(-)

diff --git a/drivers/accessibility/speakup/spk_ttyio.c b/drivers/accessibility/speakup/spk_ttyio.c
index dd683a079c08..4c0a6e1f019d 100644
--- a/drivers/accessibility/speakup/spk_ttyio.c
+++ b/drivers/accessibility/speakup/spk_ttyio.c
@@ -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;
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 3473c4b8751a..3e11fc06a932 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -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;
 
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index 8bf79d39964d..5ce8d9f10f3e 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -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;
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index 0ce4e46ff161..4467c5b94ae8 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -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,
diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
index feda04dbe837..ed3a589def6b 100644
--- a/drivers/net/caif/caif_serial.c
+++ b/drivers/net/caif/caif_serial.c
@@ -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;
diff --git a/drivers/net/can/can327.c b/drivers/net/can/can327.c
index a054f5fd0d43..24af63961030 100644
--- a/drivers/net/can/can327.c
+++ b/drivers/net/can/can327.c
@@ -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;
diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c
index fe5671dbeb77..24c6622d36bd 100644
--- a/drivers/net/can/slcan/slcan-core.c
+++ b/drivers/net/can/slcan/slcan-core.c
@@ -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;
 
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 9a1f2a3f3b4f..6ed38a3cdd73 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -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;
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 26dbcf49bfa6..5f38a002bd9e 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -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);
 
diff --git a/drivers/net/mctp/mctp-serial.c b/drivers/net/mctp/mctp-serial.c
index 5f809a18d308..5bf6fdff701c 100644
--- a/drivers/net/mctp/mctp-serial.c
+++ b/drivers/net/mctp/mctp-serial.c
@@ -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;
diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c
index a661ccdea6ab..cfd5cb609d99 100644
--- a/drivers/net/ppp/ppp_async.c
+++ b/drivers/net/ppp/ppp_async.c
@@ -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;
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index 2a5cf6be9591..164c9053f73b 100644
--- a/drivers/net/ppp/ppp_synctty.c
+++ b/drivers/net/ppp/ppp_synctty.c
@@ -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;
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index 7bfa90724e7b..e4280e37fec9 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -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;
 
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 86d89bbbaa16..a3bd1fc52aed 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -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;
diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index c86be060baed..9be0932d07e0 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -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)
 {
 	register struct n_hdlc *n_hdlc = tty->disc_data;
 	register struct n_hdlc_buf *buf;
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index d770007e5215..1053b2adb04c 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -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);
 }
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 9db42e6ed45b..684d099cbe11 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -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)
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 7fd171b7c844..624d104bd145 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -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);
 
diff --git a/include/linux/tty_buffer.h b/include/linux/tty_buffer.h
index 6f2966b15093..b11cc8c749d2 100644
--- a/include/linux/tty_buffer.h
+++ b/include/linux/tty_buffer.h
@@ -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 {
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
index a0fcffeaaa25..d33aed2172c7 100644
--- a/include/linux/tty_flip.h
+++ b/include/linux/tty_flip.h
@@ -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);
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index 5551c4400e59..a661d7df5497 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -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;
 };
diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c
index c957ca6d2f87..93775c540287 100644
--- a/net/nfc/nci/uart.c
+++ b/net/nfc/nci/uart.c
@@ -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;
 
diff --git a/sound/soc/codecs/cx20442.c b/sound/soc/codecs/cx20442.c
index 6d4938e3cbad..9d54141a0cd1 100644
--- a/sound/soc/codecs/cx20442.c
+++ b/sound/soc/codecs/cx20442.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 18/36] misc: ti-st: make st_recv() conforming to tty_ldisc_ops::receive_buf()
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (16 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 17/36] tty: use u8 for flags Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 19/36] tty: make char_buf_ptr()/flag_buf_ptr()'s offset unsigned Jiri Slaby (SUSE)
                   ` (18 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Arnd Bergmann

That is change data type to u8 and count to unsigned int. And propagate
to both hooks (st_kim_recv() and kim_int_recv()).

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
---
 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(-)

diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index 4467c5b94ae8..c1a134bd8ba7 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -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);
 
diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
index 5431a89924aa..fe682e0553b2 100644
--- a/drivers/misc/ti-st/st_kim.c
+++ b/drivers/misc/ti-st/st_kim.c
@@ -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;
diff --git a/include/linux/ti_wilink_st.h b/include/linux/ti_wilink_st.h
index 44a7f9169ac6..10642d4844f0 100644
--- a/include/linux/ti_wilink_st.h
+++ b/include/linux/ti_wilink_st.h
@@ -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);
 
 
 /*
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 19/36] tty: make char_buf_ptr()/flag_buf_ptr()'s offset unsigned
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (17 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 18/36] misc: ti-st: make st_recv() conforming to tty_ldisc_ops::receive_buf() Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 20/36] tty: tty_buffer: make all offsets unsigned Jiri Slaby (SUSE)
                   ` (17 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 include/linux/tty_buffer.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/tty_buffer.h b/include/linux/tty_buffer.h
index b11cc8c749d2..391a875be20c 100644
--- a/include/linux/tty_buffer.h
+++ b/include/linux/tty_buffer.h
@@ -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;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 20/36] tty: tty_buffer: make all offsets unsigned
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (18 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 19/36] tty: make char_buf_ptr()/flag_buf_ptr()'s offset unsigned Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 21/36] tty: don't pass write() to do_tty_write() Jiri Slaby (SUSE)
                   ` (16 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE)

All these are supposed/expected to be unsigned as they are either counts
or offsets. So switch to unsigned for clarity.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 include/linux/tty_buffer.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/tty_buffer.h b/include/linux/tty_buffer.h
index 391a875be20c..e45cba81d0e9 100644
--- a/include/linux/tty_buffer.h
+++ b/include/linux/tty_buffer.h
@@ -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[];
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 21/36] tty: don't pass write() to do_tty_write()
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (19 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 20/36] tty: tty_buffer: make all offsets unsigned Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 22/36] tty: rename and de-inline do_tty_write() Jiri Slaby (SUSE)
                   ` (15 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/tty_io.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 54036a20a102..ea5041fbbf28 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -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;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 22/36] tty: rename and de-inline do_tty_write()
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (20 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 21/36] tty: don't pass write() to do_tty_write() Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 23/36] tty: use min() in iterate_tty_write() Jiri Slaby (SUSE)
                   ` (14 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/tty_io.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index ea5041fbbf28..846460c02c58 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -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;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 23/36] tty: use min() in iterate_tty_write()
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (21 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 22/36] tty: rename and de-inline do_tty_write() Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 24/36] tty: use ssize_t for iterate_tty_read() returned type Jiri Slaby (SUSE)
                   ` (13 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/tty_io.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 846460c02c58..0cf1277e260b 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -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)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 24/36] tty: use ssize_t for iterate_tty_read() returned type
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (22 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 23/36] tty: use min() in iterate_tty_write() Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:14 ` [PATCH 25/36] tty: switch size and count types in iterate_tty_read() to size_t Jiri Slaby (SUSE)
                   ` (12 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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'.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/tty_io.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 0cf1277e260b..e8248773e3f0 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -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)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 25/36] tty: switch size and count types in iterate_tty_read() to size_t
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (23 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 24/36] tty: use ssize_t for iterate_tty_read() returned type Jiri Slaby (SUSE)
@ 2023-08-10  9:14 ` Jiri Slaby (SUSE)
  2023-08-10  9:15 ` [PATCH 26/36] tty: use min() for size computation in iterate_tty_read() Jiri Slaby (SUSE)
                   ` (11 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, 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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/tty_io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index e8248773e3f0..7cfa99fbbb62 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -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);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 26/36] tty: use min() for size computation in iterate_tty_read()
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (24 preceding siblings ...)
  2023-08-10  9:14 ` [PATCH 25/36] tty: switch size and count types in iterate_tty_read() to size_t Jiri Slaby (SUSE)
@ 2023-08-10  9:15 ` Jiri Slaby (SUSE)
  2023-08-10  9:15 ` [PATCH 27/36] tty: propagate u8 data to tty_operations::write() Jiri Slaby (SUSE)
                   ` (10 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE)

The computation is more obvious with min().

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/tty_io.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 7cfa99fbbb62..4f21a21a1fd5 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 27/36] tty: propagate u8 data to tty_operations::write()
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (25 preceding siblings ...)
  2023-08-10  9:15 ` [PATCH 26/36] tty: use min() for size computation in iterate_tty_read() Jiri Slaby (SUSE)
@ 2023-08-10  9:15 ` Jiri Slaby (SUSE)
  2023-08-11 11:52   ` Alexander Gordeev
                     ` (2 more replies)
  2023-08-10  9:15 ` [PATCH 28/36] tty: propagate u8 data to tty_operations::put_char() Jiri Slaby (SUSE)
                   ` (9 subsequent siblings)
  36 siblings, 3 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:15 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Geert Uytterhoeven,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Chris Zankel,
	Max Filippov, Arnd Bergmann, Vaibhav Gupta, Jens Taprogge,
	Karsten Keil, Scott Branden, Ulf Hansson, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, Christian Borntraeger,
	Sven Schnelle, David Lin, Johan Hovold, Alex Elder,
	Laurentiu Tudor, Jiri Kosina, David Sterba, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Arnaud Pouliquen, Oliver Neukum, Mathias Nyman,
	Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz

Data are now typed as u8. Propagate this change to
tty_operations::write().

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Cc: Jens Taprogge <jens.taprogge@taprogge.org>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: Scott Branden <scott.branden@broadcom.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: David Sterba <dsterba@suse.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
---
 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(-)

diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c
index 6dc952b0df4a..dea39008d93e 100644
--- a/arch/alpha/kernel/srmcons.c
+++ b/arch/alpha/kernel/srmcons.c
@@ -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;
 
diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c
index 6fdc13610565..e7a21234b481 100644
--- a/arch/m68k/emu/nfcon.c
+++ b/arch/m68k/emu/nfcon.c
@@ -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;
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 02b0befd6763..e5393b4ba9f8 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -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;
diff --git a/arch/um/drivers/line.h b/arch/um/drivers/line.h
index f15be75a3bf3..8354024b6b35 100644
--- a/arch/um/drivers/line.h
+++ b/arch/um/drivers/line.h
@@ -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);
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index b40b73809dd8..182ec57e2d5c 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -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 */
 
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
index ed45d04905c2..4f3dd93f1fd8 100644
--- a/drivers/char/ttyprintk.c
+++ b/drivers/char/ttyprintk.c
@@ -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;
diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c
index a01c15812b70..c3cf086e7e36 100644
--- a/drivers/ipack/devices/ipoctal.c
+++ b/drivers/ipack/devices/ipoctal.c
@@ -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;
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 45a4043c5042..cf6daf79c1a2 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -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;
diff --git a/drivers/misc/bcm-vk/bcm_vk_tty.c b/drivers/misc/bcm-vk/bcm_vk_tty.c
index 6669625ba4c8..44851b607cce 100644
--- a/drivers/misc/bcm-vk/bcm_vk_tty.c
+++ b/drivers/misc/bcm-vk/bcm_vk_tty.c
@@ -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;
diff --git a/drivers/mmc/core/sdio_uart.c b/drivers/mmc/core/sdio_uart.c
index aa659758563f..90d2fe00c0b9 100644
--- a/drivers/mmc/core/sdio_uart.c
+++ b/drivers/mmc/core/sdio_uart.c
@@ -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;
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index ce1f6081d582..014a9d29bab5 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -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;
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index a1fef666c9b0..16b6f430dfd3 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -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;
diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
index d9983550062d..123524bff734 100644
--- a/drivers/s390/char/con3270.c
+++ b/drivers/s390/char/con3270.c
@@ -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;
 
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
index 971fbb52740b..cc0f6a97124e 100644
--- a/drivers/s390/char/sclp_tty.c
+++ b/drivers/s390/char/sclp_tty.c
@@ -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);
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index a32f34a1c6d2..44974d801c1e 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -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);
 }
diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
index e1a84d6020f4..ae9978b73d9b 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -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;
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 20a34599859f..97c7ddd0f53e 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -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;
 
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index c06ad0a0744b..1dd8b86f4a32 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -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;
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c
index 8595483f4697..de36347e2145 100644
--- a/drivers/tty/ehv_bytechan.c
+++ b/drivers/tty/ehv_bytechan.c
@@ -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;
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index d02de3f0326f..faa597ffbaf9 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -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;
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 10c10cfdf92a..4c60d15c7a6f 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -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;
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index 1de1a09bf82d..2465d61b4e76 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -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;
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
index c1b8a4fd8b1e..46dd62df2442 100644
--- a/drivers/tty/hvc/hvsi.c
+++ b/drivers/tty/hvc/hvsi.c
@@ -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;
diff --git a/drivers/tty/ipwireless/hardware.c b/drivers/tty/ipwireless/hardware.c
index f5d3e68f5750..001ec318a918 100644
--- a/drivers/tty/ipwireless/hardware.c
+++ b/drivers/tty/ipwireless/hardware.c
@@ -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)
 {
diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
index 9edd5ae17580..cd43208c523c 100644
--- a/drivers/tty/ipwireless/tty.c
+++ b/drivers/tty/ipwireless/tty.c
@@ -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;
diff --git a/drivers/tty/mips_ejtag_fdc.c b/drivers/tty/mips_ejtag_fdc.c
index e81701a66429..cf4ef0c38624 100644
--- a/drivers/tty/mips_ejtag_fdc.c
+++ b/drivers/tty/mips_ejtag_fdc.c
@@ -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;
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index 42fa4c878b2e..d94cf1be651b 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -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;
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 10855e66fda1..8b4b8493fed5 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -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;
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index a3bd1fc52aed..d167e36873fe 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -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;
diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index 0454c78deee6..b3756402f5d9 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -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 */
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 2b1c8ab99dba..335f5744f320 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -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;
 
diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
index 55c3c9db7462..2a04d19d5ec0 100644
--- a/drivers/tty/serial/kgdb_nmi.c
+++ b/drivers/tty/serial/kgdb_nmi.c
@@ -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;
 
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index e31c9b6bd8ab..33df5b08d992 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -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;
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 4c6366fe015c..c7cecea38ca8 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -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;
diff --git a/drivers/tty/ttynull.c b/drivers/tty/ttynull.c
index 1d4438472442..6b74ebaa0f2d 100644
--- a/drivers/tty/ttynull.c
+++ b/drivers/tty/ttynull.c
@@ -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;
 }
diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c
index 34ba6e54789a..c223879039b8 100644
--- a/drivers/tty/vcc.c
+++ b/drivers/tty/vcc.c
@@ -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;
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index cf77011a8f4e..2f28612aee91 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -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;
 
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 11da5fb284d0..913b07b30d33 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -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;
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 1115396b46a0..1d08a1d8d3cd 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -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;
diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
index d3acc0829ee5..f5f2d0e12e69 100644
--- a/drivers/usb/host/xhci-dbgtty.c
+++ b/drivers/usb/host/xhci-dbgtty.c
@@ -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;
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 7b4805c1004d..51f738ea3f77 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -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;
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index e00034118c7b..a7bd8060ac96 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -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);
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index d73eec146529..3b5f8404dc84 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 28/36] tty: propagate u8 data to tty_operations::put_char()
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (26 preceding siblings ...)
  2023-08-10  9:15 ` [PATCH 27/36] tty: propagate u8 data to tty_operations::write() Jiri Slaby (SUSE)
@ 2023-08-10  9:15 ` Jiri Slaby (SUSE)
  2023-08-14 14:44   ` Geert Uytterhoeven
  2023-08-17 10:55   ` Alexander Gordeev
  2023-08-10  9:15 ` [PATCH 29/36] tty: make tty_operations::write()'s count size_t Jiri Slaby (SUSE)
                   ` (8 subsequent siblings)
  36 siblings, 2 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:15 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Geert Uytterhoeven,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Karsten Keil, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Mathias Nyman

Data are now typed as u8. Propagate this change to
tty_operations::put_char().

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>
---
 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(-)

diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c
index e7a21234b481..87398f834e36 100644
--- a/arch/m68k/emu/nfcon.c
+++ b/arch/m68k/emu/nfcon.c
@@ -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;
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index cf6daf79c1a2..2f38e1cfe97a 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -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;
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 16b6f430dfd3..8bbce6a4d7f5 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -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;
 
diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
index 123524bff734..6374555a0937 100644
--- a/drivers/s390/char/con3270.c
+++ b/drivers/s390/char/con3270.c
@@ -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;
 
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
index cc0f6a97124e..831a8c7cacc2 100644
--- a/drivers/s390/char/sclp_tty.c
+++ b/drivers/s390/char/sclp_tty.c
@@ -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) {
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index 44974d801c1e..e148350c1e2c 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -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);
 }
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 1dd8b86f4a32..91cf294ec8c1 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -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;
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 8b4b8493fed5..a5dfd08d4ea2 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -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;
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 33df5b08d992..d5b682ff20b3 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -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;
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index c7cecea38ca8..0264e9f7699c 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -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);
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 2f28612aee91..ea7c20d66acb 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -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);
 }
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 1d08a1d8d3cd..3e6b750aa4fc 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -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;
diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
index f5f2d0e12e69..5b82bdd82ba9 100644
--- a/drivers/usb/host/xhci-dbgtty.c
+++ b/drivers/usb/host/xhci-dbgtty.c
@@ -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;
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index a7bd8060ac96..c5299d952e59 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -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);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 29/36] tty: make tty_operations::write()'s count size_t
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (27 preceding siblings ...)
  2023-08-10  9:15 ` [PATCH 28/36] tty: propagate u8 data to tty_operations::put_char() Jiri Slaby (SUSE)
@ 2023-08-10  9:15 ` Jiri Slaby (SUSE)
  2023-08-14 17:58   ` Geert Uytterhoeven
  2023-08-10  9:15 ` [PATCH 30/36] tty: audit: unify to u8 Jiri Slaby (SUSE)
                   ` (7 subsequent siblings)
  36 siblings, 1 reply; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE)

Unify with the rest of the code. Use size_t for counts and ssize_t for
retval.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 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(-)

diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c
index dea39008d93e..d6139dbae4ac 100644
--- a/arch/alpha/kernel/srmcons.c
+++ b/arch/alpha/kernel/srmcons.c
@@ -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;
 
diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c
index 87398f834e36..3a74d493eb3e 100644
--- a/arch/m68k/emu/nfcon.c
+++ b/arch/m68k/emu/nfcon.c
@@ -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;
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index e5393b4ba9f8..b98545f3edb5 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -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;
diff --git a/arch/um/drivers/line.h b/arch/um/drivers/line.h
index 8354024b6b35..e84fb9b4165e 100644
--- a/arch/um/drivers/line.h
+++ b/arch/um/drivers/line.h
@@ -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);
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 182ec57e2d5c..7d1f8b398a46 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -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 */
 
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
index 4f3dd93f1fd8..5af804c17a75 100644
--- a/drivers/char/ttyprintk.c
+++ b/drivers/char/ttyprintk.c
@@ -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;
diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c
index c3cf086e7e36..da308be6c487 100644
--- a/drivers/ipack/devices/ipoctal.c
+++ b/drivers/ipack/devices/ipoctal.c
@@ -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;
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 2f38e1cfe97a..2f3789515445 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -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;
diff --git a/drivers/misc/bcm-vk/bcm_vk_tty.c b/drivers/misc/bcm-vk/bcm_vk_tty.c
index 44851b607cce..2bce835ca43e 100644
--- a/drivers/misc/bcm-vk/bcm_vk_tty.c
+++ b/drivers/misc/bcm-vk/bcm_vk_tty.c
@@ -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;
diff --git a/drivers/mmc/core/sdio_uart.c b/drivers/mmc/core/sdio_uart.c
index 90d2fe00c0b9..ef38dcd3a887 100644
--- a/drivers/mmc/core/sdio_uart.c
+++ b/drivers/mmc/core/sdio_uart.c
@@ -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;
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 014a9d29bab5..3f424da87bf4 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -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;
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 8bbce6a4d7f5..99361618c31f 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -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;
diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
index 6374555a0937..363315fa1666 100644
--- a/drivers/s390/char/con3270.c
+++ b/drivers/s390/char/con3270.c
@@ -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;
 
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
index 831a8c7cacc2..892c18d2f87e 100644
--- a/drivers/s390/char/sclp_tty.c
+++ b/drivers/s390/char/sclp_tty.c
@@ -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);
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index e148350c1e2c..218ae604f737 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -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);
 }
diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
index ae9978b73d9b..b31f2afb0286 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -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;
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 97c7ddd0f53e..999ce613dca8 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -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;
 
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 91cf294ec8c1..785558c65ae8 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -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;
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c
index de36347e2145..a067628e01c8 100644
--- a/drivers/tty/ehv_bytechan.c
+++ b/drivers/tty/ehv_bytechan.c
@@ -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;
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index faa597ffbaf9..4591f940b7a1 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -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;
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 4c60d15c7a6f..e93e8072ec86 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -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;
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index 2465d61b4e76..1de91fa23b04 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -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.
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
index 46dd62df2442..c57bd85aa488 100644
--- a/drivers/tty/hvc/hvsi.c
+++ b/drivers/tty/hvc/hvsi.c
@@ -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;
diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
index cd43208c523c..b6de40815fb9 100644
--- a/drivers/tty/ipwireless/tty.c
+++ b/drivers/tty/ipwireless/tty.c
@@ -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;
diff --git a/drivers/tty/mips_ejtag_fdc.c b/drivers/tty/mips_ejtag_fdc.c
index cf4ef0c38624..369ec71c24ef 100644
--- a/drivers/tty/mips_ejtag_fdc.c
+++ b/drivers/tty/mips_ejtag_fdc.c
@@ -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) */
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index d94cf1be651b..bf3f87ba3a92 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -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;
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index a5dfd08d4ea2..10aa4ed38793 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -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;
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index d167e36873fe..3e5cc30941a7 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -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;
diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index b3756402f5d9..02cd40147b3a 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -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);
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 335f5744f320..df08f13052ff 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -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;
 
diff --git a/drivers/tty/rpmsg_tty.c b/drivers/tty/rpmsg_tty.c
index 29db413bbc03..60a2915f5cfe 100644
--- a/drivers/tty/rpmsg_tty.c
+++ b/drivers/tty/rpmsg_tty.c
@@ -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
diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
index 2a04d19d5ec0..e93850f6447a 100644
--- a/drivers/tty/serial/kgdb_nmi.c
+++ b/drivers/tty/serial/kgdb_nmi.c
@@ -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;
 
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index d5b682ff20b3..7bdc21d5e13b 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -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;
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 0264e9f7699c..8112d9d5a0d8 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -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;
diff --git a/drivers/tty/ttynull.c b/drivers/tty/ttynull.c
index 6b74ebaa0f2d..e4c4273993bc 100644
--- a/drivers/tty/ttynull.c
+++ b/drivers/tty/ttynull.c
@@ -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;
 }
diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c
index c223879039b8..9cc569174c83 100644
--- a/drivers/tty/vcc.c
+++ b/drivers/tty/vcc.c
@@ -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;
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index ea7c20d66acb..5c47f77804f0 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -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;
 
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 913b07b30d33..3591880d96bd 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -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;
 
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 3e6b750aa4fc..a92eb6d90976 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -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);
diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
index 5b82bdd82ba9..b74e98e94393 100644
--- a/drivers/usb/host/xhci-dbgtty.c
+++ b/drivers/usb/host/xhci-dbgtty.c
@@ -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;
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 51f738ea3f77..17b09f03ef84 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -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)
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index c5299d952e59..18beff0cec1a 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -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);
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 3b5f8404dc84..33b135ed59c4 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -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);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 30/36] tty: audit: unify to u8
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (28 preceding siblings ...)
  2023-08-10  9:15 ` [PATCH 29/36] tty: make tty_operations::write()'s count size_t Jiri Slaby (SUSE)
@ 2023-08-10  9:15 ` Jiri Slaby (SUSE)
  2023-08-10  9:15 ` [PATCH 31/36] tty: ldops: " Jiri Slaby (SUSE)
                   ` (6 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE)

Somewhere, we use 'char', somewhere 'unsigned char'. Unify to 'u8' as
the rest of the tty layer does.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/tty.h       | 4 ++--
 drivers/tty/tty_audit.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h
index e31cd9f281de..50862f98273e 100644
--- a/drivers/tty/tty.h
+++ b/drivers/tty/tty.h
@@ -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
diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c
index 24d010589379..1d81eeefb068 100644
--- a/drivers/tty/tty_audit.c
+++ b/drivers/tty/tty_audit.c
@@ -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;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 31/36] tty: ldops: unify to u8
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (29 preceding siblings ...)
  2023-08-10  9:15 ` [PATCH 30/36] tty: audit: unify to u8 Jiri Slaby (SUSE)
@ 2023-08-10  9:15 ` Jiri Slaby (SUSE)
  2023-08-10  9:15 ` [PATCH 32/36] tty: hvc: convert counts to size_t Jiri Slaby (SUSE)
                   ` (5 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:15 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Marcel Holtmann,
	Johan Hedberg, Luiz Augusto von Dentz, Dmitry Torokhov,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Krzysztof Kozlowski

Some hooks in struct tty_ldisc_ops still reference buffers by 'unsigned
char'. Unify to 'u8' as the rest of the tty layer does.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 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(-)

diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 3e11fc06a932..a26367e9fb19 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -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;
 }
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index 5ce8d9f10f3e..1db3f30011c4 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -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;
diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c
index cfd5cb609d99..fbaaa8c102a1 100644
--- a/drivers/net/ppp/ppp_async.c
+++ b/drivers/net/ppp/ppp_async.c
@@ -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;
 }
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index 164c9053f73b..ebcdffdf4f0e 100644
--- a/drivers/net/ppp/ppp_synctty.c
+++ b/drivers/net/ppp/ppp_synctty.c
@@ -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;
 }
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 3e5cc30941a7..42759500b79e 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -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;
diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index 9be0932d07e0..a670419efe79 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -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;
diff --git a/drivers/tty/n_null.c b/drivers/tty/n_null.c
index 4a0d8bb2fb4c..5a429d923eb3 100644
--- a/drivers/tty/n_null.c
+++ b/drivers/tty/n_null.c
@@ -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;
 }
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 1053b2adb04c..f44f38bb412e 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -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;
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index a661d7df5497..af01e89074b2 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -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,
diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c
index 93775c540287..ed1508a9e093 100644
--- a/net/nfc/nci/uart.c
+++ b/net/nfc/nci/uart.c
@@ -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;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 32/36] tty: hvc: convert counts to size_t
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (30 preceding siblings ...)
  2023-08-10  9:15 ` [PATCH 31/36] tty: ldops: " Jiri Slaby (SUSE)
@ 2023-08-10  9:15 ` Jiri Slaby (SUSE)
  2023-08-10  9:15 ` [PATCH 33/36] tty: vcc: " Jiri Slaby (SUSE)
                   ` (4 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), linuxppc-dev

Unify the type of tty_operations::write() counters with the 'count'
parameter. I.e. use size_t for them.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 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(-)

diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index e93e8072ec86..959fae54ca39 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -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)
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index 1de91fa23b04..d29fdfe9d93d 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -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
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
index c57bd85aa488..a94068bce76f 100644
--- a/drivers/tty/hvc/hvsi.c
+++ b/drivers/tty/hvc/hvsi.c
@@ -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;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 33/36] tty: vcc: convert counts to size_t
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (31 preceding siblings ...)
  2023-08-10  9:15 ` [PATCH 32/36] tty: hvc: convert counts to size_t Jiri Slaby (SUSE)
@ 2023-08-10  9:15 ` Jiri Slaby (SUSE)
  2023-08-10  9:15 ` [PATCH 34/36] tty: gdm724x: " Jiri Slaby (SUSE)
                   ` (3 subsequent siblings)
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), David S. Miller

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().

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
---
 arch/sparc/include/asm/vio.h |  2 +-
 drivers/tty/vcc.c            | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/sparc/include/asm/vio.h b/arch/sparc/include/asm/vio.h
index 8a0c3c11c9ce..587fb7841096 100644
--- a/arch/sparc/include/asm/vio.h
+++ b/arch/sparc/include/asm/vio.h
@@ -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 {
diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c
index 9cc569174c83..a39ed981bfd3 100644
--- a/drivers/tty/vcc.c
+++ b/drivers/tty/vcc.c
@@ -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;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 34/36] tty: gdm724x: convert counts to size_t
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (32 preceding siblings ...)
  2023-08-10  9:15 ` [PATCH 33/36] tty: vcc: " Jiri Slaby (SUSE)
@ 2023-08-10  9:15 ` Jiri Slaby (SUSE)
  2023-08-10  9:42   ` Dan Carpenter
  2023-08-15 17:22   ` [PATCH 34/36] tty: gdm724x: convert counts to size_t Nathan Chancellor
  2023-08-10  9:15 ` [PATCH 35/36] tty: hso: simplify hso_serial_write() Jiri Slaby (SUSE)
                   ` (2 subsequent siblings)
  36 siblings, 2 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), linux-staging

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().

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: linux-staging@lists.linux.dev
---
 drivers/staging/gdm724x/gdm_tty.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
index b31f2afb0286..cbaaa8fa7474 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -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
 
 static 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,
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 35/36] tty: hso: simplify hso_serial_write()
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (33 preceding siblings ...)
  2023-08-10  9:15 ` [PATCH 34/36] tty: gdm724x: " Jiri Slaby (SUSE)
@ 2023-08-10  9:15 ` Jiri Slaby (SUSE)
  2023-08-10  9:15 ` [PATCH 36/36] tty: rfcomm: convert counts to size_t Jiri Slaby (SUSE)
  2023-08-11 10:26 ` [PATCH 00/36] tty: type unifications -- part I Ilpo Järvinen
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:15 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/usb/hso.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 3f424da87bf4..83b8452220ec 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -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 */
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [PATCH 36/36] tty: rfcomm: convert counts to size_t
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (34 preceding siblings ...)
  2023-08-10  9:15 ` [PATCH 35/36] tty: hso: simplify hso_serial_write() Jiri Slaby (SUSE)
@ 2023-08-10  9:15 ` Jiri Slaby (SUSE)
  2023-08-11 10:26 ` [PATCH 00/36] tty: type unifications -- part I Ilpo Järvinen
  36 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10  9:15 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Marcel Holtmann,
	Johan Hedberg, Luiz Augusto von Dentz

Unify the type of tty_operations::write() counters with the 'count'
parameter. I.e. use size_t for them.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
---
 net/bluetooth/rfcomm/tty.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 33b135ed59c4..94ec913dfb76 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -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)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* Re: [PATCH 34/36] tty: gdm724x: convert counts to size_t
  2023-08-10  9:15 ` [PATCH 34/36] tty: gdm724x: " Jiri Slaby (SUSE)
@ 2023-08-10  9:42   ` Dan Carpenter
  2023-08-10 10:08     ` Jiri Slaby
  2023-08-10 10:39     ` [PATCH 34-and-three-quarters/36] tty: gdm724x: simplify gdm_tty_write() Jiri Slaby (SUSE)
  2023-08-15 17:22   ` [PATCH 34/36] tty: gdm724x: convert counts to size_t Nathan Chancellor
  1 sibling, 2 replies; 68+ messages in thread
From: Dan Carpenter @ 2023-08-10  9:42 UTC (permalink / raw)
  To: Jiri Slaby (SUSE); +Cc: gregkh, linux-serial, linux-kernel, linux-staging

On Thu, Aug 10, 2023 at 11:15:08AM +0200, Jiri Slaby (SUSE) wrote:
> 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().
> 
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Cc: linux-staging@lists.linux.dev
> ---
>  drivers/staging/gdm724x/gdm_tty.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
> index b31f2afb0286..cbaaa8fa7474 100644
> --- a/drivers/staging/gdm724x/gdm_tty.c
> +++ b/drivers/staging/gdm724x/gdm_tty.c
> @@ -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
>  
>  static 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.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 34/36] tty: gdm724x: convert counts to size_t
  2023-08-10  9:42   ` Dan Carpenter
@ 2023-08-10 10:08     ` Jiri Slaby
  2023-08-10 10:39     ` [PATCH 34-and-three-quarters/36] tty: gdm724x: simplify gdm_tty_write() Jiri Slaby (SUSE)
  1 sibling, 0 replies; 68+ messages in thread
From: Jiri Slaby @ 2023-08-10 10:08 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, linux-serial, linux-kernel, linux-staging

On 10. 08. 23, 11:42, Dan Carpenter wrote:
> On Thu, Aug 10, 2023 at 11:15:08AM +0200, Jiri Slaby (SUSE) wrote:
>> 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().
>>
>> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
>> Cc: linux-staging@lists.linux.dev
>> ---
>>   drivers/staging/gdm724x/gdm_tty.c | 11 +++++------
>>   1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
>> index b31f2afb0286..cbaaa8fa7474 100644
>> --- a/drivers/staging/gdm724x/gdm_tty.c
>> +++ b/drivers/staging/gdm724x/gdm_tty.c
>> @@ -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
>>   
>>   static 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,
-- 
js
suse labs


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 34-and-three-quarters/36] tty: gdm724x: simplify gdm_tty_write()
  2023-08-10  9:42   ` Dan Carpenter
  2023-08-10 10:08     ` Jiri Slaby
@ 2023-08-10 10:39     ` Jiri Slaby (SUSE)
  2023-08-11  9:11       ` Ilpo Järvinen
  1 sibling, 1 reply; 68+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-08-10 10:39 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Dan Carpenter,
	linux-staging

len and remain can never be negative in gdm_tty_write(). So remove such
a check and move the check of remaining bytes to the loop condition.
This way, the preceding 'if' is now superfluous too. Fix all that and
make the code cleaner.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Cc: linux-staging@lists.linux.dev
---
 drivers/staging/gdm724x/gdm_tty.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
index cbaaa8fa7474..67d9bf41e836 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -158,10 +158,7 @@ static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len)
 	if (!gdm_tty_ready(gdm))
 		return -ENODEV;
 
-	if (!len)
-		return 0;
-
-	while (1) {
+	while (remain) {
 		size_t sending_len = min(MUX_TX_MAX_SIZE, remain);
 		gdm->tty_dev->send_func(gdm->tty_dev->priv_dev,
 					(void *)(buf + sent_len),
@@ -171,8 +168,6 @@ static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len)
 					gdm);
 		sent_len += sending_len;
 		remain -= sending_len;
-		if (remain <= 0)
-			break;
 	}
 
 	return len;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* Re: [PATCH 15/36] tty: make tty_ldisc_ops::*buf*() hooks operate on size_t
  2023-08-10  9:14 ` [PATCH 15/36] tty: make tty_ldisc_ops::*buf*() hooks operate on size_t Jiri Slaby (SUSE)
@ 2023-08-10 12:02   ` Mark Brown
  2023-08-11 21:34   ` Max Staudt
  1 sibling, 0 replies; 68+ messages in thread
From: Mark Brown @ 2023-08-10 12:02 UTC (permalink / raw)
  To: Jiri Slaby (SUSE)
  Cc: gregkh, linux-serial, linux-kernel, William Hubbs, Chris Brannon,
	Kirk Reiser, Samuel Thibault, Marcel Holtmann, Johan Hedberg,
	Luiz Augusto von Dentz, Dmitry Torokhov, Arnd Bergmann,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Max Staudt, Wolfgang Grandegger, Marc Kleine-Budde,
	Dario Binacchi, Andreas Koensgen, Jeremy Kerr, Matt Johnston,
	Krzysztof Kozlowski, Liam Girdwood, Jaroslav Kysela, Takashi Iwai

[-- Attachment #1: Type: text/plain, Size: 299 bytes --]

On Thu, Aug 10, 2023 at 11:14:49AM +0200, Jiri Slaby (SUSE) wrote:
> 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.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 16/36] tty: use u8 for chars
  2023-08-10  9:14 ` [PATCH 16/36] tty: use u8 for chars Jiri Slaby (SUSE)
@ 2023-08-10 12:04   ` Mark Brown
  2023-08-11 10:28   ` Ilpo Järvinen
  2023-08-11 21:34   ` Max Staudt
  2 siblings, 0 replies; 68+ messages in thread
From: Mark Brown @ 2023-08-10 12:04 UTC (permalink / raw)
  To: Jiri Slaby (SUSE)
  Cc: gregkh, linux-serial, linux-kernel, William Hubbs, Chris Brannon,
	Kirk Reiser, Samuel Thibault, Dmitry Torokhov, Arnd Bergmann,
	Max Staudt, Wolfgang Grandegger, Marc Kleine-Budde,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Dario Binacchi, Andreas Koensgen, Jeremy Kerr, Matt Johnston,
	Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Peter Ujfalusi

[-- Attachment #1: Type: text/plain, Size: 253 bytes --]

On Thu, Aug 10, 2023 at 11:14:50AM +0200, Jiri Slaby (SUSE) wrote:
> 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.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 17/36] tty: use u8 for flags
  2023-08-10  9:14 ` [PATCH 17/36] tty: use u8 for flags Jiri Slaby (SUSE)
@ 2023-08-10 12:05   ` Mark Brown
  2023-08-11 21:35   ` Max Staudt
  1 sibling, 0 replies; 68+ messages in thread
From: Mark Brown @ 2023-08-10 12:05 UTC (permalink / raw)
  To: Jiri Slaby (SUSE)
  Cc: gregkh, linux-serial, linux-kernel, William Hubbs, Chris Brannon,
	Kirk Reiser, Samuel Thibault, Marcel Holtmann, Johan Hedberg,
	Luiz Augusto von Dentz, Dmitry Torokhov, Arnd Bergmann,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Max Staudt, Wolfgang Grandegger, Marc Kleine-Budde,
	Dario Binacchi, Andreas Koensgen, Jeremy Kerr, Matt Johnston,
	Krzysztof Kozlowski, Liam Girdwood, Jaroslav Kysela, Takashi Iwai

[-- Attachment #1: Type: text/plain, Size: 304 bytes --]

On Thu, Aug 10, 2023 at 11:14:51AM +0200, Jiri Slaby (SUSE) wrote:
> 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().

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 01/36] tty: xtensa/iss: drop unneeded tty_operations hooks
  2023-08-10  9:14 ` [PATCH 01/36] tty: xtensa/iss: drop unneeded tty_operations hooks Jiri Slaby (SUSE)
@ 2023-08-10 12:37   ` Max Filippov
  0 siblings, 0 replies; 68+ messages in thread
From: Max Filippov @ 2023-08-10 12:37 UTC (permalink / raw)
  To: Jiri Slaby (SUSE); +Cc: gregkh, linux-serial, linux-kernel, Chris Zankel

On Thu, Aug 10, 2023 at 2:15 AM Jiri Slaby (SUSE) <jirislaby@kernel.org> wrote:
>
> 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.
>
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Cc: Chris Zankel <chris@zankel.net>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> ---
>  arch/xtensa/platforms/iss/console.c | 24 ------------------------
>  1 file changed, 24 deletions(-)

Acked-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 34-and-three-quarters/36] tty: gdm724x: simplify gdm_tty_write()
  2023-08-10 10:39     ` [PATCH 34-and-three-quarters/36] tty: gdm724x: simplify gdm_tty_write() Jiri Slaby (SUSE)
@ 2023-08-11  9:11       ` Ilpo Järvinen
  0 siblings, 0 replies; 68+ messages in thread
From: Ilpo Järvinen @ 2023-08-11  9:11 UTC (permalink / raw)
  To: Jiri Slaby (SUSE)
  Cc: Greg Kroah-Hartman, linux-serial, LKML, Dan Carpenter,
	linux-staging

[-- Attachment #1: Type: text/plain, Size: 1533 bytes --]

On Thu, 10 Aug 2023, Jiri Slaby (SUSE) wrote:

> len and remain can never be negative in gdm_tty_write(). So remove such
> a check and move the check of remaining bytes to the loop condition.
> This way, the preceding 'if' is now superfluous too. Fix all that and
> make the code cleaner.
> 
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>

I guess Suggested-by would be more appropriate since there's no problem 
being fixed here.

> Cc: linux-staging@lists.linux.dev

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.



> ---
>  drivers/staging/gdm724x/gdm_tty.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
> index cbaaa8fa7474..67d9bf41e836 100644
> --- a/drivers/staging/gdm724x/gdm_tty.c
> +++ b/drivers/staging/gdm724x/gdm_tty.c
> @@ -158,10 +158,7 @@ static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len)
>  	if (!gdm_tty_ready(gdm))
>  		return -ENODEV;
>  
> -	if (!len)
> -		return 0;
> -
> -	while (1) {
> +	while (remain) {
>  		size_t sending_len = min(MUX_TX_MAX_SIZE, remain);
>  		gdm->tty_dev->send_func(gdm->tty_dev->priv_dev,
>  					(void *)(buf + sent_len),
> @@ -171,8 +168,6 @@ static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len)
>  					gdm);
>  		sent_len += sending_len;
>  		remain -= sending_len;
> -		if (remain <= 0)
> -			break;
>  	}
>  
>  	return len;
> 

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 00/36] tty: type unifications -- part I.
  2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
                   ` (35 preceding siblings ...)
  2023-08-10  9:15 ` [PATCH 36/36] tty: rfcomm: convert counts to size_t Jiri Slaby (SUSE)
@ 2023-08-11 10:26 ` Ilpo Järvinen
  2023-08-14  6:59   ` Jiri Slaby
  36 siblings, 1 reply; 68+ messages in thread
From: Ilpo Järvinen @ 2023-08-11 10:26 UTC (permalink / raw)
  To: Jiri Slaby (SUSE); +Cc: Greg Kroah-Hartman, linux-serial, LKML

[-- Attachment #1: Type: text/plain, Size: 8054 bytes --]

On Thu, 10 Aug 2023, Jiri Slaby (SUSE) wrote:

> 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. 

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,

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

> 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(-)
> 
> 

-- 
 i.

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 16/36] tty: use u8 for chars
  2023-08-10  9:14 ` [PATCH 16/36] tty: use u8 for chars Jiri Slaby (SUSE)
  2023-08-10 12:04   ` Mark Brown
@ 2023-08-11 10:28   ` Ilpo Järvinen
  2023-08-14  6:35     ` Jiri Slaby
  2023-08-31 18:33     ` Andy Shevchenko
  2023-08-11 21:34   ` Max Staudt
  2 siblings, 2 replies; 68+ messages in thread
From: Ilpo Järvinen @ 2023-08-11 10:28 UTC (permalink / raw)
  To: Jiri Slaby (SUSE)
  Cc: Greg Kroah-Hartman, linux-serial, LKML, William Hubbs,
	Chris Brannon, Kirk Reiser, Samuel Thibault, Dmitry Torokhov,
	Arnd Bergmann, Max Staudt, Wolfgang Grandegger, Marc Kleine-Budde,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Dario Binacchi, Andreas Koensgen, Jeremy Kerr, Matt Johnston,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Peter Ujfalusi

On Thu, 10 Aug 2023, Jiri Slaby (SUSE) wrote:

> 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) <jirislaby@kernel.org>
> Cc: William Hubbs <w.d.hubbs@gmail.com>
> Cc: Chris Brannon <chris@the-brannons.com>
> Cc: Kirk Reiser <kirk@reisers.ca>
> Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Max Staudt <max@enpas.org>
> Cc: Wolfgang Grandegger <wg@grandegger.com>
> Cc: Marc Kleine-Budde <mkl@pengutronix.de>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> Cc: Andreas Koensgen <ajk@comnets.uni-bremen.de>
> Cc: Jeremy Kerr <jk@codeconstruct.com.au>
> Cc: Matt Johnston <matt@codeconstruct.com.au>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: Peter Ujfalusi <peter.ujfalusi@gmail.com>
> ---
>  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(-)

> diff --git a/include/linux/tty_buffer.h b/include/linux/tty_buffer.h
> index 6ceb2789e6c8..6f2966b15093 100644
> --- a/include/linux/tty_buffer.h
> +++ b/include/linux/tty_buffer.h
> @@ -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?

-- 
 i.


^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 27/36] tty: propagate u8 data to tty_operations::write()
  2023-08-10  9:15 ` [PATCH 27/36] tty: propagate u8 data to tty_operations::write() Jiri Slaby (SUSE)
@ 2023-08-11 11:52   ` Alexander Gordeev
  2023-08-17 10:42     ` Jiri Slaby
  2023-08-14 14:47   ` Geert Uytterhoeven
  2023-08-17 10:53   ` Alexander Gordeev
  2 siblings, 1 reply; 68+ messages in thread
From: Alexander Gordeev @ 2023-08-11 11:52 UTC (permalink / raw)
  To: Jiri Slaby (SUSE)
  Cc: gregkh, linux-serial, linux-kernel, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Geert Uytterhoeven,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Chris Zankel,
	Max Filippov, Arnd Bergmann, Vaibhav Gupta, Jens Taprogge,
	Karsten Keil, Scott Branden, Ulf Hansson, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger, Sven Schnelle, David Lin,
	Johan Hovold, Alex Elder, Laurentiu Tudor, Jiri Kosina,
	David Sterba, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Arnaud Pouliquen, Oliver Neukum,
	Mathias Nyman, Marcel Holtmann, Johan Hedberg,
	Luiz Augusto von Dentz

On Thu, Aug 10, 2023 at 11:15:01AM +0200, Jiri Slaby (SUSE) wrote:

Hi Jiri,

> Data are now typed as u8. Propagate this change to
> tty_operations::write().
...
>  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 +-
...
> diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
> index a1fef666c9b0..16b6f430dfd3 100644
> --- a/drivers/s390/char/con3215.c
> +++ b/drivers/s390/char/con3215.c
> @@ -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;
> diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
> index d9983550062d..123524bff734 100644
> --- a/drivers/s390/char/con3270.c
> +++ b/drivers/s390/char/con3270.c
> @@ -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;
>  
> diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
> index 971fbb52740b..cc0f6a97124e 100644
> --- a/drivers/s390/char/sclp_tty.c
> +++ b/drivers/s390/char/sclp_tty.c
> @@ -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);
> diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
> index a32f34a1c6d2..44974d801c1e 100644
> --- a/drivers/s390/char/sclp_vt220.c
> +++ b/drivers/s390/char/sclp_vt220.c
> @@ -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!

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 13/36] tty: can327: unify error paths in can327_ldisc_rx()
  2023-08-10  9:14 ` [PATCH 13/36] tty: can327: unify error paths in can327_ldisc_rx() Jiri Slaby (SUSE)
@ 2023-08-11 21:32   ` Max Staudt
  0 siblings, 0 replies; 68+ messages in thread
From: Max Staudt @ 2023-08-11 21:32 UTC (permalink / raw)
  To: Jiri Slaby (SUSE), gregkh
  Cc: linux-serial, linux-kernel, Wolfgang Grandegger,
	Marc Kleine-Budde, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-can

Thank you for simplifying this!

Reviewed-by: Max Staudt <max@enpas.org>


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:"?


^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 14/36] tty: can327, move overflow test inside can327_ldisc_rx()'s loop
  2023-08-10  9:14 ` [PATCH 14/36] tty: can327, move overflow test inside can327_ldisc_rx()'s loop Jiri Slaby (SUSE)
@ 2023-08-11 21:34   ` Max Staudt
  0 siblings, 0 replies; 68+ messages in thread
From: Max Staudt @ 2023-08-11 21:34 UTC (permalink / raw)
  To: Jiri Slaby (SUSE), gregkh
  Cc: linux-serial, linux-kernel, Wolfgang Grandegger,
	Marc Kleine-Budde, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-can

Thanks for this one as well.

Reviewed-by: Max Staudt <max@enpas.org>


^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 15/36] tty: make tty_ldisc_ops::*buf*() hooks operate on size_t
  2023-08-10  9:14 ` [PATCH 15/36] tty: make tty_ldisc_ops::*buf*() hooks operate on size_t Jiri Slaby (SUSE)
  2023-08-10 12:02   ` Mark Brown
@ 2023-08-11 21:34   ` Max Staudt
  1 sibling, 0 replies; 68+ messages in thread
From: Max Staudt @ 2023-08-11 21:34 UTC (permalink / raw)
  To: Jiri Slaby (SUSE), gregkh
  Cc: linux-serial, linux-kernel, William Hubbs, Chris Brannon,
	Kirk Reiser, Samuel Thibault, Marcel Holtmann, Johan Hedberg,
	Luiz Augusto von Dentz, Dmitry Torokhov, Arnd Bergmann,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Wolfgang Grandegger, Marc Kleine-Budde, Dario Binacchi,
	Andreas Koensgen, Jeremy Kerr, Matt Johnston, Krzysztof Kozlowski,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai

Acked-by: Max Staudt <max@enpas.org>


^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 16/36] tty: use u8 for chars
  2023-08-10  9:14 ` [PATCH 16/36] tty: use u8 for chars Jiri Slaby (SUSE)
  2023-08-10 12:04   ` Mark Brown
  2023-08-11 10:28   ` Ilpo Järvinen
@ 2023-08-11 21:34   ` Max Staudt
  2 siblings, 0 replies; 68+ messages in thread
From: Max Staudt @ 2023-08-11 21:34 UTC (permalink / raw)
  To: Jiri Slaby (SUSE), gregkh
  Cc: linux-serial, linux-kernel, William Hubbs, Chris Brannon,
	Kirk Reiser, Samuel Thibault, Dmitry Torokhov, Arnd Bergmann,
	Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Dario Binacchi,
	Andreas Koensgen, Jeremy Kerr, Matt Johnston, Liam Girdwood,
	Mark Brown, Jaroslav Kysela, Takashi Iwai, Peter Ujfalusi

Acked-by: Max Staudt <max@enpas.org>


^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 17/36] tty: use u8 for flags
  2023-08-10  9:14 ` [PATCH 17/36] tty: use u8 for flags Jiri Slaby (SUSE)
  2023-08-10 12:05   ` Mark Brown
@ 2023-08-11 21:35   ` Max Staudt
  1 sibling, 0 replies; 68+ messages in thread
From: Max Staudt @ 2023-08-11 21:35 UTC (permalink / raw)
  To: Jiri Slaby (SUSE), gregkh
  Cc: linux-serial, linux-kernel, William Hubbs, Chris Brannon,
	Kirk Reiser, Samuel Thibault, Marcel Holtmann, Johan Hedberg,
	Luiz Augusto von Dentz, Dmitry Torokhov, Arnd Bergmann,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Wolfgang Grandegger, Marc Kleine-Budde, Dario Binacchi,
	Andreas Koensgen, Jeremy Kerr, Matt Johnston, Krzysztof Kozlowski,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai

Acked-by: Max Staudt <max@enpas.org>


^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 16/36] tty: use u8 for chars
  2023-08-11 10:28   ` Ilpo Järvinen
@ 2023-08-14  6:35     ` Jiri Slaby
  2023-08-31 18:33     ` Andy Shevchenko
  1 sibling, 0 replies; 68+ messages in thread
From: Jiri Slaby @ 2023-08-14  6:35 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Greg Kroah-Hartman, linux-serial, LKML, William Hubbs,
	Chris Brannon, Kirk Reiser, Samuel Thibault, Dmitry Torokhov,
	Arnd Bergmann, Max Staudt, Wolfgang Grandegger, Marc Kleine-Budde,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Dario Binacchi, Andreas Koensgen, Jeremy Kerr, Matt Johnston,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Peter Ujfalusi

On 11. 08. 23, 12:28, Ilpo Järvinen wrote:
> On Thu, 10 Aug 2023, Jiri Slaby (SUSE) wrote:
> 
>> 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
>> index 6ceb2789e6c8..6f2966b15093 100644
>> --- a/include/linux/tty_buffer.h
>> +++ b/include/linux/tty_buffer.h
>> @@ -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?

Nope :):
https://git.kernel.org/pub/scm/linux/kernel/git/jirislaby/linux.git/commit/?h=devel&id=57c9d0cbe1ad69957a2092b66dc31dc1da4d1d4b

I am dumb not mentioning it in 00/36, see my e-mail there.

thanks,
-- 
js
suse labs


^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 00/36] tty: type unifications -- part I.
  2023-08-11 10:26 ` [PATCH 00/36] tty: type unifications -- part I Ilpo Järvinen
@ 2023-08-14  6:59   ` Jiri Slaby
  2023-08-14 14:47     ` Ilpo Järvinen
  0 siblings, 1 reply; 68+ messages in thread
From: Jiri Slaby @ 2023-08-14  6:59 UTC (permalink / raw)
  To: Ilpo Järvinen; +Cc: Greg Kroah-Hartman, linux-serial, LKML

On 11. 08. 23, 12:26, Ilpo Järvinen wrote:
> On Thu, 10 Aug 2023, Jiri Slaby (SUSE) wrote:
> 
>> 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.
> 
> 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.

tl;dr
https://git.kernel.org/pub/scm/linux/kernel/git/jirislaby/linux.git/commit/?h=devel&id=9abb593df5a9b9b72d13438f1862ca67936f6b66

----

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,
-- 
js
suse labs


^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 28/36] tty: propagate u8 data to tty_operations::put_char()
  2023-08-10  9:15 ` [PATCH 28/36] tty: propagate u8 data to tty_operations::put_char() Jiri Slaby (SUSE)
@ 2023-08-14 14:44   ` Geert Uytterhoeven
  2023-08-17 10:55   ` Alexander Gordeev
  1 sibling, 0 replies; 68+ messages in thread
From: Geert Uytterhoeven @ 2023-08-14 14:44 UTC (permalink / raw)
  To: Jiri Slaby (SUSE)
  Cc: gregkh, linux-serial, linux-kernel, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Karsten Keil, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Mathias Nyman

On Thu, Aug 10, 2023 at 11:16 AM Jiri Slaby (SUSE) <jirislaby@kernel.org> wrote:
> Data are now typed as u8. Propagate this change to
> tty_operations::put_char().
>
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>

>  arch/m68k/emu/nfcon.c                  | 4 ++--
>  drivers/tty/amiserial.c                | 2 +-

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> # m68k
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # m68k

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 00/36] tty: type unifications -- part I.
  2023-08-14  6:59   ` Jiri Slaby
@ 2023-08-14 14:47     ` Ilpo Järvinen
  0 siblings, 0 replies; 68+ messages in thread
From: Ilpo Järvinen @ 2023-08-14 14:47 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Greg Kroah-Hartman, linux-serial, LKML

[-- Attachment #1: Type: text/plain, Size: 3519 bytes --]

On Mon, 14 Aug 2023, Jiri Slaby wrote:

> On 11. 08. 23, 12:26, Ilpo Järvinen wrote:
> > On Thu, 10 Aug 2023, Jiri Slaby (SUSE) wrote:
> > 
> > > 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.
> > 
> > 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.
> 
> tl;dr
> https://git.kernel.org/pub/scm/linux/kernel/git/jirislaby/linux.git/commit/?h=devel&id=9abb593df5a9b9b72d13438f1862ca67936f6b66
> 
> ----
> 
> 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.

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.


-- 
 i.

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 27/36] tty: propagate u8 data to tty_operations::write()
  2023-08-10  9:15 ` [PATCH 27/36] tty: propagate u8 data to tty_operations::write() Jiri Slaby (SUSE)
  2023-08-11 11:52   ` Alexander Gordeev
@ 2023-08-14 14:47   ` Geert Uytterhoeven
  2023-08-17 10:53   ` Alexander Gordeev
  2 siblings, 0 replies; 68+ messages in thread
From: Geert Uytterhoeven @ 2023-08-14 14:47 UTC (permalink / raw)
  To: Jiri Slaby (SUSE)
  Cc: gregkh, linux-serial, linux-kernel, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Chris Zankel, Max Filippov, Arnd Bergmann,
	Vaibhav Gupta, Jens Taprogge, Karsten Keil, Scott Branden,
	Ulf Hansson, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, David Lin, Johan Hovold,
	Alex Elder, Laurentiu Tudor, Jiri Kosina, David Sterba, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Arnaud Pouliquen, Oliver Neukum, Mathias Nyman,
	Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz

On Thu, Aug 10, 2023 at 11:16 AM Jiri Slaby (SUSE) <jirislaby@kernel.org> wrote:
> Data are now typed as u8. Propagate this change to
> tty_operations::write().
>
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>

>  arch/m68k/emu/nfcon.c                  | 3 +--
>  drivers/tty/amiserial.c                | 2 +-

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> # m68k
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # m68k

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 29/36] tty: make tty_operations::write()'s count size_t
  2023-08-10  9:15 ` [PATCH 29/36] tty: make tty_operations::write()'s count size_t Jiri Slaby (SUSE)
@ 2023-08-14 17:58   ` Geert Uytterhoeven
  0 siblings, 0 replies; 68+ messages in thread
From: Geert Uytterhoeven @ 2023-08-14 17:58 UTC (permalink / raw)
  To: Jiri Slaby (SUSE); +Cc: gregkh, linux-serial, linux-kernel

On Thu, Aug 10, 2023 at 11:39 AM Jiri Slaby (SUSE) <jirislaby@kernel.org> wrote:
> Unify with the rest of the code. Use size_t for counts and ssize_t for
> retval.
>
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>

>  arch/m68k/emu/nfcon.c                  | 3 ++-
>  drivers/tty/amiserial.c                | 2 +-

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> # m68k
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # m68k

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 34/36] tty: gdm724x: convert counts to size_t
  2023-08-10  9:15 ` [PATCH 34/36] tty: gdm724x: " Jiri Slaby (SUSE)
  2023-08-10  9:42   ` Dan Carpenter
@ 2023-08-15 17:22   ` Nathan Chancellor
  2023-08-16  6:46     ` Jiri Slaby
  1 sibling, 1 reply; 68+ messages in thread
From: Nathan Chancellor @ 2023-08-15 17:22 UTC (permalink / raw)
  To: Jiri Slaby (SUSE); +Cc: gregkh, linux-serial, linux-kernel, linux-staging

On Thu, Aug 10, 2023 at 11:15:08AM +0200, Jiri Slaby (SUSE) wrote:
> 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().

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

> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Cc: linux-staging@lists.linux.dev
> ---
>  drivers/staging/gdm724x/gdm_tty.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
> index b31f2afb0286..cbaaa8fa7474 100644
> --- a/drivers/staging/gdm724x/gdm_tty.c
> +++ b/drivers/staging/gdm724x/gdm_tty.c
> @@ -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
>  
>  static 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,
> -- 
> 2.41.0
> 

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 34/36] tty: gdm724x: convert counts to size_t
  2023-08-15 17:22   ` [PATCH 34/36] tty: gdm724x: convert counts to size_t Nathan Chancellor
@ 2023-08-16  6:46     ` Jiri Slaby
  2023-08-16  8:40       ` David Laight
  0 siblings, 1 reply; 68+ messages in thread
From: Jiri Slaby @ 2023-08-16  6:46 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: gregkh, linux-serial, linux-kernel, linux-staging

On 15. 08. 23, 19:22, Nathan Chancellor wrote:
> On Thu, Aug 10, 2023 at 11:15:08AM +0200, Jiri Slaby (SUSE) wrote:
>> 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().
> 
> 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:

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,
-- 
js
suse labs


^ permalink raw reply	[flat|nested] 68+ messages in thread

* RE: [PATCH 34/36] tty: gdm724x: convert counts to size_t
  2023-08-16  6:46     ` Jiri Slaby
@ 2023-08-16  8:40       ` David Laight
  2023-08-16  8:58         ` Jiri Slaby
  0 siblings, 1 reply; 68+ messages in thread
From: David Laight @ 2023-08-16  8:40 UTC (permalink / raw)
  To: 'Jiri Slaby', Nathan Chancellor
  Cc: gregkh@linuxfoundation.org, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev

From: Jiri Slaby
> Sent: Wednesday, August 16, 2023 7:47 AM
> 
> On 15. 08. 23, 19:22, Nathan Chancellor wrote:
> > On Thu, Aug 10, 2023 at 11:15:08AM +0200, Jiri Slaby (SUSE) wrote:
> >> 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().
> >
> > 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:
> 
> 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.

'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)

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 34/36] tty: gdm724x: convert counts to size_t
  2023-08-16  8:40       ` David Laight
@ 2023-08-16  8:58         ` Jiri Slaby
  2023-08-16  9:18           ` David Laight
  0 siblings, 1 reply; 68+ messages in thread
From: Jiri Slaby @ 2023-08-16  8:58 UTC (permalink / raw)
  To: David Laight, Nathan Chancellor
  Cc: gregkh@linuxfoundation.org, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev

On 16. 08. 23, 10:40, David Laight wrote:
> From: Jiri Slaby
>> Sent: Wednesday, August 16, 2023 7:47 AM
>>
>> On 15. 08. 23, 19:22, Nathan Chancellor wrote:
>>> On Thu, Aug 10, 2023 at 11:15:08AM +0200, Jiri Slaby (SUSE) wrote:
>>>> 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().
>>>
>>> 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:
>>
>> 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.
> 
> '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.)

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/b4ce9dad748e489f9314a2dc95615033@AcuMS.aculab.com/

thanks,
-- 
js
suse labs


^ permalink raw reply	[flat|nested] 68+ messages in thread

* RE: [PATCH 34/36] tty: gdm724x: convert counts to size_t
  2023-08-16  8:58         ` Jiri Slaby
@ 2023-08-16  9:18           ` David Laight
  0 siblings, 0 replies; 68+ messages in thread
From: David Laight @ 2023-08-16  9:18 UTC (permalink / raw)
  To: 'Jiri Slaby', Nathan Chancellor
  Cc: gregkh@linuxfoundation.org, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev

From: Jiri Slaby
> Sent: Wednesday, August 16, 2023 9:59 AM
...
> > '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.)
> 
> 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

> 
> [1]
> https://lore.kernel.org/all/b4ce9dad748e489f9314a2dc95615033@AcuMS.aculab.com/
> 
> thanks,
> --
> js
> suse labs

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 27/36] tty: propagate u8 data to tty_operations::write()
  2023-08-11 11:52   ` Alexander Gordeev
@ 2023-08-17 10:42     ` Jiri Slaby
  0 siblings, 0 replies; 68+ messages in thread
From: Jiri Slaby @ 2023-08-17 10:42 UTC (permalink / raw)
  To: Alexander Gordeev
  Cc: gregkh, linux-serial, linux-kernel, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Geert Uytterhoeven,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Chris Zankel,
	Max Filippov, Arnd Bergmann, Vaibhav Gupta, Jens Taprogge,
	Karsten Keil, Scott Branden, Ulf Hansson, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger, Sven Schnelle, David Lin,
	Johan Hovold, Alex Elder, Laurentiu Tudor, Jiri Kosina,
	David Sterba, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Arnaud Pouliquen, Oliver Neukum,
	Mathias Nyman, Marcel Holtmann, Johan Hedberg,
	Luiz Augusto von Dentz

Hi,

On 11. 08. 23, 13:52, Alexander Gordeev wrote:
> On Thu, Aug 10, 2023 at 11:15:01AM +0200, Jiri Slaby (SUSE) wrote:
> 
> Hi Jiri,
> 
>> Data are now typed as u8. Propagate this change to
>> tty_operations::write().
> ...
>>   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 +-
> ...
>> diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
>> index a1fef666c9b0..16b6f430dfd3 100644
>> --- a/drivers/s390/char/con3215.c
>> +++ b/drivers/s390/char/con3215.c
>> @@ -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;
>> diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
>> index d9983550062d..123524bff734 100644
>> --- a/drivers/s390/char/con3270.c
>> +++ b/drivers/s390/char/con3270.c
>> @@ -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;
>>   
>> diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
>> index 971fbb52740b..cc0f6a97124e 100644
>> --- a/drivers/s390/char/sclp_tty.c
>> +++ b/drivers/s390/char/sclp_tty.c
>> @@ -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);
>> diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
>> index a32f34a1c6d2..44974d801c1e 100644
>> --- a/drivers/s390/char/sclp_vt220.c
>> +++ b/drivers/s390/char/sclp_vt220.c
>> @@ -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?

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).

> (I speak for s390, but the other affected archs are in the same boat I guess).


thanks,
-- 
js
suse labs


^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 27/36] tty: propagate u8 data to tty_operations::write()
  2023-08-10  9:15 ` [PATCH 27/36] tty: propagate u8 data to tty_operations::write() Jiri Slaby (SUSE)
  2023-08-11 11:52   ` Alexander Gordeev
  2023-08-14 14:47   ` Geert Uytterhoeven
@ 2023-08-17 10:53   ` Alexander Gordeev
  2 siblings, 0 replies; 68+ messages in thread
From: Alexander Gordeev @ 2023-08-17 10:53 UTC (permalink / raw)
  To: Jiri Slaby (SUSE)
  Cc: gregkh, linux-serial, linux-kernel, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Geert Uytterhoeven,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Chris Zankel,
	Max Filippov, Arnd Bergmann, Vaibhav Gupta, Jens Taprogge,
	Karsten Keil, Scott Branden, Ulf Hansson, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger, Sven Schnelle, David Lin,
	Johan Hovold, Alex Elder, Laurentiu Tudor, Jiri Kosina,
	David Sterba, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Arnaud Pouliquen, Oliver Neukum,
	Mathias Nyman, Marcel Holtmann, Johan Hedberg,
	Luiz Augusto von Dentz

On Thu, Aug 10, 2023 at 11:15:01AM +0200, Jiri Slaby (SUSE) wrote:
...
>  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 +--
...
> diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
> index a1fef666c9b0..16b6f430dfd3 100644
> --- a/drivers/s390/char/con3215.c
> +++ b/drivers/s390/char/con3215.c
> @@ -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;
> diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
> index d9983550062d..123524bff734 100644
> --- a/drivers/s390/char/con3270.c
> +++ b/drivers/s390/char/con3270.c
> @@ -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;
>  
> diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
> index 971fbb52740b..cc0f6a97124e 100644
> --- a/drivers/s390/char/sclp_tty.c
> +++ b/drivers/s390/char/sclp_tty.c
> @@ -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);
> diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
> index a32f34a1c6d2..44974d801c1e 100644
> --- a/drivers/s390/char/sclp_vt220.c
> +++ b/drivers/s390/char/sclp_vt220.c
> @@ -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:

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 28/36] tty: propagate u8 data to tty_operations::put_char()
  2023-08-10  9:15 ` [PATCH 28/36] tty: propagate u8 data to tty_operations::put_char() Jiri Slaby (SUSE)
  2023-08-14 14:44   ` Geert Uytterhoeven
@ 2023-08-17 10:55   ` Alexander Gordeev
  1 sibling, 0 replies; 68+ messages in thread
From: Alexander Gordeev @ 2023-08-17 10:55 UTC (permalink / raw)
  To: Jiri Slaby (SUSE)
  Cc: gregkh, linux-serial, linux-kernel, Geert Uytterhoeven,
	Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
	Sven Schnelle, Karsten Keil, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
	Mathias Nyman

On Thu, Aug 10, 2023 at 11:15:02AM +0200, Jiri Slaby (SUSE) wrote:
...
>  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 +-
...
> diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
> index 16b6f430dfd3..8bbce6a4d7f5 100644
> --- a/drivers/s390/char/con3215.c
> +++ b/drivers/s390/char/con3215.c
> @@ -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;
>  
> diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
> index 123524bff734..6374555a0937 100644
> --- a/drivers/s390/char/con3270.c
> +++ b/drivers/s390/char/con3270.c
> @@ -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;
>  
> diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
> index cc0f6a97124e..831a8c7cacc2 100644
> --- a/drivers/s390/char/sclp_tty.c
> +++ b/drivers/s390/char/sclp_tty.c
> @@ -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) {
> diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
> index 44974d801c1e..e148350c1e2c 100644
> --- a/drivers/s390/char/sclp_vt220.c
> +++ b/drivers/s390/char/sclp_vt220.c
> @@ -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:

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>

Thanks!

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 16/36] tty: use u8 for chars
  2023-08-11 10:28   ` Ilpo Järvinen
  2023-08-14  6:35     ` Jiri Slaby
@ 2023-08-31 18:33     ` Andy Shevchenko
  1 sibling, 0 replies; 68+ messages in thread
From: Andy Shevchenko @ 2023-08-31 18:33 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Jiri Slaby (SUSE), Greg Kroah-Hartman, linux-serial, LKML,
	William Hubbs, Chris Brannon, Kirk Reiser, Samuel Thibault,
	Dmitry Torokhov, Arnd Bergmann, Max Staudt, Wolfgang Grandegger,
	Marc Kleine-Budde, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Dario Binacchi, Andreas Koensgen, Jeremy Kerr,
	Matt Johnston, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Peter Ujfalusi

On Fri, Aug 11, 2023 at 01:28:56PM +0300, Ilpo Järvinen wrote:
> On Thu, 10 Aug 2023, Jiri Slaby (SUSE) wrote:

...

> > @@ -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?

It might be the performance issue due to unaligned accesses on some
architectures. But I'm just speculating...

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 68+ messages in thread

end of thread, other threads:[~2023-08-31 18:33 UTC | newest]

Thread overview: 68+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-10  9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 01/36] tty: xtensa/iss: drop unneeded tty_operations hooks Jiri Slaby (SUSE)
2023-08-10 12:37   ` Max Filippov
2023-08-10  9:14 ` [PATCH 02/36] tty: ldisc: document that ldops are optional Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 03/36] tty: remove dummy tty_ldisc_ops::poll() implementations Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 04/36] tty: n_null: remove optional ldops Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 05/36] tty: change tty_write_lock()'s ndelay parameter to bool Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 06/36] tty: tty_port: rename 'disc' to 'ld' Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 07/36] tty: drop tty_debug_wait_until_sent() Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 08/36] tty: make tty_change_softcar() more understandable Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 09/36] tty: make tty_port_client_operations operate with u8 Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 10/36] tty: make counts in tty_port_client_operations hooks size_t Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 11/36] tty: switch receive_buf() counts to size_t Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 12/36] tty: switch count in tty_ldisc_receive_buf() " Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 13/36] tty: can327: unify error paths in can327_ldisc_rx() Jiri Slaby (SUSE)
2023-08-11 21:32   ` Max Staudt
2023-08-10  9:14 ` [PATCH 14/36] tty: can327, move overflow test inside can327_ldisc_rx()'s loop Jiri Slaby (SUSE)
2023-08-11 21:34   ` Max Staudt
2023-08-10  9:14 ` [PATCH 15/36] tty: make tty_ldisc_ops::*buf*() hooks operate on size_t Jiri Slaby (SUSE)
2023-08-10 12:02   ` Mark Brown
2023-08-11 21:34   ` Max Staudt
2023-08-10  9:14 ` [PATCH 16/36] tty: use u8 for chars Jiri Slaby (SUSE)
2023-08-10 12:04   ` Mark Brown
2023-08-11 10:28   ` Ilpo Järvinen
2023-08-14  6:35     ` Jiri Slaby
2023-08-31 18:33     ` Andy Shevchenko
2023-08-11 21:34   ` Max Staudt
2023-08-10  9:14 ` [PATCH 17/36] tty: use u8 for flags Jiri Slaby (SUSE)
2023-08-10 12:05   ` Mark Brown
2023-08-11 21:35   ` Max Staudt
2023-08-10  9:14 ` [PATCH 18/36] misc: ti-st: make st_recv() conforming to tty_ldisc_ops::receive_buf() Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 19/36] tty: make char_buf_ptr()/flag_buf_ptr()'s offset unsigned Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 20/36] tty: tty_buffer: make all offsets unsigned Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 21/36] tty: don't pass write() to do_tty_write() Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 22/36] tty: rename and de-inline do_tty_write() Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 23/36] tty: use min() in iterate_tty_write() Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 24/36] tty: use ssize_t for iterate_tty_read() returned type Jiri Slaby (SUSE)
2023-08-10  9:14 ` [PATCH 25/36] tty: switch size and count types in iterate_tty_read() to size_t Jiri Slaby (SUSE)
2023-08-10  9:15 ` [PATCH 26/36] tty: use min() for size computation in iterate_tty_read() Jiri Slaby (SUSE)
2023-08-10  9:15 ` [PATCH 27/36] tty: propagate u8 data to tty_operations::write() Jiri Slaby (SUSE)
2023-08-11 11:52   ` Alexander Gordeev
2023-08-17 10:42     ` Jiri Slaby
2023-08-14 14:47   ` Geert Uytterhoeven
2023-08-17 10:53   ` Alexander Gordeev
2023-08-10  9:15 ` [PATCH 28/36] tty: propagate u8 data to tty_operations::put_char() Jiri Slaby (SUSE)
2023-08-14 14:44   ` Geert Uytterhoeven
2023-08-17 10:55   ` Alexander Gordeev
2023-08-10  9:15 ` [PATCH 29/36] tty: make tty_operations::write()'s count size_t Jiri Slaby (SUSE)
2023-08-14 17:58   ` Geert Uytterhoeven
2023-08-10  9:15 ` [PATCH 30/36] tty: audit: unify to u8 Jiri Slaby (SUSE)
2023-08-10  9:15 ` [PATCH 31/36] tty: ldops: " Jiri Slaby (SUSE)
2023-08-10  9:15 ` [PATCH 32/36] tty: hvc: convert counts to size_t Jiri Slaby (SUSE)
2023-08-10  9:15 ` [PATCH 33/36] tty: vcc: " Jiri Slaby (SUSE)
2023-08-10  9:15 ` [PATCH 34/36] tty: gdm724x: " Jiri Slaby (SUSE)
2023-08-10  9:42   ` Dan Carpenter
2023-08-10 10:08     ` Jiri Slaby
2023-08-10 10:39     ` [PATCH 34-and-three-quarters/36] tty: gdm724x: simplify gdm_tty_write() Jiri Slaby (SUSE)
2023-08-11  9:11       ` Ilpo Järvinen
2023-08-15 17:22   ` [PATCH 34/36] tty: gdm724x: convert counts to size_t Nathan Chancellor
2023-08-16  6:46     ` Jiri Slaby
2023-08-16  8:40       ` David Laight
2023-08-16  8:58         ` Jiri Slaby
2023-08-16  9:18           ` David Laight
2023-08-10  9:15 ` [PATCH 35/36] tty: hso: simplify hso_serial_write() Jiri Slaby (SUSE)
2023-08-10  9:15 ` [PATCH 36/36] tty: rfcomm: convert counts to size_t Jiri Slaby (SUSE)
2023-08-11 10:26 ` [PATCH 00/36] tty: type unifications -- part I Ilpo Järvinen
2023-08-14  6:59   ` Jiri Slaby
2023-08-14 14:47     ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).