summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-08-11tty: make tty_operations::write()'s count size_tJiri Slaby (SUSE)43-61/+82
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>
2023-08-11tty: propagate u8 data to tty_operations::put_char()Jiri Slaby (SUSE)14-18/+18
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>
2023-08-11tty: propagate u8 data to tty_operations::write()Jiri Slaby (SUSE)43-88/+53
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>
2023-08-11tty: use min() for size computation in iterate_tty_read()Jiri Slaby (SUSE)1-2/+1
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>
2023-08-11tty: switch size and count types in iterate_tty_read() to size_tJiri Slaby (SUSE)1-2/+2
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>
2023-08-11tty: use ssize_t for iterate_tty_read() returned typeJiri Slaby (SUSE)1-8/+8
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>
2023-08-11tty: use min() in iterate_tty_write()Jiri Slaby (SUSE)1-6/+2
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>
2023-08-11tty: rename and de-inline do_tty_write()Jiri Slaby (SUSE)1-3/+3
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>
2023-08-11tty: don't pass write() to do_tty_write()Jiri Slaby (SUSE)1-7/+4
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>
2023-08-11tty: tty_buffer: make all offsets unsignedJiri Slaby (SUSE)1-5/+5
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>
2023-08-11tty: make char_buf_ptr()/flag_buf_ptr()'s offset unsignedJiri Slaby (SUSE)1-2/+2
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>
2023-08-11misc: ti-st: make st_recv() conforming to tty_ldisc_ops::receive_buf()Jiri Slaby (SUSE)3-8/+7
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>
2023-08-11tty: use u8 for flagsJiri Slaby (SUSE)23-55/+54
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>
2023-08-11tty: use u8 for charsJiri Slaby (SUSE)21-81/+73
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>
2023-08-11tty: make tty_ldisc_ops::*buf*() hooks operate on size_tJiri Slaby (SUSE)19-35/+38
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>
2023-08-11tty: can327, move overflow test inside can327_ldisc_rx()'s loopJiri Slaby (SUSE)1-8/+7
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>
2023-08-11tty: can327: unify error paths in can327_ldisc_rx()Jiri Slaby (SUSE)1-14/+8
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>
2023-08-11tty: switch count in tty_ldisc_receive_buf() to size_tJiri Slaby (SUSE)3-6/+6
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>
2023-08-11tty: switch receive_buf() counts to size_tJiri Slaby (SUSE)1-4/+4
'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>
2023-08-11tty: make counts in tty_port_client_operations hooks size_tJiri Slaby (SUSE)3-11/+10
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>
2023-08-11tty: make tty_port_client_operations operate with u8Jiri Slaby (SUSE)4-12/+12
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>
2023-08-11tty: make tty_change_softcar() more understandableJiri Slaby (SUSE)1-3/+3
* 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>
2023-08-11tty: drop tty_debug_wait_until_sent()Jiri Slaby (SUSE)1-10/+0
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>
2023-08-11tty: tty_port: rename 'disc' to 'ld'Jiri Slaby (SUSE)1-11/+11
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>
2023-08-11tty: change tty_write_lock()'s ndelay parameter to boolJiri Slaby (SUSE)3-5/+5
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>
2023-08-11tty: n_null: remove optional ldopsJiri Slaby (SUSE)1-18/+0
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>
2023-08-11tty: remove dummy tty_ldisc_ops::poll() implementationsJiri Slaby (SUSE)4-30/+0
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>
2023-08-11tty: ldisc: document that ldops are optionalJiri Slaby (SUSE)1-5/+25
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>
2023-08-11tty: xtensa/iss: drop unneeded tty_operations hooksJiri Slaby (SUSE)1-24/+0
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>
2023-08-09tty: serial: qcom-geni-serial: Poll primary sequencer irq status after cancel_txVijaya Krishna Nivarthi1-5/+2
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>
2023-08-09serial: sifive: Remove redundant of_match_ptr()Ruan Jinjie1-1/+1
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>
2023-08-048250_men_mcb: remove unnecessary cast when reading registerSanjuán García, Jorge1-1/+1
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>
2023-08-04serial: cpm_uart: Remove linux/fs_uart_pd.hChristophe Leroy1-71/+0
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>
2023-08-04serial: cpm_uart: Don't include fs_uart_pd.h when not neededChristophe Leroy3-3/+0
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>
2023-08-04serial: cpm_uart: Remove stale prototype in powerpc/fsl_soc.cChristophe Leroy1-2/+0
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>
2023-08-04serial: cpm_uart: Remove cpm_uart/ subdirectoryChristophe Leroy4-7/+1
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>
2023-08-04serial: cpm_uart: Refactor cpm_uart_[un]map_pram()Christophe Leroy5-142/+49
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>
2023-08-04serial: cpm_uart: Refactor cpm_uart_allocbuf()/cpm_uart_freebuf()Christophe Leroy4-140/+72
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>
2023-08-04serial: cpm_uart: Deduplicate cpm_line_cr_cmd()Christophe Leroy4-11/+5
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>
2023-08-04serial: cpm_uart: Deduplicate cpm_set_{brg/smc_fcr/scc_fcr}()Christophe Leroy4-71/+9
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>
2023-08-04serial: cpm_uart: Use get_baudrate() instead of uart_baudrate()Christophe Leroy2-12/+4
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>
2023-08-04serial: cpm_uart: Stop using fs_uart_id enumChristophe Leroy2-3/+1
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>
2023-08-04serial: cpm_uart: Remove stale prototypes and table and macrosChristophe Leroy2-24/+1
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>
2023-08-04serial: cpm_uart: Avoid suspicious lockingChristophe Leroy1-9/+4
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>
2023-08-048250_men_mcb: Remove redundant initialization owner in mcb_driverLi Zetao1-1/+0
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>
2023-08-048250_men_mcb: Fix unsigned expression compared with zeroLi Zetao1-1/+1
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>
2023-08-04serial: max310x: fix typos in commentsHugo Villeneuve1-1/+1
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>
2023-08-04serial: max310x: add comments for membase address workaroundHugo Villeneuve1-0/+5
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>
2023-08-04tty: n_gsm: require CAP_NET_ADMIN to attach N_GSM0710 ldiscThadeu Lima de Souza Cascardo1-0/+3
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>
2023-08-048250_men_mcb: Fix unsigned comparison with less than zeroJiapeng Chong1-3/+5
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>