public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-serial <linux-serial@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 00/36] tty: type unifications -- part I.
Date: Fri, 11 Aug 2023 13:26:01 +0300 (EEST)	[thread overview]
Message-ID: <728dc060-d38c-b8d4-783-2322115cf4b4@linux.intel.com> (raw)
In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org>

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

  parent reply	other threads:[~2023-08-11 10:26 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Ilpo Järvinen [this message]
2023-08-14  6:59   ` [PATCH 00/36] tty: type unifications -- part I Jiri Slaby
2023-08-14 14:47     ` Ilpo Järvinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=728dc060-d38c-b8d4-783-2322115cf4b4@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox