summaryrefslogtreecommitdiffstats
path: root/drivers/tty/mxser.c
Commit message (Collapse)AuthorAgeFilesLines
* tty: propagate u8 data to tty_operations::write()Jiri Slaby (SUSE)2023-08-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* tty: Convert hw_stopped in tty_struct to boolIlpo Järvinen2023-03-171-3/+3
| | | | | | | | | | 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>
* tty: Call ->dtr_rts() parameter active consistentlyIlpo Järvinen2023-01-191-2/+2
| | | | | | | | | | | 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>
* tty: Convert ->dtr_rts() to take bool argumentIlpo Järvinen2023-01-191-1/+1
| | | | | | | | | | | | | | | | 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>
* tty: Convert ->carrier_raised() and callchains to boolIlpo Järvinen2023-01-191-2/+3
| | | | | | | | | | | | | | | | | | | | | | | 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>
* tty: Cleanup tty_port_set_initialized() bool parameterIlpo Järvinen2023-01-191-1/+1
| | | | | | | | | | 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>
* tty: mxser: remove redundant assignment to hwidColin Ian King2022-09-011-1/+1
| | | | | | | | | | | | | | | 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>
* tty: Make ->set_termios() old ktermios constIlpo Järvinen2022-08-301-2/+4
| | | | | | | | | | 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>
* tty: remove BOTHER ifdefsIlpo Järvinen2022-05-191-3/+2
| | | | | | | | | | BOTHER is defined by all architectures since commit d0ffb805b729 ("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>
* mxser: make use of UART_LCR_WLEN() + tty_get_char_size()Jiri Slaby2022-02-281-15/+1
| | | | | | | | | 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>
* mxser: switch from xmit_buf to kfifoJiri Slaby2022-01-261-47/+27
| | | | | | | | | | | | | 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>
* mxser: use tty_port xmit_buf helpersJiri Slaby2022-01-261-15/+9
| | | | | | | | | | | | | 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>
* mxser: fix xmit_buf leak in activate when LSR == 0xffJiri Slaby2022-01-261-4/+11
| | | | | | | | | | | | | | 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: 6769140d3047 ("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>
* mxser: use PCI_DEVICE_DATAJiri Slaby2021-11-251-26/+26
| | | | | | | | | | 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>
* mxser: move ids from pci_ids.h hereJiri Slaby2021-11-251-1/+19
| | | | | | | | | | | | 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>
* mxser: add MOXA prefix to some PCI device IDsJiri Slaby2021-11-251-16/+16
| | | | | | | | | 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>
* mxser: increase buf_overrun if tty_insert_flip_char() failsJiri Slaby2021-11-251-2/+5
| | | | | | | | | 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>
* mxser: remove tty parameter from mxser_receive_chars_new()Jiri Slaby2021-11-251-3/+2
| | | | | | | | | After the previous change (no plays with of tty->receive_room), the tty parameter is unused. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-16-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: don't throttle manuallyJiri Slaby2021-11-251-30/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | First, checking tty->receive_room to signalize whether there is enough space in the tty buffers does not make much sense. Provided the tty buffers are in tty_port and those are not checked at all. Second, if the rx path is throttled, with CRTSCTS, RTS is deasserted, but is never asserted again. This leads to port "lockup", not accepting any more input. So: 1) stty -F /dev/ttyMI0 crtscts # the mxser port 2) stty -F /dev/ttyS6 crtscts # the connected port 3) cat /dev/ttyMI0 4) "write in a loop" to /dev/ttyS6 5) cat from 3) produces the bytes from 4) 6) killall -STOP cat (the 3)'s one) 7) wait for RTS to drop on /dev/ttyMI0 8) killall -CONT cat (again the 3)'s one) cat erroneously produces no more output now (i.e. no data sent from ttyS6 to ttyMI can be seen). Note that the step 7) is performed twice: once from n_tty by tty_throttle_safe(), once by mxser_stoprx() from the receive path. Then after step 7), n_tty correctly unthrottles the input, but mxser calls mxser_stoprx() again as there is still only a little space in n_tty buffers (tty->receive_room mentioned at the beginning), but the device's FIFO is/can be already filled. After this patch, the output is correctly resumed, i.e. n_tty both throttles and unthrottles without interfering with mxser's attempts. This allows us to get rid of the non-standard ldisc_stop_rx flag from struct mxser_port. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-15-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: clean up timeout handling in mxser_wait_until_sent()Jiri Slaby2021-11-251-3/+4
| | | | | | | | | | timeout cannot be zero at the point of use. So no need to check for zero. Also precompute the expiration time (into expire) and use it. This makes the code more clear. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-14-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: use msleep_interruptible() in mxser_wait_until_sent()Jiri Slaby2021-11-251-2/+4
| | | | | | | | | | Instead of schedule_timeout_interruptible(), because: 1) we don't have to bother with the task state, and 2) msleep* guarantees to sleep that time (if not interrupted). Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-13-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: extract TX empty check from mxser_wait_until_sent()Jiri Slaby2021-11-251-7/+13
| | | | | | | | | | And move it to new mxser_tx_empty(), because: 1) it simplifies the code (esp. the locking), and 2) serial_core needs such a hook anyway, so have it ready. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-12-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: use tty_port_close() in mxser_close()Jiri Slaby2021-11-251-21/+1
| | | | | | | | | Finally, the mxser_close() code in is mostly identical to tty_port_close(), so replace the code by a single call to the function. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-11-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: don't flush buffer from mxser_close() directlyJiri Slaby2021-11-251-1/+0
| | | | | | | | | | | | | | | | | | I fail to see the point of calling mxser_flush_buffer() from mxser_close(): 1) The SW xmit buffer is freed in mxser_shutdown_port() right after the call to mxser_flush_buffer(). And all 'cnt', 'head', and 'tail' are properly initialized to 0 in mxser_activate(). 2) The HW buffer is flushed in mxser_shutdown_port() via mxser_disable_and_clear_FIFO() too. So the effect of doing it by mxser_flush_buffer() in mxser_close() is none. Hence remove it, so that when we use tty_port_close() later, the code is 1:1 identical. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-10-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: call stop_rx from mxser_shutdown_port()Jiri Slaby2021-11-251-15/+16
| | | | | | | | | | | | | | | mxser_stop_rx() should be called from mxser_shutdown_port() for several reasons: 1) info->slock is held while manipulating IER (as on other places), 2) hangup now stops rx too, 3) mxser_close() will use tty_port_close() and there is no place except tty_port_operations::shutdown() where this can be done, 4) this is the same sequence as serial_core does. So we can map this code 1:1 when switching the driver to it. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-9-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: remove tty->driver_data NULL checkJiri Slaby2021-11-251-2/+0
| | | | | | | | | Noone sets tty->driver_data to NULL in the driver, so there is no point to check that in mxser_close(). Remove the check. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-8-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: remove pointless xmit_buf checksJiri Slaby2021-11-251-11/+2
| | | | | | | | | xmit_buf is supposed to exist in all these functions. I.e. from tty_port_operations::activate() to ::shutdown(). So remove these checks. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-7-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: clean up tx handling in mxser_transmit_chars()Jiri Slaby2021-11-251-5/+3
| | | | | | | | | | | | | The port->icount.tx is handled in a too complicated manner. Instead of remembering the original count and subtracting the new one from it, simply increase tx for each character in the loop. No need for cnt variable then. Change also the "X = X & Y" assignment to simpler "X &= Y". Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-6-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: move MSR read to mxser_check_modem_status()Jiri Slaby2021-11-251-21/+25
| | | | | | | | | | | | | The MSR read is currently performed on both places where mxser_check_modem_status() is called. So move it there to avoid code duplication. Rename the variable to msr while we move it, to actually see what "status" we are testing. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-5-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: keep only !tty test in ISRJiri Slaby2021-11-251-4/+1
| | | | | | | | | | | | | | | | | | The others are superfluous with tty refcounting in place now. And they are racy in fact: * tty_port_initialized() reports false for a small moment after interrupts are enabled. * closing is 1 while the port is still alive. The queues are flushed later during close anyway. So there is no need for this special handling. Actually, the ISR should not flush the queues. It should behave as every other driver, just queue the chars into tty buffer and go on. But this will be changed later. There is still a lot code depending on having tty in ISR (and not only tty_port). Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-4-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: rename mxser_close_port() to mxser_stop_rx()Jiri Slaby2021-11-251-10/+7
| | | | | | | | | As it is the only thing it does now. This is one of the future serial_core hooks. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-3-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: remove wait for sent from mxser_close_portJiri Slaby2021-11-251-12/+0
| | | | | | | | | | | | | | | | | | | | | mxser_close() behaves like this: -> tty_port_close_start() -> tty_wait_until_sent() -> mxser_wait_until_sent() -> mxser_close_port -> wait for TEMT So it is already waited for TEMT through mxser_wait_until_sent() and there is another round of waiting in mxser_close_port(). The latter one is superfluous as nothing could be filled into the output FIFO. Remove the call. This helps unification among drivers (so that all behave the same) and future use of tty_port_close(). Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-2-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: store FCR state in mxser_port::FCRJiri Slaby2021-10-051-14/+13
| | | | | | | | | | | | | | | We force the FCR contents on many places in the code instead of writing what was actually set in mxser_change_speed() (by ->activate() or ->set_serial_info()). So introduce mxser_port::FCR to hold the proper contents and bitwise-OR the value to what needs to be set on all those locations. That is, clearing RX and/or TX FIFOs. Those flags are self-clearing, so no need to set them to mxser_port::FCR. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210922075938.31390-7-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: don't read from UART_FCRJiri Slaby2021-10-051-4/+1
| | | | | | | | | | | | | | | | The UART_FCR register is write-only. When reading it, one gets contents of (read-only) UART_IIR instead as they are shared. This mistake was performed in mxser_flush_buffer() to clear FIFOs. Actually FCR handling throughout the driver is completely broken. On many places, it respects neither mu860 settings, nor FIFO (16450 vs 16550) setting. This patch doesn't help to fix this, it actually does the same. We will introduce a mxser_port::FCR in the next patch to fix this issue. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210922075938.31390-6-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: move FIFO clearing to mxser_disable_and_clear_FIFO()Jiri Slaby2021-10-051-14/+12
| | | | | | | | | | This code is used on two places, make a helper for disabling and clearing FIFOs. And demangle the too complicated 'if' by using a local variable. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210922075938.31390-5-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: simplify FCR computation in mxser_change_speed()Jiri Slaby2021-10-051-27/+20
| | | | | | | | | | | | Provided FIFO is always enabled for MUST chips, move its FCR setting out of PORT_8250/PORT_16450 special case in mxser_change_speed(). Now, we can pre-set fcr to zero and invert the condition of the 'if'. This makes the code more readable (no functional change intended). Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210922075938.31390-4-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: make mxser_port::ldisc_stop_rx a boolJiri Slaby2021-10-051-4/+4
| | | | | | | | | It's used only as a yes-no variable, so make it a bool and switch the set values appropriately. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210922075938.31390-3-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: simplify condition in mxser_receive_chars_newJiri Slaby2021-10-051-5/+1
| | | | | | | | | | | | | mxser_receive_chars_old() is used whenever MOXA_MUST_LSR_RERR is set in status no matter the HW ID (the last 'if'). So there is no need for another check of MOXA_MUST_LSR_RERR _with_ hwid == MOXA_MUST_MU860_HWID (the third 'if'). Hence remove this subcase. That allows us to check status on a single line with both UART_LSR_BRK_ERROR_BITS (from the second 'if') and MOXA_MUST_LSR_RERR (the last 'if'). Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210922075938.31390-2-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: restore baud rate if its setting failsJiri Slaby2021-10-051-5/+11
| | | | | | | | | | | | | | | | If a user tries to set a too high rate, it fails due to check in mxser_set_baud(). But the high rate remains set in termios, so the user might think everything went smooth. Restore the baud rate from the old_termios if this happens, so that user knows nothing was changed in fact. It used to behave the correct way many years ago, but somehow the restoration vanished with commit 1c45607ad3eb (Char: mxser, remove it) -- the commit removed mxser's older clone. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210922075938.31390-1-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: use semi-colons instead of commasDan Carpenter2021-08-261-6/+6
| | | | | | | | | | This code works, but it's cleaner to use semi-colons at the end of a statement instead of a comma. Acked-by: Jiri Slaby <jirislaby@kernel.org> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Link: https://lore.kernel.org/r/20210825072435.GB13013@kili Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: drop put_tty_driverJiri Slaby2021-07-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | put_tty_driver() is an alias for tty_driver_kref_put(). There is no need for two exported identical functions, therefore switch all users of old put_tty_driver() to new tty_driver_kref_put() and remove the former for good. Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Matt Turner <mattst88@gmail.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Jeff Dike <jdike@addtoit.com> Cc: Richard Weinberger <richard@nod.at> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> Cc: Chris Zankel <chris@zankel.net> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.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: Jakub Kicinski <kuba@kernel.org> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: David Lin <dtwlin@gmail.com> Cc: Johan Hovold <johan@kernel.org> Cc: Alex Elder <elder@kernel.org> Cc: Jiri Slaby <jirislaby@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: Oliver Neukum <oneukum@suse.com> Cc: Felipe Balbi <balbi@kernel.org> 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> Acked-by: Alex Elder <elder@linaro.org> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Acked-by: Max Filippov <jcmvbkbc@gmail.com> Acked-by: David Sterba <dsterba@suse.com> Acked-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com> Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210723074317.32690-8-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: stop using alloc_tty_driverJiri Slaby2021-07-271-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | alloc_tty_driver was deprecated by tty_alloc_driver in commit 7f0bc6a68ed9 (TTY: pass flags to alloc_tty_driver) in 2012. I never got into eliminating alloc_tty_driver until now. So we still have two functions for allocating drivers which might be confusing. So get rid of alloc_tty_driver uses to eliminate it for good in the next patch. Note we need to switch return value checking as tty_alloc_driver uses ERR_PTR. And flags are now a parameter of tty_alloc_driver. Cc: Richard Henderson <rth@twiddle.net>(odd fixer:ALPHA PORT) Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Matt Turner <mattst88@gmail.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> Cc: Helge Deller <deller@gmx.de> Cc: Jeff Dike <jdike@addtoit.com> Cc: Richard Weinberger <richard@nod.at> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> Cc: Chris Zankel <chris@zankel.net> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com> Cc: Jens Taprogge <jens.taprogge@taprogge.org> Cc: Karsten Keil <isdn@linux-pingi.de> Cc: Ulf Hansson <ulf.hansson@linaro.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Christian Borntraeger <borntraeger@de.ibm.com> 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: Oliver Neukum <oneukum@suse.com> Cc: Felipe Balbi <balbi@kernel.org> Cc: Johan Hovold <johan@kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org> Cc: Johan Hedberg <johan.hedberg@gmail.com> Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Acked-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com> Acked-by: Max Filippov <jcmvbkbc@gmail.com> Acked-by: David Sterba <dsterba@suse.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210723074317.32690-5-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: introduce mxser_16550A_or_MUST helperJiri Slaby2021-06-181-13/+13
| | | | | | | | | | | | This check is used in the code on many places. Either in positive or negative form. So introduce a helper called mxser_16550A_or_MUST for this purpose. And replace all the occurrences. This simplifies many ifs in there. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210618061516.662-67-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: rename flags to old_speed in mxser_set_serial_infoJiri Slaby2021-06-181-3/+3
| | | | | | | | | | Local 'flags' are used to store speed in mxser_set_serial_info, not actual flags (by doing & ASYNC_SPD_MASK). So rename 'flags' to 'old_speed' (after what it is). Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210618061516.662-66-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: use port variable in mxser_set_serial_infoJiri Slaby2021-06-181-5/+5
| | | | | | | | | | | mxser_set_serial_info already defined a local 'port' of type struct tty_port. So use it in the code everywhere. This eliminates some text from the code there. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210618061516.662-65-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: access info->MCR under info->slockJiri Slaby2021-06-181-2/+2
| | | | | | | | | | | info->MCR is protected by info->slock all over the code. Extend the lock in mxser_tiocmget around the info->MCR fetch too. It likely doesn't change anything, but it's always good to be consistent. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210618061516.662-64-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: fix typos around enhanced modeJiri Slaby2021-06-181-9/+9
| | | | | | | | | | | Fix spelling of "enhanced" in macros and comments around them. While "enchance" comes from the original Moxa's driver, I don't think it was meant to be that. From the context, they obviously mean "enhanced". Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210618061516.662-63-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: decrypt FCR valuesJiri Slaby2021-06-181-2/+6
| | | | | | | | | | | | Currently, some of the values written to FCR are magic constants. But they are composed of well-defined bits. Use these named macros in place of the constants. No changes in objdump -d. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210618061516.662-62-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: remove xmit_cnt < 0 testsJiri Slaby2021-06-181-4/+4
| | | | | | | | | mxser_port::xmit_cnt is unsigned, it cannot be negative. Therefore remove all the xmit_cnt < 0 tests. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210618061516.662-61-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mxser: introduce and use start/stop_tx helpersJiri Slaby2021-06-181-43/+37
| | | | | | | | | | | | | Starting and stopping TX is performed on many places in the driver. It is repeated outb and info->IER modification. Create few helpers (__mxser_start_tx, mxser_start_tx, __mxser_stop_tx) and use them in the code instead of open coding. This should be a base for an uart driver for this device in the future. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210618061516.662-60-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>