Chen Ni
1c70238a2c
mxser: convert comma to semicolon
...
Replace a comma between expression statements by a semicolon.
Signed-off-by: Chen Ni <nichen@iscas.ac.cn >
Link: https://lore.kernel.org/r/20240903023754.493568-1-nichen@iscas.ac.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2024-09-03 10:47:47 +02:00
Jiri Slaby (SUSE)
b1ce5164b5
mxser: remove doubled sets of close times
...
tty_port::close_delay and ::closing_wait are set in tty_port_init() few
lines above already, no need to reset them (to the same values).
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org >
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jeremy Kerr <jk@codeconstruct.com.au >
Link: https://lore.kernel.org/r/20240808103549.429349-4-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2024-08-14 08:25:21 +02:00
Jiri Slaby (SUSE)
e64caf989c
mxser: remove stale comment
...
The comment mentions ISA removed long time ago. It also comments on
.driver_data pointing to above structures. That is not true either.
Remove that.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org >
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Reviewed-by: Jeremy Kerr <jk@codeconstruct.com.au >
Link: https://lore.kernel.org/r/20240808103549.429349-3-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2024-08-14 08:25:21 +02:00
Nathan Chancellor
1c07c9be87
tty: mxser: Remove __counted_by from mxser_board.ports[]
...
Work for __counted_by on generic pointers in structures (not just
flexible array members) has started landing in Clang 19 (current tip of
tree). During the development of this feature, a restriction was added
to __counted_by to prevent the flexible array member's element type from
including a flexible array member itself such as:
struct foo {
int count;
char buf[];
};
struct bar {
int count;
struct foo data[] __counted_by(count);
};
because the size of data cannot be calculated with the standard array
size formula:
sizeof(struct foo) * count
This restriction was downgraded to a warning but due to CONFIG_WERROR,
it can still break the build. The application of __counted_by on the
ports member of 'struct mxser_board' triggers this restriction,
resulting in:
drivers/tty/mxser.c:291:2: error: 'counted_by' should not be applied to an array with element of unknown size because 'struct mxser_port' is a struct type with a flexible array member. This will be an error in a future compiler version [-Werror,-Wbounds-safety-counted-by-elt-type-unknown-size]
291 | struct mxser_port ports[] __counted_by(nports);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Remove this use of __counted_by to fix the warning/error. However,
rather than remove it altogether, leave it commented, as it may be
possible to support this in future compiler releases.
Cc: <stable@vger.kernel.org >
Closes: https://github.com/ClangBuiltLinux/linux/issues/2026
Fixes: f34907ecca ("mxser: Annotate struct mxser_board with __counted_by")
Signed-off-by: Nathan Chancellor <nathan@kernel.org >
Link: https://lore.kernel.org/r/20240529-drop-counted-by-ports-mxser-board-v1-1-0ab217f4da6d@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org >
2024-06-28 08:54:56 -07:00
Jiri Slaby (SUSE)
59b943356b
tty: mxser: convert to u8 and size_t
...
Switch character types to u8 and sizes to size_t. To conform to
characters/sizes in the rest of the tty layer.
Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org >
Link: https://lore.kernel.org/r/20231206073712.17776-19-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-12-08 12:02:38 +01:00
Kees Cook
f34907ecca
mxser: Annotate struct mxser_board with __counted_by
...
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).
As found with Coccinelle[1], add __counted_by for struct mxser_board.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc: Jiri Slaby <jirislaby@kernel.org >
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.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: linux-serial@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Kees Cook <keescook@chromium.org >
Reviewed-by: Jiri Slaby <jirislaby@kernel.org >
Reviewed-by: "Gustavo A. R. Silva" <gustavoars@kernel.org >
Link: https://lore.kernel.org/r/20230922175245.work.196-kees@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-10-03 14:35:49 +02:00
Jiri Slaby (SUSE)
95713967ba
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 >
2023-08-11 21:12:46 +02:00
Jiri Slaby (SUSE)
dcaafbe6ee
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 >
2023-08-11 21:12:46 +02:00
Jiri Slaby (SUSE)
69851e4ab8
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 >
2023-08-11 21:12:46 +02:00
Ilpo Järvinen
035173c91c
tty: Convert hw_stopped in tty_struct to bool
...
hw_stopped in tty_struct is used like bool, convert the variable type
to bool.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Acked-by: Ulf Hansson <ulf.hansson@linaro.org > # For MMC
Link: https://lore.kernel.org/r/20230309082035.14880-9-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-03-17 15:01:09 +01:00
Ilpo Järvinen
5701cb8bf5
tty: Call ->dtr_rts() parameter active consistently
...
Convert various parameter names for ->dtr_rts() and related functions
from onoff, on, and raise to active.
Reviewed-by: Jiri Slaby <jirislaby@kernel.org >
Acked-by: Ulf Hansson <ulf.hansson@linaro.org > # For MMC
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230117090358.4796-12-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 16:04:35 +01:00
Ilpo Järvinen
5d42039907
tty: Convert ->dtr_rts() to take bool argument
...
Convert the raise/on parameter in ->dtr_rts() to bool through the
callchain. The parameter is used like bool. In USB serial, there
remains a few implicit bool -> larger type conversions because some
devices use u8 in their control messages.
In moxa_tiocmget(), dtr variable was reused for line status which
requires int so use a separate variable for status.
Reviewed-by: Jiri Slaby <jirislaby@kernel.org >
Acked-by: Ulf Hansson <ulf.hansson@linaro.org > # For MMC
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230117090358.4796-8-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 16:04:35 +01:00
Ilpo Järvinen
b300fb26c5
tty: Convert ->carrier_raised() and callchains to bool
...
Return boolean from ->carrier_raised() instead of 0 and 1. Make the
return type change also to tty_port_carrier_raised() that makes the
->carrier_raised() call (+ cd variable in moxa into which its return
value is stored).
Also cleans up a few unnecessary constructs related to this change:
return xx ? 1 : 0;
-> return xx;
if (xx)
return 1;
return 0;
-> return xx;
Reviewed-by: Jiri Slaby <jirislaby@kernel.org >
Acked-by: Ulf Hansson <ulf.hansson@linaro.org > # For MMC
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230117090358.4796-7-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 16:04:35 +01:00
Ilpo Järvinen
515be7baed
tty: Cleanup tty_port_set_initialized() bool parameter
...
Make callers pass true/false consistently for bool val.
Reviewed-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com >
Reviewed-by: Jiri Slaby <jirislaby@kernel.org >
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230117090358.4796-2-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 16:04:34 +01:00
Colin Ian King
e4cdd25caf
tty: mxser: remove redundant assignment to hwid
...
The variable hwid is assigned a value but it is never read. The
assignment is redundant and can be removed.
Cleans up clang scan build warning:
drivers/tty/mxser.c:401:7: warning: Although the value stored to 'hwid'
is used in the enclosing expression, the value is never actually read
from 'hwid' [deadcode.DeadStores]
Acked-by: Jiri Slaby <jirislaby@kernel.org >
Signed-off-by: Colin Ian King <colin.i.king@gmail.com >
Link: https://lore.kernel.org/r/20220730130925.150018-1-colin.i.king@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2022-09-01 17:59:36 +02:00
Ilpo Järvinen
a8c11c1520
tty: Make ->set_termios() old ktermios const
...
There should be no reason to adjust old ktermios which is going to get
discarded anyway.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com >
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20220816115739.10928-9-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2022-08-30 14:22:35 +02:00
Ilpo Järvinen
69648d7bda
tty: remove BOTHER ifdefs
...
BOTHER is defined by all architectures since commit d0ffb805b7
("arch/alpha, termios: implement BOTHER, IBSHIFT and termios2").
Reviewed-by: Johan Hovold <johan@kernel.org >
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20220513082906.11096-3-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2022-05-19 18:26:17 +02:00
Jiri Slaby
e7d6f84c9b
mxser: make use of UART_LCR_WLEN() + tty_get_char_size()
...
Having a generic UART_LCR_WLEN() macro and the tty_get_char_size()
helper, we can remove all those repeated switch-cases in drivers.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20220224095558.30929-5-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2022-02-28 22:17:25 +01:00
Jiri Slaby
32330c8334
mxser: switch from xmit_buf to kfifo
...
Use kfifo for xmit buffer handling. The change is mostly
straightforward. It saves complexity both on the stuffing side
(mxser_write() and mxser_put_char()) and pulling side
(mxser_transmit_chars()). In fact, the loop in mxser_write() can be
completely deleted as the wrap of the buffer is taken care of in the
kfifo code now.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20220124071430.14907-8-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2022-01-26 14:54:48 +01:00
Jiri Slaby
92cc9d1d14
mxser: use tty_port xmit_buf helpers
...
For the mxser driver to use kfifo, use tty_port_alloc_xmit_buf() and
tty_port_free_xmit_buf() helpers in activate/shutdown, respectively.
As these calls have to be done in a non-atomic context, we have to move
them outside spinlock and make sure irq is really stopped after we write
to the ISR register.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20220124071430.14907-7-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2022-01-26 14:54:48 +01:00
Jiri Slaby
cd3a4907ee
mxser: fix xmit_buf leak in activate when LSR == 0xff
...
When LSR is 0xff in ->activate() (rather unlike), we return an error.
Provided ->shutdown() is not called when ->activate() fails, nothing
actually frees the buffer in this case.
Fix this by properly freeing the buffer in a designated label. We jump
there also from the "!info->type" if now too.
Fixes: 6769140d30 ("tty: mxser: use the tty_port_open method")
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20220124071430.14907-6-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2022-01-26 14:54:48 +01:00
Jiri Slaby
c668d56764
mxser: use PCI_DEVICE_DATA
...
Now that we have all the PCI device IDs unified, we can use
PCI_DEVICE_DATA() macro to simplify mxser's pci_device_id list, i.e.
mxser_pcibrds.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20211118073125.12283-20-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-11-25 18:33:22 +01:00
Jiri Slaby
4167bd25ec
mxser: move ids from pci_ids.h here
...
There is no point having MOXA PCI device IDs in include/linux/pci_ids.h.
Move them to the driver and sort them all by the ID.
Cc: Bjorn Helgaas <bhelgaas@google.com >
Cc: linux-pci@vger.kernel.org
Acked-by: Bjorn Helgaas <bhelgaas@google.com >
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20211118073125.12283-19-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-11-25 18:33:22 +01:00
Jiri Slaby
16add04f7b
mxser: add MOXA prefix to some PCI device IDs
...
Some of the MOXA PCI device IDs contain _MOXA_, some don't. Add it to
the latter, so that they are all unified.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20211118073125.12283-18-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-11-25 18:33:22 +01:00
Jiri Slaby
eb68ac0462
mxser: increase buf_overrun if tty_insert_flip_char() fails
...
mxser doesn't increase port->icount.buf_overrun at all. Do so if overrun
happens, so that it can be read from the stats.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20211118073125.12283-17-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-11-25 18:33:22 +01:00