platform/kernel/linux-starfive.git
11 months agotty: ldops: unify to u8
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:15:05 +0000 (11:15 +0200)]
tty: ldops: unify to u8

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>
Link: https://lore.kernel.org/r/20230810091510.13006-32-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: audit: unify to u8
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:15:04 +0000 (11:15 +0200)]
tty: audit: unify to u8

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>
Link: https://lore.kernel.org/r/20230810091510.13006-31-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: make tty_operations::write()'s count size_t
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:15:03 +0000 (11:15 +0200)]
tty: make tty_operations::write()'s count size_t

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>
Link: https://lore.kernel.org/r/20230810091510.13006-30-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: propagate u8 data to tty_operations::put_char()
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:15:02 +0000 (11:15 +0200)]
tty: propagate u8 data to tty_operations::put_char()

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>
Link: https://lore.kernel.org/r/20230810091510.13006-29-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: propagate u8 data to tty_operations::write()
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:15:01 +0000 (11:15 +0200)]
tty: propagate u8 data to tty_operations::write()

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>
Link: https://lore.kernel.org/r/20230810091510.13006-28-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: use min() for size computation in iterate_tty_read()
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:15:00 +0000 (11:15 +0200)]
tty: use min() for size computation in iterate_tty_read()

The computation is more obvious with min().

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230810091510.13006-27-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: switch size and count types in iterate_tty_read() to size_t
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:59 +0000 (11:14 +0200)]
tty: switch size and count types in iterate_tty_read() to size_t

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>
Link: https://lore.kernel.org/r/20230810091510.13006-26-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: use ssize_t for iterate_tty_read() returned type
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:58 +0000 (11:14 +0200)]
tty: use ssize_t for iterate_tty_read() returned type

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>
Link: https://lore.kernel.org/r/20230810091510.13006-25-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: use min() in iterate_tty_write()
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:57 +0000 (11:14 +0200)]
tty: use min() in iterate_tty_write()

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>
Link: https://lore.kernel.org/r/20230810091510.13006-24-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: rename and de-inline do_tty_write()
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:56 +0000 (11:14 +0200)]
tty: rename and de-inline do_tty_write()

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>
Link: https://lore.kernel.org/r/20230810091510.13006-23-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: don't pass write() to do_tty_write()
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:55 +0000 (11:14 +0200)]
tty: don't pass write() to do_tty_write()

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>
Link: https://lore.kernel.org/r/20230810091510.13006-22-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: tty_buffer: make all offsets unsigned
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:54 +0000 (11:14 +0200)]
tty: tty_buffer: make all offsets unsigned

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>
Link: https://lore.kernel.org/r/20230810091510.13006-21-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: make char_buf_ptr()/flag_buf_ptr()'s offset unsigned
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:53 +0000 (11:14 +0200)]
tty: make char_buf_ptr()/flag_buf_ptr()'s offset unsigned

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>
Link: https://lore.kernel.org/r/20230810091510.13006-20-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agomisc: ti-st: make st_recv() conforming to tty_ldisc_ops::receive_buf()
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:52 +0000 (11:14 +0200)]
misc: ti-st: make st_recv() conforming to tty_ldisc_ops::receive_buf()

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>
Link: https://lore.kernel.org/r/20230810091510.13006-19-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: use u8 for flags
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:51 +0000 (11:14 +0200)]
tty: use u8 for flags

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>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230810091510.13006-18-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: use u8 for chars
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:50 +0000 (11:14 +0200)]
tty: use u8 for chars

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>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230810091510.13006-17-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: make tty_ldisc_ops::*buf*() hooks operate on size_t
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:49 +0000 (11:14 +0200)]
tty: make tty_ldisc_ops::*buf*() hooks operate on size_t

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>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230810091510.13006-16-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: can327, move overflow test inside can327_ldisc_rx()'s loop
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:48 +0000 (11:14 +0200)]
tty: can327, move overflow test inside can327_ldisc_rx()'s loop

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
Link: https://lore.kernel.org/r/20230810091510.13006-15-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: can327: unify error paths in can327_ldisc_rx()
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:47 +0000 (11:14 +0200)]
tty: can327: unify error paths in can327_ldisc_rx()

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
Link: https://lore.kernel.org/r/20230810091510.13006-14-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: switch count in tty_ldisc_receive_buf() to size_t
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:46 +0000 (11:14 +0200)]
tty: switch count in tty_ldisc_receive_buf() to size_t

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>
Link: https://lore.kernel.org/r/20230810091510.13006-13-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: switch receive_buf() counts to size_t
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:45 +0000 (11:14 +0200)]
tty: switch receive_buf() counts to size_t

'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>
Link: https://lore.kernel.org/r/20230810091510.13006-12-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: make counts in tty_port_client_operations hooks size_t
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:44 +0000 (11:14 +0200)]
tty: make counts in tty_port_client_operations hooks size_t

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>
Link: https://lore.kernel.org/r/20230810091510.13006-11-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: make tty_port_client_operations operate with u8
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:43 +0000 (11:14 +0200)]
tty: make tty_port_client_operations operate with u8

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>
Link: https://lore.kernel.org/r/20230810091510.13006-10-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: make tty_change_softcar() more understandable
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:42 +0000 (11:14 +0200)]
tty: make tty_change_softcar() more understandable

* 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>
Link: https://lore.kernel.org/r/20230810091510.13006-9-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: drop tty_debug_wait_until_sent()
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:41 +0000 (11:14 +0200)]
tty: drop tty_debug_wait_until_sent()

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>
Link: https://lore.kernel.org/r/20230810091510.13006-8-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: tty_port: rename 'disc' to 'ld'
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:40 +0000 (11:14 +0200)]
tty: tty_port: rename 'disc' to 'ld'

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>
Link: https://lore.kernel.org/r/20230810091510.13006-7-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: change tty_write_lock()'s ndelay parameter to bool
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:39 +0000 (11:14 +0200)]
tty: change tty_write_lock()'s ndelay parameter to bool

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

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230810091510.13006-6-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: n_null: remove optional ldops
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:38 +0000 (11:14 +0200)]
tty: n_null: remove optional ldops

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>
Link: https://lore.kernel.org/r/20230810091510.13006-5-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: remove dummy tty_ldisc_ops::poll() implementations
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:37 +0000 (11:14 +0200)]
tty: remove dummy tty_ldisc_ops::poll() implementations

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>
Link: https://lore.kernel.org/r/20230810091510.13006-4-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: ldisc: document that ldops are optional
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:36 +0000 (11:14 +0200)]
tty: ldisc: document that ldops are optional

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>
Link: https://lore.kernel.org/r/20230810091510.13006-3-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: xtensa/iss: drop unneeded tty_operations hooks
Jiri Slaby (SUSE) [Thu, 10 Aug 2023 09:14:35 +0000 (11:14 +0200)]
tty: xtensa/iss: drop unneeded tty_operations hooks

All ::flush_chars(), ::hangup(), and ::wait_until_sent() from struct
tty_operations are optional. There is no need to provide them with
empty bodies.

tty_operations::put_char() needs not be provided if it is the same as
tty_operations::write(tty, &ch, 1).

So drop all of them.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Link: https://lore.kernel.org/r/20230810091510.13006-2-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: serial: qcom-geni-serial: Poll primary sequencer irq status after cancel_tx
Vijaya Krishna Nivarthi [Wed, 9 Aug 2023 10:53:13 +0000 (16:23 +0530)]
tty: serial: qcom-geni-serial: Poll primary sequencer irq status after cancel_tx

TX is handled by primary sequencer. After cancelling primary command, poll
primary sequencer's irq status instead of that of secondary.
While at it, also remove a couple of redundant lines that read from IRQ_EN
register and write back same.

Fixes: 2aaa43c70778 ("tty: serial: qcom-geni-serial: add support for serial engine DMA")
Signed-off-by: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com>
Link: https://lore.kernel.org/r/1691578393-9891-1-git-send-email-quic_vnivarth@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: sifive: Remove redundant of_match_ptr()
Ruan Jinjie [Wed, 9 Aug 2023 08:55:41 +0000 (16:55 +0800)]
serial: sifive: Remove redundant of_match_ptr()

The driver depends on CONFIG_OF, it is not necessary to use
of_match_ptr() here.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20230809085541.2969654-1-ruanjinjie@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months ago8250_men_mcb: remove unnecessary cast when reading register
Sanjuán García, Jorge [Thu, 3 Aug 2023 09:59:07 +0000 (09:59 +0000)]
8250_men_mcb: remove unnecessary cast when reading register

Fixes following sparse warning:

drivers/tty/serial/8250/8250_men_mcb.c:92:21: sparse: cast removes
    address space '__iomem' of expression
drivers/tty/serial/8250/8250_men_mcb.c:92:21: sparse: incorrect type
    in argument 1 (different address spaces) expected void const volatile
    [noderef] __iomem *addr got void *

Fixes: 2554e6ba28a2 ("8250_men_mcb: Read num ports from register data.")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202307261517.x1O9OAkd-lkp@intel.com/
Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
Link: https://lore.kernel.org/r/20230803095816.110864-1-jorge.sanjuangarcia@duagon.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: cpm_uart: Remove linux/fs_uart_pd.h
Christophe Leroy [Thu, 3 Aug 2023 13:56:53 +0000 (15:56 +0200)]
serial: cpm_uart: Remove linux/fs_uart_pd.h

linux/fs_uart_pd.h is not used anymore. Remove it.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/f2cb444fa2b5776c9c51b5e46ea85edab62d1524.1691068700.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: cpm_uart: Don't include fs_uart_pd.h when not needed
Christophe Leroy [Thu, 3 Aug 2023 13:56:52 +0000 (15:56 +0200)]
serial: cpm_uart: Don't include fs_uart_pd.h when not needed

Remove inclusion of fs_uart_pd.h from all files not using
anything from that file.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/c7996ef4de56e7ee42a434e37d214cba337a146c.1691068700.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: cpm_uart: Remove stale prototype in powerpc/fsl_soc.c
Christophe Leroy [Thu, 3 Aug 2023 13:56:51 +0000 (15:56 +0200)]
serial: cpm_uart: Remove stale prototype in powerpc/fsl_soc.c

Commit 0b5cf10691eb ("[POWERPC] 8xx: Convert mpc866ads to the new
device binding.") removed last definition of init_smc_ioports().

Remove it.

And don't include anymore fs_uart_pd.h which is only included to
provide fs_uart_platform_info structure.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/2869659e7faa20b0a506347bc4d1059e22709f19.1691068700.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: cpm_uart: Remove cpm_uart/ subdirectory
Christophe Leroy [Thu, 3 Aug 2023 13:56:50 +0000 (15:56 +0200)]
serial: cpm_uart: Remove cpm_uart/ subdirectory

cpm_uart/ subdirectory only has cpm_uart_core.c and cpm_uart.h now.

Move them up and remove cpm_uart/ directory while renaming
cpm_uart_core.c as cpm_uart.c

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/9b8b8f89fc386480030f5339abe307541ae436a6.1691068700.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: cpm_uart: Refactor cpm_uart_[un]map_pram()
Christophe Leroy [Thu, 3 Aug 2023 13:56:49 +0000 (15:56 +0200)]
serial: cpm_uart: Refactor cpm_uart_[un]map_pram()

cpm_uart_map_pram() and cpm_uart_unmap_pram() are very
similar for CPM1 and CPM2.

On CPM1 cpm_uart_map_pram() uses of_iomap() while CPM2 uses
of_address_to_resource()/ioremap(). CPM2 version will also
work on CPM1.

On CPM2 cpm_uart_map_pram() and cpm_uart_unmap_pram() has a special
handling for SMC. Just gate it by an IS_ENABLED(CONFIG_CPM2).

So move the CPM2 version into cpm_uart_core.c which is the only
user of those two fonctions and refactor to also handle CPM1 as
mentionned above.

PROFF_SMC_SIZE is only defined for SMC2 and used only there. To make
it simple, just use the numerical value 64, this is the only place
it is used and anyway there's already the same numerical value for
the alignment.

Use cpm_muram_alloc() instead of cpm_dpalloc() macro.

Then cpm_uart_cpm1.c and cpm_uart_cpm2.c are now empty and go away.

Replace printk(KERN_WARN by pr_warn( to make checkpatch happier.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/44a266106c421319aa8e700c2db52d5dcd652c0f.1691068700.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: cpm_uart: Refactor cpm_uart_allocbuf()/cpm_uart_freebuf()
Christophe Leroy [Thu, 3 Aug 2023 13:56:48 +0000 (15:56 +0200)]
serial: cpm_uart: Refactor cpm_uart_allocbuf()/cpm_uart_freebuf()

cpm_uart_freebuf() is identical for CPM1 and CPM2.

cpm_uart_allocbuf() only has a small difference between CPM1 and CPM2
as shown below:

CPM1:
if (is_con) {
/* was hostalloc but changed cause it blows away the */
/* large tlb mapping when pinning the kernel area    */
mem_addr = (u8 *) cpm_dpram_addr(cpm_dpalloc(memsz, 8));
dma_addr = (u32)cpm_dpram_phys(mem_addr);
} else
mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, &dma_addr,
      GFP_KERNEL);

CPM2:

if (is_con) {
mem_addr = kzalloc(memsz, GFP_NOWAIT);
dma_addr = virt_to_bus(mem_addr);
}
else
mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, &dma_addr,
      GFP_KERNEL);

Refactor this by using IS_ENABLED(CONFIG_CPM1)
and move both functions in cpm_uart_core.c as they are used only there.

While doing this, add the necessary casts to silence sparse for the CPM1
part. This is because a dma alloc is not expected to be an iomem but
for CPM1 as we use DPRAM this is seen as iomem.

Also replace calls to cpm_dpxxxx() by relevant cpm_muram_xxxx() calls.
This is needed at least for cpm_dpram_phys() which is only defined
for CPM1. Just do the same for all so that cpm_dpxxxx() macros can get
droped in the future.

To silence checkpatch, replace printk(KERN_ERR by pr_err( and display
function name instead of hard coded filename. Also replace
mem_addr == NULL by !mem_addr.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/606dfdd258a4f2f2882e2e189bef37526bb3b499.1691068700.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: cpm_uart: Deduplicate cpm_line_cr_cmd()
Christophe Leroy [Thu, 3 Aug 2023 13:56:47 +0000 (15:56 +0200)]
serial: cpm_uart: Deduplicate cpm_line_cr_cmd()

cpm_line_cr_cmd() is identical for CPM1 and CPM2 and
is used only in cpm_uart_core.c. Move it there.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/6996e6ff93067dcddebf0d0c86487345149e165c.1691068700.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: cpm_uart: Deduplicate cpm_set_{brg/smc_fcr/scc_fcr}()
Christophe Leroy [Thu, 3 Aug 2023 13:56:46 +0000 (15:56 +0200)]
serial: cpm_uart: Deduplicate cpm_set_{brg/smc_fcr/scc_fcr}()

CPMFCR_EB is the same as SMC_EB and is defined
for both CPM1 and CPM2.

CPMFCR_GBL is defined as 0 for CPM1.

Therefore the CPM2 version of cpm_set_scc_fcr() and
cpm_set_smc_fcr() can be used on both CPM1 and CPM2.

And cpm_set_brg() is already identical and just a
wrapper of cpm_setbrg().

In addition those three fonctions are only called once
from cpm_uart_core.c, so just replace the calls with
the content of the CPM2 versions of them.

And DPRAM_BASE is identical so can go in cpm_uart.h. While
moving it, use cpm_muram_addr() directly instead of the
cpm_dpram_addr() macro and remove __force tag which isn't needed.

Then cpm_uart_cpm1.h and cpm_uart_cpm2.h go away.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/6920e61fd362961ae1aeda897c8bfe1efacdc9dc.1691068700.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: cpm_uart: Use get_baudrate() instead of uart_baudrate()
Christophe Leroy [Thu, 3 Aug 2023 13:56:45 +0000 (15:56 +0200)]
serial: cpm_uart: Use get_baudrate() instead of uart_baudrate()

uart_baudrate() is just a trivial wrapper to get_baudrate().

Use get_baudrate() directly and remove assignment in if condition.

And also remove uart_clock() which is not used since
commit 0b2a2e5b7747 ("cpm_uart: Remove !CONFIG_PPC_CPM_NEW_BINDING
code")

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/4d497386f576a3df768e44a04f9bb512e424c311.1691068700.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: cpm_uart: Stop using fs_uart_id enum
Christophe Leroy [Thu, 3 Aug 2023 13:56:44 +0000 (15:56 +0200)]
serial: cpm_uart: Stop using fs_uart_id enum

Using an enum indirection to define numeric macros is
pointless. Directly use the wanted numeric value.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/4772d2a21894db443fe42836421eb22206a334aa.1691068700.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: cpm_uart: Remove stale prototypes and table and macros
Christophe Leroy [Thu, 3 Aug 2023 13:56:43 +0000 (15:56 +0200)]
serial: cpm_uart: Remove stale prototypes and table and macros

cpm_uart_init_portdesc()
smc1_lineif()
smc2_lineif()
scc1_lineif()
scc2_lineif()
scc3_lineif()
scc4_lineif()

Those functions were removed by commit 0b2a2e5b7747 ("cpm_uart: Remove
!CONFIG_PPC_CPM_NEW_BINDING code"). Remove stale prototypes.

UART_SMC{1..2} and UART_SCC{1..4} and SCC_WAIT_CLOSING macros are not
used anymore since the above commit.

cpm_uart_ports[] isn't used outside cpm_uart_core.c since the
same commit, so make it static.

cpm_uart_init_smc() and cpm_uart_init_scc() don't need a forward
declaration.

FLAG_DISCARDING and IS_DISCARDING have never been used since at
least 2.6.12 and the start of git repository for kernel.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/96ef20ae1df056d1b7967871ba6e27e5b5aaeea6.1691068700.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: cpm_uart: Avoid suspicious locking
Christophe Leroy [Thu, 3 Aug 2023 13:56:42 +0000 (15:56 +0200)]
serial: cpm_uart: Avoid suspicious locking

  CHECK   drivers/tty/serial/cpm_uart/cpm_uart_core.c
drivers/tty/serial/cpm_uart/cpm_uart_core.c:1271:39: warning: context imbalance in 'cpm_uart_console_write' - unexpected unlock

Allthough 'nolock' is not expected to change, sparse find the following
form suspicious:

if (unlikely(nolock)) {
local_irq_save(flags);
} else {
spin_lock_irqsave(&pinfo->port.lock, flags);
}

cpm_uart_early_write(pinfo, s, count, true);

if (unlikely(nolock)) {
local_irq_restore(flags);
} else {
spin_unlock_irqrestore(&pinfo->port.lock, flags);
}

Rewrite it a more obvious form:

if (unlikely(oops_in_progress)) {
local_irq_save(flags);
cpm_uart_early_write(pinfo, s, count, true);
local_irq_restore(flags);
} else {
spin_lock_irqsave(&pinfo->port.lock, flags);
cpm_uart_early_write(pinfo, s, count, true);
spin_unlock_irqrestore(&pinfo->port.lock, flags);
}

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/f7da5cdc9287960185829cfef681a7d8614efa1f.1691068700.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months ago8250_men_mcb: Remove redundant initialization owner in mcb_driver
Li Zetao [Fri, 4 Aug 2023 10:08:43 +0000 (18:08 +0800)]
8250_men_mcb: Remove redundant initialization owner in mcb_driver

The module_mcb_driver() will set "THIS_MODULE" to driver.owner when
register a mcb_driver driver, so it is redundant initialization to set
driver.owner in mcb_driver statement. Remove it for clean code.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
Link: https://lore.kernel.org/r/20230804100843.100348-1-lizetao1@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months ago8250_men_mcb: Fix unsigned expression compared with zero
Li Zetao [Thu, 3 Aug 2023 14:20:53 +0000 (22:20 +0800)]
8250_men_mcb: Fix unsigned expression compared with zero

There is a warning reported by coccinelle:

./drivers/tty/serial/8250/8250_men_mcb.c:226:6-19: WARNING:
Unsigned expression compared with zero: data -> line [ i ]     <     0

The array "line" of serial_8250_men_mcb_data is used to record the
registered serial port. When register a port failed, it will return
an error code, but the type of "line" is "unsigned int", causing
the error code to reverse. Modify the type of "data -> line" to solve
this problem.

Fixes: 2554e6ba28a2 ("8250_men_mcb: Read num ports from register data.")
Signed-off-by: Li Zetao <lizetao1@huawei.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230803142053.1308926-1-lizetao1@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: max310x: fix typos in comments
Hugo Villeneuve [Thu, 3 Aug 2023 17:59:31 +0000 (13:59 -0400)]
serial: max310x: fix typos in comments

cotroller -> controller.

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Link: https://lore.kernel.org/r/20230803175931.981625-1-hugo@hugovil.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoserial: max310x: add comments for membase address workaround
Hugo Villeneuve [Thu, 3 Aug 2023 14:05:51 +0000 (10:05 -0400)]
serial: max310x: add comments for membase address workaround

Add comments about workaround used to configure membase address. This
follows suggestions made during review of a sc16is7xx driver patch to
add the same workaround.

Link: https://lore.kernel.org/lkml/2936e18f-44ea-faed-9fa0-2ddefe7c3194@linux.intel.com
Link: https://lore.kernel.org/lkml/20230801131655.80bd8f97f018dda6155d65f6@hugovil.com/
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Link: https://lore.kernel.org/r/20230803140551.970141-1-hugo@hugovil.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: n_gsm: require CAP_NET_ADMIN to attach N_GSM0710 ldisc
Thadeu Lima de Souza Cascardo [Mon, 31 Jul 2023 18:59:42 +0000 (15:59 -0300)]
tty: n_gsm: require CAP_NET_ADMIN to attach N_GSM0710 ldisc

Any unprivileged user can attach N_GSM0710 ldisc, but it requires
CAP_NET_ADMIN to create a GSM network anyway.

Require initial namespace CAP_NET_ADMIN to do that.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Link: https://lore.kernel.org/r/20230731185942.279611-1-cascardo@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months ago8250_men_mcb: Fix unsigned comparison with less than zero
Jiapeng Chong [Thu, 3 Aug 2023 08:47:53 +0000 (16:47 +0800)]
8250_men_mcb: Fix unsigned comparison with less than zero

The data->line[i] is defined as unsigned int type, if(data->line[i] < 0)
is invalid, so replace data->line[i] with res.

./drivers/tty/serial/8250/8250_men_mcb.c:223:6-19: WARNING: Unsigned expression compared with zero: data->line[i] < 0.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=6088
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230803084753.51253-1-jiapeng.chong@linux.alibaba.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: serial: samsung: Set missing PM ops for hibernation support
Anton Eliasson [Thu, 3 Aug 2023 11:26:42 +0000 (13:26 +0200)]
tty: serial: samsung: Set missing PM ops for hibernation support

At least freeze, restore and thaw need to be set in order for the driver
to support system hibernation. The existing suspend/resume functions can
be reused since those functions don't touch the device's power state or
wakeup capability. Use the helper macros SET_SYSTEM_SLEEP_PM_OPS and
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS for symmetry with similar drivers.

Signed-off-by: Anton Eliasson <anton.eliasson@axis.com>
Link: https://lore.kernel.org/r/20230803-samsung_tty_pm_ops-v1-1-1ea7be72194d@axis.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: serial: xilinx_uartps: Do not check for 0 return after calling platform_get_irq()
Ruan Jinjie [Thu, 3 Aug 2023 09:17:12 +0000 (17:17 +0800)]
tty: serial: xilinx_uartps: Do not check for 0 return after calling platform_get_irq()

Since commit a85a6c86c25b ("driver core: platform: Clarify that
IRQ 0 is invalid"), there is no possible for
platform_get_irq() to return 0. Use the return value
from platform_get_irq().

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20230803091712.596987-1-ruanjinjie@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: synclink_gt: Fix potential deadlock on &info->lock
Chengfeng Ye [Fri, 28 Jul 2023 12:39:01 +0000 (12:39 +0000)]
tty: synclink_gt: Fix potential deadlock on &info->lock

As &info->lock is acquired by slgt_interrupt() under irq context, other
process context code acquiring the lock should disable irq, otherwise
deadlock could happen if the irq preempt the execution while the
lock is held in process context on the same CPU.

Lock acquisition inside set_params32() does not disable irq, and this
function is called by slgt_compat_ioctl() from process context.

Possible deadlock scenario:
slgt_compat_ioctl()
    -> set_params32()
    -> spin_lock(&info->lock)
        <irq>
        -> slgt_interrupt()
        -> spin_lock(&info->lock); (deadlock here)

This flaw was found by an experimental static analysis tool I am developing
for irq-related deadlock. x86_64 allmodconfig using gcc shows no new
warning.

The patch fixes the potential deadlock by spin_lock_irqsave() like other
lock acquisition sites.

Signed-off-by: Chengfeng Ye <dg573847474@gmail.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230728123901.64225-1-dg573847474@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: vt: Remove some repetitive initialization
oushixiong [Thu, 3 Aug 2023 06:54:09 +0000 (14:54 +0800)]
tty: vt: Remove some repetitive initialization

Members vc_col, vc_rows and vc_size_row of the struct vc_data have been
initialized in visual_init(), so it is no longer needed to initialize
them in vc_init() again.

Signed-off-by: oushixiong <oushixiong@kylinos.cn>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230803065409.461031-1-oushixiong@kylinos.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agotty: serial: Remove redundant initialization for ma35d1serial_driver
Li Zetao [Thu, 3 Aug 2023 03:23:53 +0000 (11:23 +0800)]
tty: serial: Remove redundant initialization for ma35d1serial_driver

There is a warning reported by coccinelle:

./drivers/tty/serial/ma35d1_serial.c:791:3-8:
No need to set .owner here. The core will do it.

The module_platform_driver() will set "THIS_MODULE" to driver.owner
when register a driver for platform-level devices, so it is redundant
initialization to set driver.owner in ma35d1serial_driver statement.
Remove it to silence the warning.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
Link: https://lore.kernel.org/r/20230803032353.3045221-1-lizetao1@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agonet: nfc: remove casts from tty->disc_data
Jiri Slaby [Tue, 1 Aug 2023 06:22:37 +0000 (08:22 +0200)]
net: nfc: remove casts from tty->disc_data

tty->disc_data is 'void *', so there is no need to cast from that.
Therefore remove the casts and assign the pointer directly.

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: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: linux-can@vger.kernel.org
Cc: netdev@vger.kernel.org
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Max Staudt <max@enpas.org>
Link: https://lore.kernel.org/r/20230801062237.2687-3-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agocan: can327: remove casts from tty->disc_data
Jiri Slaby [Tue, 1 Aug 2023 06:22:36 +0000 (08:22 +0200)]
can: can327: remove casts from tty->disc_data

tty->disc_data is 'void *', so there is no need to cast from that.
Therefore remove the casts and assign the pointer directly.

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: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Cc: linux-can@vger.kernel.org
Cc: netdev@vger.kernel.org
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Max Staudt <max@enpas.org>
Link: https://lore.kernel.org/r/20230801062237.2687-2-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agotty: synclink_gt: mark as BROKEN
Jiri Slaby [Mon, 31 Jul 2023 09:00:02 +0000 (11:00 +0200)]
tty: synclink_gt: mark as BROKEN

After walking and trying to clean up the worst in the driver, I came
across the pci_driver::remove() _empty_ implementation. That would crash
the system at least during hot-unplug (or write to remove in sysfs).

There are many other problems:
* Initialization + deinitialization apparently comes from no-hotplug
  support age. It needs a rewrite.
* Hairy debug macros. Drop them.
* Use of self-baked lists. Replace by list.
* The order of the functions should be inverted and fwd decls dropped.
* Coding style from the stone age. Fix.
* I assume there are many bugs, but the code is unreadable at times, so
  hard to judge. There is one example posted [1].

I was able to find only one user back in 2016. So mark the driver as
BROKEN for some time. Either someone will notice and we can bring the
driver to this century. Or we will drop it completely if noone cares.

[1] https://lore.kernel.org/all/20230728123901.64225-1-dg573847474@gmail.com/

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Chengfeng Ye <dg573847474@gmail.com>
Link: https://lore.kernel.org/r/20230731090002.15680-8-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agotty: synclink_gt: make default_params const
Jiri Slaby [Mon, 31 Jul 2023 09:00:01 +0000 (11:00 +0200)]
tty: synclink_gt: make default_params const

default_params are only read, so move them from .data to .rodata using
'const'.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230731090002.15680-7-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agotty: synclink_gt: use PCI_VDEVICE
Jiri Slaby [Mon, 31 Jul 2023 09:00:00 +0000 (11:00 +0200)]
tty: synclink_gt: use PCI_VDEVICE

It makes the device entries quite a bit readable.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230731090002.15680-6-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agotty: synclink_gt: drop info messages from init/exit functions
Jiri Slaby [Mon, 31 Jul 2023 08:59:59 +0000 (10:59 +0200)]
tty: synclink_gt: drop info messages from init/exit functions

It is preferred NOT to print anything from init and exit functions of a
module. (If everything goes fine.)

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230731090002.15680-5-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agotty: synclink_gt: define global strings as const strings
Jiri Slaby [Mon, 31 Jul 2023 08:59:58 +0000 (10:59 +0200)]
tty: synclink_gt: define global strings as const strings

And not non-const pointers to strings.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230731090002.15680-4-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agotty: synclink_gt: drop global slgt_driver_name array
Jiri Slaby [Mon, 31 Jul 2023 08:59:57 +0000 (10:59 +0200)]
tty: synclink_gt: drop global slgt_driver_name array

It's used on one place, so put the containing string there directly.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230731090002.15680-3-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agotty: synclink_gt: convert CALC_REGADDR() macro to an inline
Jiri Slaby [Mon, 31 Jul 2023 08:59:56 +0000 (10:59 +0200)]
tty: synclink_gt: convert CALC_REGADDR() macro to an inline

It makes the code more readable and less error-prone as the result is
returned and not stored in a variable newly defined inside the macro.

Note that cast to 'unsigned long' and back to 'void *' was eliminated as
info->reg_addr is 'char *' already (so the addition is per bytes
already).

This nicely cleans up the callers too.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230731090002.15680-2-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agomisc: ti-st: don't check for tty data == NULL
Jiri Slaby [Mon, 31 Jul 2023 08:02:44 +0000 (10:02 +0200)]
misc: ti-st: don't check for tty data == NULL

tty data passed to tty_ldisc_ops::receive_buf() are never NULL. Remove
this check.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20230731080244.2698-11-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agomisc: ti-st: remove ptr from recv functions
Jiri Slaby [Mon, 31 Jul 2023 08:02:43 +0000 (10:02 +0200)]
misc: ti-st: remove ptr from recv functions

ptr is the same as data, so use ptr directly as a parameter and drop the
useless local variable.

Likely, the two were introduced to have a different type. But 'char' and
'unsigned char' are the same in the kernel for a long time.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20230731080244.2698-10-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agomisc: ti-st: remove forward declarations and make st_int_recv() static
Jiri Slaby [Mon, 31 Jul 2023 08:02:42 +0000 (10:02 +0200)]
misc: ti-st: remove forward declarations and make st_int_recv() static

st_kim_recv() is already declared in linux/ti_wilink_st.h. Given that is
already included in st_core.c, drop the re-declaration from there.

st_int_recv() is used only in st_core.c and the forward declaration is
not needed. So drop the declaration and make the function static.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20230731080244.2698-9-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agospeakup: switch to unsigned iterator in spk_ttyio_receive_buf2()
Jiri Slaby [Mon, 31 Jul 2023 08:02:41 +0000 (10:02 +0200)]
speakup: switch to unsigned iterator in spk_ttyio_receive_buf2()

Now, that spk_ttyio_receive_buf2() receives an unsigned count, the
iterator can/should be unsigned too. Switch to that to be explicit.

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: speakup@linux-speakup.org
Link: https://lore.kernel.org/r/20230731080244.2698-8-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agoserial: altera_jtaguart: switch status to u32
Jiri Slaby [Mon, 31 Jul 2023 08:02:40 +0000 (10:02 +0200)]
serial: altera_jtaguart: switch status to u32

'status' is assigned a result from readl(). There is no need for the
variable to be 'unsigned long'. readl() returns 32bit values.

Provided, this is a Nios II driver (32-bit), there is no change in
semantics. This only makes the type explicit.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Tobias Klauser <tklauser@distanz.ch>
Link: https://lore.kernel.org/r/20230731080244.2698-7-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agocan: slcan: remove casts from tty->disc_data
Jiri Slaby [Mon, 31 Jul 2023 08:02:39 +0000 (10:02 +0200)]
can: slcan: remove casts from tty->disc_data

tty->disc_data is 'void *', so there is no need to cast from that.
Therefore remove the casts and assign the pointer directly.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Dario Binacchi <dario.binacchi@amarulasolutions.com>
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
Cc: netdev@vger.kernel.org
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Link: https://lore.kernel.org/r/20230731080244.2698-6-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agoinput: serport: remove casts from tty->disc_data
Jiri Slaby [Mon, 31 Jul 2023 08:02:38 +0000 (10:02 +0200)]
input: serport: remove casts from tty->disc_data

tty->disc_data is 'void *', so there is no need to cast from that.
Therefore remove the casts and assign the pointer directly.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Link: https://lore.kernel.org/r/20230731080244.2698-5-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agotty: hvsi: remove an extra variable from hvsi_write()
Jiri Slaby [Mon, 31 Jul 2023 08:02:37 +0000 (10:02 +0200)]
tty: hvsi: remove an extra variable from hvsi_write()

'source' is the same as 'buf'. Rename the parameter ('buf') to
'source' and drop the local variable.

Likely, the two were introduced to have a different type. But 'char' and
'unsigned char' are the same in the kernel for a long time.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20230731080244.2698-4-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agoBluetooth: rfcomm: remove casts from tty->driver_data
Jiri Slaby [Mon, 31 Jul 2023 08:02:36 +0000 (10:02 +0200)]
Bluetooth: rfcomm: remove casts from tty->driver_data

tty->driver_data is 'void *', so there is no need to cast from that.
Therefore remove the casts and assign the pointer directly.

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: linux-bluetooth@vger.kernel.org
Link: https://lore.kernel.org/r/20230731080244.2698-3-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agoserial: move WARN_ON() in uart_write() to the condition
Jiri Slaby [Mon, 31 Jul 2023 08:02:35 +0000 (10:02 +0200)]
serial: move WARN_ON() in uart_write() to the condition

uart code currently does the following in uart_write() and
uart_flush_buffer():
  if (cond) {
    WARN_ON(1);
    return;
  }

It can be rewritten to more obvious and more readable:
  if (WARN_ON(cond))
    return;

Do so.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230731080244.2698-2-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agoMerge 6.5-rc4 into tty-next
Greg Kroah-Hartman [Mon, 31 Jul 2023 07:39:56 +0000 (09:39 +0200)]
Merge 6.5-rc4 into tty-next

We need the serial/tty fixes in here as well for testing and future
development.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agoLinux 6.5-rc4
Linus Torvalds [Sun, 30 Jul 2023 20:23:47 +0000 (13:23 -0700)]
Linux 6.5-rc4

12 months agoMerge tag 'spi-fix-v6.5-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Linus Torvalds [Sun, 30 Jul 2023 19:54:31 +0000 (12:54 -0700)]
Merge tag 'spi-fix-v6.5-rc3' of git://git./linux/kernel/git/broonie/spi

Pull spi fixes from Mark Brown:
 "A bunch of fixes for the Qualcomm QSPI driver, fixing multiple issues
  with the newly added DMA mode - it had a number of issues exposed when
  tested in a wider range of use cases, both race condition style issues
  and issues with different inputs to those that had been used in test"

* tag 'spi-fix-v6.5-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
  spi: spi-qcom-qspi: Add mem_ops to avoid PIO for badly sized reads
  spi: spi-qcom-qspi: Fallback to PIO for xfers that aren't multiples of 4 bytes
  spi: spi-qcom-qspi: Add DMA_CHAIN_DONE to ALL_IRQS
  spi: spi-qcom-qspi: Call dma_wmb() after setting up descriptors
  spi: spi-qcom-qspi: Use GFP_ATOMIC flag while allocating for descriptor
  spi: spi-qcom-qspi: Ignore disabled interrupts' status in isr

12 months agoMerge tag 'regulator-fix-v6.5-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 30 Jul 2023 19:52:05 +0000 (12:52 -0700)]
Merge tag 'regulator-fix-v6.5-rc3' of git://git./linux/kernel/git/broonie/regulator

Pull regulator fixes from Mark Brown:
 "A couple of small fixes for the the mt6358 driver, fixing error
  reporting and a bootstrapping issue"

* tag 'regulator-fix-v6.5-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
  regulator: mt6358: Fix incorrect VCN33 sync error message
  regulator: mt6358: Sync VCN33_* enable status after checking ID

12 months agoMerge tag 'usb-6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Linus Torvalds [Sun, 30 Jul 2023 18:57:51 +0000 (11:57 -0700)]
Merge tag 'usb-6.5-rc4' of git://git./linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
 "Here are a set of USB driver fixes for 6.5-rc4. Include in here are:

   - new USB serial device ids

   - dwc3 driver fixes for reported issues

   - typec driver fixes for reported problems

   - gadget driver fixes

   - reverts of some problematic USB changes that went into -rc1

  All of these have been in linux-next with no reported problems"

* tag 'usb-6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (24 commits)
  usb: misc: ehset: fix wrong if condition
  usb: dwc3: pci: skip BYT GPIO lookup table for hardwired phy
  usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config
  usb: gadget: call usb_gadget_check_config() to verify UDC capability
  usb: typec: Use sysfs_emit_at when concatenating the string
  usb: typec: Iterate pds array when showing the pd list
  usb: typec: Set port->pd before adding device for typec_port
  usb: typec: qcom: fix return value check in qcom_pmic_typec_probe()
  Revert "usb: gadget: tegra-xudc: Fix error check in tegra_xudc_powerdomain_init()"
  Revert "usb: xhci: tegra: Fix error check"
  USB: gadget: Fix the memory leak in raw_gadget driver
  usb: gadget: core: remove unbalanced mutex_unlock in usb_gadget_activate
  Revert "usb: dwc3: core: Enable AutoRetry feature in the controller"
  Revert "xhci: add quirk for host controllers that don't update endpoint DCS"
  USB: quirks: add quirk for Focusrite Scarlett
  usb: xhci-mtk: set the dma max_seg_size
  MAINTAINERS: drop invalid usb/cdns3 Reviewer e-mail
  usb: dwc3: don't reset device side if dwc3 was configured as host-only
  usb: typec: ucsi: move typec_set_mode(TYPEC_STATE_SAFE) to ucsi_unregister_partner()
  usb: ohci-at91: Fix the unhandle interrupt when resume
  ...

12 months agoMerge tag 'tty-6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Linus Torvalds [Sun, 30 Jul 2023 18:51:36 +0000 (11:51 -0700)]
Merge tag 'tty-6.5-rc4' of git://git./linux/kernel/git/gregkh/tty

Pull tty/serial fixes from Greg KH:
 "Here are some small TTY and serial driver fixes for 6.5-rc4 for some
  reported problems. Included in here is:

   - TIOCSTI fix for braille readers

   - documentation fix for minor numbers

   - MAINTAINERS update for new serial files in -rc1

   - minor serial driver fixes for reported problems

  All of these have been in linux-next with no reported problems"

* tag 'tty-6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
  serial: 8250_dw: Preserve original value of DLF register
  tty: serial: sh-sci: Fix sleeping in atomic context
  serial: sifive: Fix sifive_serial_console_setup() section
  Documentation: devices.txt: reconcile serial/ucc_uart minor numers
  MAINTAINERS: Update TTY layer for lists and recently added files
  tty: n_gsm: fix UAF in gsm_cleanup_mux
  TIOCSTI: always enable for CAP_SYS_ADMIN

12 months agoMerge tag 'staging-6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
Linus Torvalds [Sun, 30 Jul 2023 18:47:56 +0000 (11:47 -0700)]
Merge tag 'staging-6.5-rc4' of git://git./linux/kernel/git/gregkh/staging

Pull staging driver fixes from Greg KH:
 "Here are three small staging driver fixes for 6.5-rc4 that resolve
  some reported problems. These fixes are:

   - fix for an old bug in the r8712 driver

   - fbtft driver fix for a spi device

   - potential overflow fix in the ks7010 driver

  All of these have been in linux-next with no reported problems"

* tag 'staging-6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
  staging: ks7010: potential buffer overflow in ks_wlan_set_encode_ext()
  staging: fbtft: ili9341: use macro FBTFT_REGISTER_SPI_DRIVER
  staging: r8712: Fix memory leak in _r8712_init_xmit_priv()

12 months agoMerge tag 'char-misc-6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
Linus Torvalds [Sun, 30 Jul 2023 18:44:00 +0000 (11:44 -0700)]
Merge tag 'char-misc-6.5-rc4' of git://git./linux/kernel/git/gregkh/char-misc

Pull char driver and Documentation fixes from Greg KH:
 "Here is a char driver fix and some documentation updates for 6.5-rc4
  that contain the following changes:

   - sram/genalloc bugfix for reported problem

   - security-bugs.rst update based on recent discussions

   - embargoed-hardware-issues minor cleanups and then partial revert
     for the project/company lists

  All of these have been in linux-next for a while with no reported
  problems, and the documentation updates have all been reviewed by the
  relevant developers"

* tag 'char-misc-6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
  misc/genalloc: Name subpools by of_node_full_name()
  Documentation: embargoed-hardware-issues.rst: add AMD to the list
  Documentation: embargoed-hardware-issues.rst: clean out empty and unused entries
  Documentation: security-bugs.rst: clarify CVE handling
  Documentation: security-bugs.rst: update preferences when dealing with the linux-distros group

12 months agoMerge tag 'probes-fixes-v6.5-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 30 Jul 2023 18:27:22 +0000 (11:27 -0700)]
Merge tag 'probes-fixes-v6.5-rc3' of git://git./linux/kernel/git/trace/linux-trace

Pull probe fixes from Masami Hiramatsu:

 - probe-events: add NULL check for some BTF API calls which can return
   error code and NULL.

 - ftrace selftests: check fprobe and kprobe event correctly. This fixes
   a miss condition of the test command.

 - kprobes: do not allow probing functions that start with "__cfi_" or
   "__pfx_" since those are auto generated for kernel CFI and not
   executed.

* tag 'probes-fixes-v6.5-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  kprobes: Prohibit probing on CFI preamble symbol
  selftests/ftrace: Fix to check fprobe event eneblement
  tracing/probes: Fix to add NULL check for BTF APIs

12 months agoMerge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Linus Torvalds [Sun, 30 Jul 2023 18:19:08 +0000 (11:19 -0700)]
Merge tag 'for-linus' of git://git./virt/kvm/kvm

Pull kvm fixes from Paolo Bonzini:
 "x86:

   - Do not register IRQ bypass consumer if posted interrupts not
     supported

   - Fix missed device interrupt due to non-atomic update of IRR

   - Use GFP_KERNEL_ACCOUNT for pid_table in ipiv

   - Make VMREAD error path play nice with noinstr

   - x86: Acquire SRCU read lock when handling fastpath MSR writes

   - Support linking rseq tests statically against glibc 2.35+

   - Fix reference count for stats file descriptors

   - Detect userspace setting invalid CR0

  Non-KVM:

   - Remove coccinelle script that has caused multiple confusion
     ("debugfs, coccinelle: check for obsolete DEFINE_SIMPLE_ATTRIBUTE()
     usage", acked by Greg)"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (21 commits)
  KVM: selftests: Expand x86's sregs test to cover illegal CR0 values
  KVM: VMX: Don't fudge CR0 and CR4 for restricted L2 guest
  KVM: x86: Disallow KVM_SET_SREGS{2} if incoming CR0 is invalid
  Revert "debugfs, coccinelle: check for obsolete DEFINE_SIMPLE_ATTRIBUTE() usage"
  KVM: selftests: Verify stats fd is usable after VM fd has been closed
  KVM: selftests: Verify stats fd can be dup()'d and read
  KVM: selftests: Verify userspace can create "redundant" binary stats files
  KVM: selftests: Explicitly free vcpus array in binary stats test
  KVM: selftests: Clean up stats fd in common stats_test() helper
  KVM: selftests: Use pread() to read binary stats header
  KVM: Grab a reference to KVM for VM and vCPU stats file descriptors
  selftests/rseq: Play nice with binaries statically linked against glibc 2.35+
  Revert "KVM: SVM: Skip WRMSR fastpath on VM-Exit if next RIP isn't valid"
  KVM: x86: Acquire SRCU read lock when handling fastpath MSR writes
  KVM: VMX: Use vmread_error() to report VM-Fail in "goto" path
  KVM: VMX: Make VMREAD error path play nice with noinstr
  KVM: x86/irq: Conditionally register IRQ bypass consumer again
  KVM: X86: Use GFP_KERNEL_ACCOUNT for pid_table in ipiv
  KVM: x86: check the kvm_cpu_get_interrupt result before using it
  KVM: x86: VMX: set irr_pending in kvm_apic_update_irr
  ...

12 months agoMerge tag 'locking_urgent_for_v6.5_rc4' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 30 Jul 2023 18:12:32 +0000 (11:12 -0700)]
Merge tag 'locking_urgent_for_v6.5_rc4' of git://git./linux/kernel/git/tip/tip

Pull locking fix from Borislav Petkov:

 - Fix a rtmutex race condition resulting from sharing of the sort key
   between the lock waiters and the PI chain tree (->pi_waiters) of a
   task by giving each tree their own sort key

* tag 'locking_urgent_for_v6.5_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  locking/rtmutex: Fix task->pi_waiters integrity

12 months agoMerge tag 'x86_urgent_for_v6.5_rc4' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 30 Jul 2023 18:05:35 +0000 (11:05 -0700)]
Merge tag 'x86_urgent_for_v6.5_rc4' of git://git./linux/kernel/git/tip/tip

Pull x86 fixes from Borislav Petkov:

 - AMD's automatic IBRS doesn't enable cross-thread branch target
   injection protection (STIBP) for user processes. Enable STIBP on such
   systems.

 - Do not delete (but put the ref instead) of AMD MCE error thresholding
   sysfs kobjects when destroying them in order not to delete the kernfs
   pointer prematurely

 - Restore annotation in ret_from_fork_asm() in order to fix kthread
   stack unwinding from being marked as unreliable and thus breaking
   livepatching

* tag 'x86_urgent_for_v6.5_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/cpu: Enable STIBP on AMD if Automatic IBRS is enabled
  x86/MCE/AMD: Decrement threshold_bank refcount when removing threshold blocks
  x86: Fix kthread unwind

12 months agoMerge tag 'irq_urgent_for_v6.5_rc4' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 30 Jul 2023 17:59:19 +0000 (10:59 -0700)]
Merge tag 'irq_urgent_for_v6.5_rc4' of git://git./linux/kernel/git/tip/tip

Pull irq fixes from Borislav Petkov:

 - Work around an erratum on GIC700, where a race between a CPU handling
   a wake-up interrupt, a change of affinity, and another CPU going to
   sleep can result in a lack of wake-up event on the next interrupt

 - Fix the locking required on a VPE for GICv4

 - Enable Rockchip 3588001 erratum workaround for RK3588S

 - Fix the irq-bcm6345-l1 assumtions of the boot CPU always be the first
   CPU in the system

* tag 'irq_urgent_for_v6.5_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  irqchip/gic-v3: Workaround for GIC-700 erratum 2941627
  irqchip/gic-v3: Enable Rockchip 3588001 erratum workaround for RK3588S
  irqchip/gic-v4.1: Properly lock VPEs when doing a directLPI invalidation
  irq-bcm6345-l1: Do not assume a fixed block to cpu mapping

12 months agoparport_pc: add support for ASIX AX99100
Jiaqing Zhao [Mon, 24 Jul 2023 08:39:33 +0000 (08:39 +0000)]
parport_pc: add support for ASIX AX99100

The PCI function 2 on ASIX AX99100 PCIe to Multi I/O Controller can be
configured as a single-port parallel port controller. The subvendor id
is 0x2000 when configured as parallel port. It supports IEEE-1284 EPP /
ECP with its ECR on BAR1.

Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Link: https://lore.kernel.org/r/20230724083933.3173513-5-jiaqing.zhao@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agoserial: 8250_pci: add support for ASIX AX99100
Jiaqing Zhao [Mon, 24 Jul 2023 08:39:32 +0000 (08:39 +0000)]
serial: 8250_pci: add support for ASIX AX99100

Each of the 4 PCI functions on ASIX AX99100 PCIe to Multi I/O
Controller can be configured as a single-port serial port controller.
The subvendor id is 0x1000 when configured as serial port and MSI
interrupts are supported.

Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230724083933.3173513-4-jiaqing.zhao@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agocan: ems_pci: move ASIX AX99100 ids to pci_ids.h
Jiaqing Zhao [Mon, 24 Jul 2023 08:39:31 +0000 (08:39 +0000)]
can: ems_pci: move ASIX AX99100 ids to pci_ids.h

Move PCI Vendor and Device ID of ASIX AX99100 PCIe to Multi I/O
Controller to pci_ids.h for its serial and parallel port driver
support in subsequent patches.

Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Link: https://lore.kernel.org/r/20230724083933.3173513-3-jiaqing.zhao@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agocan: ems_pci: remove PCI_SUBVENDOR_ID_ASIX definition
Jiaqing Zhao [Mon, 24 Jul 2023 08:39:30 +0000 (08:39 +0000)]
can: ems_pci: remove PCI_SUBVENDOR_ID_ASIX definition

PCI_SUBVENDOR_ID_ASIX is defined as 0xa000, which is not the vendor id
assigned to ASIX by PCI-SIG. Remove it to avoid possible confusion and
conflict.

Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Link: https://lore.kernel.org/r/20230724083933.3173513-2-jiaqing.zhao@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agoserial: sprd: Fix DMA buffer leak issue
Chunyan Zhang [Tue, 25 Jul 2023 06:40:53 +0000 (14:40 +0800)]
serial: sprd: Fix DMA buffer leak issue

Release DMA buffer when _probe() returns failure to avoid memory leak.

Fixes: f4487db58eb7 ("serial: sprd: Add DMA mode support")
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230725064053.235448-2-chunyan.zhang@unisoc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agoserial: sprd: Assign sprd_port after initialized to avoid wrong access
Chunyan Zhang [Tue, 25 Jul 2023 06:40:52 +0000 (14:40 +0800)]
serial: sprd: Assign sprd_port after initialized to avoid wrong access

The global pointer 'sprd_port' may not zero when sprd_probe returns
failure, that is a risk for sprd_port to be accessed afterward, and
may lead to unexpected errors.

For example:

There are two UART ports, UART1 is used for console and configured in
kernel command line, i.e. "console=";

The UART1 probe failed and the memory allocated to sprd_port[1] was
released, but sprd_port[1] was not set to NULL;

In UART2 probe, the same virtual address was allocated to sprd_port[2],
and UART2 probe process finally will go into sprd_console_setup() to
register UART1 as console since it is configured as preferred console
(filled to console_cmdline[]), but the console parameters (sprd_port[1])
belong to UART2.

So move the sprd_port[] assignment to where the port already initialized
can avoid the above issue.

Fixes: b7396a38fb28 ("tty/serial: Add Spreadtrum sc9836-uart driver support")
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Link: https://lore.kernel.org/r/20230725064053.235448-1-chunyan.zhang@unisoc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agoserial: sc16is7xx: Put IOControl register into regmap_volatile
Hui Wang [Mon, 24 Jul 2023 03:47:27 +0000 (11:47 +0800)]
serial: sc16is7xx: Put IOControl register into regmap_volatile

According to the IOControl register bits description in the page 31 of
the product datasheet, we know the bit 3 of IOControl register is
softreset, this bit will self-clearing once the reset finish.

In the probe, the softreset bit is set, and when we read this register
from debugfs/regmap interface, we found the softreset bit is still
setting, this confused us for a while. Finally we found this register
is cached, to read the real value from register, we could put it
into the regmap_volatile().

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Link: https://lore.kernel.org/r/20230724034727.17335-1-hui.wang@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agodrivers:tty: fix return value check in asc_init_port
Yuanjun Gong [Mon, 17 Jul 2023 14:47:33 +0000 (22:47 +0800)]
drivers:tty: fix return value check in asc_init_port

in asc_init_port, clk_prepare_enable may fail, therefore, the
return value of clk_prepare_enable should be checked.

Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
Link: https://lore.kernel.org/r/20230717144733.24194-1-ruc_gongyuanjun@163.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agotty: serial: meson: refactor objects definition for different devnames
Dmitry Rokosov [Fri, 28 Jul 2023 07:15:22 +0000 (10:15 +0300)]
tty: serial: meson: refactor objects definition for different devnames

Macroses for name generation are not useful. They hide the real place
for object declaration. Instead, use direct names such as
'meson_uart_driver_*' and 'meson_serial_console_*' for all objects.

Additionally, rename 'MESON_SERIAL_CONSOLE_DEFINE()' to
'MESON_SERIAL_CONSOLE()', and 'MESON_UART_DRIVER_DEFINE()' to
'MESON_UART_DRIVER()' to simplify the code.

Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
Suggested-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20230728071522.17503-1-ddrokosov@sberdevices.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months ago8250_men_mcb: fix error handling in read_uarts_available_from_reg()
Yang Yingliang [Fri, 28 Jul 2023 08:57:23 +0000 (16:57 +0800)]
8250_men_mcb: fix error handling in read_uarts_available_from_reg()

If ioremap() fails, it returns NULL pointer, not ERR_PTR(), fix the
return value check and call release_mem_region() to release resource.

Fixes: c563831ba879 ("8250_men_mcb: Make UART config auto configurable")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20230728085723.3195044-1-yangyingliang@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agoMerge tag '6.5-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Linus Torvalds [Sun, 30 Jul 2023 03:49:13 +0000 (20:49 -0700)]
Merge tag '6.5-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull smb client fixes from Steve French:
 "Four small SMB3 client fixes:

   - two reconnect fixes (to address the case where non-default
     iocharset gets incorrectly overridden at reconnect with the
     default charset)

   - fix for NTLMSSP_AUTH request setting a flag incorrectly)

   - Add missing check for invalid tlink (tree connection) in ioctl"

* tag '6.5-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
  cifs: add missing return value check for cifs_sb_tlink
  smb3: do not set NTLMSSP_VERSION flag for negotiate not auth request
  cifs: fix charset issue in reconnection
  fs/nls: make load_nls() take a const parameter