linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/69] mxser: cleanup
@ 2021-06-18  6:14 Jiri Slaby
  2021-06-18  6:14 ` [PATCH 01/70] mxser: drop ISA support Jiri Slaby
                   ` (70 more replies)
  0 siblings, 71 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

I was given a few cards from MOXA (thanks a lot). So I cleaned up the
driver and can continue maintaining it.

A long term goal is to convert the driver to serial_core.

Jiri Slaby (70):
  mxser: drop ISA support
  mxser: renumber mxser_cards
  mxser: remove info printout from init
  mxser: integrate mxser.h into .c
  mxser: cleanup Gpci_uart_info struct
  mxser: rename CheckIsMoxaMust to mxser_get_must_hwid
  mxser: rename mxser_board::chip_flag to must_hwid
  mxser: introduce enum mxser_must_hwid
  mxser: drop constant board::uart_type
  mxser: move max_baud from port to board
  mxser: remove nonsense from ISR
  mxser: cleanup LSR handling in mxser_receive_chars
  mxser: extract port ISR
  mxser: simplify mxser_interrupt and drop mxser_board::vector_mask
  mxser: extract mxser_receive_chars_new
  mxser: extract mxser_receive_chars_old
  mxser: remove else from LSR bits checks
  mxser: correct types for uart variables
  mxser: make xmit ring buffer variables unsigned
  mxser: drop UART_MCR_AFE and UART_LSR_SPECIAL defines
  mxser: drop unused MOXA_DIAGNOSE macro
  mxser: remove MOXA_GET_MAJOR deprecated ioctl
  mxser: remove MOXA_SET_BAUD_METHOD ioctl
  mxser: remove MOXA_ASPP_MON and friends
  mxser: remove MOXA_ASPP_LSTATUS ioctl
  mxser: remove MOXA_CHKPORTENABLE ioctl
  mxser: remove MOXA_GETDATACOUNT ioctl
  mxser: remove MOXA_GETMSTATUS ioctl
  mxser: remove MOXA_ASPP_OQUEUE ioctl
  mxser: remove MOXA_HighSpeedOn ioctl
  mxser: remove cnt from mxser_receive_chars
  mxser: don't allocate MXSER_PORTS + 1
  mxser: drop unused mxser_port::normal_termios
  mxser: remove unused mxser_port::stop_rx
  mxser: drop mxser_port::baud_base
  mxser: drop mxser_port::custom_divisor
  mxser: cleanup mxser_change_speed
  mxser: extract mxser_ioctl_op_mode
  mxser: simplify mxser_ioctl_op_mode
  mxser: dedup mxser_must_set_enhance_mode
  mxser: introduce mxser_must_select_bank and use it
  mxser: clean up the rest of MUST helpers
  mxser: move board init into mxser_initbrd
  mxser: inline mxser_board_remove into mxser_remove
  mxser: pci, switch to managed resources
  mxser: move request irq to probe and switch to managed
  mxser: remove info message from probe
  mxser: remove mxser_cardinfo
  mxser: cleanup mxser_process_txrx_fifo
  mxser: rework and simplify mxser_open
  mxser: make mxser_board::idx really an index
  mxser: alloc struct mxser_board dynamically
  mxser: alloc only needed # of ports
  mxser: remove pointless ioaddr checks
  mxser: cleanup mxser_rs_break
  mxser: cleanup mxser_dtr_rts
  mxser: don't start TX from tty_operations::put_char
  mxser: extract and dedup CTS handling
  mxser: introduce and use start/stop_tx helpers
  mxser: remove xmit_cnt < 0 tests
  mxser: decrypt FCR values
  mxser: fix typos around enhanced mode
  mxser: access info->MCR under info->slock
  mxser: use port variable in mxser_set_serial_info
  mxser: rename flags to old_speed in mxser_set_serial_info
  mxser: introduce mxser_16550A_or_MUST helper
  mxser: Documentation, remove traces of callout device
  mxser: Documentation, make the docs up-to-date
  mxser: Documentation, fix typos
  MAINTAINERS: add me back as mxser maintainer

 .../driver-api/serial/moxa-smartio.rst        |  496 +----
 MAINTAINERS                                   |    3 +-
 drivers/tty/Kconfig                           |    2 +-
 drivers/tty/mxser.c                           | 1950 +++++------------
 drivers/tty/mxser.h                           |  151 --
 5 files changed, 622 insertions(+), 1980 deletions(-)
 delete mode 100644 drivers/tty/mxser.h

-- 
2.32.0


^ permalink raw reply	[flat|nested] 72+ messages in thread

* [PATCH 01/70] mxser: drop ISA support
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 02/70] mxser: renumber mxser_cards Jiri Slaby
                   ` (69 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

While mxser PCI cards are still around and produced (Moxa provided me
with two recently), ISA cards are obsolete for a long time. I haven't
seen anyone using the cards and the ISA code paths are barely tested.

Hence, remove ISA support from mxser driver so that we can clean the
driver up.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 .../driver-api/serial/moxa-smartio.rst        | 107 +-----
 drivers/tty/Kconfig                           |   2 +-
 drivers/tty/mxser.c                           | 348 +-----------------
 3 files changed, 17 insertions(+), 440 deletions(-)

diff --git a/Documentation/driver-api/serial/moxa-smartio.rst b/Documentation/driver-api/serial/moxa-smartio.rst
index 156100f17c3f..aedda2546242 100644
--- a/Documentation/driver-api/serial/moxa-smartio.rst
+++ b/Documentation/driver-api/serial/moxa-smartio.rst
@@ -37,8 +37,7 @@ Date: 01/21/2008
 	CP-102U, CP-102UL, CP-102UF
 	CP-132U-I, CP-132UL,
 	CP-132, CP-132I, CP132S, CP-132IS,
-	CI-132, CI-132I, CI-132IS,
-	(C102H, C102HI, C102HIS, C102P, CP-102, CP-102S)
+	(CP-102, CP-102S)
 
     - 4 ports multiport board
 	CP-104EL,
@@ -46,10 +45,7 @@ Date: 01/21/2008
 	CP-134U, CP-134U-I,
 	C104H/PCI, C104HS/PCI,
 	CP-114, CP-114I, CP-114S, CP-114IS, CP-114UL,
-	C104H, C104HS,
-	CI-104J, CI-104JS,
-	CI-134, CI-134I, CI-134IS,
-	(C114HI, CT-114I, C104P),
+	(C114HI, CT-114I),
 	POS-104UL,
 	CB-114,
 	CB-134I
@@ -58,8 +54,6 @@ Date: 01/21/2008
 	CP-118EL, CP-168EL,
 	CP-118U, CP-168U,
 	C168H/PCI,
-	C168H, C168HS,
-	(C168P),
 	CB-108
 
    This driver and installation procedure have been developed upon Linux Kernel
@@ -78,9 +72,6 @@ Date: 01/21/2008
 		 Monitor program to observe data count and line status signals.
     - msterm     A simple terminal program which is useful in testing serial
 	         ports.
-    - io-irq.exe
-		 Configuration program to setup ISA boards. Please note that
-                 this program can only be executed under DOS.
 
    All the drivers and utilities are published in form of source code under
    GNU General Public License in this version. Please refer to GNU General
@@ -112,17 +103,6 @@ Date: 01/21/2008
 3.1 Hardware installation
 =========================
 
-   There are two types of buses, ISA and PCI, for Smartio/Industio
-   family multiport board.
-
-ISA board
----------
-
-   You'll have to configure CAP address, I/O address, Interrupt Vector
-   as well as IRQ before installing this driver. Please refer to hardware
-   installation procedure in User's Manual before proceed any further.
-   Please make sure the JP1 is open after the ISA board is set properly.
-
 PCI/UPCI board
 --------------
 
@@ -194,16 +174,6 @@ Device naming when more than 2 boards installed
    Under Kernel 2.6 and upper, the cum Device is Obsolete. So use ttyM*
    device instead.
 
-Board sequence
---------------
-
-   This driver will activate ISA boards according to the parameter set
-   in the driver. After all specified ISA board activated, PCI board
-   will be installed in the system automatically driven.
-   Therefore the board number is sorted by the CAP address of ISA boards.
-   For PCI boards, their sequence will be after ISA boards and C168H/PCI
-   has higher priority than C104H/PCI boards.
-
 3.4 Module driver configuration
 ===============================
 
@@ -274,12 +244,10 @@ Board sequence
 
    ::
 
-	 # modprobe mxser <argument>
+	 # modprobe mxser
 
    will activate the module driver. You may run "lsmod" to check
-   if "mxser" is activated. If the MOXA board is ISA board, the
-   <argument> is needed. Please refer to section "3.4.5" for more
-   information.
+   if "mxser" is activated.
 
 ------------- Load MOXA driver on boot --------------------
 
@@ -296,13 +264,6 @@ Board sequence
    achieved by rc file. We offer one "rc.mxser" file to simplify
    the procedure under "moxa/mxser/driver".
 
-   But if you use ISA board, please modify the "modprobe ..." command
-   to add the argument (see "3.4.5" section). After modifying the
-   rc.mxser, please try to execute "/moxa/mxser/driver/rc.mxser"
-   manually to make sure the modification is ok. If any error
-   encountered, please try to modify again. If the modification is
-   completed, follow the below step.
-
    Run following command for setting rc files::
 
 	 # cd /moxa/mxser/driver
@@ -316,21 +277,6 @@ Board sequence
 
    Reboot and check if moxa.o activated by "lsmod" command.
 
-3.4.5. specify CAP address
---------------------------
-
-   If you'd like to drive Smartio/Industio ISA boards in the system,
-   you'll have to add parameter to specify CAP address of given
-   board while activating "mxser.o". The format for parameters are
-   as follows.::
-
-	   modprobe mxser ioaddr=0x???,0x???,0x???,0x???
-				  |  |  |    |
-				  |  |  |    +- 4th ISA board
-				  |  |  +------ 3rd ISA board
-				  |  +------------ 2nd ISA board
-				  +-------------------1st ISA board
-
 3.5 Static driver configuration for Linux kernel 2.4.x and 2.6.x
 ================================================================
 
@@ -357,35 +303,7 @@ Board sequence
 	  # cd /usr/src/linux/drivers/char
 	  # ln -s /moxa/mxser/driver/mxser.c mxser.c
 
-3.5.3 Add CAP address list for ISA boards.
-------------------------------------------
-
-    For PCI boards user, please skip this step.
-
-    In module mode, the CAP address for ISA board is given by
-    parameter. In static driver configuration, you'll have to
-    assign it within driver's source code. If you will not
-    install any ISA boards, you may skip to next portion.
-    The instructions to modify driver source code are as
-    below.
-
-    a. run::
-
-	# cd /moxa/mxser/driver
-	# vi mxser.c
-
-    b. Find the array mxserBoardCAP[] as below::
-
-	  static int mxserBoardCAP[] = {0x00, 0x00, 0x00, 0x00};
-
-    c. Change the address within this array using vi. For
-       example, to driver 2 ISA boards with CAP address
-       0x280 and 0x180 as 1st and 2nd board. Just to change
-       the source code as follows::
-
-	  static int mxserBoardCAP[] = {0x280, 0x180, 0x00, 0x00};
-
-3.5.4 Setup kernel configuration
+3.5.3 Setup kernel configuration
 --------------------------------
 
     Configure the kernel::
@@ -398,7 +316,7 @@ Board sequence
     SmartIO support] driver with "[*]" for built-in (not "[M]"), then
     select [Exit] to exit this program.
 
-3.5.5 Rebuild kernel
+3.5.4 Rebuild kernel
 --------------------
 
     The following are for Linux kernel rebuilding, for your
@@ -426,14 +344,14 @@ Board sequence
           directory /usr/src/linux.
 
 
-3.5.6 Make tty device and special file
+3.5.5 Make tty device and special file
 --------------------------------------
 
     ::
        # cd /moxa/mxser/driver
        # ./msmknod
 
-3.5.7 Make utility
+3.5.6 Make utility
 ------------------
 
     ::
@@ -441,7 +359,7 @@ Board sequence
 	  # cd /moxa/mxser/utility
 	  # make clean; make install
 
-3.5.8 Reboot
+3.5.7 Reboot
 ------------
 
 
@@ -591,13 +509,6 @@ msterm - Terminal Emulation
    Each port within the same multiport board shares the same IRQ. Please set
    one IRQ (IRQ doesn't equal to zero) for one Moxa board.
 
-   Error msg:
-	      No interrupt vector be set for Moxa ISA board(CAP=xxx).
-
-   Solution:
-   Moxa ISA board needs an interrupt vector.Please refer to user's manual
-   "Hardware Installation" chapter to set interrupt vector.
-
    Error msg:
               Couldn't install MOXA Smartio/Industio family driver!
 
diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig
index f6a7fd6d3bb6..476c11278235 100644
--- a/drivers/tty/Kconfig
+++ b/drivers/tty/Kconfig
@@ -204,7 +204,7 @@ config MOXA_INTELLIO
 
 config MOXA_SMARTIO
 	tristate "Moxa SmartIO support v. 2.0"
-	depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA)
+	depends on SERIAL_NONSTANDARD && PCI
 	help
 	  Say Y here if you have a Moxa SmartIO multiport serial card and/or
 	  want to help develop a new version of this driver.
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index a74e6146a748..3a00f180f54a 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -70,18 +70,8 @@
 #define PCI_DEVICE_ID_CB134I	0x1341
 #define PCI_DEVICE_ID_CP138U	0x1380
 
-
-#define C168_ASIC_ID    1
-#define C104_ASIC_ID    2
-#define C102_ASIC_ID	0xB
-#define CI132_ASIC_ID	4
-#define CI134_ASIC_ID	3
-#define CI104J_ASIC_ID  5
-
 #define MXSER_HIGHBAUD	1
-#define MXSER_HAS2	2
 
-/* This is only for PCI */
 static const struct {
 	int type;
 	int tx_fifo;
@@ -105,14 +95,14 @@ struct mxser_cardinfo {
 };
 
 static const struct mxser_cardinfo mxser_cards[] = {
-/* 0*/	{ "C168 series",	8, },
-	{ "C104 series",	4, },
-	{ "CI-104J series",	4, },
+/* 0*/	{ },
+	{ },
+	{ },
 	{ "C168H/PCI series",	8, },
 	{ "C104H/PCI series",	4, },
-/* 5*/	{ "C102 series",	4, MXSER_HAS2 },	/* C102-ISA */
-	{ "CI-132 series",	4, MXSER_HAS2 },
-	{ "CI-134 series",	4, },
+/* 5*/	{ },
+	{ },
+	{ },
 	{ "CP-132 series",	2, },
 	{ "CP-114 series",	4, },
 /*10*/	{ "CT-114 series",	4, },
@@ -172,15 +162,12 @@ static const struct pci_device_id mxser_pcibrds[] = {
 };
 MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
 
-static unsigned long ioaddr[MXSER_BOARDS];
 static int ttymajor = MXSERMAJOR;
 
 /* Variables for insmod */
 
 MODULE_AUTHOR("Casper Yang");
 MODULE_DESCRIPTION("MOXA Smartio/Industio Family Multiport Board Device Driver");
-module_param_hw_array(ioaddr, ulong, ioport, NULL, 0);
-MODULE_PARM_DESC(ioaddr, "ISA io addresses to look for a moxa board");
 module_param(ttymajor, int, 0);
 MODULE_LICENSE("GPL");
 
@@ -300,7 +287,6 @@ static void mxser_enable_must_enchance_mode(unsigned long baseio)
 	outb(oldlcr, baseio + UART_LCR);
 }
 
-#ifdef	CONFIG_PCI
 static void mxser_disable_must_enchance_mode(unsigned long baseio)
 {
 	u8 oldlcr;
@@ -315,7 +301,6 @@ static void mxser_disable_must_enchance_mode(unsigned long baseio)
 	outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
 	outb(oldlcr, baseio + UART_LCR);
 }
-#endif
 
 static void mxser_set_must_xon1_value(unsigned long baseio, u8 value)
 {
@@ -387,7 +372,6 @@ static void mxser_set_must_enum_value(unsigned long baseio, u8 value)
 	outb(oldlcr, baseio + UART_LCR);
 }
 
-#ifdef CONFIG_PCI
 static void mxser_get_must_hardware_id(unsigned long baseio, u8 *pId)
 {
 	u8 oldlcr;
@@ -404,7 +388,6 @@ static void mxser_get_must_hardware_id(unsigned long baseio, u8 *pId)
 	*pId = inb(baseio + MOXA_MUST_HWID_REGISTER);
 	outb(oldlcr, baseio + UART_LCR);
 }
-#endif
 
 static void SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(unsigned long baseio)
 {
@@ -483,7 +466,6 @@ static void mxser_disable_must_rx_software_flow_control(unsigned long baseio)
 	outb(oldlcr, baseio + UART_LCR);
 }
 
-#ifdef CONFIG_PCI
 static int CheckIsMoxaMust(unsigned long io)
 {
 	u8 oldmcr, hwid;
@@ -506,7 +488,6 @@ static int CheckIsMoxaMust(unsigned long io)
 	}
 	return MOXA_OTHER_UART;
 }
-#endif
 
 static void process_txrx_fifo(struct mxser_port *info)
 {
@@ -1398,109 +1379,6 @@ static int mxser_tiocmset(struct tty_struct *tty,
 	return 0;
 }
 
-static int __init mxser_program_mode(int port)
-{
-	int id, i, j, n;
-
-	outb(0, port);
-	outb(0, port);
-	outb(0, port);
-	(void)inb(port);
-	(void)inb(port);
-	outb(0, port);
-	(void)inb(port);
-
-	id = inb(port + 1) & 0x1F;
-	if ((id != C168_ASIC_ID) &&
-			(id != C104_ASIC_ID) &&
-			(id != C102_ASIC_ID) &&
-			(id != CI132_ASIC_ID) &&
-			(id != CI134_ASIC_ID) &&
-			(id != CI104J_ASIC_ID))
-		return -1;
-	for (i = 0, j = 0; i < 4; i++) {
-		n = inb(port + 2);
-		if (n == 'M') {
-			j = 1;
-		} else if ((j == 1) && (n == 1)) {
-			j = 2;
-			break;
-		} else
-			j = 0;
-	}
-	if (j != 2)
-		id = -2;
-	return id;
-}
-
-static void __init mxser_normal_mode(int port)
-{
-	int i, n;
-
-	outb(0xA5, port + 1);
-	outb(0x80, port + 3);
-	outb(12, port + 0);	/* 9600 bps */
-	outb(0, port + 1);
-	outb(0x03, port + 3);	/* 8 data bits */
-	outb(0x13, port + 4);	/* loop back mode */
-	for (i = 0; i < 16; i++) {
-		n = inb(port + 5);
-		if ((n & 0x61) == 0x60)
-			break;
-		if ((n & 1) == 1)
-			(void)inb(port);
-	}
-	outb(0x00, port + 4);
-}
-
-#define CHIP_SK 	0x01	/* Serial Data Clock  in Eprom */
-#define CHIP_DO 	0x02	/* Serial Data Output in Eprom */
-#define CHIP_CS 	0x04	/* Serial Chip Select in Eprom */
-#define CHIP_DI 	0x08	/* Serial Data Input  in Eprom */
-#define EN_CCMD 	0x000	/* Chip's command register     */
-#define EN0_RSARLO	0x008	/* Remote start address reg 0  */
-#define EN0_RSARHI	0x009	/* Remote start address reg 1  */
-#define EN0_RCNTLO	0x00A	/* Remote byte count reg WR    */
-#define EN0_RCNTHI	0x00B	/* Remote byte count reg WR    */
-#define EN0_DCFG	0x00E	/* Data configuration reg WR   */
-#define EN0_PORT	0x010	/* Rcv missed frame error counter RD */
-#define ENC_PAGE0	0x000	/* Select page 0 of chip registers   */
-#define ENC_PAGE3	0x0C0	/* Select page 3 of chip registers   */
-static int __init mxser_read_register(int port, unsigned short *regs)
-{
-	int i, k, value, id;
-	unsigned int j;
-
-	id = mxser_program_mode(port);
-	if (id < 0)
-		return id;
-	for (i = 0; i < 14; i++) {
-		k = (i & 0x3F) | 0x180;
-		for (j = 0x100; j > 0; j >>= 1) {
-			outb(CHIP_CS, port);
-			if (k & j) {
-				outb(CHIP_CS | CHIP_DO, port);
-				outb(CHIP_CS | CHIP_DO | CHIP_SK, port);	/* A? bit of read */
-			} else {
-				outb(CHIP_CS, port);
-				outb(CHIP_CS | CHIP_SK, port);	/* A? bit of read */
-			}
-		}
-		(void)inb(port);
-		value = 0;
-		for (k = 0, j = 0x8000; k < 16; k++, j >>= 1) {
-			outb(CHIP_CS, port);
-			outb(CHIP_CS | CHIP_SK, port);
-			if (inb(port) & CHIP_DI)
-				value |= j;
-		}
-		regs[i] = value;
-		outb(0, port);
-	}
-	mxser_normal_mode(port);
-	return id;
-}
-
 static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
 {
 	struct mxser_port *ip;
@@ -2346,37 +2224,6 @@ static const struct tty_port_operations mxser_port_ops = {
  * The MOXA Smartio/Industio serial driver boot-time initialization code!
  */
 
-static bool allow_overlapping_vector;
-module_param(allow_overlapping_vector, bool, S_IRUGO);
-MODULE_PARM_DESC(allow_overlapping_vector, "whether we allow ISA cards to be configured such that vector overlabs IO ports (default=no)");
-
-static bool mxser_overlapping_vector(struct mxser_board *brd)
-{
-	return allow_overlapping_vector &&
-		brd->vector >= brd->ports[0].ioaddr &&
-		brd->vector < brd->ports[0].ioaddr + 8 * brd->info->nports;
-}
-
-static int mxser_request_vector(struct mxser_board *brd)
-{
-	if (mxser_overlapping_vector(brd))
-		return 0;
-	return request_region(brd->vector, 1, "mxser(vector)") ? 0 : -EIO;
-}
-
-static void mxser_release_vector(struct mxser_board *brd)
-{
-	if (mxser_overlapping_vector(brd))
-		return;
-	release_region(brd->vector, 1);
-}
-
-static void mxser_release_ISA_res(struct mxser_board *brd)
-{
-	release_region(brd->ports[0].ioaddr, 8 * brd->info->nports);
-	mxser_release_vector(brd);
-}
-
 static int mxser_initbrd(struct mxser_board *brd)
 {
 	struct mxser_port *info;
@@ -2439,125 +2286,9 @@ static void mxser_board_remove(struct mxser_board *brd)
 	free_irq(brd->irq, brd);
 }
 
-static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd)
-{
-	int id, i, bits, ret;
-	unsigned short regs[16], irq;
-	unsigned char scratch, scratch2;
-
-	brd->chip_flag = MOXA_OTHER_UART;
-
-	id = mxser_read_register(cap, regs);
-	switch (id) {
-	case C168_ASIC_ID:
-		brd->info = &mxser_cards[0];
-		break;
-	case C104_ASIC_ID:
-		brd->info = &mxser_cards[1];
-		break;
-	case CI104J_ASIC_ID:
-		brd->info = &mxser_cards[2];
-		break;
-	case C102_ASIC_ID:
-		brd->info = &mxser_cards[5];
-		break;
-	case CI132_ASIC_ID:
-		brd->info = &mxser_cards[6];
-		break;
-	case CI134_ASIC_ID:
-		brd->info = &mxser_cards[7];
-		break;
-	default:
-		return 0;
-	}
-
-	irq = 0;
-	/* some ISA cards have 2 ports, but we want to see them as 4-port (why?)
-	   Flag-hack checks if configuration should be read as 2-port here. */
-	if (brd->info->nports == 2 || (brd->info->flags & MXSER_HAS2)) {
-		irq = regs[9] & 0xF000;
-		irq = irq | (irq >> 4);
-		if (irq != (regs[9] & 0xFF00))
-			goto err_irqconflict;
-	} else if (brd->info->nports == 4) {
-		irq = regs[9] & 0xF000;
-		irq = irq | (irq >> 4);
-		irq = irq | (irq >> 8);
-		if (irq != regs[9])
-			goto err_irqconflict;
-	} else if (brd->info->nports == 8) {
-		irq = regs[9] & 0xF000;
-		irq = irq | (irq >> 4);
-		irq = irq | (irq >> 8);
-		if ((irq != regs[9]) || (irq != regs[10]))
-			goto err_irqconflict;
-	}
-
-	if (!irq) {
-		printk(KERN_ERR "mxser: interrupt number unset\n");
-		return -EIO;
-	}
-	brd->irq = ((int)(irq & 0xF000) >> 12);
-	for (i = 0; i < 8; i++)
-		brd->ports[i].ioaddr = (int) regs[i + 1] & 0xFFF8;
-	if ((regs[12] & 0x80) == 0) {
-		printk(KERN_ERR "mxser: invalid interrupt vector\n");
-		return -EIO;
-	}
-	brd->vector = (int)regs[11];	/* interrupt vector */
-	if (id == 1)
-		brd->vector_mask = 0x00FF;
-	else
-		brd->vector_mask = 0x000F;
-	for (i = 7, bits = 0x0100; i >= 0; i--, bits <<= 1) {
-		if (regs[12] & bits) {
-			brd->ports[i].baud_base = 921600;
-			brd->ports[i].max_baud = 921600;
-		} else {
-			brd->ports[i].baud_base = 115200;
-			brd->ports[i].max_baud = 115200;
-		}
-	}
-	scratch2 = inb(cap + UART_LCR) & (~UART_LCR_DLAB);
-	outb(scratch2 | UART_LCR_DLAB, cap + UART_LCR);
-	outb(0, cap + UART_EFR);	/* EFR is the same as FCR */
-	outb(scratch2, cap + UART_LCR);
-	outb(UART_FCR_ENABLE_FIFO, cap + UART_FCR);
-	scratch = inb(cap + UART_IIR);
-
-	if (scratch & 0xC0)
-		brd->uart_type = PORT_16550A;
-	else
-		brd->uart_type = PORT_16450;
-	if (!request_region(brd->ports[0].ioaddr, 8 * brd->info->nports,
-			"mxser(IO)")) {
-		printk(KERN_ERR "mxser: can't request ports I/O region: "
-				"0x%.8lx-0x%.8lx\n",
-				brd->ports[0].ioaddr, brd->ports[0].ioaddr +
-				8 * brd->info->nports - 1);
-		return -EIO;
-	}
-
-	ret = mxser_request_vector(brd);
-	if (ret) {
-		release_region(brd->ports[0].ioaddr, 8 * brd->info->nports);
-		printk(KERN_ERR "mxser: can't request interrupt vector region: "
-				"0x%.8lx-0x%.8lx\n",
-				brd->ports[0].ioaddr, brd->ports[0].ioaddr +
-				8 * brd->info->nports - 1);
-		return ret;
-	}
-	return brd->info->nports;
-
-err_irqconflict:
-	printk(KERN_ERR "mxser: invalid interrupt number\n");
-	return -EIO;
-}
-
 static int mxser_probe(struct pci_dev *pdev,
 		const struct pci_device_id *ent)
 {
-#ifdef CONFIG_PCI
 	struct mxser_board *brd;
 	unsigned int i, j;
 	unsigned long ioaddress;
@@ -2673,14 +2404,10 @@ static int mxser_probe(struct pci_dev *pdev,
 	pci_disable_device(pdev);
 err:
 	return retval;
-#else
-	return -ENODEV;
-#endif
 }
 
 static void mxser_remove(struct pci_dev *pdev)
 {
-#ifdef CONFIG_PCI
 	struct mxser_board *brd = pci_get_drvdata(pdev);
 
 	mxser_board_remove(brd);
@@ -2689,7 +2416,6 @@ static void mxser_remove(struct pci_dev *pdev)
 	pci_release_region(pdev, 3);
 	pci_disable_device(pdev);
 	brd->info = NULL;
-#endif
 }
 
 static struct pci_driver mxser_driver = {
@@ -2701,9 +2427,6 @@ static struct pci_driver mxser_driver = {
 
 static int __init mxser_module_init(void)
 {
-	struct mxser_board *brd;
-	struct device *tty_dev;
-	unsigned int b, i, m;
 	int retval;
 
 	mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1);
@@ -2731,57 +2454,10 @@ static int __init mxser_module_init(void)
 		goto err_put;
 	}
 
-	/* Start finding ISA boards here */
-	for (m = 0, b = 0; b < MXSER_BOARDS; b++) {
-		if (!ioaddr[b])
-			continue;
-
-		brd = &mxser_boards[m];
-		retval = mxser_get_ISA_conf(ioaddr[b], brd);
-		if (retval <= 0) {
-			brd->info = NULL;
-			continue;
-		}
-
-		printk(KERN_INFO "mxser: found MOXA %s board (CAP=0x%lx)\n",
-				brd->info->name, ioaddr[b]);
-
-		/* mxser_initbrd will hook ISR. */
-		if (mxser_initbrd(brd) < 0) {
-			mxser_release_ISA_res(brd);
-			brd->info = NULL;
-			continue;
-		}
-
-		brd->idx = m * MXSER_PORTS_PER_BOARD;
-		for (i = 0; i < brd->info->nports; i++) {
-			tty_dev = tty_port_register_device(&brd->ports[i].port,
-					mxvar_sdriver, brd->idx + i, NULL);
-			if (IS_ERR(tty_dev)) {
-				for (; i > 0; i--)
-					tty_unregister_device(mxvar_sdriver,
-						brd->idx + i - 1);
-				for (i = 0; i < brd->info->nports; i++)
-					tty_port_destroy(&brd->ports[i].port);
-				free_irq(brd->irq, brd);
-				mxser_release_ISA_res(brd);
-				brd->info = NULL;
-				break;
-			}
-		}
-		if (brd->info == NULL)
-			continue;
-
-		m++;
-	}
-
 	retval = pci_register_driver(&mxser_driver);
 	if (retval) {
 		printk(KERN_ERR "mxser: can't register pci driver\n");
-		if (!m) {
-			retval = -ENODEV;
-			goto err_unr;
-		} /* else: we have some ISA cards under control */
+		goto err_unr;
 	}
 
 	return 0;
@@ -2794,19 +2470,9 @@ static int __init mxser_module_init(void)
 
 static void __exit mxser_module_exit(void)
 {
-	unsigned int i;
-
 	pci_unregister_driver(&mxser_driver);
-
-	for (i = 0; i < MXSER_BOARDS; i++) /* ISA remains */
-		if (mxser_boards[i].info != NULL)
-			mxser_board_remove(&mxser_boards[i]);
 	tty_unregister_driver(mxvar_sdriver);
 	put_tty_driver(mxvar_sdriver);
-
-	for (i = 0; i < MXSER_BOARDS; i++)
-		if (mxser_boards[i].info != NULL)
-			mxser_release_ISA_res(&mxser_boards[i]);
 }
 
 module_init(mxser_module_init);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 02/70] mxser: renumber mxser_cards
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
  2021-06-18  6:14 ` [PATCH 01/70] mxser: drop ISA support Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 03/70] mxser: remove info printout from init Jiri Slaby
                   ` (68 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

After the ISA cards removal in the previous patch, the mxser_cards array
has holes in it. So renumber the array while updating PCI device's
driver_data.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 80 +++++++++++++++++++++------------------------
 1 file changed, 37 insertions(+), 43 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 3a00f180f54a..ef539f084e55 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -95,69 +95,63 @@ struct mxser_cardinfo {
 };
 
 static const struct mxser_cardinfo mxser_cards[] = {
-/* 0*/	{ },
-	{ },
-	{ },
-	{ "C168H/PCI series",	8, },
+/* 0*/	{ "C168H/PCI series",	8, },
 	{ "C104H/PCI series",	4, },
-/* 5*/	{ },
-	{ },
-	{ },
 	{ "CP-132 series",	2, },
 	{ "CP-114 series",	4, },
-/*10*/	{ "CT-114 series",	4, },
-	{ "CP-102 series",	2, MXSER_HIGHBAUD },
+	{ "CT-114 series",	4, },
+/* 5*/	{ "CP-102 series",	2, MXSER_HIGHBAUD },
 	{ "CP-104U series",	4, },
 	{ "CP-168U series",	8, },
 	{ "CP-132U series",	2, },
-/*15*/	{ "CP-134U series",	4, },
-	{ "CP-104JU series",	4, },
+	{ "CP-134U series",	4, },
+/*10*/	{ "CP-104JU series",	4, },
 	{ "Moxa UC7000 Serial",	8, },		/* RC7000 */
 	{ "CP-118U series",	8, },
 	{ "CP-102UL series",	2, },
-/*20*/	{ "CP-102U series",	2, },
-	{ "CP-118EL series",	8, },
+	{ "CP-102U series",	2, },
+/*15*/	{ "CP-118EL series",	8, },
 	{ "CP-168EL series",	8, },
 	{ "CP-104EL series",	4, },
 	{ "CB-108 series",	8, },
-/*25*/	{ "CB-114 series",	4, },
-	{ "CB-134I series",	4, },
+	{ "CB-114 series",	4, },
+/*20*/	{ "CB-134I series",	4, },
 	{ "CP-138U series",	8, },
 	{ "POS-104UL series",	4, },
 	{ "CP-114UL series",	4, },
-/*30*/	{ "CP-102UF series",	2, },
-	{ "CP-112UL series",	2, },
+	{ "CP-102UF series",	2, },
+/*25*/	{ "CP-112UL series",	2, },
 };
 
 /* driver_data correspond to the lines in the structure above
    see also ISA probe function before you change something */
 static const struct pci_device_id mxser_pcibrds[] = {
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C168),	.driver_data = 3 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C104),	.driver_data = 4 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132),	.driver_data = 8 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP114),	.driver_data = 9 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CT114),	.driver_data = 10 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102),	.driver_data = 11 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104U),	.driver_data = 12 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168U),	.driver_data = 13 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132U),	.driver_data = 14 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP134U),	.driver_data = 15 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104JU),.driver_data = 16 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_RC7000),	.driver_data = 17 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118U),	.driver_data = 18 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102UL),.driver_data = 19 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102U),	.driver_data = 20 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118EL),.driver_data = 21 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168EL),.driver_data = 22 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104EL),.driver_data = 23 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB108),	.driver_data = 24 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB114),	.driver_data = 25 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB134I),	.driver_data = 26 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP138U),	.driver_data = 27 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_POS104UL),	.driver_data = 28 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP114UL),	.driver_data = 29 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP102UF),	.driver_data = 30 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP112UL),	.driver_data = 31 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C168),	.driver_data = 0 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C104),	.driver_data = 1 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132),	.driver_data = 2 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP114),	.driver_data = 3 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CT114),	.driver_data = 4 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102),	.driver_data = 5 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104U),	.driver_data = 6 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168U),	.driver_data = 7 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132U),	.driver_data = 8 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP134U),	.driver_data = 9 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104JU),.driver_data = 10 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_RC7000),	.driver_data = 11 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118U),	.driver_data = 12 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102UL),.driver_data = 13 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102U),	.driver_data = 14 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118EL),.driver_data = 15 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168EL),.driver_data = 16 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104EL),.driver_data = 17 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB108),	.driver_data = 18 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB114),	.driver_data = 19 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB134I),	.driver_data = 20 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP138U),	.driver_data = 21 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_POS104UL),	.driver_data = 22 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP114UL),	.driver_data = 23 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP102UF),	.driver_data = 24 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP112UL),	.driver_data = 25 },
 	{ }
 };
 MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 03/70] mxser: remove info printout from init
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
  2021-06-18  6:14 ` [PATCH 01/70] mxser: drop ISA support Jiri Slaby
  2021-06-18  6:14 ` [PATCH 02/70] mxser: renumber mxser_cards Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 04/70] mxser: integrate mxser.h into .c Jiri Slaby
                   ` (67 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

There is no reason/desire to print module information upon module load.
Drop this printk (and a version define).

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index ef539f084e55..d91f8e791aab 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -43,7 +43,6 @@
 
 #include "mxser.h"
 
-#define	MXSER_VERSION	"2.0.5"		/* 1.14 */
 #define	MXSERMAJOR	 174
 
 #define MXSER_BOARDS		4	/* Max. boards */
@@ -2427,9 +2426,6 @@ static int __init mxser_module_init(void)
 	if (!mxvar_sdriver)
 		return -ENOMEM;
 
-	printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n",
-		MXSER_VERSION);
-
 	/* Initialize the tty_driver structure */
 	mxvar_sdriver->name = "ttyMI";
 	mxvar_sdriver->major = ttymajor;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 04/70] mxser: integrate mxser.h into .c
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (2 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 03/70] mxser: remove info printout from init Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 05/70] mxser: cleanup Gpci_uart_info struct Jiri Slaby
                   ` (66 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

As mxser.h serves only mxser.c, integrate the definitions into .c and
drop .h. There are some "semi-public" ioctl definitions, but they are
mostly go away in the next patches. If something, they would need to
live in an uapi header anyway.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 130 +++++++++++++++++++++++++++++++++++++-
 drivers/tty/mxser.h | 151 --------------------------------------------
 2 files changed, 129 insertions(+), 152 deletions(-)
 delete mode 100644 drivers/tty/mxser.h

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index d91f8e791aab..0c779559f978 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -41,7 +41,135 @@
 #include <asm/irq.h>
 #include <linux/uaccess.h>
 
-#include "mxser.h"
+/*
+ *	Semi-public control interfaces
+ */
+
+/*
+ *	MOXA ioctls
+ */
+
+#define MOXA			0x400
+#define MOXA_GETDATACOUNT	(MOXA + 23)
+#define MOXA_DIAGNOSE		(MOXA + 50)
+#define MOXA_CHKPORTENABLE	(MOXA + 60)
+#define MOXA_HighSpeedOn	(MOXA + 61)
+#define MOXA_GET_MAJOR		(MOXA + 63)
+#define MOXA_GETMSTATUS		(MOXA + 65)
+#define MOXA_SET_OP_MODE	(MOXA + 66)
+#define MOXA_GET_OP_MODE	(MOXA + 67)
+
+#define RS232_MODE		0
+#define RS485_2WIRE_MODE	1
+#define RS422_MODE		2
+#define RS485_4WIRE_MODE	3
+#define OP_MODE_MASK		3
+
+#define MOXA_SDS_RSTICOUNTER	(MOXA + 69)
+#define MOXA_ASPP_OQUEUE	(MOXA + 70)
+#define MOXA_ASPP_MON		(MOXA + 73)
+#define MOXA_ASPP_LSTATUS	(MOXA + 74)
+#define MOXA_ASPP_MON_EXT	(MOXA + 75)
+#define MOXA_SET_BAUD_METHOD	(MOXA + 76)
+
+/* --------------------------------------------------- */
+
+#define NPPI_NOTIFY_PARITY	0x01
+#define NPPI_NOTIFY_FRAMING	0x02
+#define NPPI_NOTIFY_HW_OVERRUN	0x04
+#define NPPI_NOTIFY_SW_OVERRUN	0x08
+#define NPPI_NOTIFY_BREAK	0x10
+
+#define NPPI_NOTIFY_CTSHOLD         0x01	/* Tx hold by CTS low */
+#define NPPI_NOTIFY_DSRHOLD         0x02	/* Tx hold by DSR low */
+#define NPPI_NOTIFY_XOFFHOLD        0x08	/* Tx hold by Xoff received */
+#define NPPI_NOTIFY_XOFFXENT        0x10	/* Xoff Sent */
+
+/*
+ * Follow just what Moxa Must chip defines.
+ *
+ * When LCR register (offset 0x03) writes the following value, the Must chip
+ * will enter enchance mode. And write value on EFR (offset 0x02) bit 6,7 to
+ * change bank.
+ */
+#define MOXA_MUST_ENTER_ENCHANCE	0xBF
+
+/* when enhance mode enabled, access on general bank register */
+#define MOXA_MUST_GDL_REGISTER		0x07
+#define MOXA_MUST_GDL_MASK		0x7F
+#define MOXA_MUST_GDL_HAS_BAD_DATA	0x80
+
+#define MOXA_MUST_LSR_RERR		0x80	/* error in receive FIFO */
+/* enchance register bank select and enchance mode setting register */
+/* when LCR register equals to 0xBF */
+#define MOXA_MUST_EFR_REGISTER		0x02
+#define MOXA_MUST_EFR_EFRB_ENABLE	0x10 /* enchance mode enable */
+/* enchance register bank set 0, 1, 2 */
+#define MOXA_MUST_EFR_BANK0		0x00
+#define MOXA_MUST_EFR_BANK1		0x40
+#define MOXA_MUST_EFR_BANK2		0x80
+#define MOXA_MUST_EFR_BANK3		0xC0
+#define MOXA_MUST_EFR_BANK_MASK		0xC0
+
+/* set XON1 value register, when LCR=0xBF and change to bank0 */
+#define MOXA_MUST_XON1_REGISTER		0x04
+
+/* set XON2 value register, when LCR=0xBF and change to bank0 */
+#define MOXA_MUST_XON2_REGISTER		0x05
+
+/* set XOFF1 value register, when LCR=0xBF and change to bank0 */
+#define MOXA_MUST_XOFF1_REGISTER	0x06
+
+/* set XOFF2 value register, when LCR=0xBF and change to bank0 */
+#define MOXA_MUST_XOFF2_REGISTER	0x07
+
+#define MOXA_MUST_RBRTL_REGISTER	0x04
+#define MOXA_MUST_RBRTH_REGISTER	0x05
+#define MOXA_MUST_RBRTI_REGISTER	0x06
+#define MOXA_MUST_THRTL_REGISTER	0x07
+#define MOXA_MUST_ENUM_REGISTER		0x04
+#define MOXA_MUST_HWID_REGISTER		0x05
+#define MOXA_MUST_ECR_REGISTER		0x06
+#define MOXA_MUST_CSR_REGISTER		0x07
+
+#define MOXA_MUST_FCR_GDA_MODE_ENABLE	0x20 /* good data mode enable */
+#define MOXA_MUST_FCR_GDA_ONLY_ENABLE	0x10 /* only good data put into RxFIFO */
+
+#define MOXA_MUST_IER_ECTSI		0x80 /* enable CTS interrupt */
+#define MOXA_MUST_IER_ERTSI		0x40 /* enable RTS interrupt */
+#define MOXA_MUST_IER_XINT		0x20 /* enable Xon/Xoff interrupt */
+#define MOXA_MUST_IER_EGDAI		0x10 /* enable GDA interrupt */
+
+#define MOXA_MUST_RECV_ISR		(UART_IER_RDI | MOXA_MUST_IER_EGDAI)
+
+/* GDA interrupt pending */
+#define MOXA_MUST_IIR_GDA		0x1C
+#define MOXA_MUST_IIR_RDA		0x04
+#define MOXA_MUST_IIR_RTO		0x0C
+#define MOXA_MUST_IIR_LSR		0x06
+
+/* received Xon/Xoff or specical interrupt pending */
+#define MOXA_MUST_IIR_XSC		0x10
+
+/* RTS/CTS change state interrupt pending */
+#define MOXA_MUST_IIR_RTSCTS		0x20
+#define MOXA_MUST_IIR_MASK		0x3E
+
+#define MOXA_MUST_MCR_XON_FLAG		0x40
+#define MOXA_MUST_MCR_XON_ANY		0x80
+#define MOXA_MUST_MCR_TX_XON		0x08
+
+#define MOXA_MUST_EFR_SF_MASK		0x0F /* software flow control on chip mask value */
+#define MOXA_MUST_EFR_SF_TX1		0x08 /* send Xon1/Xoff1 */
+#define MOXA_MUST_EFR_SF_TX2		0x04 /* send Xon2/Xoff2 */
+#define MOXA_MUST_EFR_SF_TX12		0x0C /* send Xon1,Xon2/Xoff1,Xoff2 */
+#define MOXA_MUST_EFR_SF_TX_NO		0x00 /* don't send Xon/Xoff */
+#define MOXA_MUST_EFR_SF_TX_MASK	0x0C /* Tx software flow control mask */
+#define MOXA_MUST_EFR_SF_RX_NO		0x00 /* don't receive Xon/Xoff */
+#define MOXA_MUST_EFR_SF_RX1		0x02 /* receive Xon1/Xoff1 */
+#define MOXA_MUST_EFR_SF_RX2		0x01 /* receive Xon2/Xoff2 */
+#define MOXA_MUST_EFR_SF_RX12		0x03 /* receive Xon1,Xon2/Xoff1,Xoff2 */
+#define MOXA_MUST_EFR_SF_RX_MASK	0x03 /* Rx software flow control mask */
 
 #define	MXSERMAJOR	 174
 
diff --git a/drivers/tty/mxser.h b/drivers/tty/mxser.h
deleted file mode 100644
index e6cb15626567..000000000000
--- a/drivers/tty/mxser.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _MXSER_H
-#define _MXSER_H
-
-/*
- *	Semi-public control interfaces
- */
-
-/*
- *	MOXA ioctls
- */
-
-#define MOXA			0x400
-#define MOXA_GETDATACOUNT	(MOXA + 23)
-#define MOXA_DIAGNOSE		(MOXA + 50)
-#define MOXA_CHKPORTENABLE	(MOXA + 60)
-#define MOXA_HighSpeedOn	(MOXA + 61)
-#define MOXA_GET_MAJOR		(MOXA + 63)
-#define MOXA_GETMSTATUS		(MOXA + 65)
-#define MOXA_SET_OP_MODE	(MOXA + 66)
-#define MOXA_GET_OP_MODE	(MOXA + 67)
-
-#define RS232_MODE		0
-#define RS485_2WIRE_MODE	1
-#define RS422_MODE		2
-#define RS485_4WIRE_MODE	3
-#define OP_MODE_MASK		3
-
-#define MOXA_SDS_RSTICOUNTER	(MOXA + 69)
-#define MOXA_ASPP_OQUEUE  	(MOXA + 70)
-#define MOXA_ASPP_MON     	(MOXA + 73)
-#define MOXA_ASPP_LSTATUS 	(MOXA + 74)
-#define MOXA_ASPP_MON_EXT 	(MOXA + 75)
-#define MOXA_SET_BAUD_METHOD	(MOXA + 76)
-
-/* --------------------------------------------------- */
-
-#define NPPI_NOTIFY_PARITY	0x01
-#define NPPI_NOTIFY_FRAMING	0x02
-#define NPPI_NOTIFY_HW_OVERRUN	0x04
-#define NPPI_NOTIFY_SW_OVERRUN	0x08
-#define NPPI_NOTIFY_BREAK	0x10
-
-#define NPPI_NOTIFY_CTSHOLD         0x01	/* Tx hold by CTS low */
-#define NPPI_NOTIFY_DSRHOLD         0x02	/* Tx hold by DSR low */
-#define NPPI_NOTIFY_XOFFHOLD        0x08	/* Tx hold by Xoff received */
-#define NPPI_NOTIFY_XOFFXENT        0x10	/* Xoff Sent */
-
-/* follow just for Moxa Must chip define. */
-/* */
-/* when LCR register (offset 0x03) write following value, */
-/* the Must chip will enter enchance mode. And write value */
-/* on EFR (offset 0x02) bit 6,7 to change bank. */
-#define MOXA_MUST_ENTER_ENCHANCE	0xBF
-
-/* when enhance mode enable, access on general bank register */
-#define MOXA_MUST_GDL_REGISTER		0x07
-#define MOXA_MUST_GDL_MASK		0x7F
-#define MOXA_MUST_GDL_HAS_BAD_DATA	0x80
-
-#define MOXA_MUST_LSR_RERR		0x80	/* error in receive FIFO */
-/* enchance register bank select and enchance mode setting register */
-/* when LCR register equal to 0xBF */
-#define MOXA_MUST_EFR_REGISTER		0x02
-/* enchance mode enable */
-#define MOXA_MUST_EFR_EFRB_ENABLE	0x10
-/* enchance reister bank set 0, 1, 2 */
-#define MOXA_MUST_EFR_BANK0		0x00
-#define MOXA_MUST_EFR_BANK1		0x40
-#define MOXA_MUST_EFR_BANK2		0x80
-#define MOXA_MUST_EFR_BANK3		0xC0
-#define MOXA_MUST_EFR_BANK_MASK		0xC0
-
-/* set XON1 value register, when LCR=0xBF and change to bank0 */
-#define MOXA_MUST_XON1_REGISTER		0x04
-
-/* set XON2 value register, when LCR=0xBF and change to bank0 */
-#define MOXA_MUST_XON2_REGISTER		0x05
-
-/* set XOFF1 value register, when LCR=0xBF and change to bank0 */
-#define MOXA_MUST_XOFF1_REGISTER	0x06
-
-/* set XOFF2 value register, when LCR=0xBF and change to bank0 */
-#define MOXA_MUST_XOFF2_REGISTER	0x07
-
-#define MOXA_MUST_RBRTL_REGISTER	0x04
-#define MOXA_MUST_RBRTH_REGISTER	0x05
-#define MOXA_MUST_RBRTI_REGISTER	0x06
-#define MOXA_MUST_THRTL_REGISTER	0x07
-#define MOXA_MUST_ENUM_REGISTER		0x04
-#define MOXA_MUST_HWID_REGISTER		0x05
-#define MOXA_MUST_ECR_REGISTER		0x06
-#define MOXA_MUST_CSR_REGISTER		0x07
-
-/* good data mode enable */
-#define MOXA_MUST_FCR_GDA_MODE_ENABLE	0x20
-/* only good data put into RxFIFO */
-#define MOXA_MUST_FCR_GDA_ONLY_ENABLE	0x10
-
-/* enable CTS interrupt */
-#define MOXA_MUST_IER_ECTSI		0x80
-/* enable RTS interrupt */
-#define MOXA_MUST_IER_ERTSI		0x40
-/* enable Xon/Xoff interrupt */
-#define MOXA_MUST_IER_XINT		0x20
-/* enable GDA interrupt */
-#define MOXA_MUST_IER_EGDAI		0x10
-
-#define MOXA_MUST_RECV_ISR		(UART_IER_RDI | MOXA_MUST_IER_EGDAI)
-
-/* GDA interrupt pending */
-#define MOXA_MUST_IIR_GDA		0x1C
-#define MOXA_MUST_IIR_RDA		0x04
-#define MOXA_MUST_IIR_RTO		0x0C
-#define MOXA_MUST_IIR_LSR		0x06
-
-/* received Xon/Xoff or specical interrupt pending */
-#define MOXA_MUST_IIR_XSC		0x10
-
-/* RTS/CTS change state interrupt pending */
-#define MOXA_MUST_IIR_RTSCTS		0x20
-#define MOXA_MUST_IIR_MASK		0x3E
-
-#define MOXA_MUST_MCR_XON_FLAG		0x40
-#define MOXA_MUST_MCR_XON_ANY		0x80
-#define MOXA_MUST_MCR_TX_XON		0x08
-
-/* software flow control on chip mask value */
-#define MOXA_MUST_EFR_SF_MASK		0x0F
-/* send Xon1/Xoff1 */
-#define MOXA_MUST_EFR_SF_TX1		0x08
-/* send Xon2/Xoff2 */
-#define MOXA_MUST_EFR_SF_TX2		0x04
-/* send Xon1,Xon2/Xoff1,Xoff2 */
-#define MOXA_MUST_EFR_SF_TX12		0x0C
-/* don't send Xon/Xoff */
-#define MOXA_MUST_EFR_SF_TX_NO		0x00
-/* Tx software flow control mask */
-#define MOXA_MUST_EFR_SF_TX_MASK	0x0C
-/* don't receive Xon/Xoff */
-#define MOXA_MUST_EFR_SF_RX_NO		0x00
-/* receive Xon1/Xoff1 */
-#define MOXA_MUST_EFR_SF_RX1		0x02
-/* receive Xon2/Xoff2 */
-#define MOXA_MUST_EFR_SF_RX2		0x01
-/* receive Xon1,Xon2/Xoff1,Xoff2 */
-#define MOXA_MUST_EFR_SF_RX12		0x03
-/* Rx software flow control mask */
-#define MOXA_MUST_EFR_SF_RX_MASK	0x03
-
-#endif
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 05/70] mxser: cleanup Gpci_uart_info struct
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (3 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 04/70] mxser: integrate mxser.h into .c Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 06/70] mxser: rename CheckIsMoxaMust to mxser_get_must_hwid Jiri Slaby
                   ` (65 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

The Gpci_uart_info structure contains up to tripled information and
chose weird types for the members. Deduplicate the members and choose
proper types for the data -- everything can be u8 except baud rate.
There, we use speed_t, which is used in this context.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 42 ++++++++++++++++++------------------------
 1 file changed, 18 insertions(+), 24 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 0c779559f978..3b3f0da9ea64 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -200,18 +200,15 @@
 #define MXSER_HIGHBAUD	1
 
 static const struct {
-	int type;
-	int tx_fifo;
-	int rx_fifo;
-	int xmit_fifo_size;
-	int rx_high_water;
-	int rx_trigger;
-	int rx_low_water;
-	long max_baud;
+	u8 type;
+	u8 fifo_size;
+	u8 rx_high_water;
+	u8 rx_low_water;
+	speed_t max_baud;
 } Gpci_uart_info[] = {
-	{MOXA_OTHER_UART, 16, 16, 16, 14, 14, 1, 921600L},
-	{MOXA_MUST_MU150_HWID, 64, 64, 64, 48, 48, 16, 230400L},
-	{MOXA_MUST_MU860_HWID, 128, 128, 128, 96, 96, 32, 921600L}
+	{ MOXA_OTHER_UART,	 16, 14,  1, 921600 },
+	{ MOXA_MUST_MU150_HWID,	 64, 48, 16, 230400 },
+	{ MOXA_MUST_MU860_HWID, 128, 96, 32, 921600 }
 };
 #define UART_INFO_NUM	ARRAY_SIZE(Gpci_uart_info)
 
@@ -331,11 +328,10 @@ struct mxser_port {
 
 	unsigned long ioaddr;
 	unsigned long opmode_ioaddr;
-	int max_baud;
+	speed_t max_baud;
 
-	int rx_high_water;
-	int rx_trigger;		/* Rx fifo trigger level */
-	int rx_low_water;
+	u8 rx_high_water;
+	u8 rx_low_water;
 	int baud_base;		/* max. speed */
 	int type;		/* UART type */
 
@@ -354,7 +350,7 @@ struct mxser_port {
 
 	int read_status_mask;
 	int ignore_status_mask;
-	unsigned int xmit_fifo_size;
+	u8 xmit_fifo_size;
 	int xmit_head;
 	int xmit_tail;
 	int xmit_cnt;
@@ -470,9 +466,9 @@ static void mxser_set_must_fifo_value(struct mxser_port *info)
 	efr |= MOXA_MUST_EFR_BANK1;
 
 	outb(efr, info->ioaddr + MOXA_MUST_EFR_REGISTER);
-	outb((u8)info->rx_high_water, info->ioaddr + MOXA_MUST_RBRTH_REGISTER);
-	outb((u8)info->rx_trigger, info->ioaddr + MOXA_MUST_RBRTI_REGISTER);
-	outb((u8)info->rx_low_water, info->ioaddr + MOXA_MUST_RBRTL_REGISTER);
+	outb(info->rx_high_water, info->ioaddr + MOXA_MUST_RBRTH_REGISTER);
+	outb(info->rx_high_water, info->ioaddr + MOXA_MUST_RBRTI_REGISTER);
+	outb(info->rx_low_water, info->ioaddr + MOXA_MUST_RBRTL_REGISTER);
 	outb(oldlcr, info->ioaddr + UART_LCR);
 }
 
@@ -615,17 +611,15 @@ static void process_txrx_fifo(struct mxser_port *info)
 	int i;
 
 	if ((info->type == PORT_16450) || (info->type == PORT_8250)) {
-		info->rx_trigger = 1;
 		info->rx_high_water = 1;
 		info->rx_low_water = 1;
 		info->xmit_fifo_size = 1;
 	} else
 		for (i = 0; i < UART_INFO_NUM; i++)
 			if (info->board->chip_flag == Gpci_uart_info[i].type) {
-				info->rx_trigger = Gpci_uart_info[i].rx_trigger;
 				info->rx_low_water = Gpci_uart_info[i].rx_low_water;
 				info->rx_high_water = Gpci_uart_info[i].rx_high_water;
-				info->xmit_fifo_size = Gpci_uart_info[i].xmit_fifo_size;
+				info->xmit_fifo_size = Gpci_uart_info[i].fifo_size;
 				break;
 			}
 }
@@ -667,7 +661,7 @@ static void mxser_dtr_rts(struct tty_port *port, int on)
 	spin_unlock_irqrestore(&mp->slock, flags);
 }
 
-static int mxser_set_baud(struct tty_struct *tty, long newspd)
+static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
 {
 	struct mxser_port *info = tty->driver_data;
 	unsigned int quot = 0, baud;
@@ -793,7 +787,7 @@ static void mxser_change_speed(struct tty_struct *tty)
 			fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
 			mxser_set_must_fifo_value(info);
 		} else {
-			switch (info->rx_trigger) {
+			switch (info->rx_high_water) {
 			case 1:
 				fcr |= UART_FCR_TRIGGER_1;
 				break;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 06/70] mxser: rename CheckIsMoxaMust to mxser_get_must_hwid
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (4 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 05/70] mxser: cleanup Gpci_uart_info struct Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 07/70] mxser: rename mxser_board::chip_flag to must_hwid Jiri Slaby
                   ` (64 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

CheckIsMoxaMust actually finds out what the card is. So rename it to
mxser_must_get_hwid, so that the name conforms to the semantics of the
function.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 3b3f0da9ea64..72e1aeabdee7 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -583,7 +583,7 @@ static void mxser_disable_must_rx_software_flow_control(unsigned long baseio)
 	outb(oldlcr, baseio + UART_LCR);
 }
 
-static int CheckIsMoxaMust(unsigned long io)
+static int mxser_must_get_hwid(unsigned long io)
 {
 	u8 oldmcr, hwid;
 	int i;
@@ -2452,7 +2452,7 @@ static int mxser_probe(struct pci_dev *pdev,
 	/* irq */
 	brd->irq = pdev->irq;
 
-	brd->chip_flag = CheckIsMoxaMust(brd->ports[0].ioaddr);
+	brd->chip_flag = mxser_must_get_hwid(brd->ports[0].ioaddr);
 	brd->uart_type = PORT_16550A;
 	brd->vector_mask = 0;
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 07/70] mxser: rename mxser_board::chip_flag to must_hwid
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (5 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 06/70] mxser: rename CheckIsMoxaMust to mxser_get_must_hwid Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 08/70] mxser: introduce enum mxser_must_hwid Jiri Slaby
                   ` (63 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

It is named IsMoxaMustChipFlag in the original Moxa's driver. Over the
time, it was reduced to chip_flag which doesn't make much sense. So dub
it again by what it is: must_hwid (mxser_must_get_hwid assigns to it).

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 70 ++++++++++++++++++++++-----------------------
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 72e1aeabdee7..1865f965334a 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -370,7 +370,7 @@ struct mxser_board {
 	unsigned long vector;
 	unsigned long vector_mask;
 
-	int chip_flag;
+	int must_hwid;
 	int uart_type;
 
 	struct mxser_port ports[MXSER_PORTS_PER_BOARD];
@@ -616,7 +616,7 @@ static void process_txrx_fifo(struct mxser_port *info)
 		info->xmit_fifo_size = 1;
 	} else
 		for (i = 0; i < UART_INFO_NUM; i++)
-			if (info->board->chip_flag == Gpci_uart_info[i].type) {
+			if (info->board->must_hwid == Gpci_uart_info[i].type) {
 				info->rx_low_water = Gpci_uart_info[i].rx_low_water;
 				info->rx_high_water = Gpci_uart_info[i].rx_high_water;
 				info->xmit_fifo_size = Gpci_uart_info[i].fifo_size;
@@ -775,7 +775,7 @@ static void mxser_change_speed(struct tty_struct *tty)
 		cval |= UART_LCR_SPAR;
 
 	if ((info->type == PORT_8250) || (info->type == PORT_16450)) {
-		if (info->board->chip_flag) {
+		if (info->board->must_hwid) {
 			fcr = UART_FCR_ENABLE_FIFO;
 			fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
 			mxser_set_must_fifo_value(info);
@@ -783,7 +783,7 @@ static void mxser_change_speed(struct tty_struct *tty)
 			fcr = 0;
 	} else {
 		fcr = UART_FCR_ENABLE_FIFO;
-		if (info->board->chip_flag) {
+		if (info->board->must_hwid) {
 			fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
 			mxser_set_must_fifo_value(info);
 		} else {
@@ -810,7 +810,7 @@ static void mxser_change_speed(struct tty_struct *tty)
 	tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
 	if (cflag & CRTSCTS) {
 		info->IER |= UART_IER_MSI;
-		if ((info->type == PORT_16550A) || (info->board->chip_flag)) {
+		if ((info->type == PORT_16550A) || (info->board->must_hwid)) {
 			info->MCR |= UART_MCR_AFE;
 		} else {
 			status = inb(info->ioaddr + UART_MSR);
@@ -818,7 +818,7 @@ static void mxser_change_speed(struct tty_struct *tty)
 				if (status & UART_MSR_CTS) {
 					tty->hw_stopped = 0;
 					if (info->type != PORT_16550A &&
-							!info->board->chip_flag) {
+							!info->board->must_hwid) {
 						outb(info->IER & ~UART_IER_THRI,
 							info->ioaddr +
 							UART_IER);
@@ -832,7 +832,7 @@ static void mxser_change_speed(struct tty_struct *tty)
 				if (!(status & UART_MSR_CTS)) {
 					tty->hw_stopped = 1;
 					if ((info->type != PORT_16550A) &&
-							(!info->board->chip_flag)) {
+							(!info->board->must_hwid)) {
 						info->IER &= ~UART_IER_THRI;
 						outb(info->IER, info->ioaddr +
 								UART_IER);
@@ -876,7 +876,7 @@ static void mxser_change_speed(struct tty_struct *tty)
 						UART_LSR_FE;
 		}
 	}
-	if (info->board->chip_flag) {
+	if (info->board->must_hwid) {
 		mxser_set_must_xon1_value(info->ioaddr, START_CHAR(tty));
 		mxser_set_must_xoff1_value(info->ioaddr, STOP_CHAR(tty));
 		if (I_IXON(tty)) {
@@ -926,7 +926,7 @@ static void mxser_check_modem_status(struct tty_struct *tty,
 				tty->hw_stopped = 0;
 
 				if ((port->type != PORT_16550A) &&
-						(!port->board->chip_flag)) {
+						(!port->board->must_hwid)) {
 					outb(port->IER & ~UART_IER_THRI,
 						port->ioaddr + UART_IER);
 					port->IER |= UART_IER_THRI;
@@ -939,7 +939,7 @@ static void mxser_check_modem_status(struct tty_struct *tty,
 			if (!(status & UART_MSR_CTS)) {
 				tty->hw_stopped = 1;
 				if (port->type != PORT_16550A &&
-						!port->board->chip_flag) {
+						!port->board->must_hwid) {
 					port->IER &= ~UART_IER_THRI;
 					outb(port->IER, port->ioaddr +
 							UART_IER);
@@ -973,7 +973,7 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
 	 * Clear the FIFO buffers and disable them
 	 * (they will be reenabled in mxser_change_speed())
 	 */
-	if (info->board->chip_flag)
+	if (info->board->must_hwid)
 		outb((UART_FCR_CLEAR_RCVR |
 			UART_FCR_CLEAR_XMIT |
 			MOXA_MUST_FCR_GDA_MODE_ENABLE), info->ioaddr + UART_FCR);
@@ -1015,7 +1015,7 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
 	 */
 	info->IER = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI;
 
-	if (info->board->chip_flag)
+	if (info->board->must_hwid)
 		info->IER |= MOXA_MUST_IER_EGDAI;
 	outb(info->IER, info->ioaddr + UART_IER);	/* enable interrupts */
 
@@ -1067,7 +1067,7 @@ static void mxser_shutdown_port(struct tty_port *port)
 	outb(0x00, info->ioaddr + UART_IER);
 
 	/* clear Rx/Tx FIFO's */
-	if (info->board->chip_flag)
+	if (info->board->must_hwid)
 		outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT |
 				MOXA_MUST_FCR_GDA_MODE_ENABLE,
 				info->ioaddr + UART_FCR);
@@ -1079,7 +1079,7 @@ static void mxser_shutdown_port(struct tty_port *port)
 	(void) inb(info->ioaddr + UART_RX);
 
 
-	if (info->board->chip_flag)
+	if (info->board->must_hwid)
 		SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->ioaddr);
 
 	spin_unlock_irqrestore(&info->slock, flags);
@@ -1139,7 +1139,7 @@ static void mxser_close_port(struct tty_port *port)
 	 * line status register.
 	 */
 	info->IER &= ~UART_IER_RLSI;
-	if (info->board->chip_flag)
+	if (info->board->must_hwid)
 		info->IER &= ~MOXA_MUST_RECV_ISR;
 
 	outb(info->IER, info->ioaddr + UART_IER);
@@ -1217,7 +1217,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
 	if (info->xmit_cnt && !tty->flow.stopped) {
 		if (!tty->hw_stopped ||
 				(info->type == PORT_16550A) ||
-				(info->board->chip_flag)) {
+				(info->board->must_hwid)) {
 			spin_lock_irqsave(&info->slock, flags);
 			outb(info->IER & ~UART_IER_THRI, info->ioaddr +
 					UART_IER);
@@ -1248,7 +1248,7 @@ static int mxser_put_char(struct tty_struct *tty, unsigned char ch)
 	if (!tty->flow.stopped) {
 		if (!tty->hw_stopped ||
 				(info->type == PORT_16550A) ||
-				info->board->chip_flag) {
+				info->board->must_hwid) {
 			spin_lock_irqsave(&info->slock, flags);
 			outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
 			info->IER |= UART_IER_THRI;
@@ -1267,7 +1267,7 @@ static void mxser_flush_chars(struct tty_struct *tty)
 
 	if (info->xmit_cnt <= 0 || tty->flow.stopped || !info->port.xmit_buf ||
 			(tty->hw_stopped && info->type != PORT_16550A &&
-			 !info->board->chip_flag))
+			 !info->board->must_hwid))
 		return;
 
 	spin_lock_irqsave(&info->slock, flags);
@@ -1631,7 +1631,7 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
 				if (ip->type == PORT_16550A)
 					me->fifo[p] = 1;
 
-				if (ip->board->chip_flag == MOXA_MUST_MU860_HWID) {
+				if (ip->board->must_hwid == MOXA_MUST_MU860_HWID) {
 					opmode = inb(ip->opmode_ioaddr)>>((p % 4) * 2);
 					opmode &= OP_MODE_MASK;
 				} else {
@@ -1691,7 +1691,7 @@ static int mxser_ioctl(struct tty_struct *tty,
 		int shiftbit;
 		unsigned char val, mask;
 
-		if (info->board->chip_flag != MOXA_MUST_MU860_HWID)
+		if (info->board->must_hwid != MOXA_MUST_MU860_HWID)
 			return -EFAULT;
 
 		p = tty->index % 4;
@@ -1853,7 +1853,7 @@ static void mxser_stoprx(struct tty_struct *tty)
 
 	info->ldisc_stop_rx = 1;
 	if (I_IXOFF(tty)) {
-		if (info->board->chip_flag) {
+		if (info->board->must_hwid) {
 			info->IER &= ~MOXA_MUST_RECV_ISR;
 			outb(info->IER, info->ioaddr + UART_IER);
 		} else {
@@ -1889,7 +1889,7 @@ static void mxser_unthrottle(struct tty_struct *tty)
 		if (info->x_char)
 			info->x_char = 0;
 		else {
-			if (info->board->chip_flag) {
+			if (info->board->must_hwid) {
 				info->IER |= MOXA_MUST_RECV_ISR;
 				outb(info->IER, info->ioaddr + UART_IER);
 			} else {
@@ -1958,7 +1958,7 @@ static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termi
 	if ((old_termios->c_iflag & IXON) && !I_IXON(tty)) {
 		tty->flow.stopped = 0;
 
-		if (info->board->chip_flag) {
+		if (info->board->must_hwid) {
 			spin_lock_irqsave(&info->slock, flags);
 			mxser_disable_must_rx_software_flow_control(
 					info->ioaddr);
@@ -2068,11 +2068,11 @@ static void mxser_receive_chars(struct tty_struct *tty,
 	recv_room = tty->receive_room;
 	if (recv_room == 0 && !port->ldisc_stop_rx)
 		mxser_stoprx(tty);
-	if (port->board->chip_flag != MOXA_OTHER_UART) {
+	if (port->board->must_hwid != MOXA_OTHER_UART) {
 
 		if (*status & UART_LSR_SPECIAL)
 			goto intr_old;
-		if (port->board->chip_flag == MOXA_MUST_MU860_HWID &&
+		if (port->board->must_hwid == MOXA_MUST_MU860_HWID &&
 				(*status & MOXA_MUST_LSR_RERR))
 			goto intr_old;
 		if (*status & MOXA_MUST_LSR_RERR)
@@ -2080,7 +2080,7 @@ static void mxser_receive_chars(struct tty_struct *tty,
 
 		gdl = inb(port->ioaddr + MOXA_MUST_GDL_REGISTER);
 
-		if (port->board->chip_flag == MOXA_MUST_MU150_HWID)
+		if (port->board->must_hwid == MOXA_MUST_MU150_HWID)
 			gdl &= MOXA_MUST_GDL_MASK;
 		if (gdl >= recv_room) {
 			if (!port->ldisc_stop_rx)
@@ -2100,7 +2100,7 @@ static void mxser_receive_chars(struct tty_struct *tty,
 			break;
 
 		ch = inb(port->ioaddr + UART_RX);
-		if (port->board->chip_flag && (*status & UART_LSR_OE))
+		if (port->board->must_hwid && (*status & UART_LSR_OE))
 			outb(0x23, port->ioaddr + UART_FCR);
 		*status &= port->read_status_mask;
 		if (*status & port->ignore_status_mask) {
@@ -2137,7 +2137,7 @@ static void mxser_receive_chars(struct tty_struct *tty,
 
 		}
 
-		if (port->board->chip_flag)
+		if (port->board->must_hwid)
 			break;
 
 		*status = inb(port->ioaddr + UART_LSR);
@@ -2171,7 +2171,7 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 	if (port->xmit_cnt <= 0 || tty->flow.stopped ||
 			(tty->hw_stopped &&
 			(port->type != PORT_16550A) &&
-			(!port->board->chip_flag))) {
+			(!port->board->must_hwid))) {
 		port->IER &= ~UART_IER_THRI;
 		outb(port->IER, port->ioaddr + UART_IER);
 		return;
@@ -2267,7 +2267,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
 				if (status & UART_LSR_BI)
 					port->err_shadow |= NPPI_NOTIFY_BREAK;
 
-				if (port->board->chip_flag) {
+				if (port->board->must_hwid) {
 					if (iir == MOXA_MUST_IIR_GDA ||
 					    iir == MOXA_MUST_IIR_RDA ||
 					    iir == MOXA_MUST_IIR_RTO ||
@@ -2285,7 +2285,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
 				if (msr & UART_MSR_ANY_DELTA)
 					mxser_check_modem_status(tty, port, msr);
 
-				if (port->board->chip_flag) {
+				if (port->board->must_hwid) {
 					if (iir == 0x02 && (status &
 								UART_LSR_THRE))
 						mxser_transmit_chars(tty, port);
@@ -2357,7 +2357,7 @@ static int mxser_initbrd(struct mxser_board *brd)
 		info->ldisc_stop_rx = 0;
 
 		/* Enhance mode enabled here */
-		if (brd->chip_flag != MOXA_OTHER_UART)
+		if (brd->must_hwid != MOXA_OTHER_UART)
 			mxser_enable_must_enchance_mode(info->ioaddr);
 
 		info->type = brd->uart_type;
@@ -2452,13 +2452,13 @@ static int mxser_probe(struct pci_dev *pdev,
 	/* irq */
 	brd->irq = pdev->irq;
 
-	brd->chip_flag = mxser_must_get_hwid(brd->ports[0].ioaddr);
+	brd->must_hwid = mxser_must_get_hwid(brd->ports[0].ioaddr);
 	brd->uart_type = PORT_16550A;
 	brd->vector_mask = 0;
 
 	for (i = 0; i < brd->info->nports; i++) {
 		for (j = 0; j < UART_INFO_NUM; j++) {
-			if (Gpci_uart_info[j].type == brd->chip_flag) {
+			if (Gpci_uart_info[j].type == brd->must_hwid) {
 				brd->ports[i].max_baud =
 					Gpci_uart_info[j].max_baud;
 
@@ -2470,7 +2470,7 @@ static int mxser_probe(struct pci_dev *pdev,
 		}
 	}
 
-	if (brd->chip_flag == MOXA_MUST_MU860_HWID) {
+	if (brd->must_hwid == MOXA_MUST_MU860_HWID) {
 		for (i = 0; i < brd->info->nports; i++) {
 			if (i < 4)
 				brd->ports[i].opmode_ioaddr = ioaddress + 4;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 08/70] mxser: introduce enum mxser_must_hwid
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (6 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 07/70] mxser: rename mxser_board::chip_flag to must_hwid Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 09/70] mxser: drop constant board::uart_type Jiri Slaby
                   ` (62 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Provided the MUST HW ID is an enumeration, define one (enum
mxser_must_hwid) and use it in the code.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 1865f965334a..558bd4140ee1 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -178,11 +178,6 @@
 #define MXSER_PORTS		(MXSER_BOARDS * MXSER_PORTS_PER_BOARD)
 #define MXSER_ISR_PASS_LIMIT	100
 
-/*CheckIsMoxaMust return value*/
-#define MOXA_OTHER_UART		0x00
-#define MOXA_MUST_MU150_HWID	0x01
-#define MOXA_MUST_MU860_HWID	0x02
-
 #define WAKEUP_CHARS		256
 
 #define UART_MCR_AFE		0x20
@@ -199,6 +194,12 @@
 
 #define MXSER_HIGHBAUD	1
 
+enum mxser_must_hwid {
+	MOXA_OTHER_UART		= 0x00,
+	MOXA_MUST_MU150_HWID	= 0x01,
+	MOXA_MUST_MU860_HWID	= 0x02,
+};
+
 static const struct {
 	u8 type;
 	u8 fifo_size;
@@ -370,7 +371,7 @@ struct mxser_board {
 	unsigned long vector;
 	unsigned long vector_mask;
 
-	int must_hwid;
+	enum mxser_must_hwid must_hwid;
 	int uart_type;
 
 	struct mxser_port ports[MXSER_PORTS_PER_BOARD];
@@ -583,7 +584,7 @@ static void mxser_disable_must_rx_software_flow_control(unsigned long baseio)
 	outb(oldlcr, baseio + UART_LCR);
 }
 
-static int mxser_must_get_hwid(unsigned long io)
+static enum mxser_must_hwid mxser_must_get_hwid(unsigned long io)
 {
 	u8 oldmcr, hwid;
 	int i;
@@ -599,10 +600,10 @@ static int mxser_must_get_hwid(unsigned long io)
 	}
 
 	mxser_get_must_hardware_id(io, &hwid);
-	for (i = 1; i < UART_INFO_NUM; i++) { /* 0 = OTHER_UART */
+	for (i = 1; i < UART_INFO_NUM; i++) /* 0 = OTHER_UART */
 		if (hwid == Gpci_uart_info[i].type)
-			return (int)hwid;
-	}
+			return hwid;
+
 	return MOXA_OTHER_UART;
 }
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 09/70] mxser: drop constant board::uart_type
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (7 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 08/70] mxser: introduce enum mxser_must_hwid Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 10/70] mxser: move max_baud from port to board Jiri Slaby
                   ` (61 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

board::uart_type is always set to PORT_16550A. So, use this constant in
the code instead. And drop the mxser_board member.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 558bd4140ee1..a6121fea7a55 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -372,7 +372,6 @@ struct mxser_board {
 	unsigned long vector_mask;
 
 	enum mxser_must_hwid must_hwid;
-	int uart_type;
 
 	struct mxser_port ports[MXSER_PORTS_PER_BOARD];
 };
@@ -2361,7 +2360,7 @@ static int mxser_initbrd(struct mxser_board *brd)
 		if (brd->must_hwid != MOXA_OTHER_UART)
 			mxser_enable_must_enchance_mode(info->ioaddr);
 
-		info->type = brd->uart_type;
+		info->type = PORT_16550A;
 
 		process_txrx_fifo(info);
 
@@ -2454,7 +2453,6 @@ static int mxser_probe(struct pci_dev *pdev,
 	brd->irq = pdev->irq;
 
 	brd->must_hwid = mxser_must_get_hwid(brd->ports[0].ioaddr);
-	brd->uart_type = PORT_16550A;
 	brd->vector_mask = 0;
 
 	for (i = 0; i < brd->info->nports; i++) {
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 10/70] mxser: move max_baud from port to board
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (8 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 09/70] mxser: drop constant board::uart_type Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 11/70] mxser: remove nonsense from ISR Jiri Slaby
                   ` (60 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

mxser_port::max_baud is actually a board property, not port's. So move
it to mxser_board.

While at it, drop the printk informing about max baud rate during probe.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index a6121fea7a55..db594a64ff00 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -329,7 +329,6 @@ struct mxser_port {
 
 	unsigned long ioaddr;
 	unsigned long opmode_ioaddr;
-	speed_t max_baud;
 
 	u8 rx_high_water;
 	u8 rx_low_water;
@@ -372,6 +371,7 @@ struct mxser_board {
 	unsigned long vector_mask;
 
 	enum mxser_must_hwid must_hwid;
+	speed_t max_baud;
 
 	struct mxser_port ports[MXSER_PORTS_PER_BOARD];
 };
@@ -671,7 +671,7 @@ static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
 	if (!info->ioaddr)
 		return -1;
 
-	if (newspd > info->max_baud)
+	if (newspd > info->board->max_baud)
 		return -1;
 
 	if (newspd == 134) {
@@ -2345,9 +2345,6 @@ static int mxser_initbrd(struct mxser_board *brd)
 	unsigned int i;
 	int retval;
 
-	printk(KERN_INFO "mxser: max. baud rate = %d bps\n",
-			brd->ports[0].max_baud);
-
 	for (i = 0; i < brd->info->nports; i++) {
 		info = &brd->ports[i];
 		tty_port_init(&info->port);
@@ -2455,17 +2452,14 @@ static int mxser_probe(struct pci_dev *pdev,
 	brd->must_hwid = mxser_must_get_hwid(brd->ports[0].ioaddr);
 	brd->vector_mask = 0;
 
-	for (i = 0; i < brd->info->nports; i++) {
-		for (j = 0; j < UART_INFO_NUM; j++) {
-			if (Gpci_uart_info[j].type == brd->must_hwid) {
-				brd->ports[i].max_baud =
-					Gpci_uart_info[j].max_baud;
-
-				/* exception....CP-102 */
-				if (brd->info->flags & MXSER_HIGHBAUD)
-					brd->ports[i].max_baud = 921600;
-				break;
-			}
+	for (j = 0; j < UART_INFO_NUM; j++) {
+		if (Gpci_uart_info[j].type == brd->must_hwid) {
+			brd->max_baud = Gpci_uart_info[j].max_baud;
+
+			/* exception....CP-102 */
+			if (brd->info->flags & MXSER_HIGHBAUD)
+				brd->max_baud = 921600;
+			break;
 		}
 	}
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 11/70] mxser: remove nonsense from ISR
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (9 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 10/70] mxser: move max_baud from port to board Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 12/70] mxser: cleanup LSR handling in mxser_receive_chars Jiri Slaby
                   ` (59 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

request_irq was passed a board. There is no need to check dev_id and/or
find the appropriate board in the ISR. Neither check if board is NULL.
Remove this nonsense.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index db594a64ff00..6602b2741271 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -2207,23 +2207,13 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 static irqreturn_t mxser_interrupt(int irq, void *dev_id)
 {
 	int status, iir, i;
-	struct mxser_board *brd = NULL;
+	struct mxser_board *brd = dev_id;
 	struct mxser_port *port;
 	int max, irqbits, bits, msr;
 	unsigned int int_cnt, pass_counter = 0;
 	int handled = IRQ_NONE;
 	struct tty_struct *tty;
 
-	for (i = 0; i < MXSER_BOARDS; i++)
-		if (dev_id == &mxser_boards[i]) {
-			brd = dev_id;
-			break;
-		}
-
-	if (i == MXSER_BOARDS)
-		goto irq_stop;
-	if (brd == NULL)
-		goto irq_stop;
 	max = brd->info->nports;
 	while (pass_counter++ < MXSER_ISR_PASS_LIMIT) {
 		irqbits = inb(brd->vector) & brd->vector_mask;
@@ -2299,7 +2289,6 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
 		}
 	}
 
-irq_stop:
 	return handled;
 }
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 12/70] mxser: cleanup LSR handling in mxser_receive_chars
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (10 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 11/70] mxser: remove nonsense from ISR Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 13/70] mxser: extract port ISR Jiri Slaby
                   ` (58 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

mxser_interrupt is a bit confusing as it passes a pointer to LSR
variable ("status") to mxser_receive_chars. That function can indeed
update the LCR variable. Make this clear by not passing a variable by
reference, instead, return updated status. And change its type
accordingly -- to u8.

Note that the next patches will rework ISR so that even the definition
of status will be u8 soon too.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 6602b2741271..9ba3af4626c6 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -2056,8 +2056,8 @@ static int mxser_rs_break(struct tty_struct *tty, int break_state)
 	return 0;
 }
 
-static void mxser_receive_chars(struct tty_struct *tty,
-				struct mxser_port *port, int *status)
+static u8 mxser_receive_chars(struct tty_struct *tty,
+		struct mxser_port *port, u8 status)
 {
 	unsigned char ch, gdl;
 	int ignored = 0;
@@ -2070,12 +2070,12 @@ static void mxser_receive_chars(struct tty_struct *tty,
 		mxser_stoprx(tty);
 	if (port->board->must_hwid != MOXA_OTHER_UART) {
 
-		if (*status & UART_LSR_SPECIAL)
+		if (status & UART_LSR_SPECIAL)
 			goto intr_old;
 		if (port->board->must_hwid == MOXA_MUST_MU860_HWID &&
-				(*status & MOXA_MUST_LSR_RERR))
+				(status & MOXA_MUST_LSR_RERR))
 			goto intr_old;
-		if (*status & MOXA_MUST_LSR_RERR)
+		if (status & MOXA_MUST_LSR_RERR)
 			goto intr_old;
 
 		gdl = inb(port->ioaddr + MOXA_MUST_GDL_REGISTER);
@@ -2100,28 +2100,28 @@ static void mxser_receive_chars(struct tty_struct *tty,
 			break;
 
 		ch = inb(port->ioaddr + UART_RX);
-		if (port->board->must_hwid && (*status & UART_LSR_OE))
+		if (port->board->must_hwid && (status & UART_LSR_OE))
 			outb(0x23, port->ioaddr + UART_FCR);
-		*status &= port->read_status_mask;
-		if (*status & port->ignore_status_mask) {
+		status &= port->read_status_mask;
+		if (status & port->ignore_status_mask) {
 			if (++ignored > 100)
 				break;
 		} else {
 			char flag = 0;
-			if (*status & UART_LSR_SPECIAL) {
-				if (*status & UART_LSR_BI) {
+			if (status & UART_LSR_SPECIAL) {
+				if (status & UART_LSR_BI) {
 					flag = TTY_BREAK;
 					port->icount.brk++;
 
 					if (port->port.flags & ASYNC_SAK)
 						do_SAK(tty);
-				} else if (*status & UART_LSR_PE) {
+				} else if (status & UART_LSR_PE) {
 					flag = TTY_PARITY;
 					port->icount.parity++;
-				} else if (*status & UART_LSR_FE) {
+				} else if (status & UART_LSR_FE) {
 					flag = TTY_FRAME;
 					port->icount.frame++;
-				} else if (*status & UART_LSR_OE) {
+				} else if (status & UART_LSR_OE) {
 					flag = TTY_OVERRUN;
 					port->icount.overrun++;
 				} else
@@ -2140,8 +2140,8 @@ static void mxser_receive_chars(struct tty_struct *tty,
 		if (port->board->must_hwid)
 			break;
 
-		*status = inb(port->ioaddr + UART_LSR);
-	} while (*status & UART_LSR_DR);
+		status = inb(port->ioaddr + UART_LSR);
+	} while (status & UART_LSR_DR);
 
 end_intr:
 	mxvar_log.rxcnt[tty->index] += cnt;
@@ -2149,6 +2149,8 @@ static void mxser_receive_chars(struct tty_struct *tty,
 	port->mon_data.up_rxcnt += cnt;
 
 	tty_flip_buffer_push(&port->port);
+
+	return status;
 }
 
 static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port)
@@ -2262,14 +2264,14 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
 					    iir == MOXA_MUST_IIR_RDA ||
 					    iir == MOXA_MUST_IIR_RTO ||
 					    iir == MOXA_MUST_IIR_LSR)
-						mxser_receive_chars(tty, port,
-								&status);
+						status = mxser_receive_chars(tty,
+								port, status);
 
 				} else {
 					status &= port->read_status_mask;
 					if (status & UART_LSR_DR)
-						mxser_receive_chars(tty, port,
-								&status);
+						status = mxser_receive_chars(tty,
+								port, status);
 				}
 				msr = inb(port->ioaddr + UART_MSR);
 				if (msr & UART_MSR_ANY_DELTA)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 13/70] mxser: extract port ISR
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (11 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 12/70] mxser: cleanup LSR handling in mxser_receive_chars Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 14/70] mxser: simplify mxser_interrupt and drop mxser_board::vector_mask Jiri Slaby
                   ` (57 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

The ISR is terrible mix of letters. Let's extract the proper per-port
handling to a separate function called mxser_port_isr. This way, we can
actually see what both mxser_interrupt and mxser_port_isr do now.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 119 ++++++++++++++++++++++++--------------------
 1 file changed, 64 insertions(+), 55 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 9ba3af4626c6..555b9b37b52f 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -2203,18 +2203,78 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 	}
 }
 
+static bool mxser_port_isr(struct mxser_port *port)
+{
+	struct tty_struct *tty;
+	u8 iir, msr, status;
+	bool error = false;
+
+	iir = inb(port->ioaddr + UART_IIR);
+	if (iir & UART_IIR_NO_INT)
+		return true;
+
+	iir &= MOXA_MUST_IIR_MASK;
+	tty = tty_port_tty_get(&port->port);
+	if (!tty || port->closing || !tty_port_initialized(&port->port)) {
+		status = inb(port->ioaddr + UART_LSR);
+		outb(0x27, port->ioaddr + UART_FCR);
+		inb(port->ioaddr + UART_MSR);
+
+		error = true;
+		goto put_tty;
+	}
+
+	status = inb(port->ioaddr + UART_LSR);
+
+	if (status & UART_LSR_PE)
+		port->err_shadow |= NPPI_NOTIFY_PARITY;
+	if (status & UART_LSR_FE)
+		port->err_shadow |= NPPI_NOTIFY_FRAMING;
+	if (status & UART_LSR_OE)
+		port->err_shadow |= NPPI_NOTIFY_HW_OVERRUN;
+	if (status & UART_LSR_BI)
+		port->err_shadow |= NPPI_NOTIFY_BREAK;
+
+	if (port->board->must_hwid) {
+		if (iir == MOXA_MUST_IIR_GDA ||
+		    iir == MOXA_MUST_IIR_RDA ||
+		    iir == MOXA_MUST_IIR_RTO ||
+		    iir == MOXA_MUST_IIR_LSR)
+			status = mxser_receive_chars(tty, port, status);
+	} else {
+		status &= port->read_status_mask;
+		if (status & UART_LSR_DR)
+			status = mxser_receive_chars(tty, port, status);
+	}
+
+	msr = inb(port->ioaddr + UART_MSR);
+	if (msr & UART_MSR_ANY_DELTA)
+		mxser_check_modem_status(tty, port, msr);
+
+	if (port->board->must_hwid) {
+		if (iir == 0x02 && (status & UART_LSR_THRE))
+			mxser_transmit_chars(tty, port);
+	} else {
+		if (status & UART_LSR_THRE)
+			mxser_transmit_chars(tty, port);
+	}
+
+put_tty:
+	tty_kref_put(tty);
+
+	return error;
+}
+
 /*
  * This is the serial driver's generic interrupt routine
  */
 static irqreturn_t mxser_interrupt(int irq, void *dev_id)
 {
-	int status, iir, i;
 	struct mxser_board *brd = dev_id;
 	struct mxser_port *port;
-	int max, irqbits, bits, msr;
 	unsigned int int_cnt, pass_counter = 0;
+	int max, irqbits, bits, i;
 	int handled = IRQ_NONE;
-	struct tty_struct *tty;
 
 	max = brd->info->nports;
 	while (pass_counter++ < MXSER_ISR_PASS_LIMIT) {
@@ -2233,59 +2293,8 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
 			int_cnt = 0;
 			spin_lock(&port->slock);
 			do {
-				iir = inb(port->ioaddr + UART_IIR);
-				if (iir & UART_IIR_NO_INT)
-					break;
-				iir &= MOXA_MUST_IIR_MASK;
-				tty = tty_port_tty_get(&port->port);
-				if (!tty || port->closing ||
-				    !tty_port_initialized(&port->port)) {
-					status = inb(port->ioaddr + UART_LSR);
-					outb(0x27, port->ioaddr + UART_FCR);
-					inb(port->ioaddr + UART_MSR);
-					tty_kref_put(tty);
+				if (mxser_port_isr(port))
 					break;
-				}
-
-				status = inb(port->ioaddr + UART_LSR);
-
-				if (status & UART_LSR_PE)
-					port->err_shadow |= NPPI_NOTIFY_PARITY;
-				if (status & UART_LSR_FE)
-					port->err_shadow |= NPPI_NOTIFY_FRAMING;
-				if (status & UART_LSR_OE)
-					port->err_shadow |=
-						NPPI_NOTIFY_HW_OVERRUN;
-				if (status & UART_LSR_BI)
-					port->err_shadow |= NPPI_NOTIFY_BREAK;
-
-				if (port->board->must_hwid) {
-					if (iir == MOXA_MUST_IIR_GDA ||
-					    iir == MOXA_MUST_IIR_RDA ||
-					    iir == MOXA_MUST_IIR_RTO ||
-					    iir == MOXA_MUST_IIR_LSR)
-						status = mxser_receive_chars(tty,
-								port, status);
-
-				} else {
-					status &= port->read_status_mask;
-					if (status & UART_LSR_DR)
-						status = mxser_receive_chars(tty,
-								port, status);
-				}
-				msr = inb(port->ioaddr + UART_MSR);
-				if (msr & UART_MSR_ANY_DELTA)
-					mxser_check_modem_status(tty, port, msr);
-
-				if (port->board->must_hwid) {
-					if (iir == 0x02 && (status &
-								UART_LSR_THRE))
-						mxser_transmit_chars(tty, port);
-				} else {
-					if (status & UART_LSR_THRE)
-						mxser_transmit_chars(tty, port);
-				}
-				tty_kref_put(tty);
 			} while (int_cnt++ < MXSER_ISR_PASS_LIMIT);
 			spin_unlock(&port->slock);
 		}
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 14/70] mxser: simplify mxser_interrupt and drop mxser_board::vector_mask
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (12 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 13/70] mxser: extract port ISR Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 15/70] mxser: extract mxser_receive_chars_new Jiri Slaby
                   ` (56 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

mxser_board::vector_mask is just a bitfield with bits set for all
available ports.  We can obtain this value simply by
"BIT(brd->info->nports) - 1" directly in the ISR. So remove vector_mask
and simplify the code a bit.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 555b9b37b52f..df59ca88acab 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -368,7 +368,6 @@ struct mxser_board {
 	int irq;
 	const struct mxser_cardinfo *info;
 	unsigned long vector;
-	unsigned long vector_mask;
 
 	enum mxser_must_hwid must_hwid;
 	speed_t max_baud;
@@ -2273,18 +2272,18 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
 	struct mxser_board *brd = dev_id;
 	struct mxser_port *port;
 	unsigned int int_cnt, pass_counter = 0;
-	int max, irqbits, bits, i;
+	unsigned int i, max = brd->info->nports;
 	int handled = IRQ_NONE;
+	u8 irqbits, bits, mask = BIT(max) - 1;
 
-	max = brd->info->nports;
 	while (pass_counter++ < MXSER_ISR_PASS_LIMIT) {
-		irqbits = inb(brd->vector) & brd->vector_mask;
-		if (irqbits == brd->vector_mask)
+		irqbits = inb(brd->vector) & mask;
+		if (irqbits == mask)
 			break;
 
 		handled = IRQ_HANDLED;
 		for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) {
-			if (irqbits == brd->vector_mask)
+			if (irqbits == mask)
 				break;
 			if (bits & irqbits)
 				continue;
@@ -2450,7 +2449,6 @@ static int mxser_probe(struct pci_dev *pdev,
 	brd->irq = pdev->irq;
 
 	brd->must_hwid = mxser_must_get_hwid(brd->ports[0].ioaddr);
-	brd->vector_mask = 0;
 
 	for (j = 0; j < UART_INFO_NUM; j++) {
 		if (Gpci_uart_info[j].type == brd->must_hwid) {
@@ -2475,7 +2473,6 @@ static int mxser_probe(struct pci_dev *pdev,
 	}
 
 	for (i = 0; i < brd->info->nports; i++) {
-		brd->vector_mask |= (1 << i);
 		brd->ports[i].baud_base = 921600;
 	}
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 15/70] mxser: extract mxser_receive_chars_new
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (13 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 14/70] mxser: simplify mxser_interrupt and drop mxser_board::vector_mask Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 16/70] mxser: extract mxser_receive_chars_old Jiri Slaby
                   ` (55 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Extract the new handling of receive chars (using the MUST chip
enhancements) into a separate function. This eliminates the need for the
intr_old label and makes the code of mxser_receive_chars more compact.
In the next step, we will extract the old handling too.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 60 +++++++++++++++++++++++++--------------------
 1 file changed, 34 insertions(+), 26 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index df59ca88acab..a321aba24d58 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -2055,10 +2055,41 @@ static int mxser_rs_break(struct tty_struct *tty, int break_state)
 	return 0;
 }
 
+static bool mxser_receive_chars_new(struct tty_struct *tty,
+		struct mxser_port *port, u8 status, int *cnt)
+{
+	enum mxser_must_hwid hwid = port->board->must_hwid;
+	u8 gdl;
+
+	if (hwid == MOXA_OTHER_UART)
+		return false;
+	if (status & UART_LSR_SPECIAL)
+		return false;
+	if (hwid == MOXA_MUST_MU860_HWID && (status & MOXA_MUST_LSR_RERR))
+		return false;
+	if (status & MOXA_MUST_LSR_RERR)
+		return false;
+
+	gdl = inb(port->ioaddr + MOXA_MUST_GDL_REGISTER);
+	if (hwid == MOXA_MUST_MU150_HWID)
+		gdl &= MOXA_MUST_GDL_MASK;
+
+	if (gdl >= tty->receive_room && !port->ldisc_stop_rx)
+		mxser_stoprx(tty);
+
+	while (gdl--) {
+		u8 ch = inb(port->ioaddr + UART_RX);
+		tty_insert_flip_char(&port->port, ch, 0);
+		(*cnt)++;
+	}
+
+	return true;
+}
+
 static u8 mxser_receive_chars(struct tty_struct *tty,
 		struct mxser_port *port, u8 status)
 {
-	unsigned char ch, gdl;
+	unsigned char ch;
 	int ignored = 0;
 	int cnt = 0;
 	int recv_room;
@@ -2067,32 +2098,9 @@ static u8 mxser_receive_chars(struct tty_struct *tty,
 	recv_room = tty->receive_room;
 	if (recv_room == 0 && !port->ldisc_stop_rx)
 		mxser_stoprx(tty);
-	if (port->board->must_hwid != MOXA_OTHER_UART) {
-
-		if (status & UART_LSR_SPECIAL)
-			goto intr_old;
-		if (port->board->must_hwid == MOXA_MUST_MU860_HWID &&
-				(status & MOXA_MUST_LSR_RERR))
-			goto intr_old;
-		if (status & MOXA_MUST_LSR_RERR)
-			goto intr_old;
-
-		gdl = inb(port->ioaddr + MOXA_MUST_GDL_REGISTER);
-
-		if (port->board->must_hwid == MOXA_MUST_MU150_HWID)
-			gdl &= MOXA_MUST_GDL_MASK;
-		if (gdl >= recv_room) {
-			if (!port->ldisc_stop_rx)
-				mxser_stoprx(tty);
-		}
-		while (gdl--) {
-			ch = inb(port->ioaddr + UART_RX);
-			tty_insert_flip_char(&port->port, ch, 0);
-			cnt++;
-		}
+
+	if (mxser_receive_chars_new(tty, port, status, &cnt))
 		goto end_intr;
-	}
-intr_old:
 
 	do {
 		if (max-- < 0)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 16/70] mxser: extract mxser_receive_chars_old
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (14 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 15/70] mxser: extract mxser_receive_chars_new Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 17/70] mxser: remove else from LSR bits checks Jiri Slaby
                   ` (54 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index a321aba24d58..6b8f2b0e0726 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -2086,28 +2086,21 @@ static bool mxser_receive_chars_new(struct tty_struct *tty,
 	return true;
 }
 
-static u8 mxser_receive_chars(struct tty_struct *tty,
-		struct mxser_port *port, u8 status)
+static u8 mxser_receive_chars_old(struct tty_struct *tty,
+		                struct mxser_port *port, u8 status, int *cnt)
 {
-	unsigned char ch;
+	enum mxser_must_hwid hwid = port->board->must_hwid;
+	int recv_room = tty->receive_room;
 	int ignored = 0;
-	int cnt = 0;
-	int recv_room;
 	int max = 256;
-
-	recv_room = tty->receive_room;
-	if (recv_room == 0 && !port->ldisc_stop_rx)
-		mxser_stoprx(tty);
-
-	if (mxser_receive_chars_new(tty, port, status, &cnt))
-		goto end_intr;
+	u8 ch;
 
 	do {
 		if (max-- < 0)
 			break;
 
 		ch = inb(port->ioaddr + UART_RX);
-		if (port->board->must_hwid && (status & UART_LSR_OE))
+		if (hwid && (status & UART_LSR_OE))
 			outb(0x23, port->ioaddr + UART_FCR);
 		status &= port->read_status_mask;
 		if (status & port->ignore_status_mask) {
@@ -2135,8 +2128,8 @@ static u8 mxser_receive_chars(struct tty_struct *tty,
 					flag = TTY_BREAK;
 			}
 			tty_insert_flip_char(&port->port, ch, flag);
-			cnt++;
-			if (cnt >= recv_room) {
+			(*cnt)++;
+			if (*cnt >= recv_room) {
 				if (!port->ldisc_stop_rx)
 					mxser_stoprx(tty);
 				break;
@@ -2144,13 +2137,26 @@ static u8 mxser_receive_chars(struct tty_struct *tty,
 
 		}
 
-		if (port->board->must_hwid)
+		if (hwid)
 			break;
 
 		status = inb(port->ioaddr + UART_LSR);
 	} while (status & UART_LSR_DR);
 
-end_intr:
+	return status;
+}
+
+static u8 mxser_receive_chars(struct tty_struct *tty,
+		struct mxser_port *port, u8 status)
+{
+	int cnt = 0;
+
+	if (tty->receive_room == 0 && !port->ldisc_stop_rx)
+		mxser_stoprx(tty);
+
+	if (!mxser_receive_chars_new(tty, port, status, &cnt))
+		status = mxser_receive_chars_old(tty, port, status, &cnt);
+
 	mxvar_log.rxcnt[tty->index] += cnt;
 	port->mon_data.rxcnt += cnt;
 	port->mon_data.up_rxcnt += cnt;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 17/70] mxser: remove else from LSR bits checks
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (15 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 16/70] mxser: extract mxser_receive_chars_old Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 18/70] mxser: correct types for uart variables Jiri Slaby
                   ` (53 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

UART_LSR_SPECIAL is composed of UART_LSR_BI, UART_LSR_PE, UART_LSR_FE,
UART_LSR_OE. So status cannot be anything else. Remove the unused else
branch.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 6b8f2b0e0726..1b8032c9351e 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -2124,8 +2124,7 @@ static u8 mxser_receive_chars_old(struct tty_struct *tty,
 				} else if (status & UART_LSR_OE) {
 					flag = TTY_OVERRUN;
 					port->icount.overrun++;
-				} else
-					flag = TTY_BREAK;
+				}
 			}
 			tty_insert_flip_char(&port->port, ch, flag);
 			(*cnt)++;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 18/70] mxser: correct types for uart variables
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (16 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 17/70] mxser: remove else from LSR bits checks Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 19/70] mxser: make xmit ring buffer variables unsigned Jiri Slaby
                   ` (52 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

In struct mxser_port, all the UART registers and masks, and the xon/xoff
character are stored into int. Let's re-type all these as UART registers
are 8bit (u8) and xon/xoff character is an unsigned char (cc_t in
ktermios).

This save some bytes in memory, but more importantly the change makes it
what it really is.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 1b8032c9351e..45f36d92c5ea 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -335,9 +335,9 @@ struct mxser_port {
 	int baud_base;		/* max. speed */
 	int type;		/* UART type */
 
-	int x_char;		/* xon/xoff character */
-	int IER;		/* Interrupt Enable Register */
-	int MCR;		/* Modem control register */
+	unsigned char x_char;	/* xon/xoff character */
+	u8 IER;			/* Interrupt Enable Register */
+	u8 MCR;			/* Modem control register */
 
 	unsigned char stop_rx;
 	unsigned char ldisc_stop_rx;
@@ -348,8 +348,8 @@ struct mxser_port {
 	struct async_icount icount; /* kernel counters for 4 input interrupts */
 	unsigned int timeout;
 
-	int read_status_mask;
-	int ignore_status_mask;
+	u8 read_status_mask;
+	u8 ignore_status_mask;
 	u8 xmit_fifo_size;
 	int xmit_head;
 	int xmit_tail;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 19/70] mxser: make xmit ring buffer variables unsigned
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (17 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 18/70] mxser: correct types for uart variables Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 20/70] mxser: drop UART_MCR_AFE and UART_LSR_SPECIAL defines Jiri Slaby
                   ` (51 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Make the xmit ring buffer pointers and counter (xmit_head, xmit_tail,
xmit_cnt) unsigned. Now, the assumptions for the compiler are clear --
they cannot be negative.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 45f36d92c5ea..53136a7d92b1 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -351,9 +351,9 @@ struct mxser_port {
 	u8 read_status_mask;
 	u8 ignore_status_mask;
 	u8 xmit_fifo_size;
-	int xmit_head;
-	int xmit_tail;
-	int xmit_cnt;
+	unsigned int xmit_head;
+	unsigned int xmit_tail;
+	unsigned int xmit_cnt;
 	int closing;
 
 	struct ktermios normal_termios;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 20/70] mxser: drop UART_MCR_AFE and UART_LSR_SPECIAL defines
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (18 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 19/70] mxser: make xmit ring buffer variables unsigned Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 21/70] mxser: drop unused MOXA_DIAGNOSE macro Jiri Slaby
                   ` (50 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

* UART_MCR_AFE is a redefinition of serial_reg.h's one.
* UART_LSR_SPECIAL is a redefinition of serial_reg.h's
  UART_LSR_BRK_ERROR_BITS.

So remove both and replace the latter uses by already defined
UART_LSR_BRK_ERROR_BITS.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 53136a7d92b1..79d7cecb7765 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -180,9 +180,6 @@
 
 #define WAKEUP_CHARS		256
 
-#define UART_MCR_AFE		0x20
-#define UART_LSR_SPECIAL	0x1E
-
 #define PCI_DEVICE_ID_POS104UL	0x1044
 #define PCI_DEVICE_ID_CB108	0x1080
 #define PCI_DEVICE_ID_CP102UF	0x1023
@@ -2063,7 +2060,7 @@ static bool mxser_receive_chars_new(struct tty_struct *tty,
 
 	if (hwid == MOXA_OTHER_UART)
 		return false;
-	if (status & UART_LSR_SPECIAL)
+	if (status & UART_LSR_BRK_ERROR_BITS)
 		return false;
 	if (hwid == MOXA_MUST_MU860_HWID && (status & MOXA_MUST_LSR_RERR))
 		return false;
@@ -2108,7 +2105,7 @@ static u8 mxser_receive_chars_old(struct tty_struct *tty,
 				break;
 		} else {
 			char flag = 0;
-			if (status & UART_LSR_SPECIAL) {
+			if (status & UART_LSR_BRK_ERROR_BITS) {
 				if (status & UART_LSR_BI) {
 					flag = TTY_BREAK;
 					port->icount.brk++;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 21/70] mxser: drop unused MOXA_DIAGNOSE macro
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (19 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 20/70] mxser: drop UART_MCR_AFE and UART_LSR_SPECIAL defines Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 22/70] mxser: remove MOXA_GET_MAJOR deprecated ioctl Jiri Slaby
                   ` (49 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

It's unused.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 79d7cecb7765..a830a4359ea1 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -51,7 +51,6 @@
 
 #define MOXA			0x400
 #define MOXA_GETDATACOUNT	(MOXA + 23)
-#define MOXA_DIAGNOSE		(MOXA + 50)
 #define MOXA_CHKPORTENABLE	(MOXA + 60)
 #define MOXA_HighSpeedOn	(MOXA + 61)
 #define MOXA_GET_MAJOR		(MOXA + 63)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 22/70] mxser: remove MOXA_GET_MAJOR deprecated ioctl
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (20 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 21/70] mxser: drop unused MOXA_DIAGNOSE macro Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 23/70] mxser: remove MOXA_SET_BAUD_METHOD ioctl Jiri Slaby
                   ` (48 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

MOXA_GET_MAJOR was deprecated in commit 41aee9a121fd (Char: mxser, ioctl
cleanup) in 2008. Remove this ioctl finally.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index a830a4359ea1..a55b20f98cb3 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -53,7 +53,6 @@
 #define MOXA_GETDATACOUNT	(MOXA + 23)
 #define MOXA_CHKPORTENABLE	(MOXA + 60)
 #define MOXA_HighSpeedOn	(MOXA + 61)
-#define MOXA_GET_MAJOR		(MOXA + 63)
 #define MOXA_GETMSTATUS		(MOXA + 65)
 #define MOXA_SET_OP_MODE	(MOXA + 66)
 #define MOXA_GET_OP_MODE	(MOXA + 67)
@@ -1499,12 +1498,6 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
 	int ret = 0;
 
 	switch (cmd) {
-	case MOXA_GET_MAJOR:
-		printk_ratelimited(KERN_WARNING "mxser: '%s' uses deprecated ioctl "
-					"%x (GET_MAJOR), fix your userspace\n",
-					current->comm, cmd);
-		return put_user(ttymajor, (int __user *)argp);
-
 	case MOXA_CHKPORTENABLE:
 		result = 0;
 		for (i = 0; i < MXSER_BOARDS; i++)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 23/70] mxser: remove MOXA_SET_BAUD_METHOD ioctl
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (21 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 22/70] mxser: remove MOXA_GET_MAJOR deprecated ioctl Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 24/70] mxser: remove MOXA_ASPP_MON and friends Jiri Slaby
                   ` (47 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

1) The semantics are defined exactly nowhere.
2) The ioctl definition was never exposed to userspace, so noone should
   actually be reliably using this.
3) It's not even mentioned in any of the mxser utilities.

Provided the above, remove this mxser-special ioctl.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index a55b20f98cb3..cf3b8f9f7e1e 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -68,7 +68,6 @@
 #define MOXA_ASPP_MON		(MOXA + 73)
 #define MOXA_ASPP_LSTATUS	(MOXA + 74)
 #define MOXA_ASPP_MON_EXT	(MOXA + 75)
-#define MOXA_SET_BAUD_METHOD	(MOXA + 76)
 
 /* --------------------------------------------------- */
 
@@ -381,7 +380,6 @@ struct mxser_mstatus {
 static struct mxser_board mxser_boards[MXSER_BOARDS];
 static struct tty_driver *mxvar_sdriver;
 static struct mxser_log mxvar_log;
-static int mxser_set_baud_method[MXSER_PORTS + 1];
 
 static void mxser_enable_must_enchance_mode(unsigned long baseio)
 {
@@ -738,8 +736,7 @@ static void mxser_change_speed(struct tty_struct *tty)
 	if (!info->ioaddr)
 		return;
 
-	if (mxser_set_baud_method[tty->index] == 0)
-		mxser_set_baud(tty, tty_get_baud_rate(tty));
+	mxser_set_baud(tty, tty_get_baud_rate(tty));
 
 	/* byte size and parity */
 	switch (cflag & CSIZE) {
@@ -1788,14 +1785,6 @@ static int mxser_ioctl(struct tty_struct *tty,
 		info->err_shadow = 0;
 		return 0;
 	}
-	case MOXA_SET_BAUD_METHOD: {
-		int method;
-
-		if (get_user(method, (int __user *)argp))
-			return -EFAULT;
-		mxser_set_baud_method[tty->index] = method;
-		return put_user(method, (int __user *)argp);
-	}
 	default:
 		return -ENOIOCTLCMD;
 	}
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 24/70] mxser: remove MOXA_ASPP_MON and friends
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (22 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 23/70] mxser: remove MOXA_SET_BAUD_METHOD ioctl Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 25/70] mxser: remove MOXA_ASPP_LSTATUS ioctl Jiri Slaby
                   ` (46 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

1) MOXA_ASPP_MON_EXT is broken at least since commit ecbbfd44a08f (TTY:
   move tty buffers to tty_port) in 2012.
2) The ioctl definitions were never exposed to userspace, so noone should
   actually be reliably using them.
3) They're not even mentioned in any of the mxser utilities.

So remove all these mxser-special ioctls: MOXA_ASPP_MON,
MOXA_ASPP_MON_EXT, and MOXA_SDS_RSTICOUNTER.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 184 --------------------------------------------
 1 file changed, 184 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index cf3b8f9f7e1e..68c2f2346dcf 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -63,11 +63,8 @@
 #define RS485_4WIRE_MODE	3
 #define OP_MODE_MASK		3
 
-#define MOXA_SDS_RSTICOUNTER	(MOXA + 69)
 #define MOXA_ASPP_OQUEUE	(MOXA + 70)
-#define MOXA_ASPP_MON		(MOXA + 73)
 #define MOXA_ASPP_LSTATUS	(MOXA + 74)
-#define MOXA_ASPP_MON_EXT	(MOXA + 75)
 
 /* --------------------------------------------------- */
 
@@ -77,11 +74,6 @@
 #define NPPI_NOTIFY_SW_OVERRUN	0x08
 #define NPPI_NOTIFY_BREAK	0x10
 
-#define NPPI_NOTIFY_CTSHOLD         0x01	/* Tx hold by CTS low */
-#define NPPI_NOTIFY_DSRHOLD         0x02	/* Tx hold by DSR low */
-#define NPPI_NOTIFY_XOFFHOLD        0x08	/* Tx hold by Xoff received */
-#define NPPI_NOTIFY_XOFFXENT        0x10	/* Xoff Sent */
-
 /*
  * Follow just what Moxa Must chip defines.
  *
@@ -290,31 +282,6 @@ struct mxser_log {
 	unsigned long txcnt[MXSER_PORTS];
 };
 
-struct mxser_mon {
-	unsigned long rxcnt;
-	unsigned long txcnt;
-	unsigned long up_rxcnt;
-	unsigned long up_txcnt;
-	int modem_status;
-	unsigned char hold_reason;
-};
-
-struct mxser_mon_ext {
-	unsigned long rx_cnt[32];
-	unsigned long tx_cnt[32];
-	unsigned long up_rxcnt[32];
-	unsigned long up_txcnt[32];
-	int modem_status[32];
-
-	long baudrate[32];
-	int databits[32];
-	int stopbits[32];
-	int parity[32];
-	int flowctrl[32];
-	int fifo[32];
-	int iftype[32];
-};
-
 struct mxser_board;
 
 struct mxser_port {
@@ -352,8 +319,6 @@ struct mxser_port {
 
 	struct ktermios normal_termios;
 
-	struct mxser_mon mon_data;
-
 	spinlock_t slock;
 };
 
@@ -616,22 +581,6 @@ static void process_txrx_fifo(struct mxser_port *info)
 			}
 }
 
-static unsigned char mxser_get_msr(int baseaddr, int mode, int port)
-{
-	static unsigned char mxser_msr[MXSER_PORTS + 1];
-	unsigned char status = 0;
-
-	status = inb(baseaddr + UART_MSR);
-
-	mxser_msr[port] &= 0x0F;
-	mxser_msr[port] |= status;
-	status = mxser_msr[port];
-	if (mode)
-		mxser_msr[port] = 0;
-
-	return status;
-}
-
 static int mxser_carrier_raised(struct tty_port *port)
 {
 	struct mxser_port *mp = container_of(port, struct mxser_port, port);
@@ -903,7 +852,6 @@ static void mxser_check_modem_status(struct tty_struct *tty,
 		port->icount.dcd++;
 	if (status & UART_MSR_DCTS)
 		port->icount.cts++;
-	port->mon_data.modem_status = status;
 	wake_up_interruptible(&port->port.delta_msr_wait);
 
 	if (tty_port_check_carrier(&port->port) && (status & UART_MSR_DDCD)) {
@@ -1544,93 +1492,6 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
 			}
 		return 0;
 	}
-	case MOXA_ASPP_MON_EXT: {
-		struct mxser_mon_ext *me; /* it's 2k, stack unfriendly */
-		unsigned int cflag, iflag, p;
-		u8 opmode;
-
-		me = kzalloc(sizeof(*me), GFP_KERNEL);
-		if (!me)
-			return -ENOMEM;
-
-		for (i = 0, p = 0; i < MXSER_BOARDS; i++) {
-			for (j = 0; j < MXSER_PORTS_PER_BOARD; j++, p++) {
-				if (p >= ARRAY_SIZE(me->rx_cnt)) {
-					i = MXSER_BOARDS;
-					break;
-				}
-				ip = &mxser_boards[i].ports[j];
-				port = &ip->port;
-
-				mutex_lock(&port->mutex);
-				if (!ip->ioaddr) {
-					mutex_unlock(&port->mutex);
-					continue;
-				}
-
-				spin_lock_irq(&ip->slock);
-				status = mxser_get_msr(ip->ioaddr, 0, p);
-
-				if (status & UART_MSR_TERI)
-					ip->icount.rng++;
-				if (status & UART_MSR_DDSR)
-					ip->icount.dsr++;
-				if (status & UART_MSR_DDCD)
-					ip->icount.dcd++;
-				if (status & UART_MSR_DCTS)
-					ip->icount.cts++;
-
-				ip->mon_data.modem_status = status;
-				me->rx_cnt[p] = ip->mon_data.rxcnt;
-				me->tx_cnt[p] = ip->mon_data.txcnt;
-				me->up_rxcnt[p] = ip->mon_data.up_rxcnt;
-				me->up_txcnt[p] = ip->mon_data.up_txcnt;
-				me->modem_status[p] =
-					ip->mon_data.modem_status;
-				spin_unlock_irq(&ip->slock);
-
-				tty = tty_port_tty_get(&ip->port);
-
-				if (!tty) {
-					cflag = ip->normal_termios.c_cflag;
-					iflag = ip->normal_termios.c_iflag;
-					me->baudrate[p] = tty_termios_baud_rate(&ip->normal_termios);
-				} else {
-					cflag = tty->termios.c_cflag;
-					iflag = tty->termios.c_iflag;
-					me->baudrate[p] = tty_get_baud_rate(tty);
-				}
-				tty_kref_put(tty);
-
-				me->databits[p] = cflag & CSIZE;
-				me->stopbits[p] = cflag & CSTOPB;
-				me->parity[p] = cflag & (PARENB | PARODD |
-						CMSPAR);
-
-				if (cflag & CRTSCTS)
-					me->flowctrl[p] |= 0x03;
-
-				if (iflag & (IXON | IXOFF))
-					me->flowctrl[p] |= 0x0C;
-
-				if (ip->type == PORT_16550A)
-					me->fifo[p] = 1;
-
-				if (ip->board->must_hwid == MOXA_MUST_MU860_HWID) {
-					opmode = inb(ip->opmode_ioaddr)>>((p % 4) * 2);
-					opmode &= OP_MODE_MASK;
-				} else {
-					opmode = RS232_MODE;
-				}
-				me->iftype[p] = opmode;
-				mutex_unlock(&port->mutex);
-			}
-		}
-		if (copy_to_user(argp, me, sizeof(*me)))
-			ret = -EFAULT;
-		kfree(me);
-		return ret;
-	}
 	default:
 		return -ENOIOCTLCMD;
 	}
@@ -1729,13 +1590,6 @@ static int mxser_ioctl(struct tty_struct *tty,
 				mxser_cflags_changed(info, arg, &cnow));
 	case MOXA_HighSpeedOn:
 		return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp);
-	case MOXA_SDS_RSTICOUNTER:
-		spin_lock_irq(&info->slock);
-		info->mon_data.rxcnt = 0;
-		info->mon_data.txcnt = 0;
-		spin_unlock_irq(&info->slock);
-		return 0;
-
 	case MOXA_ASPP_OQUEUE:{
 		int len, lsr;
 
@@ -1747,37 +1601,6 @@ static int mxser_ioctl(struct tty_struct *tty,
 
 		return put_user(len, (int __user *)argp);
 	}
-	case MOXA_ASPP_MON: {
-		int mcr, status;
-
-		spin_lock_irq(&info->slock);
-		status = mxser_get_msr(info->ioaddr, 1, tty->index);
-		mxser_check_modem_status(tty, info, status);
-
-		mcr = inb(info->ioaddr + UART_MCR);
-		spin_unlock_irq(&info->slock);
-
-		if (mcr & MOXA_MUST_MCR_XON_FLAG)
-			info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFHOLD;
-		else
-			info->mon_data.hold_reason |= NPPI_NOTIFY_XOFFHOLD;
-
-		if (mcr & MOXA_MUST_MCR_TX_XON)
-			info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFXENT;
-		else
-			info->mon_data.hold_reason |= NPPI_NOTIFY_XOFFXENT;
-
-		if (tty->hw_stopped)
-			info->mon_data.hold_reason |= NPPI_NOTIFY_CTSHOLD;
-		else
-			info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD;
-
-		if (copy_to_user(argp, &info->mon_data,
-				sizeof(struct mxser_mon)))
-			return -EFAULT;
-
-		return 0;
-	}
 	case MOXA_ASPP_LSTATUS: {
 		if (put_user(info->err_shadow, (unsigned char __user *)argp))
 			return -EFAULT;
@@ -2135,8 +1958,6 @@ static u8 mxser_receive_chars(struct tty_struct *tty,
 		status = mxser_receive_chars_old(tty, port, status, &cnt);
 
 	mxvar_log.rxcnt[tty->index] += cnt;
-	port->mon_data.rxcnt += cnt;
-	port->mon_data.up_rxcnt += cnt;
 
 	tty_flip_buffer_push(&port->port);
 
@@ -2151,8 +1972,6 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 		outb(port->x_char, port->ioaddr + UART_TX);
 		port->x_char = 0;
 		mxvar_log.txcnt[tty->index]++;
-		port->mon_data.txcnt++;
-		port->mon_data.up_txcnt++;
 		port->icount.tx++;
 		return;
 	}
@@ -2180,8 +1999,6 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 	} while (--count > 0);
 	mxvar_log.txcnt[tty->index] += (cnt - port->xmit_cnt);
 
-	port->mon_data.txcnt += (cnt - port->xmit_cnt);
-	port->mon_data.up_txcnt += (cnt - port->xmit_cnt);
 	port->icount.tx += (cnt - port->xmit_cnt);
 
 	if (port->xmit_cnt < WAKEUP_CHARS)
@@ -2355,7 +2172,6 @@ static int mxser_initbrd(struct mxser_board *brd)
 		info->port.close_delay = 5 * HZ / 10;
 		info->port.closing_wait = 30 * HZ;
 		info->normal_termios = mxvar_sdriver->init_termios;
-		memset(&info->mon_data, 0, sizeof(struct mxser_mon));
 		info->err_shadow = 0;
 		spin_lock_init(&info->slock);
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 25/70] mxser: remove MOXA_ASPP_LSTATUS ioctl
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (23 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 24/70] mxser: remove MOXA_ASPP_MON and friends Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 26/70] mxser: remove MOXA_CHKPORTENABLE ioctl Jiri Slaby
                   ` (45 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

1) The semantics are defined exactly nowhere.
2) The ioctl definition was never exposed to userspace, so noone should
   actually be reliably using this.
3) It's not even mentioned in any of the mxser utilities.

Provided the above, remove this mxser-special ioctl.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 25 -------------------------
 1 file changed, 25 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 68c2f2346dcf..38e12ff17529 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -64,16 +64,9 @@
 #define OP_MODE_MASK		3
 
 #define MOXA_ASPP_OQUEUE	(MOXA + 70)
-#define MOXA_ASPP_LSTATUS	(MOXA + 74)
 
 /* --------------------------------------------------- */
 
-#define NPPI_NOTIFY_PARITY	0x01
-#define NPPI_NOTIFY_FRAMING	0x02
-#define NPPI_NOTIFY_HW_OVERRUN	0x04
-#define NPPI_NOTIFY_SW_OVERRUN	0x08
-#define NPPI_NOTIFY_BREAK	0x10
-
 /*
  * Follow just what Moxa Must chip defines.
  *
@@ -304,7 +297,6 @@ struct mxser_port {
 	unsigned char ldisc_stop_rx;
 
 	int custom_divisor;
-	unsigned char err_shadow;
 
 	struct async_icount icount; /* kernel counters for 4 input interrupts */
 	unsigned int timeout;
@@ -1601,13 +1593,6 @@ static int mxser_ioctl(struct tty_struct *tty,
 
 		return put_user(len, (int __user *)argp);
 	}
-	case MOXA_ASPP_LSTATUS: {
-		if (put_user(info->err_shadow, (unsigned char __user *)argp))
-			return -EFAULT;
-
-		info->err_shadow = 0;
-		return 0;
-	}
 	default:
 		return -ENOIOCTLCMD;
 	}
@@ -2033,15 +2018,6 @@ static bool mxser_port_isr(struct mxser_port *port)
 
 	status = inb(port->ioaddr + UART_LSR);
 
-	if (status & UART_LSR_PE)
-		port->err_shadow |= NPPI_NOTIFY_PARITY;
-	if (status & UART_LSR_FE)
-		port->err_shadow |= NPPI_NOTIFY_FRAMING;
-	if (status & UART_LSR_OE)
-		port->err_shadow |= NPPI_NOTIFY_HW_OVERRUN;
-	if (status & UART_LSR_BI)
-		port->err_shadow |= NPPI_NOTIFY_BREAK;
-
 	if (port->board->must_hwid) {
 		if (iir == MOXA_MUST_IIR_GDA ||
 		    iir == MOXA_MUST_IIR_RDA ||
@@ -2172,7 +2148,6 @@ static int mxser_initbrd(struct mxser_board *brd)
 		info->port.close_delay = 5 * HZ / 10;
 		info->port.closing_wait = 30 * HZ;
 		info->normal_termios = mxvar_sdriver->init_termios;
-		info->err_shadow = 0;
 		spin_lock_init(&info->slock);
 
 		/* before set INT ISR, disable all int */
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 26/70] mxser: remove MOXA_CHKPORTENABLE ioctl
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (24 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 25/70] mxser: remove MOXA_ASPP_LSTATUS ioctl Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 27/70] mxser: remove MOXA_GETDATACOUNT ioctl Jiri Slaby
                   ` (44 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

1) MOXA_CHKPORTENABLE is broken at least since commit ecbbfd44a08f (TTY:
   move tty buffers to tty_port) in 2012.
2) The ioctl definition was never exposed to userspace, so noone should
   actually be reliably using this.
3) It's not even mentioned in any of the mxser utilities.

Provided the above, remove this mxser-special ioctl.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 38e12ff17529..ebe657426636 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -51,7 +51,6 @@
 
 #define MOXA			0x400
 #define MOXA_GETDATACOUNT	(MOXA + 23)
-#define MOXA_CHKPORTENABLE	(MOXA + 60)
 #define MOXA_HighSpeedOn	(MOXA + 61)
 #define MOXA_GETMSTATUS		(MOXA + 65)
 #define MOXA_SET_OP_MODE	(MOXA + 66)
@@ -1430,18 +1429,11 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
 	struct mxser_port *ip;
 	struct tty_port *port;
 	struct tty_struct *tty;
-	int result, status;
+	int status;
 	unsigned int i, j;
 	int ret = 0;
 
 	switch (cmd) {
-	case MOXA_CHKPORTENABLE:
-		result = 0;
-		for (i = 0; i < MXSER_BOARDS; i++)
-			for (j = 0; j < MXSER_PORTS_PER_BOARD; j++)
-				if (mxser_boards[i].ports[j].ioaddr)
-					result |= (1 << i);
-		return put_user(result, (unsigned long __user *)argp);
 	case MOXA_GETDATACOUNT:
 		/* The receive side is locked by port->slock but it isn't
 		   clear that an exact snapshot is worth copying here */
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 27/70] mxser: remove MOXA_GETDATACOUNT ioctl
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (25 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 26/70] mxser: remove MOXA_CHKPORTENABLE ioctl Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 28/70] mxser: remove MOXA_GETMSTATUS ioctl Jiri Slaby
                   ` (43 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

1) MOXA_GETDATACOUNT is broken at least since commit ecbbfd44a08f (TTY:
   move tty buffers to tty_port) in 2012.
   Even though it's mentioned in the mon_p moxa utility, obviously noone
   ever tried that in that timeframe.
2) The ioctl definition was never exposed to userspace, so noone should
   actually be reliably using this.

Provided the above, remove this mxser-special ioctl.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index ebe657426636..9e241f8bd814 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -50,7 +50,6 @@
  */
 
 #define MOXA			0x400
-#define MOXA_GETDATACOUNT	(MOXA + 23)
 #define MOXA_HighSpeedOn	(MOXA + 61)
 #define MOXA_GETMSTATUS		(MOXA + 65)
 #define MOXA_SET_OP_MODE	(MOXA + 66)
@@ -268,12 +267,6 @@ MODULE_DESCRIPTION("MOXA Smartio/Industio Family Multiport Board Device Driver")
 module_param(ttymajor, int, 0);
 MODULE_LICENSE("GPL");
 
-struct mxser_log {
-	int tick;
-	unsigned long rxcnt[MXSER_PORTS];
-	unsigned long txcnt[MXSER_PORTS];
-};
-
 struct mxser_board;
 
 struct mxser_port {
@@ -335,7 +328,6 @@ struct mxser_mstatus {
 
 static struct mxser_board mxser_boards[MXSER_BOARDS];
 static struct tty_driver *mxvar_sdriver;
-static struct mxser_log mxvar_log;
 
 static void mxser_enable_must_enchance_mode(unsigned long baseio)
 {
@@ -1431,15 +1423,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
 	struct tty_struct *tty;
 	int status;
 	unsigned int i, j;
-	int ret = 0;
 
 	switch (cmd) {
-	case MOXA_GETDATACOUNT:
-		/* The receive side is locked by port->slock but it isn't
-		   clear that an exact snapshot is worth copying here */
-		if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log)))
-			ret = -EFAULT;
-		return ret;
 	case MOXA_GETMSTATUS: {
 		struct mxser_mstatus ms, __user *msu = argp;
 		for (i = 0; i < MXSER_BOARDS; i++)
@@ -1934,8 +1919,6 @@ static u8 mxser_receive_chars(struct tty_struct *tty,
 	if (!mxser_receive_chars_new(tty, port, status, &cnt))
 		status = mxser_receive_chars_old(tty, port, status, &cnt);
 
-	mxvar_log.rxcnt[tty->index] += cnt;
-
 	tty_flip_buffer_push(&port->port);
 
 	return status;
@@ -1948,7 +1931,6 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 	if (port->x_char) {
 		outb(port->x_char, port->ioaddr + UART_TX);
 		port->x_char = 0;
-		mxvar_log.txcnt[tty->index]++;
 		port->icount.tx++;
 		return;
 	}
@@ -1974,7 +1956,6 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 		if (--port->xmit_cnt <= 0)
 			break;
 	} while (--count > 0);
-	mxvar_log.txcnt[tty->index] += (cnt - port->xmit_cnt);
 
 	port->icount.tx += (cnt - port->xmit_cnt);
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 28/70] mxser: remove MOXA_GETMSTATUS ioctl
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (26 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 27/70] mxser: remove MOXA_GETDATACOUNT ioctl Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 29/70] mxser: remove MOXA_ASPP_OQUEUE ioctl Jiri Slaby
                   ` (42 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

1) MOXA_GETMSTATUS is broken at least since commit ecbbfd44a08f (TTY:
   move tty buffers to tty_port) in 2012.
   Even though it's mentioned in the mon_pa moxa utility, obviously
   noone ever tried that in that timeframe.
2) The ioctl definition was never exposed to userspace, so noone
   should actually be reliably using this.

Provided the above, remove this mxser-special ioctl.

And remove the whole concept of mxser_ioctl_special as this was the last
ioctl in there.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 62 +--------------------------------------------
 1 file changed, 1 insertion(+), 61 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 9e241f8bd814..1eb48141d6ca 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -51,7 +51,6 @@
 
 #define MOXA			0x400
 #define MOXA_HighSpeedOn	(MOXA + 61)
-#define MOXA_GETMSTATUS		(MOXA + 65)
 #define MOXA_SET_OP_MODE	(MOXA + 66)
 #define MOXA_GET_OP_MODE	(MOXA + 67)
 
@@ -318,14 +317,6 @@ struct mxser_board {
 	struct mxser_port ports[MXSER_PORTS_PER_BOARD];
 };
 
-struct mxser_mstatus {
-	tcflag_t cflag;
-	int cts;
-	int dsr;
-	int ri;
-	int dcd;
-};
-
 static struct mxser_board mxser_boards[MXSER_BOARDS];
 static struct tty_driver *mxvar_sdriver;
 
@@ -1416,57 +1407,6 @@ static int mxser_tiocmset(struct tty_struct *tty,
 	return 0;
 }
 
-static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
-{
-	struct mxser_port *ip;
-	struct tty_port *port;
-	struct tty_struct *tty;
-	int status;
-	unsigned int i, j;
-
-	switch (cmd) {
-	case MOXA_GETMSTATUS: {
-		struct mxser_mstatus ms, __user *msu = argp;
-		for (i = 0; i < MXSER_BOARDS; i++)
-			for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) {
-				ip = &mxser_boards[i].ports[j];
-				port = &ip->port;
-				memset(&ms, 0, sizeof(ms));
-
-				mutex_lock(&port->mutex);
-				if (!ip->ioaddr)
-					goto copy;
-				
-				tty = tty_port_tty_get(port);
-
-				if (!tty)
-					ms.cflag = ip->normal_termios.c_cflag;
-				else
-					ms.cflag = tty->termios.c_cflag;
-				tty_kref_put(tty);
-				spin_lock_irq(&ip->slock);
-				status = inb(ip->ioaddr + UART_MSR);
-				spin_unlock_irq(&ip->slock);
-				if (status & UART_MSR_DCD)
-					ms.dcd = 1;
-				if (status & UART_MSR_DSR)
-					ms.dsr = 1;
-				if (status & UART_MSR_CTS)
-					ms.cts = 1;
-			copy:
-				mutex_unlock(&port->mutex);
-				if (copy_to_user(msu, &ms, sizeof(ms)))
-					return -EFAULT;
-				msu++;
-			}
-		return 0;
-	}
-	default:
-		return -ENOIOCTLCMD;
-	}
-	return 0;
-}
-
 static int mxser_cflags_changed(struct mxser_port *info, unsigned long arg,
 		struct async_icount *cprev)
 {
@@ -1497,7 +1437,7 @@ static int mxser_ioctl(struct tty_struct *tty,
 	void __user *argp = (void __user *)arg;
 
 	if (tty->index == MXSER_PORTS)
-		return mxser_ioctl_special(cmd, argp);
+		return -ENOTTY;
 
 	if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) {
 		int p;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 29/70] mxser: remove MOXA_ASPP_OQUEUE ioctl
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (27 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 28/70] mxser: remove MOXA_GETMSTATUS ioctl Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 30/70] mxser: remove MOXA_HighSpeedOn ioctl Jiri Slaby
                   ` (41 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

1) The semantics are defined exactly nowhere.
2) The ioctl definition was never exposed to userspace, so noone should
   actually be reliably using this.
3) It's not even mentioned in any of the mxser utilities.

Provided the above, remove this mxser-special ioctl.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 1eb48141d6ca..ca417d9a03cf 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -60,8 +60,6 @@
 #define RS485_4WIRE_MODE	3
 #define OP_MODE_MASK		3
 
-#define MOXA_ASPP_OQUEUE	(MOXA + 70)
-
 /* --------------------------------------------------- */
 
 /*
@@ -1499,17 +1497,6 @@ static int mxser_ioctl(struct tty_struct *tty,
 				mxser_cflags_changed(info, arg, &cnow));
 	case MOXA_HighSpeedOn:
 		return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp);
-	case MOXA_ASPP_OQUEUE:{
-		int len, lsr;
-
-		len = mxser_chars_in_buffer(tty);
-		spin_lock_irq(&info->slock);
-		lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_THRE;
-		spin_unlock_irq(&info->slock);
-		len += (lsr ? 0 : 1);
-
-		return put_user(len, (int __user *)argp);
-	}
 	default:
 		return -ENOIOCTLCMD;
 	}
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 30/70] mxser: remove MOXA_HighSpeedOn ioctl
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (28 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 29/70] mxser: remove MOXA_ASPP_OQUEUE ioctl Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 31/70] mxser: remove cnt from mxser_receive_chars Jiri Slaby
                   ` (40 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

1) The semantics are defined exactly nowhere.
2) The ioctl definition was never exposed to userspace, so noone should
   actually be reliably using this.
3) It's not even mentioned in any of the mxser utilities.

Provided the above, remove this mxser-special ioctl.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index ca417d9a03cf..586fa3575673 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -50,7 +50,6 @@
  */
 
 #define MOXA			0x400
-#define MOXA_HighSpeedOn	(MOXA + 61)
 #define MOXA_SET_OP_MODE	(MOXA + 66)
 #define MOXA_GET_OP_MODE	(MOXA + 67)
 
@@ -1495,8 +1494,6 @@ static int mxser_ioctl(struct tty_struct *tty,
 
 		return wait_event_interruptible(info->port.delta_msr_wait,
 				mxser_cflags_changed(info, arg, &cnow));
-	case MOXA_HighSpeedOn:
-		return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp);
 	default:
 		return -ENOIOCTLCMD;
 	}
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 31/70] mxser: remove cnt from mxser_receive_chars
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (29 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 30/70] mxser: remove MOXA_HighSpeedOn ioctl Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 32/70] mxser: don't allocate MXSER_PORTS + 1 Jiri Slaby
                   ` (39 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

After the previous ioctls removal, cnt is needed only in
mxser_receive_chars_old now. So remove it from mxser_receive_chars and
mxser_receive_chars_new and account only in mxser_receive_chars_old.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 586fa3575673..d354c80083fd 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1743,7 +1743,7 @@ static int mxser_rs_break(struct tty_struct *tty, int break_state)
 }
 
 static bool mxser_receive_chars_new(struct tty_struct *tty,
-		struct mxser_port *port, u8 status, int *cnt)
+		struct mxser_port *port, u8 status)
 {
 	enum mxser_must_hwid hwid = port->board->must_hwid;
 	u8 gdl;
@@ -1767,19 +1767,19 @@ static bool mxser_receive_chars_new(struct tty_struct *tty,
 	while (gdl--) {
 		u8 ch = inb(port->ioaddr + UART_RX);
 		tty_insert_flip_char(&port->port, ch, 0);
-		(*cnt)++;
 	}
 
 	return true;
 }
 
 static u8 mxser_receive_chars_old(struct tty_struct *tty,
-		                struct mxser_port *port, u8 status, int *cnt)
+		                struct mxser_port *port, u8 status)
 {
 	enum mxser_must_hwid hwid = port->board->must_hwid;
 	int recv_room = tty->receive_room;
 	int ignored = 0;
 	int max = 256;
+	int cnt = 0;
 	u8 ch;
 
 	do {
@@ -1814,8 +1814,8 @@ static u8 mxser_receive_chars_old(struct tty_struct *tty,
 				}
 			}
 			tty_insert_flip_char(&port->port, ch, flag);
-			(*cnt)++;
-			if (*cnt >= recv_room) {
+			cnt++;
+			if (cnt >= recv_room) {
 				if (!port->ldisc_stop_rx)
 					mxser_stoprx(tty);
 				break;
@@ -1835,13 +1835,11 @@ static u8 mxser_receive_chars_old(struct tty_struct *tty,
 static u8 mxser_receive_chars(struct tty_struct *tty,
 		struct mxser_port *port, u8 status)
 {
-	int cnt = 0;
-
 	if (tty->receive_room == 0 && !port->ldisc_stop_rx)
 		mxser_stoprx(tty);
 
-	if (!mxser_receive_chars_new(tty, port, status, &cnt))
-		status = mxser_receive_chars_old(tty, port, status, &cnt);
+	if (!mxser_receive_chars_new(tty, port, status))
+		status = mxser_receive_chars_old(tty, port, status);
 
 	tty_flip_buffer_push(&port->port);
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 32/70] mxser: don't allocate MXSER_PORTS + 1
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (30 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 31/70] mxser: remove cnt from mxser_receive_chars Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 33/70] mxser: drop unused mxser_port::normal_termios Jiri Slaby
                   ` (38 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

The MXSER_PORTS's tty_device is never registered and neither its
tty_port instance exists. Hence, it's quite pointless to allocate it.

It used to be used for global information fetches via ioctls. We have
just removed these as non-existent tty_device+tty_port was exactly the
reason to remove the ioctls.

It would be peculiar to add this "virtual" port as we require a backing
tty_port since commit ecbbfd44a08f (TTY: move tty buffers to tty_port)
in 2012.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index d354c80083fd..007137c3b5c9 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1004,11 +1004,8 @@ static void mxser_shutdown_port(struct tty_port *port)
 static int mxser_open(struct tty_struct *tty, struct file *filp)
 {
 	struct mxser_port *info;
-	int line;
+	int line = tty->index;
 
-	line = tty->index;
-	if (line == MXSER_PORTS)
-		return 0;
 	info = &mxser_boards[line / MXSER_PORTS_PER_BOARD].ports[line % MXSER_PORTS_PER_BOARD];
 	if (!info->ioaddr)
 		return -ENODEV;
@@ -1077,7 +1074,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
 	struct mxser_port *info = tty->driver_data;
 	struct tty_port *port = &info->port;
 
-	if (tty->index == MXSER_PORTS || info == NULL)
+	if (info == NULL)
 		return;
 	if (tty_port_close_start(port, tty, filp) == 0)
 		return;
@@ -1216,9 +1213,6 @@ static int mxser_get_serial_info(struct tty_struct *tty,
 	struct tty_port *port = &info->port;
 	unsigned int closing_wait, close_delay;
 
-	if (tty->index == MXSER_PORTS)
-		return -ENOTTY;
-
 	mutex_lock(&port->mutex);
 
 	close_delay = jiffies_to_msecs(info->port.close_delay) / 10;
@@ -1249,8 +1243,6 @@ static int mxser_set_serial_info(struct tty_struct *tty,
 	unsigned int flags, close_delay, closing_wait;
 	int retval = 0;
 
-	if (tty->index == MXSER_PORTS)
-		return -ENOTTY;
 	if (tty_io_error(tty))
 		return -EIO;
 
@@ -1354,9 +1346,6 @@ static int mxser_tiocmget(struct tty_struct *tty)
 	unsigned char control, status;
 	unsigned long flags;
 
-
-	if (tty->index == MXSER_PORTS)
-		return -ENOIOCTLCMD;
 	if (tty_io_error(tty))
 		return -EIO;
 
@@ -1381,9 +1370,6 @@ static int mxser_tiocmset(struct tty_struct *tty,
 	struct mxser_port *info = tty->driver_data;
 	unsigned long flags;
 
-
-	if (tty->index == MXSER_PORTS)
-		return -ENOIOCTLCMD;
 	if (tty_io_error(tty))
 		return -EIO;
 
@@ -1433,9 +1419,6 @@ static int mxser_ioctl(struct tty_struct *tty,
 	unsigned long flags;
 	void __user *argp = (void __user *)arg;
 
-	if (tty->index == MXSER_PORTS)
-		return -ENOTTY;
-
 	if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) {
 		int p;
 		unsigned long opmode;
@@ -2211,7 +2194,7 @@ static int __init mxser_module_init(void)
 {
 	int retval;
 
-	mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1);
+	mxvar_sdriver = alloc_tty_driver(MXSER_PORTS);
 	if (!mxvar_sdriver)
 		return -ENOMEM;
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 33/70] mxser: drop unused mxser_port::normal_termios
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (31 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 32/70] mxser: don't allocate MXSER_PORTS + 1 Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 34/70] mxser: remove unused mxser_port::stop_rx Jiri Slaby
                   ` (37 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

After the previous patches, mxser_port::normal_termios is unused, so
time to wave bye-bye.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 007137c3b5c9..e10fbe7270c9 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -297,8 +297,6 @@ struct mxser_port {
 	unsigned int xmit_cnt;
 	int closing;
 
-	struct ktermios normal_termios;
-
 	spinlock_t slock;
 };
 
@@ -2025,7 +2023,6 @@ static int mxser_initbrd(struct mxser_board *brd)
 		info->custom_divisor = info->baud_base * 16;
 		info->port.close_delay = 5 * HZ / 10;
 		info->port.closing_wait = 30 * HZ;
-		info->normal_termios = mxvar_sdriver->init_termios;
 		spin_lock_init(&info->slock);
 
 		/* before set INT ISR, disable all int */
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 34/70] mxser: remove unused mxser_port::stop_rx
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (32 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 33/70] mxser: drop unused mxser_port::normal_termios Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 35/70] mxser: drop mxser_port::baud_base Jiri Slaby
                   ` (36 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

It's been a long time since mxser_port::stop_rx was abandoned. Remove it.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index e10fbe7270c9..b47b17ec1f12 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -281,7 +281,6 @@ struct mxser_port {
 	u8 IER;			/* Interrupt Enable Register */
 	u8 MCR;			/* Modem control register */
 
-	unsigned char stop_rx;
 	unsigned char ldisc_stop_rx;
 
 	int custom_divisor;
@@ -2009,7 +2008,6 @@ static int mxser_initbrd(struct mxser_board *brd)
 		tty_port_init(&info->port);
 		info->port.ops = &mxser_port_ops;
 		info->board = brd;
-		info->stop_rx = 0;
 		info->ldisc_stop_rx = 0;
 
 		/* Enhance mode enabled here */
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 35/70] mxser: drop mxser_port::baud_base
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (33 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 34/70] mxser: remove unused mxser_port::stop_rx Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 36/70] mxser: drop mxser_port::custom_divisor Jiri Slaby
                   ` (35 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

It's an once-set constant, so define a macro for the constant
(MXSER_BAUD_BASE) and use it in the code instead.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index b47b17ec1f12..204b71c4d1ae 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -156,6 +156,8 @@
 
 #define WAKEUP_CHARS		256
 
+#define MXSER_BAUD_BASE		921600
+
 #define PCI_DEVICE_ID_POS104UL	0x1044
 #define PCI_DEVICE_ID_CB108	0x1080
 #define PCI_DEVICE_ID_CP102UF	0x1023
@@ -274,7 +276,6 @@ struct mxser_port {
 
 	u8 rx_high_water;
 	u8 rx_low_water;
-	int baud_base;		/* max. speed */
 	int type;		/* UART type */
 
 	unsigned char x_char;	/* xon/xoff character */
@@ -584,13 +585,13 @@ static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
 		return -1;
 
 	if (newspd == 134) {
-		quot = 2 * info->baud_base / 269;
+		quot = 2 * MXSER_BAUD_BASE / 269;
 		tty_encode_baud_rate(tty, 134, 134);
 	} else if (newspd) {
-		quot = info->baud_base / newspd;
+		quot = MXSER_BAUD_BASE / newspd;
 		if (quot == 0)
 			quot = 1;
-		baud = info->baud_base/quot;
+		baud = MXSER_BAUD_BASE / quot;
 		tty_encode_baud_rate(tty, baud, baud);
 	} else {
 		quot = 0;
@@ -601,7 +602,7 @@ static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
 	 * u64 domain
 	 */
 	timeout = (u64)info->xmit_fifo_size * HZ * 10 * quot;
-	do_div(timeout, info->baud_base);
+	do_div(timeout, MXSER_BAUD_BASE);
 	info->timeout = timeout + HZ / 50; /* Add .02 seconds of slop */
 
 	if (quot) {
@@ -623,7 +624,7 @@ static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
 
 #ifdef BOTHER
 	if (C_BAUD(tty) == BOTHER) {
-		quot = info->baud_base % newspd;
+		quot = MXSER_BAUD_BASE % newspd;
 		quot *= 8;
 		if (quot % newspd > newspd / 2) {
 			quot /= newspd;
@@ -1222,7 +1223,7 @@ static int mxser_get_serial_info(struct tty_struct *tty,
 	ss->port = info->ioaddr,
 	ss->irq = info->board->irq,
 	ss->flags = info->port.flags,
-	ss->baud_base = info->baud_base,
+	ss->baud_base = MXSER_BAUD_BASE,
 	ss->close_delay = close_delay;
 	ss->closing_wait = closing_wait;
 	ss->custom_divisor = info->custom_divisor,
@@ -1263,7 +1264,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,
 		closing_wait = msecs_to_jiffies(closing_wait * 10);
 
 	if (!capable(CAP_SYS_ADMIN)) {
-		if ((ss->baud_base != info->baud_base) ||
+		if ((ss->baud_base != MXSER_BAUD_BASE) ||
 				(close_delay != info->port.close_delay) ||
 				(closing_wait != info->port.closing_wait) ||
 				((ss->flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK))) {
@@ -1282,7 +1283,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,
 		port->close_delay = close_delay;
 		port->closing_wait = closing_wait;
 		if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST &&
-				(ss->baud_base != info->baud_base ||
+				(ss->baud_base != MXSER_BAUD_BASE ||
 				ss->custom_divisor !=
 				info->custom_divisor)) {
 			if (ss->custom_divisor == 0) {
@@ -2018,7 +2019,7 @@ static int mxser_initbrd(struct mxser_board *brd)
 
 		process_txrx_fifo(info);
 
-		info->custom_divisor = info->baud_base * 16;
+		info->custom_divisor = MXSER_BAUD_BASE * 16;
 		info->port.close_delay = 5 * HZ / 10;
 		info->port.closing_wait = 30 * HZ;
 		spin_lock_init(&info->slock);
@@ -2127,10 +2128,6 @@ static int mxser_probe(struct pci_dev *pdev,
 		outb(0, ioaddress + 0x0c);	/* default set to RS232 mode */
 	}
 
-	for (i = 0; i < brd->info->nports; i++) {
-		brd->ports[i].baud_base = 921600;
-	}
-
 	/* mxser_initbrd will hook ISR. */
 	retval = mxser_initbrd(brd);
 	if (retval)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 36/70] mxser: drop mxser_port::custom_divisor
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (34 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 35/70] mxser: drop mxser_port::baud_base Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 37/70] mxser: cleanup mxser_change_speed Jiri Slaby
                   ` (34 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

It's an once-set constant, so define a macro for the constant
(MXSER_CUSTOM_DIVISOR) and use it in the code instead.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 204b71c4d1ae..c4ee5cb6952e 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -157,6 +157,7 @@
 #define WAKEUP_CHARS		256
 
 #define MXSER_BAUD_BASE		921600
+#define MXSER_CUSTOM_DIVISOR	(MXSER_BAUD_BASE * 16)
 
 #define PCI_DEVICE_ID_POS104UL	0x1044
 #define PCI_DEVICE_ID_CB108	0x1080
@@ -284,8 +285,6 @@ struct mxser_port {
 
 	unsigned char ldisc_stop_rx;
 
-	int custom_divisor;
-
 	struct async_icount icount; /* kernel counters for 4 input interrupts */
 	unsigned int timeout;
 
@@ -1226,7 +1225,7 @@ static int mxser_get_serial_info(struct tty_struct *tty,
 	ss->baud_base = MXSER_BAUD_BASE,
 	ss->close_delay = close_delay;
 	ss->closing_wait = closing_wait;
-	ss->custom_divisor = info->custom_divisor,
+	ss->custom_divisor = MXSER_CUSTOM_DIVISOR,
 	mutex_unlock(&port->mutex);
 	return 0;
 }
@@ -1285,7 +1284,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,
 		if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST &&
 				(ss->baud_base != MXSER_BAUD_BASE ||
 				ss->custom_divisor !=
-				info->custom_divisor)) {
+				MXSER_CUSTOM_DIVISOR)) {
 			if (ss->custom_divisor == 0) {
 				mutex_unlock(&port->mutex);
 				return -EINVAL;
@@ -2019,7 +2018,6 @@ static int mxser_initbrd(struct mxser_board *brd)
 
 		process_txrx_fifo(info);
 
-		info->custom_divisor = MXSER_BAUD_BASE * 16;
 		info->port.close_delay = 5 * HZ / 10;
 		info->port.closing_wait = 30 * HZ;
 		spin_lock_init(&info->slock);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 37/70] mxser: cleanup mxser_change_speed
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (35 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 36/70] mxser: drop mxser_port::custom_divisor Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 38/70] mxser: extract mxser_ioctl_op_mode Jiri Slaby
                   ` (33 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

* use UART macros instead of magic constants
* let the default case reuse already existing code (CS5 case)

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index c4ee5cb6952e..2a8bbce790f3 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -657,24 +657,23 @@ static void mxser_change_speed(struct tty_struct *tty)
 
 	/* byte size and parity */
 	switch (cflag & CSIZE) {
+	default:
 	case CS5:
-		cval = 0x00;
+		cval = UART_LCR_WLEN5;
 		break;
 	case CS6:
-		cval = 0x01;
+		cval = UART_LCR_WLEN6;
 		break;
 	case CS7:
-		cval = 0x02;
+		cval = UART_LCR_WLEN7;
 		break;
 	case CS8:
-		cval = 0x03;
+		cval = UART_LCR_WLEN8;
 		break;
-	default:
-		cval = 0x00;
-		break;		/* too keep GCC shut... */
 	}
+
 	if (cflag & CSTOPB)
-		cval |= 0x04;
+		cval |= UART_LCR_STOP;
 	if (cflag & PARENB)
 		cval |= UART_LCR_PARITY;
 	if (!(cflag & PARODD))
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 38/70] mxser: extract mxser_ioctl_op_mode
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (36 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 37/70] mxser: cleanup mxser_change_speed Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 39/70] mxser: simplify mxser_ioctl_op_mode Jiri Slaby
                   ` (32 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

This ioctl code sets RS232, RS422 or RS485 mode. Move the code to a
separate function (mxser_ioctl_op_mode) with a note that these
mxser-special ioctls should be likely replaced eventually by TIOCGRS485
and TIOCSRS485.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 83 ++++++++++++++++++++++++---------------------
 1 file changed, 45 insertions(+), 38 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 2a8bbce790f3..4a584db09494 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1407,6 +1407,48 @@ static int mxser_cflags_changed(struct mxser_port *info, unsigned long arg,
 	return ret;
 }
 
+/* We should likely switch to TIOCGRS485/TIOCSRS485. */
+static int mxser_ioctl_op_mode(struct mxser_port *port, int index, bool set,
+		int __user *u_opmode)
+{
+	static const unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f };
+	int opmode, p = index % 4;
+	int shiftbit = p * 2;
+	unsigned char val, mask;
+
+	if (port->board->must_hwid != MOXA_MUST_MU860_HWID)
+		return -EFAULT;
+
+	if (set) {
+		if (get_user(opmode, u_opmode))
+			return -EFAULT;
+
+		if (opmode != RS232_MODE && opmode != RS485_2WIRE_MODE &&
+				opmode != RS422_MODE &&
+				opmode != RS485_4WIRE_MODE)
+			return -EFAULT;
+
+		mask = ModeMask[p];
+
+		spin_lock_irq(&port->slock);
+		val = inb(port->opmode_ioaddr);
+		val &= mask;
+		val |= (opmode << shiftbit);
+		outb(val, port->opmode_ioaddr);
+		spin_unlock_irq(&port->slock);
+	} else {
+		spin_lock_irq(&port->slock);
+		opmode = inb(port->opmode_ioaddr) >> shiftbit;
+		spin_unlock_irq(&port->slock);
+
+		opmode &= OP_MODE_MASK;
+		if (put_user(opmode, u_opmode))
+			return -EFAULT;
+	}
+
+	return 0;
+}
+
 static int mxser_ioctl(struct tty_struct *tty,
 		unsigned int cmd, unsigned long arg)
 {
@@ -1415,44 +1457,9 @@ static int mxser_ioctl(struct tty_struct *tty,
 	unsigned long flags;
 	void __user *argp = (void __user *)arg;
 
-	if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) {
-		int p;
-		unsigned long opmode;
-		static unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f };
-		int shiftbit;
-		unsigned char val, mask;
-
-		if (info->board->must_hwid != MOXA_MUST_MU860_HWID)
-			return -EFAULT;
-
-		p = tty->index % 4;
-		if (cmd == MOXA_SET_OP_MODE) {
-			if (get_user(opmode, (int __user *) argp))
-				return -EFAULT;
-			if (opmode != RS232_MODE &&
-					opmode != RS485_2WIRE_MODE &&
-					opmode != RS422_MODE &&
-					opmode != RS485_4WIRE_MODE)
-				return -EFAULT;
-			mask = ModeMask[p];
-			shiftbit = p * 2;
-			spin_lock_irq(&info->slock);
-			val = inb(info->opmode_ioaddr);
-			val &= mask;
-			val |= (opmode << shiftbit);
-			outb(val, info->opmode_ioaddr);
-			spin_unlock_irq(&info->slock);
-		} else {
-			shiftbit = p * 2;
-			spin_lock_irq(&info->slock);
-			opmode = inb(info->opmode_ioaddr) >> shiftbit;
-			spin_unlock_irq(&info->slock);
-			opmode &= OP_MODE_MASK;
-			if (put_user(opmode, (int __user *)argp))
-				return -EFAULT;
-		}
-		return 0;
-	}
+	if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE)
+		return mxser_ioctl_op_mode(info, tty->index,
+				cmd == MOXA_SET_OP_MODE, argp);
 
 	if (cmd != TIOCMIWAIT && tty_io_error(tty))
 		return -EIO;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 39/70] mxser: simplify mxser_ioctl_op_mode
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (37 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 38/70] mxser: extract mxser_ioctl_op_mode Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 40/70] mxser: dedup mxser_must_set_enhance_mode Jiri Slaby
                   ` (31 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

* ModeMask local array is just inverted OP_MODE_MASK shifted by shiftbit.
  Drop this array and use the value directly.
* return from the if's true branch and drop 'else' branch by moving the
  code completely outside the if.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 4a584db09494..e082ae055c39 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1411,10 +1411,9 @@ static int mxser_cflags_changed(struct mxser_port *info, unsigned long arg,
 static int mxser_ioctl_op_mode(struct mxser_port *port, int index, bool set,
 		int __user *u_opmode)
 {
-	static const unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f };
 	int opmode, p = index % 4;
 	int shiftbit = p * 2;
-	unsigned char val, mask;
+	u8 val;
 
 	if (port->board->must_hwid != MOXA_MUST_MU860_HWID)
 		return -EFAULT;
@@ -1423,30 +1422,24 @@ static int mxser_ioctl_op_mode(struct mxser_port *port, int index, bool set,
 		if (get_user(opmode, u_opmode))
 			return -EFAULT;
 
-		if (opmode != RS232_MODE && opmode != RS485_2WIRE_MODE &&
-				opmode != RS422_MODE &&
-				opmode != RS485_4WIRE_MODE)
-			return -EFAULT;
-
-		mask = ModeMask[p];
+		if (opmode & ~OP_MODE_MASK)
+			return -EINVAL;
 
 		spin_lock_irq(&port->slock);
 		val = inb(port->opmode_ioaddr);
-		val &= mask;
+		val &= ~(OP_MODE_MASK << shiftbit);
 		val |= (opmode << shiftbit);
 		outb(val, port->opmode_ioaddr);
 		spin_unlock_irq(&port->slock);
-	} else {
-		spin_lock_irq(&port->slock);
-		opmode = inb(port->opmode_ioaddr) >> shiftbit;
-		spin_unlock_irq(&port->slock);
 
-		opmode &= OP_MODE_MASK;
-		if (put_user(opmode, u_opmode))
-			return -EFAULT;
+		return 0;
 	}
 
-	return 0;
+	spin_lock_irq(&port->slock);
+	opmode = inb(port->opmode_ioaddr) >> shiftbit;
+	spin_unlock_irq(&port->slock);
+
+	return put_user(opmode & OP_MODE_MASK, u_opmode);
 }
 
 static int mxser_ioctl(struct tty_struct *tty,
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 40/70] mxser: dedup mxser_must_set_enhance_mode
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (38 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 39/70] mxser: simplify mxser_ioctl_op_mode Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 41/70] mxser: introduce mxser_must_select_bank and use it Jiri Slaby
                   ` (30 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

There are multiple copies of setting the EFR register. Separate it to a
new universal function called __mxser_must_set_EFR. And use it in the
code by introducing mxser_must_set_enhance_mode instead of
mxser_disable_must_enchance_mode and mxser_enable_must_enchance_mode.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index e082ae055c39..7caf369571f1 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -314,34 +314,24 @@ struct mxser_board {
 static struct mxser_board mxser_boards[MXSER_BOARDS];
 static struct tty_driver *mxvar_sdriver;
 
-static void mxser_enable_must_enchance_mode(unsigned long baseio)
+static u8 __mxser_must_set_EFR(unsigned long baseio, u8 clear, u8 set,
+		bool restore_LCR)
 {
-	u8 oldlcr;
-	u8 efr;
+	u8 oldlcr, efr;
 
 	oldlcr = inb(baseio + UART_LCR);
 	outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
 
 	efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
-	efr |= MOXA_MUST_EFR_EFRB_ENABLE;
+	efr &= ~clear;
+	efr |= set;
 
 	outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
-	outb(oldlcr, baseio + UART_LCR);
-}
-
-static void mxser_disable_must_enchance_mode(unsigned long baseio)
-{
-	u8 oldlcr;
-	u8 efr;
-
-	oldlcr = inb(baseio + UART_LCR);
-	outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
 
-	efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
-	efr &= ~MOXA_MUST_EFR_EFRB_ENABLE;
+	if (restore_LCR)
+		outb(oldlcr, baseio + UART_LCR);
 
-	outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
-	outb(oldlcr, baseio + UART_LCR);
+	return oldlcr;
 }
 
 static void mxser_set_must_xon1_value(unsigned long baseio, u8 value)
@@ -431,6 +421,18 @@ static void mxser_get_must_hardware_id(unsigned long baseio, u8 *pId)
 	outb(oldlcr, baseio + UART_LCR);
 }
 
+static void mxser_must_set_EFR(unsigned long baseio, u8 clear, u8 set)
+{
+	__mxser_must_set_EFR(baseio, clear, set, true);
+}
+
+static void mxser_must_set_enhance_mode(unsigned long baseio, bool enable)
+{
+	mxser_must_set_EFR(baseio,
+			enable ? 0 : MOXA_MUST_EFR_EFRB_ENABLE,
+			enable ? MOXA_MUST_EFR_EFRB_ENABLE : 0);
+}
+
 static void SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(unsigned long baseio)
 {
 	u8 oldlcr;
@@ -514,7 +516,7 @@ static enum mxser_must_hwid mxser_must_get_hwid(unsigned long io)
 	int i;
 
 	outb(0, io + UART_LCR);
-	mxser_disable_must_enchance_mode(io);
+	mxser_must_set_enhance_mode(io, false);
 	oldmcr = inb(io + UART_MCR);
 	outb(0, io + UART_MCR);
 	mxser_set_must_xon1_value(io, 0x11);
@@ -2011,7 +2013,7 @@ static int mxser_initbrd(struct mxser_board *brd)
 
 		/* Enhance mode enabled here */
 		if (brd->must_hwid != MOXA_OTHER_UART)
-			mxser_enable_must_enchance_mode(info->ioaddr);
+			mxser_must_set_enhance_mode(info->ioaddr, true);
 
 		info->type = PORT_16550A;
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 41/70] mxser: introduce mxser_must_select_bank and use it
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (39 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 40/70] mxser: dedup mxser_must_set_enhance_mode Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 42/70] mxser: clean up the rest of MUST helpers Jiri Slaby
                   ` (29 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Again, selecting a bank in the EFR register is duplicated many times.
Extract it to a separate function (mxser_must_select_bank) and use it on
all the places.

This cleans up most of the helpers. And mxser_get_must_hardware_id now
returns the HW ID directly, not via a by-reference parameter.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 74 ++++++++++-----------------------------------
 1 file changed, 16 insertions(+), 58 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 7caf369571f1..392aee47c803 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -334,53 +334,29 @@ static u8 __mxser_must_set_EFR(unsigned long baseio, u8 clear, u8 set,
 	return oldlcr;
 }
 
-static void mxser_set_must_xon1_value(unsigned long baseio, u8 value)
+static u8 mxser_must_select_bank(unsigned long baseio, u8 bank)
 {
-	u8 oldlcr;
-	u8 efr;
-
-	oldlcr = inb(baseio + UART_LCR);
-	outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
-	efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
-	efr &= ~MOXA_MUST_EFR_BANK_MASK;
-	efr |= MOXA_MUST_EFR_BANK0;
+	return __mxser_must_set_EFR(baseio, MOXA_MUST_EFR_BANK_MASK, bank,
+			false);
+}
 
-	outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
+static void mxser_set_must_xon1_value(unsigned long baseio, u8 value)
+{
+	u8 oldlcr = mxser_must_select_bank(baseio, MOXA_MUST_EFR_BANK0);
 	outb(value, baseio + MOXA_MUST_XON1_REGISTER);
 	outb(oldlcr, baseio + UART_LCR);
 }
 
 static void mxser_set_must_xoff1_value(unsigned long baseio, u8 value)
 {
-	u8 oldlcr;
-	u8 efr;
-
-	oldlcr = inb(baseio + UART_LCR);
-	outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
-	efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
-	efr &= ~MOXA_MUST_EFR_BANK_MASK;
-	efr |= MOXA_MUST_EFR_BANK0;
-
-	outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
+	u8 oldlcr = mxser_must_select_bank(baseio, MOXA_MUST_EFR_BANK0);
 	outb(value, baseio + MOXA_MUST_XOFF1_REGISTER);
 	outb(oldlcr, baseio + UART_LCR);
 }
 
 static void mxser_set_must_fifo_value(struct mxser_port *info)
 {
-	u8 oldlcr;
-	u8 efr;
-
-	oldlcr = inb(info->ioaddr + UART_LCR);
-	outb(MOXA_MUST_ENTER_ENCHANCE, info->ioaddr + UART_LCR);
-
-	efr = inb(info->ioaddr + MOXA_MUST_EFR_REGISTER);
-	efr &= ~MOXA_MUST_EFR_BANK_MASK;
-	efr |= MOXA_MUST_EFR_BANK1;
-
-	outb(efr, info->ioaddr + MOXA_MUST_EFR_REGISTER);
+	u8 oldlcr = mxser_must_select_bank(info->ioaddr, MOXA_MUST_EFR_BANK1);
 	outb(info->rx_high_water, info->ioaddr + MOXA_MUST_RBRTH_REGISTER);
 	outb(info->rx_high_water, info->ioaddr + MOXA_MUST_RBRTI_REGISTER);
 	outb(info->rx_low_water, info->ioaddr + MOXA_MUST_RBRTL_REGISTER);
@@ -389,36 +365,18 @@ static void mxser_set_must_fifo_value(struct mxser_port *info)
 
 static void mxser_set_must_enum_value(unsigned long baseio, u8 value)
 {
-	u8 oldlcr;
-	u8 efr;
-
-	oldlcr = inb(baseio + UART_LCR);
-	outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
-	efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
-	efr &= ~MOXA_MUST_EFR_BANK_MASK;
-	efr |= MOXA_MUST_EFR_BANK2;
-
-	outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
+	u8 oldlcr = mxser_must_select_bank(baseio, MOXA_MUST_EFR_BANK2);
 	outb(value, baseio + MOXA_MUST_ENUM_REGISTER);
 	outb(oldlcr, baseio + UART_LCR);
 }
 
-static void mxser_get_must_hardware_id(unsigned long baseio, u8 *pId)
+static u8 mxser_get_must_hardware_id(unsigned long baseio)
 {
-	u8 oldlcr;
-	u8 efr;
-
-	oldlcr = inb(baseio + UART_LCR);
-	outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
-	efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
-	efr &= ~MOXA_MUST_EFR_BANK_MASK;
-	efr |= MOXA_MUST_EFR_BANK2;
-
-	outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
-	*pId = inb(baseio + MOXA_MUST_HWID_REGISTER);
+	u8 oldlcr = mxser_must_select_bank(baseio, MOXA_MUST_EFR_BANK2);
+	u8 id = inb(baseio + MOXA_MUST_HWID_REGISTER);
 	outb(oldlcr, baseio + UART_LCR);
+
+	return id;
 }
 
 static void mxser_must_set_EFR(unsigned long baseio, u8 clear, u8 set)
@@ -525,7 +483,7 @@ static enum mxser_must_hwid mxser_must_get_hwid(unsigned long io)
 		return MOXA_OTHER_UART;
 	}
 
-	mxser_get_must_hardware_id(io, &hwid);
+	hwid = mxser_get_must_hardware_id(io);
 	for (i = 1; i < UART_INFO_NUM; i++) /* 0 = OTHER_UART */
 		if (hwid == Gpci_uart_info[i].type)
 			return hwid;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 42/70] mxser: clean up the rest of MUST helpers
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (40 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 41/70] mxser: introduce mxser_must_select_bank and use it Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 43/70] mxser: move board init into mxser_initbrd Jiri Slaby
                   ` (28 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Clean up the rest of MUST helpers. They all can use the newly added
mxser_must_set_EFR. And passing a bool instead of having two functions
(_enable+_disable) simplifies the code a lot too.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 97 ++++++---------------------------------------
 1 file changed, 12 insertions(+), 85 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 392aee47c803..ff85a6e15d9d 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -391,81 +391,21 @@ static void mxser_must_set_enhance_mode(unsigned long baseio, bool enable)
 			enable ? MOXA_MUST_EFR_EFRB_ENABLE : 0);
 }
 
-static void SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(unsigned long baseio)
+static void mxser_must_no_sw_flow_control(unsigned long baseio)
 {
-	u8 oldlcr;
-	u8 efr;
-
-	oldlcr = inb(baseio + UART_LCR);
-	outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
-	efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
-	efr &= ~MOXA_MUST_EFR_SF_MASK;
-
-	outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
-	outb(oldlcr, baseio + UART_LCR);
-}
-
-static void mxser_enable_must_tx_software_flow_control(unsigned long baseio)
-{
-	u8 oldlcr;
-	u8 efr;
-
-	oldlcr = inb(baseio + UART_LCR);
-	outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
-	efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
-	efr &= ~MOXA_MUST_EFR_SF_TX_MASK;
-	efr |= MOXA_MUST_EFR_SF_TX1;
-
-	outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
-	outb(oldlcr, baseio + UART_LCR);
-}
-
-static void mxser_disable_must_tx_software_flow_control(unsigned long baseio)
-{
-	u8 oldlcr;
-	u8 efr;
-
-	oldlcr = inb(baseio + UART_LCR);
-	outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
-	efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
-	efr &= ~MOXA_MUST_EFR_SF_TX_MASK;
-
-	outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
-	outb(oldlcr, baseio + UART_LCR);
+	mxser_must_set_EFR(baseio, MOXA_MUST_EFR_SF_MASK, 0);
 }
 
-static void mxser_enable_must_rx_software_flow_control(unsigned long baseio)
+static void mxser_must_set_tx_sw_flow_control(unsigned long baseio, bool enable)
 {
-	u8 oldlcr;
-	u8 efr;
-
-	oldlcr = inb(baseio + UART_LCR);
-	outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
-	efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
-	efr &= ~MOXA_MUST_EFR_SF_RX_MASK;
-	efr |= MOXA_MUST_EFR_SF_RX1;
-
-	outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
-	outb(oldlcr, baseio + UART_LCR);
+	mxser_must_set_EFR(baseio, MOXA_MUST_EFR_SF_TX_MASK,
+			enable ? MOXA_MUST_EFR_SF_TX1 : 0);
 }
 
-static void mxser_disable_must_rx_software_flow_control(unsigned long baseio)
+static void mxser_must_set_rx_sw_flow_control(unsigned long baseio, bool enable)
 {
-	u8 oldlcr;
-	u8 efr;
-
-	oldlcr = inb(baseio + UART_LCR);
-	outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
-	efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
-	efr &= ~MOXA_MUST_EFR_SF_RX_MASK;
-
-	outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
-	outb(oldlcr, baseio + UART_LCR);
+	mxser_must_set_EFR(baseio, MOXA_MUST_EFR_SF_RX_MASK,
+			enable ? MOXA_MUST_EFR_SF_RX1 : 0);
 }
 
 static enum mxser_must_hwid mxser_must_get_hwid(unsigned long io)
@@ -746,20 +686,8 @@ static void mxser_change_speed(struct tty_struct *tty)
 	if (info->board->must_hwid) {
 		mxser_set_must_xon1_value(info->ioaddr, START_CHAR(tty));
 		mxser_set_must_xoff1_value(info->ioaddr, STOP_CHAR(tty));
-		if (I_IXON(tty)) {
-			mxser_enable_must_rx_software_flow_control(
-					info->ioaddr);
-		} else {
-			mxser_disable_must_rx_software_flow_control(
-					info->ioaddr);
-		}
-		if (I_IXOFF(tty)) {
-			mxser_enable_must_tx_software_flow_control(
-					info->ioaddr);
-		} else {
-			mxser_disable_must_tx_software_flow_control(
-					info->ioaddr);
-		}
+		mxser_must_set_rx_sw_flow_control(info->ioaddr, I_IXON(tty));
+		mxser_must_set_tx_sw_flow_control(info->ioaddr, I_IXOFF(tty));
 	}
 
 
@@ -946,7 +874,7 @@ static void mxser_shutdown_port(struct tty_port *port)
 
 
 	if (info->board->must_hwid)
-		SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->ioaddr);
+		mxser_must_no_sw_flow_control(info->ioaddr);
 
 	spin_unlock_irqrestore(&info->slock, flags);
 }
@@ -1585,8 +1513,7 @@ static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termi
 
 		if (info->board->must_hwid) {
 			spin_lock_irqsave(&info->slock, flags);
-			mxser_disable_must_rx_software_flow_control(
-					info->ioaddr);
+			mxser_must_set_rx_sw_flow_control(info->ioaddr, false);
 			spin_unlock_irqrestore(&info->slock, flags);
 		}
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 43/70] mxser: move board init into mxser_initbrd
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (41 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 42/70] mxser: clean up the rest of MUST helpers Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 44/70] mxser: inline mxser_board_remove into mxser_remove Jiri Slaby
                   ` (27 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

What's done in ->probe for board is actually its initialization. So move
it to mxser_initbrd where it belongs.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 53 ++++++++++++++++++++++++---------------------
 1 file changed, 28 insertions(+), 25 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index ff85a6e15d9d..3b20eb96d788 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1888,9 +1888,36 @@ static int mxser_initbrd(struct mxser_board *brd)
 	struct mxser_port *info;
 	unsigned int i;
 	int retval;
+	bool is_mu860;
+
+	brd->must_hwid = mxser_must_get_hwid(brd->ports[0].ioaddr);
+	is_mu860 = brd->must_hwid == MOXA_MUST_MU860_HWID;
+
+	for (i = 0; i < UART_INFO_NUM; i++) {
+		if (Gpci_uart_info[i].type == brd->must_hwid) {
+			brd->max_baud = Gpci_uart_info[i].max_baud;
+
+			/* exception....CP-102 */
+			if (brd->info->flags & MXSER_HIGHBAUD)
+				brd->max_baud = 921600;
+			break;
+		}
+	}
+
+	if (is_mu860) {
+		/* set to RS232 mode by default */
+		outb(0, brd->vector + 4);
+		outb(0, brd->vector + 0x0c);
+	}
 
 	for (i = 0; i < brd->info->nports; i++) {
 		info = &brd->ports[i];
+		if (is_mu860) {
+			if (i < 4)
+				info->opmode_ioaddr = brd->vector + 4;
+			else
+				info->opmode_ioaddr = brd->vector + 0x0c;
+		}
 		tty_port_init(&info->port);
 		info->port.ops = &mxser_port_ops;
 		info->board = brd;
@@ -1941,7 +1968,7 @@ static int mxser_probe(struct pci_dev *pdev,
 		const struct pci_device_id *ent)
 {
 	struct mxser_board *brd;
-	unsigned int i, j;
+	unsigned int i;
 	unsigned long ioaddress;
 	struct device *tty_dev;
 	int retval = -EINVAL;
@@ -1988,30 +2015,6 @@ static int mxser_probe(struct pci_dev *pdev,
 	/* irq */
 	brd->irq = pdev->irq;
 
-	brd->must_hwid = mxser_must_get_hwid(brd->ports[0].ioaddr);
-
-	for (j = 0; j < UART_INFO_NUM; j++) {
-		if (Gpci_uart_info[j].type == brd->must_hwid) {
-			brd->max_baud = Gpci_uart_info[j].max_baud;
-
-			/* exception....CP-102 */
-			if (brd->info->flags & MXSER_HIGHBAUD)
-				brd->max_baud = 921600;
-			break;
-		}
-	}
-
-	if (brd->must_hwid == MOXA_MUST_MU860_HWID) {
-		for (i = 0; i < brd->info->nports; i++) {
-			if (i < 4)
-				brd->ports[i].opmode_ioaddr = ioaddress + 4;
-			else
-				brd->ports[i].opmode_ioaddr = ioaddress + 0x0c;
-		}
-		outb(0, ioaddress + 4);	/* default set to RS232 mode */
-		outb(0, ioaddress + 0x0c);	/* default set to RS232 mode */
-	}
-
 	/* mxser_initbrd will hook ISR. */
 	retval = mxser_initbrd(brd);
 	if (retval)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 44/70] mxser: inline mxser_board_remove into mxser_remove
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (42 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 43/70] mxser: move board init into mxser_initbrd Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 45/70] mxser: pci, switch to managed resources Jiri Slaby
                   ` (26 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

The only user of mxser_board_remove is mxser_remove. Move there those
few lines.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 3b20eb96d788..196750676400 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1953,17 +1953,6 @@ static int mxser_initbrd(struct mxser_board *brd)
 	return retval;
 }
 
-static void mxser_board_remove(struct mxser_board *brd)
-{
-	unsigned int i;
-
-	for (i = 0; i < brd->info->nports; i++) {
-		tty_unregister_device(mxvar_sdriver, brd->idx + i);
-		tty_port_destroy(&brd->ports[i].port);
-	}
-	free_irq(brd->irq, brd);
-}
-
 static int mxser_probe(struct pci_dev *pdev,
 		const struct pci_device_id *ent)
 {
@@ -2053,8 +2042,14 @@ static int mxser_probe(struct pci_dev *pdev,
 static void mxser_remove(struct pci_dev *pdev)
 {
 	struct mxser_board *brd = pci_get_drvdata(pdev);
+	unsigned int i;
+
+	for (i = 0; i < brd->info->nports; i++) {
+		tty_unregister_device(mxvar_sdriver, brd->idx + i);
+		tty_port_destroy(&brd->ports[i].port);
+	}
 
-	mxser_board_remove(brd);
+	free_irq(brd->irq, brd);
 
 	pci_release_region(pdev, 2);
 	pci_release_region(pdev, 3);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 45/70] mxser: pci, switch to managed resources
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (43 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 44/70] mxser: inline mxser_board_remove into mxser_remove Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 46/70] mxser: move request irq to probe and switch to managed Jiri Slaby
                   ` (25 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Switch to managed resources for PCI using pcim_enable_device.
Regions and device disabling is now taken care of by the core and we
need not unwind. Neither in ->probe, nor in ->remove. That simplifies
the code.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 196750676400..be58ee025180 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1978,7 +1978,7 @@ static int mxser_probe(struct pci_dev *pdev,
 		mxser_cards[ent->driver_data].name,
 		pdev->bus->number, PCI_SLOT(pdev->devfn));
 
-	retval = pci_enable_device(pdev);
+	retval = pcim_enable_device(pdev);
 	if (retval) {
 		dev_err(&pdev->dev, "PCI enable failed\n");
 		goto err;
@@ -1988,7 +1988,7 @@ static int mxser_probe(struct pci_dev *pdev,
 	ioaddress = pci_resource_start(pdev, 2);
 	retval = pci_request_region(pdev, 2, "mxser(IO)");
 	if (retval)
-		goto err_dis;
+		goto err;
 
 	brd->info = &mxser_cards[ent->driver_data];
 	for (i = 0; i < brd->info->nports; i++)
@@ -2007,7 +2007,7 @@ static int mxser_probe(struct pci_dev *pdev,
 	/* mxser_initbrd will hook ISR. */
 	retval = mxser_initbrd(brd);
 	if (retval)
-		goto err_rel3;
+		goto err_zero;
 
 	for (i = 0; i < brd->info->nports; i++) {
 		tty_dev = tty_port_register_device(&brd->ports[i].port,
@@ -2028,13 +2028,8 @@ static int mxser_probe(struct pci_dev *pdev,
 	for (i = 0; i < brd->info->nports; i++)
 		tty_port_destroy(&brd->ports[i].port);
 	free_irq(brd->irq, brd);
-err_rel3:
-	pci_release_region(pdev, 3);
 err_zero:
 	brd->info = NULL;
-	pci_release_region(pdev, 2);
-err_dis:
-	pci_disable_device(pdev);
 err:
 	return retval;
 }
@@ -2051,9 +2046,6 @@ static void mxser_remove(struct pci_dev *pdev)
 
 	free_irq(brd->irq, brd);
 
-	pci_release_region(pdev, 2);
-	pci_release_region(pdev, 3);
-	pci_disable_device(pdev);
 	brd->info = NULL;
 }
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 46/70] mxser: move request irq to probe and switch to managed
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (44 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 45/70] mxser: pci, switch to managed resources Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 47/70] mxser: remove info message from probe Jiri Slaby
                   ` (24 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Move request_irq from mxser_initbrd to mxser_probe so that we can switch
it to managed request. It simplifies the cleanup code.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index be58ee025180..83c795acdb19 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1883,11 +1883,10 @@ static const struct tty_port_operations mxser_port_ops = {
  * The MOXA Smartio/Industio serial driver boot-time initialization code!
  */
 
-static int mxser_initbrd(struct mxser_board *brd)
+static void mxser_initbrd(struct mxser_board *brd)
 {
 	struct mxser_port *info;
 	unsigned int i;
-	int retval;
 	bool is_mu860;
 
 	brd->must_hwid = mxser_must_get_hwid(brd->ports[0].ioaddr);
@@ -1939,18 +1938,6 @@ static int mxser_initbrd(struct mxser_board *brd)
 		outb(inb(info->ioaddr + UART_IER) & 0xf0,
 			info->ioaddr + UART_IER);
 	}
-
-	retval = request_irq(brd->irq, mxser_interrupt, IRQF_SHARED, "mxser",
-			brd);
-	if (retval) {
-		for (i = 0; i < brd->info->nports; i++)
-			tty_port_destroy(&brd->ports[i].port);
-		printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may "
-			"conflict with another device.\n",
-			brd->info->name, brd->irq);
-	}
-
-	return retval;
 }
 
 static int mxser_probe(struct pci_dev *pdev,
@@ -2004,10 +1991,14 @@ static int mxser_probe(struct pci_dev *pdev,
 	/* irq */
 	brd->irq = pdev->irq;
 
-	/* mxser_initbrd will hook ISR. */
-	retval = mxser_initbrd(brd);
-	if (retval)
-		goto err_zero;
+	mxser_initbrd(brd);
+
+	retval = devm_request_irq(&pdev->dev, brd->irq, mxser_interrupt,
+			IRQF_SHARED, "mxser", brd);
+	if (retval) {
+		dev_err(&pdev->dev, "request irq failed");
+		goto err_relbrd;
+	}
 
 	for (i = 0; i < brd->info->nports; i++) {
 		tty_dev = tty_port_register_device(&brd->ports[i].port,
@@ -2027,7 +2018,6 @@ static int mxser_probe(struct pci_dev *pdev,
 err_relbrd:
 	for (i = 0; i < brd->info->nports; i++)
 		tty_port_destroy(&brd->ports[i].port);
-	free_irq(brd->irq, brd);
 err_zero:
 	brd->info = NULL;
 err:
@@ -2044,8 +2034,6 @@ static void mxser_remove(struct pci_dev *pdev)
 		tty_port_destroy(&brd->ports[i].port);
 	}
 
-	free_irq(brd->irq, brd);
-
 	brd->info = NULL;
 }
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 47/70] mxser: remove info message from probe
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (45 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 46/70] mxser: move request irq to probe and switch to managed Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 48/70] mxser: remove mxser_cardinfo Jiri Slaby
                   ` (23 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

There is a dev_info in ->probe which prints device's name, bus and slot
numbers. All these can be fetched from the lspci output. So remove this
useless print.

This eliminates the whole mxser_cardinfo::name field.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 56 +++++++++++++++++++++------------------------
 1 file changed, 26 insertions(+), 30 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 83c795acdb19..04a39c1f13bb 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -190,38 +190,37 @@ static const struct {
 #define UART_INFO_NUM	ARRAY_SIZE(Gpci_uart_info)
 
 struct mxser_cardinfo {
-	char *name;
 	unsigned int nports;
 	unsigned int flags;
 };
 
 static const struct mxser_cardinfo mxser_cards[] = {
-/* 0*/	{ "C168H/PCI series",	8, },
-	{ "C104H/PCI series",	4, },
-	{ "CP-132 series",	2, },
-	{ "CP-114 series",	4, },
-	{ "CT-114 series",	4, },
-/* 5*/	{ "CP-102 series",	2, MXSER_HIGHBAUD },
-	{ "CP-104U series",	4, },
-	{ "CP-168U series",	8, },
-	{ "CP-132U series",	2, },
-	{ "CP-134U series",	4, },
-/*10*/	{ "CP-104JU series",	4, },
-	{ "Moxa UC7000 Serial",	8, },		/* RC7000 */
-	{ "CP-118U series",	8, },
-	{ "CP-102UL series",	2, },
-	{ "CP-102U series",	2, },
-/*15*/	{ "CP-118EL series",	8, },
-	{ "CP-168EL series",	8, },
-	{ "CP-104EL series",	4, },
-	{ "CB-108 series",	8, },
-	{ "CB-114 series",	4, },
-/*20*/	{ "CB-134I series",	4, },
-	{ "CP-138U series",	8, },
-	{ "POS-104UL series",	4, },
-	{ "CP-114UL series",	4, },
-	{ "CP-102UF series",	2, },
-/*25*/	{ "CP-112UL series",	2, },
+/* 0*/	{ 8, },
+	{ 4, },
+	{ 2, },
+	{ 4, },
+	{ 4, },
+/* 5*/	{ 2, MXSER_HIGHBAUD },
+	{ 4, },
+	{ 8, },
+	{ 2, },
+	{ 4, },
+/*10*/	{ 4, },
+	{ 8, },		/* RC7000 */
+	{ 8, },
+	{ 2, },
+	{ 2, },
+/*15*/	{ 8, },
+	{ 8, },
+	{ 4, },
+	{ 8, },
+	{ 4, },
+/*20*/	{ 4, },
+	{ 8, },
+	{ 4, },
+	{ 4, },
+	{ 2, },
+/*25*/	{ 2, },
 };
 
 /* driver_data correspond to the lines in the structure above
@@ -1961,9 +1960,6 @@ static int mxser_probe(struct pci_dev *pdev,
 
 	brd = &mxser_boards[i];
 	brd->idx = i * MXSER_PORTS_PER_BOARD;
-	dev_info(&pdev->dev, "found MOXA %s board (BusNo=%d, DevNo=%d)\n",
-		mxser_cards[ent->driver_data].name,
-		pdev->bus->number, PCI_SLOT(pdev->devfn));
 
 	retval = pcim_enable_device(pdev);
 	if (retval) {
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 48/70] mxser: remove mxser_cardinfo
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (46 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 47/70] mxser: remove info message from probe Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 49/70] mxser: cleanup mxser_process_txrx_fifo Jiri Slaby
                   ` (22 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Now that mxser_cards array (of struct mxser_cardinfo) contains only port
count and a quirk, we can encode these two directly into
pci_device_id::driver_data. And we can remove this struct completely.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 113 ++++++++++++++++----------------------------
 1 file changed, 41 insertions(+), 72 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 04a39c1f13bb..bb4110d466cb 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -168,7 +168,8 @@
 #define PCI_DEVICE_ID_CB134I	0x1341
 #define PCI_DEVICE_ID_CP138U	0x1380
 
-#define MXSER_HIGHBAUD	1
+#define MXSER_NPORTS(ddata)		((ddata) & 0xffU)
+#define MXSER_HIGHBAUD			0x0100
 
 enum mxser_must_hwid {
 	MOXA_OTHER_UART		= 0x00,
@@ -189,69 +190,36 @@ static const struct {
 };
 #define UART_INFO_NUM	ARRAY_SIZE(Gpci_uart_info)
 
-struct mxser_cardinfo {
-	unsigned int nports;
-	unsigned int flags;
-};
-
-static const struct mxser_cardinfo mxser_cards[] = {
-/* 0*/	{ 8, },
-	{ 4, },
-	{ 2, },
-	{ 4, },
-	{ 4, },
-/* 5*/	{ 2, MXSER_HIGHBAUD },
-	{ 4, },
-	{ 8, },
-	{ 2, },
-	{ 4, },
-/*10*/	{ 4, },
-	{ 8, },		/* RC7000 */
-	{ 8, },
-	{ 2, },
-	{ 2, },
-/*15*/	{ 8, },
-	{ 8, },
-	{ 4, },
-	{ 8, },
-	{ 4, },
-/*20*/	{ 4, },
-	{ 8, },
-	{ 4, },
-	{ 4, },
-	{ 2, },
-/*25*/	{ 2, },
-};
 
 /* driver_data correspond to the lines in the structure above
    see also ISA probe function before you change something */
 static const struct pci_device_id mxser_pcibrds[] = {
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C168),	.driver_data = 0 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C104),	.driver_data = 1 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C168),	.driver_data = 8 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C104),	.driver_data = 4 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132),	.driver_data = 2 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP114),	.driver_data = 3 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP114),	.driver_data = 4 },
 	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CT114),	.driver_data = 4 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102),	.driver_data = 5 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104U),	.driver_data = 6 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168U),	.driver_data = 7 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132U),	.driver_data = 8 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP134U),	.driver_data = 9 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104JU),.driver_data = 10 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_RC7000),	.driver_data = 11 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118U),	.driver_data = 12 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102UL),.driver_data = 13 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102U),	.driver_data = 14 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118EL),.driver_data = 15 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168EL),.driver_data = 16 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104EL),.driver_data = 17 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB108),	.driver_data = 18 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB114),	.driver_data = 19 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB134I),	.driver_data = 20 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP138U),	.driver_data = 21 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_POS104UL),	.driver_data = 22 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP114UL),	.driver_data = 23 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP102UF),	.driver_data = 24 },
-	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP112UL),	.driver_data = 25 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102),	.driver_data = 2 | MXSER_HIGHBAUD },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104U),	.driver_data = 4 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168U),	.driver_data = 8 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132U),	.driver_data = 2 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP134U),	.driver_data = 4 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104JU),.driver_data = 4 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_RC7000),	.driver_data = 8 }, /* RC7000 */
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118U),	.driver_data = 8 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102UL),.driver_data = 2 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102U),	.driver_data = 2 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118EL),.driver_data = 8 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168EL),.driver_data = 8 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104EL),.driver_data = 4 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB108),	.driver_data = 8 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB114),	.driver_data = 4 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB134I),	.driver_data = 4 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP138U),	.driver_data = 8 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_POS104UL),	.driver_data = 4 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP114UL),	.driver_data = 4 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP102UF),	.driver_data = 2 },
+	{ PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP112UL),	.driver_data = 2 },
 	{ }
 };
 MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
@@ -300,8 +268,8 @@ struct mxser_port {
 
 struct mxser_board {
 	unsigned int idx;
+	unsigned short nports;
 	int irq;
-	const struct mxser_cardinfo *info;
 	unsigned long vector;
 
 	enum mxser_must_hwid must_hwid;
@@ -1816,7 +1784,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
 	struct mxser_board *brd = dev_id;
 	struct mxser_port *port;
 	unsigned int int_cnt, pass_counter = 0;
-	unsigned int i, max = brd->info->nports;
+	unsigned int i, max = brd->nports;
 	int handled = IRQ_NONE;
 	u8 irqbits, bits, mask = BIT(max) - 1;
 
@@ -1882,7 +1850,7 @@ static const struct tty_port_operations mxser_port_ops = {
  * The MOXA Smartio/Industio serial driver boot-time initialization code!
  */
 
-static void mxser_initbrd(struct mxser_board *brd)
+static void mxser_initbrd(struct mxser_board *brd, bool high_baud)
 {
 	struct mxser_port *info;
 	unsigned int i;
@@ -1896,7 +1864,7 @@ static void mxser_initbrd(struct mxser_board *brd)
 			brd->max_baud = Gpci_uart_info[i].max_baud;
 
 			/* exception....CP-102 */
-			if (brd->info->flags & MXSER_HIGHBAUD)
+			if (high_baud)
 				brd->max_baud = 921600;
 			break;
 		}
@@ -1908,7 +1876,7 @@ static void mxser_initbrd(struct mxser_board *brd)
 		outb(0, brd->vector + 0x0c);
 	}
 
-	for (i = 0; i < brd->info->nports; i++) {
+	for (i = 0; i < brd->nports; i++) {
 		info = &brd->ports[i];
 		if (is_mu860) {
 			if (i < 4)
@@ -1945,11 +1913,12 @@ static int mxser_probe(struct pci_dev *pdev,
 	struct mxser_board *brd;
 	unsigned int i;
 	unsigned long ioaddress;
+	unsigned short nports = MXSER_NPORTS(ent->driver_data);
 	struct device *tty_dev;
 	int retval = -EINVAL;
 
 	for (i = 0; i < MXSER_BOARDS; i++)
-		if (mxser_boards[i].info == NULL)
+		if (mxser_boards[i].nports == 0)
 			break;
 
 	if (i >= MXSER_BOARDS) {
@@ -1973,8 +1942,8 @@ static int mxser_probe(struct pci_dev *pdev,
 	if (retval)
 		goto err;
 
-	brd->info = &mxser_cards[ent->driver_data];
-	for (i = 0; i < brd->info->nports; i++)
+	brd->nports = nports;
+	for (i = 0; i < nports; i++)
 		brd->ports[i].ioaddr = ioaddress + 8 * i;
 
 	/* vector */
@@ -1987,7 +1956,7 @@ static int mxser_probe(struct pci_dev *pdev,
 	/* irq */
 	brd->irq = pdev->irq;
 
-	mxser_initbrd(brd);
+	mxser_initbrd(brd, ent->driver_data & MXSER_HIGHBAUD);
 
 	retval = devm_request_irq(&pdev->dev, brd->irq, mxser_interrupt,
 			IRQF_SHARED, "mxser", brd);
@@ -1996,7 +1965,7 @@ static int mxser_probe(struct pci_dev *pdev,
 		goto err_relbrd;
 	}
 
-	for (i = 0; i < brd->info->nports; i++) {
+	for (i = 0; i < nports; i++) {
 		tty_dev = tty_port_register_device(&brd->ports[i].port,
 				mxvar_sdriver, brd->idx + i, &pdev->dev);
 		if (IS_ERR(tty_dev)) {
@@ -2012,10 +1981,10 @@ static int mxser_probe(struct pci_dev *pdev,
 
 	return 0;
 err_relbrd:
-	for (i = 0; i < brd->info->nports; i++)
+	for (i = 0; i < nports; i++)
 		tty_port_destroy(&brd->ports[i].port);
 err_zero:
-	brd->info = NULL;
+	brd->nports = 0;
 err:
 	return retval;
 }
@@ -2025,12 +1994,12 @@ static void mxser_remove(struct pci_dev *pdev)
 	struct mxser_board *brd = pci_get_drvdata(pdev);
 	unsigned int i;
 
-	for (i = 0; i < brd->info->nports; i++) {
+	for (i = 0; i < brd->nports; i++) {
 		tty_unregister_device(mxvar_sdriver, brd->idx + i);
 		tty_port_destroy(&brd->ports[i].port);
 	}
 
-	brd->info = NULL;
+	brd->nports = 0;
 }
 
 static struct pci_driver mxser_driver = {
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 49/70] mxser: cleanup mxser_process_txrx_fifo
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (47 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 48/70] mxser: remove mxser_cardinfo Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 50/70] mxser: rework and simplify mxser_open Jiri Slaby
                   ` (21 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Rename process_txrx_fifo to mxser_process_txrx_fifo and:
* remove useless parentheses
* return from the 'if's true branch and process the rest in normal code
  flow (shift the code one level left)

All this to make the code more readable.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index bb4110d466cb..1e54e94a7ca6 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -398,22 +398,24 @@ static enum mxser_must_hwid mxser_must_get_hwid(unsigned long io)
 	return MOXA_OTHER_UART;
 }
 
-static void process_txrx_fifo(struct mxser_port *info)
+static void mxser_process_txrx_fifo(struct mxser_port *info)
 {
-	int i;
+	unsigned int i;
 
-	if ((info->type == PORT_16450) || (info->type == PORT_8250)) {
+	if (info->type == PORT_16450 || info->type == PORT_8250) {
 		info->rx_high_water = 1;
 		info->rx_low_water = 1;
 		info->xmit_fifo_size = 1;
-	} else
-		for (i = 0; i < UART_INFO_NUM; i++)
-			if (info->board->must_hwid == Gpci_uart_info[i].type) {
-				info->rx_low_water = Gpci_uart_info[i].rx_low_water;
-				info->rx_high_water = Gpci_uart_info[i].rx_high_water;
-				info->xmit_fifo_size = Gpci_uart_info[i].fifo_size;
-				break;
-			}
+		return;
+	}
+
+	for (i = 0; i < UART_INFO_NUM; i++)
+		if (info->board->must_hwid == Gpci_uart_info[i].type) {
+			info->rx_low_water = Gpci_uart_info[i].rx_low_water;
+			info->rx_high_water = Gpci_uart_info[i].rx_high_water;
+			info->xmit_fifo_size = Gpci_uart_info[i].fifo_size;
+			break;
+		}
 }
 
 static int mxser_carrier_raised(struct tty_port *port)
@@ -1149,7 +1151,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,
 
 		info->type = ss->type;
 
-		process_txrx_fifo(info);
+		mxser_process_txrx_fifo(info);
 	}
 
 	if (tty_port_initialized(port)) {
@@ -1895,7 +1897,7 @@ static void mxser_initbrd(struct mxser_board *brd, bool high_baud)
 
 		info->type = PORT_16550A;
 
-		process_txrx_fifo(info);
+		mxser_process_txrx_fifo(info);
 
 		info->port.close_delay = 5 * HZ / 10;
 		info->port.closing_wait = 30 * HZ;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 50/70] mxser: rework and simplify mxser_open
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (48 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 49/70] mxser: cleanup mxser_process_txrx_fifo Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 51/70] mxser: make mxser_board::idx really an index Jiri Slaby
                   ` (20 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

In mxser_open, tty->port is already set thanks to
tty_port_register_device in ->probe. So we can simply use container_of
to deduce the struct mxser_port's pointer. Thus avoiding divisions and
complex computations.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 1e54e94a7ca6..ea5e61a5a173 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -856,15 +856,12 @@ static void mxser_shutdown_port(struct tty_port *port)
  */
 static int mxser_open(struct tty_struct *tty, struct file *filp)
 {
-	struct mxser_port *info;
-	int line = tty->index;
+	struct tty_port *tport = tty->port;
+	struct mxser_port *port = container_of(tport, struct mxser_port, port);
 
-	info = &mxser_boards[line / MXSER_PORTS_PER_BOARD].ports[line % MXSER_PORTS_PER_BOARD];
-	if (!info->ioaddr)
-		return -ENODEV;
+	tty->driver_data = port;
 
-	tty->driver_data = info;
-	return tty_port_open(&info->port, tty, filp);
+	return tty_port_open(tport, tty, filp);
 }
 
 static void mxser_flush_buffer(struct tty_struct *tty)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 51/70] mxser: make mxser_board::idx really an index
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (49 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 50/70] mxser: rework and simplify mxser_open Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 52/70] mxser: alloc struct mxser_board dynamically Jiri Slaby
                   ` (19 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

mxser_board::idx is named as index, but actually contain a base. So
assign index there. And for base, introduce a local variable.

This is needed for the next patch (use index as a bit index).

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index ea5e61a5a173..30b3a5ab6bea 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1910,7 +1910,7 @@ static int mxser_probe(struct pci_dev *pdev,
 		const struct pci_device_id *ent)
 {
 	struct mxser_board *brd;
-	unsigned int i;
+	unsigned int i, base;
 	unsigned long ioaddress;
 	unsigned short nports = MXSER_NPORTS(ent->driver_data);
 	struct device *tty_dev;
@@ -1927,7 +1927,8 @@ static int mxser_probe(struct pci_dev *pdev,
 	}
 
 	brd = &mxser_boards[i];
-	brd->idx = i * MXSER_PORTS_PER_BOARD;
+	brd->idx = i;
+	base = i * MXSER_PORTS_PER_BOARD;
 
 	retval = pcim_enable_device(pdev);
 	if (retval) {
@@ -1966,12 +1967,12 @@ static int mxser_probe(struct pci_dev *pdev,
 
 	for (i = 0; i < nports; i++) {
 		tty_dev = tty_port_register_device(&brd->ports[i].port,
-				mxvar_sdriver, brd->idx + i, &pdev->dev);
+				mxvar_sdriver, base + i, &pdev->dev);
 		if (IS_ERR(tty_dev)) {
 			retval = PTR_ERR(tty_dev);
 			for (; i > 0; i--)
 				tty_unregister_device(mxvar_sdriver,
-					brd->idx + i - 1);
+					base + i - 1);
 			goto err_relbrd;
 		}
 	}
@@ -1991,10 +1992,10 @@ static int mxser_probe(struct pci_dev *pdev,
 static void mxser_remove(struct pci_dev *pdev)
 {
 	struct mxser_board *brd = pci_get_drvdata(pdev);
-	unsigned int i;
+	unsigned int i, base = brd->idx * MXSER_PORTS_PER_BOARD;
 
 	for (i = 0; i < brd->nports; i++) {
-		tty_unregister_device(mxvar_sdriver, brd->idx + i);
+		tty_unregister_device(mxvar_sdriver, base + i);
 		tty_port_destroy(&brd->ports[i].port);
 	}
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 52/70] mxser: alloc struct mxser_board dynamically
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (50 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 51/70] mxser: make mxser_board::idx really an index Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:14 ` [PATCH 53/70] mxser: alloc only needed # of ports Jiri Slaby
                   ` (18 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

There is no need to preallocate an array of four struct mxser_board's.
In most cases a single board or two will be present in a machine. So
allocate struct mxser_board as needed in ->probe.

This makes mxser_boards a bit array. There we store which indexes are
free (unallocated).

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 30b3a5ab6bea..0e99225e260f 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -278,7 +278,7 @@ struct mxser_board {
 	struct mxser_port ports[MXSER_PORTS_PER_BOARD];
 };
 
-static struct mxser_board mxser_boards[MXSER_BOARDS];
+static DECLARE_BITMAP(mxser_boards, MXSER_BOARDS);
 static struct tty_driver *mxvar_sdriver;
 
 static u8 __mxser_must_set_EFR(unsigned long baseio, u8 clear, u8 set,
@@ -1916,31 +1916,32 @@ static int mxser_probe(struct pci_dev *pdev,
 	struct device *tty_dev;
 	int retval = -EINVAL;
 
-	for (i = 0; i < MXSER_BOARDS; i++)
-		if (mxser_boards[i].nports == 0)
-			break;
-
+	i = find_first_zero_bit(mxser_boards, MXSER_BOARDS);
 	if (i >= MXSER_BOARDS) {
 		dev_err(&pdev->dev, "too many boards found (maximum %d), board "
 				"not configured\n", MXSER_BOARDS);
 		goto err;
 	}
 
-	brd = &mxser_boards[i];
+	brd = devm_kzalloc(&pdev->dev, sizeof(*brd), GFP_KERNEL);
+	if (!brd)
+		goto err;
+
 	brd->idx = i;
+	__set_bit(brd->idx, mxser_boards);
 	base = i * MXSER_PORTS_PER_BOARD;
 
 	retval = pcim_enable_device(pdev);
 	if (retval) {
 		dev_err(&pdev->dev, "PCI enable failed\n");
-		goto err;
+		goto err_zero;
 	}
 
 	/* io address */
 	ioaddress = pci_resource_start(pdev, 2);
 	retval = pci_request_region(pdev, 2, "mxser(IO)");
 	if (retval)
-		goto err;
+		goto err_zero;
 
 	brd->nports = nports;
 	for (i = 0; i < nports; i++)
@@ -1984,7 +1985,7 @@ static int mxser_probe(struct pci_dev *pdev,
 	for (i = 0; i < nports; i++)
 		tty_port_destroy(&brd->ports[i].port);
 err_zero:
-	brd->nports = 0;
+	__clear_bit(brd->idx, mxser_boards);
 err:
 	return retval;
 }
@@ -1999,7 +2000,7 @@ static void mxser_remove(struct pci_dev *pdev)
 		tty_port_destroy(&brd->ports[i].port);
 	}
 
-	brd->nports = 0;
+	__clear_bit(brd->idx, mxser_boards);
 }
 
 static struct pci_driver mxser_driver = {
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 53/70] mxser: alloc only needed # of ports
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (51 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 52/70] mxser: alloc struct mxser_board dynamically Jiri Slaby
@ 2021-06-18  6:14 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 54/70] mxser: remove pointless ioaddr checks Jiri Slaby
                   ` (17 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Many boards have only 2 ports. But we always allocate 8 ports (struct
mxser_port) in each struct mxser_board.

Switch this to an empty/variable sized array ([]) and allocate the
needed number of ports using struct_size helper in ->probe.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 0e99225e260f..81e2b72fca3f 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -275,7 +275,7 @@ struct mxser_board {
 	enum mxser_must_hwid must_hwid;
 	speed_t max_baud;
 
-	struct mxser_port ports[MXSER_PORTS_PER_BOARD];
+	struct mxser_port ports[];
 };
 
 static DECLARE_BITMAP(mxser_boards, MXSER_BOARDS);
@@ -1923,7 +1923,8 @@ static int mxser_probe(struct pci_dev *pdev,
 		goto err;
 	}
 
-	brd = devm_kzalloc(&pdev->dev, sizeof(*brd), GFP_KERNEL);
+	brd = devm_kzalloc(&pdev->dev, struct_size(brd, ports, nports),
+			GFP_KERNEL);
 	if (!brd)
 		goto err;
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 54/70] mxser: remove pointless ioaddr checks
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (52 preceding siblings ...)
  2021-06-18  6:14 ` [PATCH 53/70] mxser: alloc only needed # of ports Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 55/70] mxser: cleanup mxser_rs_break Jiri Slaby
                   ` (16 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

struct mxser_port::ioaddr can never be NULL once set in ->probe. Hence
the checks for it are pointless. Remove them.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 81e2b72fca3f..e5f8d08de8fd 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -446,9 +446,6 @@ static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
 	unsigned char cval;
 	u64 timeout;
 
-	if (!info->ioaddr)
-		return -1;
-
 	if (newspd > info->board->max_baud)
 		return -1;
 
@@ -519,8 +516,6 @@ static void mxser_change_speed(struct tty_struct *tty)
 	unsigned char status;
 
 	cflag = tty->termios.c_cflag;
-	if (!info->ioaddr)
-		return;
 
 	mxser_set_baud(tty, tty_get_baud_rate(tty));
 
@@ -724,7 +719,7 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
 
 	spin_lock_irqsave(&info->slock, flags);
 
-	if (!info->ioaddr || !info->type) {
+	if (!info->type) {
 		set_bit(TTY_IO_ERROR, &tty->flags);
 		free_page(page);
 		spin_unlock_irqrestore(&info->slock, flags);
@@ -1097,10 +1092,6 @@ static int mxser_set_serial_info(struct tty_struct *tty,
 		return -EIO;
 
 	mutex_lock(&port->mutex);
-	if (!info->ioaddr) {
-		mutex_unlock(&port->mutex);
-		return -ENODEV;
-	}
 
 	if (ss->irq != info->board->irq ||
 			ss->port != info->ioaddr) {
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 55/70] mxser: cleanup mxser_rs_break
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (53 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 54/70] mxser: remove pointless ioaddr checks Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 56/70] mxser: cleanup mxser_dtr_rts Jiri Slaby
                   ` (15 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

mxser_rs_break now does all inb, outb, & or | in a single statement. The
code is hard to follow, so make it more readable by doing one-line =
one-statement.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index e5f8d08de8fd..5789c4343f10 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1553,15 +1553,17 @@ static int mxser_rs_break(struct tty_struct *tty, int break_state)
 {
 	struct mxser_port *info = tty->driver_data;
 	unsigned long flags;
+	u8 lcr;
 
 	spin_lock_irqsave(&info->slock, flags);
+	lcr = inb(info->ioaddr + UART_LCR);
 	if (break_state == -1)
-		outb(inb(info->ioaddr + UART_LCR) | UART_LCR_SBC,
-			info->ioaddr + UART_LCR);
+		lcr |= UART_LCR_SBC;
 	else
-		outb(inb(info->ioaddr + UART_LCR) & ~UART_LCR_SBC,
-			info->ioaddr + UART_LCR);
+		lcr &= ~UART_LCR_SBC;
+	outb(lcr, info->ioaddr + UART_LCR);
 	spin_unlock_irqrestore(&info->slock, flags);
+
 	return 0;
 }
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 56/70] mxser: cleanup mxser_dtr_rts
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (54 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 55/70] mxser: cleanup mxser_rs_break Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 57/70] mxser: don't start TX from tty_operations::put_char Jiri Slaby
                   ` (14 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

mxser_dtr_rts now does all inb, outb, & or | in a single statement.  The
code is hard to follow, so make it more readable by doing one-line =
one-statement.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 5789c4343f10..daf820c086f4 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -428,14 +428,15 @@ static void mxser_dtr_rts(struct tty_port *port, int on)
 {
 	struct mxser_port *mp = container_of(port, struct mxser_port, port);
 	unsigned long flags;
+	u8 mcr;
 
 	spin_lock_irqsave(&mp->slock, flags);
+	mcr = inb(mp->ioaddr + UART_MCR);
 	if (on)
-		outb(inb(mp->ioaddr + UART_MCR) |
-			UART_MCR_DTR | UART_MCR_RTS, mp->ioaddr + UART_MCR);
+		mcr |= UART_MCR_DTR | UART_MCR_RTS;
 	else
-		outb(inb(mp->ioaddr + UART_MCR)&~(UART_MCR_DTR | UART_MCR_RTS),
-			mp->ioaddr + UART_MCR);
+		mcr &= ~(UART_MCR_DTR | UART_MCR_RTS);
+	outb(mcr, mp->ioaddr + UART_MCR);
 	spin_unlock_irqrestore(&mp->slock, flags);
 }
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 57/70] mxser: don't start TX from tty_operations::put_char
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (55 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 56/70] mxser: cleanup mxser_dtr_rts Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 58/70] mxser: extract and dedup CTS handling Jiri Slaby
                   ` (13 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

TX is not supposed to be started from tty_operations::put_char. Line
disciplines ought to call tty_operations::put_char several times and
then do a single tty_operations::flush_chars to start TX.

Fix this in mxser by removing TX startup from mxser_put_char.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index daf820c086f4..52dbdd4282b2 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -998,17 +998,7 @@ static int mxser_put_char(struct tty_struct *tty, unsigned char ch)
 	info->xmit_head &= SERIAL_XMIT_SIZE - 1;
 	info->xmit_cnt++;
 	spin_unlock_irqrestore(&info->slock, flags);
-	if (!tty->flow.stopped) {
-		if (!tty->hw_stopped ||
-				(info->type == PORT_16550A) ||
-				info->board->must_hwid) {
-			spin_lock_irqsave(&info->slock, flags);
-			outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
-			info->IER |= UART_IER_THRI;
-			outb(info->IER, info->ioaddr + UART_IER);
-			spin_unlock_irqrestore(&info->slock, flags);
-		}
-	}
+
 	return 1;
 }
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 58/70] mxser: extract and dedup CTS handling
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (56 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 57/70] mxser: don't start TX from tty_operations::put_char Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 59/70] mxser: introduce and use start/stop_tx helpers Jiri Slaby
                   ` (12 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

CTS is handled on two locations in mxser. Extract the code into
separation function mxser_handle_cts. And call it from the two
locations.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/mxser.c | 87 +++++++++++++++++----------------------------
 1 file changed, 33 insertions(+), 54 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 52dbdd4282b2..00363d98277e 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -506,6 +506,35 @@ static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
 	return 0;
 }
 
+static void mxser_handle_cts(struct tty_struct *tty, struct mxser_port *info,
+		u8 msr)
+{
+	bool cts = msr & UART_MSR_CTS;
+
+	if (tty->hw_stopped) {
+		if (cts) {
+			tty->hw_stopped = 0;
+
+			if (info->type != PORT_16550A &&
+					!info->board->must_hwid) {
+				outb(info->IER & ~UART_IER_THRI,
+					info->ioaddr + UART_IER);
+				info->IER |= UART_IER_THRI;
+				outb(info->IER, info->ioaddr + UART_IER);
+			}
+			tty_wakeup(tty);
+		}
+		return;
+	} else if (cts)
+		return;
+
+	tty->hw_stopped = 1;
+	if (info->type != PORT_16550A && !info->board->must_hwid) {
+		info->IER &= ~UART_IER_THRI;
+		outb(info->IER, info->ioaddr + UART_IER);
+	}
+}
+
 /*
  * This routine is called to set the UART divisor registers to match
  * the specified baud rate for a serial port.
@@ -514,7 +543,6 @@ static void mxser_change_speed(struct tty_struct *tty)
 {
 	struct mxser_port *info = tty->driver_data;
 	unsigned cflag, cval, fcr;
-	unsigned char status;
 
 	cflag = tty->termios.c_cflag;
 
@@ -585,32 +613,8 @@ static void mxser_change_speed(struct tty_struct *tty)
 		if ((info->type == PORT_16550A) || (info->board->must_hwid)) {
 			info->MCR |= UART_MCR_AFE;
 		} else {
-			status = inb(info->ioaddr + UART_MSR);
-			if (tty->hw_stopped) {
-				if (status & UART_MSR_CTS) {
-					tty->hw_stopped = 0;
-					if (info->type != PORT_16550A &&
-							!info->board->must_hwid) {
-						outb(info->IER & ~UART_IER_THRI,
-							info->ioaddr +
-							UART_IER);
-						info->IER |= UART_IER_THRI;
-						outb(info->IER, info->ioaddr +
-								UART_IER);
-					}
-					tty_wakeup(tty);
-				}
-			} else {
-				if (!(status & UART_MSR_CTS)) {
-					tty->hw_stopped = 1;
-					if ((info->type != PORT_16550A) &&
-							(!info->board->must_hwid)) {
-						info->IER &= ~UART_IER_THRI;
-						outb(info->IER, info->ioaddr +
-								UART_IER);
-					}
-				}
-			}
+			mxser_handle_cts(tty, info,
+					inb(info->ioaddr + UART_MSR));
 		}
 	}
 	outb(info->MCR, info->ioaddr + UART_MCR);
@@ -679,33 +683,8 @@ static void mxser_check_modem_status(struct tty_struct *tty,
 			wake_up_interruptible(&port->port.open_wait);
 	}
 
-	if (tty_port_cts_enabled(&port->port)) {
-		if (tty->hw_stopped) {
-			if (status & UART_MSR_CTS) {
-				tty->hw_stopped = 0;
-
-				if ((port->type != PORT_16550A) &&
-						(!port->board->must_hwid)) {
-					outb(port->IER & ~UART_IER_THRI,
-						port->ioaddr + UART_IER);
-					port->IER |= UART_IER_THRI;
-					outb(port->IER, port->ioaddr +
-							UART_IER);
-				}
-				tty_wakeup(tty);
-			}
-		} else {
-			if (!(status & UART_MSR_CTS)) {
-				tty->hw_stopped = 1;
-				if (port->type != PORT_16550A &&
-						!port->board->must_hwid) {
-					port->IER &= ~UART_IER_THRI;
-					outb(port->IER, port->ioaddr +
-							UART_IER);
-				}
-			}
-		}
-	}
+	if (tty_port_cts_enabled(&port->port))
+		mxser_handle_cts(tty, port, status);
 }
 
 static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 59/70] mxser: introduce and use start/stop_tx helpers
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (57 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 58/70] mxser: extract and dedup CTS handling Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 60/70] mxser: remove xmit_cnt < 0 tests Jiri Slaby
                   ` (11 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

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>
---
 drivers/tty/mxser.c | 80 +++++++++++++++++++++------------------------
 1 file changed, 37 insertions(+), 43 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 00363d98277e..e46974e9421a 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -418,6 +418,28 @@ static void mxser_process_txrx_fifo(struct mxser_port *info)
 		}
 }
 
+static void __mxser_start_tx(struct mxser_port *info)
+{
+	outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
+	info->IER |= UART_IER_THRI;
+	outb(info->IER, info->ioaddr + UART_IER);
+}
+
+static void mxser_start_tx(struct mxser_port *info)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&info->slock, flags);
+	__mxser_start_tx(info);
+	spin_unlock_irqrestore(&info->slock, flags);
+}
+
+static void __mxser_stop_tx(struct mxser_port *info)
+{
+	info->IER &= ~UART_IER_THRI;
+	outb(info->IER, info->ioaddr + UART_IER);
+}
+
 static int mxser_carrier_raised(struct tty_port *port)
 {
 	struct mxser_port *mp = container_of(port, struct mxser_port, port);
@@ -516,12 +538,8 @@ static void mxser_handle_cts(struct tty_struct *tty, struct mxser_port *info,
 			tty->hw_stopped = 0;
 
 			if (info->type != PORT_16550A &&
-					!info->board->must_hwid) {
-				outb(info->IER & ~UART_IER_THRI,
-					info->ioaddr + UART_IER);
-				info->IER |= UART_IER_THRI;
-				outb(info->IER, info->ioaddr + UART_IER);
-			}
+					!info->board->must_hwid)
+				__mxser_start_tx(info);
 			tty_wakeup(tty);
 		}
 		return;
@@ -529,10 +547,8 @@ static void mxser_handle_cts(struct tty_struct *tty, struct mxser_port *info,
 		return;
 
 	tty->hw_stopped = 1;
-	if (info->type != PORT_16550A && !info->board->must_hwid) {
-		info->IER &= ~UART_IER_THRI;
-		outb(info->IER, info->ioaddr + UART_IER);
-	}
+	if (info->type != PORT_16550A && !info->board->must_hwid)
+		__mxser_stop_tx(info);
 }
 
 /*
@@ -947,16 +963,9 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
 	}
 
 	if (info->xmit_cnt && !tty->flow.stopped) {
-		if (!tty->hw_stopped ||
-				(info->type == PORT_16550A) ||
-				(info->board->must_hwid)) {
-			spin_lock_irqsave(&info->slock, flags);
-			outb(info->IER & ~UART_IER_THRI, info->ioaddr +
-					UART_IER);
-			info->IER |= UART_IER_THRI;
-			outb(info->IER, info->ioaddr + UART_IER);
-			spin_unlock_irqrestore(&info->slock, flags);
-		}
+		if (!tty->hw_stopped || info->type == PORT_16550A ||
+				info->board->must_hwid)
+			mxser_start_tx(info);
 	}
 	return total;
 }
@@ -985,20 +994,13 @@ static int mxser_put_char(struct tty_struct *tty, unsigned char ch)
 static void mxser_flush_chars(struct tty_struct *tty)
 {
 	struct mxser_port *info = tty->driver_data;
-	unsigned long flags;
 
 	if (info->xmit_cnt <= 0 || tty->flow.stopped || !info->port.xmit_buf ||
 			(tty->hw_stopped && info->type != PORT_16550A &&
 			 !info->board->must_hwid))
 		return;
 
-	spin_lock_irqsave(&info->slock, flags);
-
-	outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
-	info->IER |= UART_IER_THRI;
-	outb(info->IER, info->ioaddr + UART_IER);
-
-	spin_unlock_irqrestore(&info->slock, flags);
+	mxser_start_tx(info);
 }
 
 static unsigned int mxser_write_room(struct tty_struct *tty)
@@ -1399,10 +1401,8 @@ static void mxser_stop(struct tty_struct *tty)
 	unsigned long flags;
 
 	spin_lock_irqsave(&info->slock, flags);
-	if (info->IER & UART_IER_THRI) {
-		info->IER &= ~UART_IER_THRI;
-		outb(info->IER, info->ioaddr + UART_IER);
-	}
+	if (info->IER & UART_IER_THRI)
+		__mxser_stop_tx(info);
 	spin_unlock_irqrestore(&info->slock, flags);
 }
 
@@ -1412,11 +1412,8 @@ static void mxser_start(struct tty_struct *tty)
 	unsigned long flags;
 
 	spin_lock_irqsave(&info->slock, flags);
-	if (info->xmit_cnt && info->port.xmit_buf) {
-		outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
-		info->IER |= UART_IER_THRI;
-		outb(info->IER, info->ioaddr + UART_IER);
-	}
+	if (info->xmit_cnt && info->port.xmit_buf)
+		__mxser_start_tx(info);
 	spin_unlock_irqrestore(&info->slock, flags);
 }
 
@@ -1659,8 +1656,7 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 			(tty->hw_stopped &&
 			(port->type != PORT_16550A) &&
 			(!port->board->must_hwid))) {
-		port->IER &= ~UART_IER_THRI;
-		outb(port->IER, port->ioaddr + UART_IER);
+		__mxser_stop_tx(port);
 		return;
 	}
 
@@ -1679,10 +1675,8 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 	if (port->xmit_cnt < WAKEUP_CHARS)
 		tty_wakeup(tty);
 
-	if (port->xmit_cnt <= 0) {
-		port->IER &= ~UART_IER_THRI;
-		outb(port->IER, port->ioaddr + UART_IER);
-	}
+	if (port->xmit_cnt <= 0)
+		__mxser_stop_tx(port);
 }
 
 static bool mxser_port_isr(struct mxser_port *port)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 60/70] mxser: remove xmit_cnt < 0 tests
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (58 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 59/70] mxser: introduce and use start/stop_tx helpers Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 61/70] mxser: decrypt FCR values Jiri Slaby
                   ` (10 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

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>
---
 drivers/tty/mxser.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index e46974e9421a..1a8698e58b1c 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -995,7 +995,7 @@ static void mxser_flush_chars(struct tty_struct *tty)
 {
 	struct mxser_port *info = tty->driver_data;
 
-	if (info->xmit_cnt <= 0 || tty->flow.stopped || !info->port.xmit_buf ||
+	if (!info->xmit_cnt || tty->flow.stopped || !info->port.xmit_buf ||
 			(tty->hw_stopped && info->type != PORT_16550A &&
 			 !info->board->must_hwid))
 		return;
@@ -1652,7 +1652,7 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 	if (port->port.xmit_buf == NULL)
 		return;
 
-	if (port->xmit_cnt <= 0 || tty->flow.stopped ||
+	if (!port->xmit_cnt || tty->flow.stopped ||
 			(tty->hw_stopped &&
 			(port->type != PORT_16550A) &&
 			(!port->board->must_hwid))) {
@@ -1666,7 +1666,7 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 		outb(port->port.xmit_buf[port->xmit_tail++],
 			port->ioaddr + UART_TX);
 		port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE - 1);
-		if (--port->xmit_cnt <= 0)
+		if (!--port->xmit_cnt)
 			break;
 	} while (--count > 0);
 
@@ -1675,7 +1675,7 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 	if (port->xmit_cnt < WAKEUP_CHARS)
 		tty_wakeup(tty);
 
-	if (port->xmit_cnt <= 0)
+	if (!port->xmit_cnt)
 		__mxser_stop_tx(port);
 }
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 61/70] mxser: decrypt FCR values
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (59 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 60/70] mxser: remove xmit_cnt < 0 tests Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 62/70] mxser: fix typos around enhanced mode Jiri Slaby
                   ` (9 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

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>
---
 drivers/tty/mxser.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 1a8698e58b1c..c8ba062d8824 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1580,7 +1580,9 @@ static u8 mxser_receive_chars_old(struct tty_struct *tty,
 
 		ch = inb(port->ioaddr + UART_RX);
 		if (hwid && (status & UART_LSR_OE))
-			outb(0x23, port->ioaddr + UART_FCR);
+			outb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR |
+					MOXA_MUST_FCR_GDA_MODE_ENABLE,
+					port->ioaddr + UART_FCR);
 		status &= port->read_status_mask;
 		if (status & port->ignore_status_mask) {
 			if (++ignored > 100)
@@ -1693,7 +1695,9 @@ static bool mxser_port_isr(struct mxser_port *port)
 	tty = tty_port_tty_get(&port->port);
 	if (!tty || port->closing || !tty_port_initialized(&port->port)) {
 		status = inb(port->ioaddr + UART_LSR);
-		outb(0x27, port->ioaddr + UART_FCR);
+		outb(MOXA_MUST_FCR_GDA_MODE_ENABLE | UART_FCR_ENABLE_FIFO |
+				UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT,
+				port->ioaddr + UART_FCR);
 		inb(port->ioaddr + UART_MSR);
 
 		error = true;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 62/70] mxser: fix typos around enhanced mode
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (60 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 61/70] mxser: decrypt FCR values Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 63/70] mxser: access info->MCR under info->slock Jiri Slaby
                   ` (8 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

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>
---
 drivers/tty/mxser.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index c8ba062d8824..54b9a9c7c9e9 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -64,23 +64,23 @@
 /*
  * Follow just what Moxa Must chip defines.
  *
- * When LCR register (offset 0x03) writes the following value, the Must chip
- * will enter enchance mode. And write value on EFR (offset 0x02) bit 6,7 to
+ * When LCR register (offset 0x03) is written the following value, the Must chip
+ * will enter enhanced mode. And a write to EFR (offset 0x02) bit 6,7 will
  * change bank.
  */
-#define MOXA_MUST_ENTER_ENCHANCE	0xBF
+#define MOXA_MUST_ENTER_ENHANCED	0xBF
 
-/* when enhance mode enabled, access on general bank register */
+/* when enhanced mode is enabled, access to general bank register */
 #define MOXA_MUST_GDL_REGISTER		0x07
 #define MOXA_MUST_GDL_MASK		0x7F
 #define MOXA_MUST_GDL_HAS_BAD_DATA	0x80
 
 #define MOXA_MUST_LSR_RERR		0x80	/* error in receive FIFO */
-/* enchance register bank select and enchance mode setting register */
-/* when LCR register equals to 0xBF */
+/* enhanced register bank select and enhanced mode setting register */
+/* This works only when LCR register equals to 0xBF */
 #define MOXA_MUST_EFR_REGISTER		0x02
-#define MOXA_MUST_EFR_EFRB_ENABLE	0x10 /* enchance mode enable */
-/* enchance register bank set 0, 1, 2 */
+#define MOXA_MUST_EFR_EFRB_ENABLE	0x10 /* enhanced mode enable */
+/* enhanced register bank set 0, 1, 2 */
 #define MOXA_MUST_EFR_BANK0		0x00
 #define MOXA_MUST_EFR_BANK1		0x40
 #define MOXA_MUST_EFR_BANK2		0x80
@@ -287,7 +287,7 @@ static u8 __mxser_must_set_EFR(unsigned long baseio, u8 clear, u8 set,
 	u8 oldlcr, efr;
 
 	oldlcr = inb(baseio + UART_LCR);
-	outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
+	outb(MOXA_MUST_ENTER_ENHANCED, baseio + UART_LCR);
 
 	efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
 	efr &= ~clear;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 63/70] mxser: access info->MCR under info->slock
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (61 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 62/70] mxser: fix typos around enhanced mode Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 64/70] mxser: use port variable in mxser_set_serial_info Jiri Slaby
                   ` (7 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

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>
---
 drivers/tty/mxser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 54b9a9c7c9e9..5dd121450813 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1162,13 +1162,13 @@ static int mxser_tiocmget(struct tty_struct *tty)
 	if (tty_io_error(tty))
 		return -EIO;
 
-	control = info->MCR;
-
 	spin_lock_irqsave(&info->slock, flags);
+	control = info->MCR;
 	status = inb(info->ioaddr + UART_MSR);
 	if (status & UART_MSR_ANY_DELTA)
 		mxser_check_modem_status(tty, info, status);
 	spin_unlock_irqrestore(&info->slock, flags);
+
 	return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) |
 		    ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) |
 		    ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) |
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 64/70] mxser: use port variable in mxser_set_serial_info
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (62 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 63/70] mxser: access info->MCR under info->slock Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 65/70] mxser: rename flags to old_speed " Jiri Slaby
                   ` (6 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

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>
---
 drivers/tty/mxser.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 5dd121450813..2f724b4d3f43 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1080,14 +1080,14 @@ static int mxser_set_serial_info(struct tty_struct *tty,
 
 	if (!capable(CAP_SYS_ADMIN)) {
 		if ((ss->baud_base != MXSER_BAUD_BASE) ||
-				(close_delay != info->port.close_delay) ||
-				(closing_wait != info->port.closing_wait) ||
-				((ss->flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK))) {
+				(close_delay != port->close_delay) ||
+				(closing_wait != port->closing_wait) ||
+				((ss->flags & ~ASYNC_USR_MASK) != (port->flags & ~ASYNC_USR_MASK))) {
 			mutex_unlock(&port->mutex);
 			return -EPERM;
 		}
-		info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) |
-				(ss->flags & ASYNC_USR_MASK));
+		port->flags = (port->flags & ~ASYNC_USR_MASK) |
+				(ss->flags & ASYNC_USR_MASK);
 	} else {
 		/*
 		 * OK, past this point, all the error checking has been done.
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 65/70] mxser: rename flags to old_speed in mxser_set_serial_info
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (63 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 64/70] mxser: use port variable in mxser_set_serial_info Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 66/70] mxser: introduce mxser_16550A_or_MUST helper Jiri Slaby
                   ` (5 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

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>
---
 drivers/tty/mxser.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 2f724b4d3f43..f238d17d6fdf 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1057,7 +1057,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,
 	struct tty_port *port = &info->port;
 	speed_t baud;
 	unsigned long sl_flags;
-	unsigned int flags, close_delay, closing_wait;
+	unsigned int old_speed, close_delay, closing_wait;
 	int retval = 0;
 
 	if (tty_io_error(tty))
@@ -1071,7 +1071,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,
 		return -EINVAL;
 	}
 
-	flags = port->flags & ASYNC_SPD_MASK;
+	old_speed = port->flags & ASYNC_SPD_MASK;
 
 	close_delay = msecs_to_jiffies(ss->close_delay * 10);
 	closing_wait = ss->closing_wait;
@@ -1115,7 +1115,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,
 	}
 
 	if (tty_port_initialized(port)) {
-		if (flags != (port->flags & ASYNC_SPD_MASK)) {
+		if (old_speed != (port->flags & ASYNC_SPD_MASK)) {
 			spin_lock_irqsave(&info->slock, sl_flags);
 			mxser_change_speed(tty);
 			spin_unlock_irqrestore(&info->slock, sl_flags);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 66/70] mxser: introduce mxser_16550A_or_MUST helper
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (64 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 65/70] mxser: rename flags to old_speed " Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 67/70] mxser: Documentation, remove traces of callout device Jiri Slaby
                   ` (4 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

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>
---
 drivers/tty/mxser.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index f238d17d6fdf..900ccb2ca166 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -398,6 +398,11 @@ static enum mxser_must_hwid mxser_must_get_hwid(unsigned long io)
 	return MOXA_OTHER_UART;
 }
 
+static bool mxser_16550A_or_MUST(struct mxser_port *info)
+{
+	return info->type == PORT_16550A || info->board->must_hwid;
+}
+
 static void mxser_process_txrx_fifo(struct mxser_port *info)
 {
 	unsigned int i;
@@ -537,8 +542,7 @@ static void mxser_handle_cts(struct tty_struct *tty, struct mxser_port *info,
 		if (cts) {
 			tty->hw_stopped = 0;
 
-			if (info->type != PORT_16550A &&
-					!info->board->must_hwid)
+			if (!mxser_16550A_or_MUST(info))
 				__mxser_start_tx(info);
 			tty_wakeup(tty);
 		}
@@ -547,7 +551,7 @@ static void mxser_handle_cts(struct tty_struct *tty, struct mxser_port *info,
 		return;
 
 	tty->hw_stopped = 1;
-	if (info->type != PORT_16550A && !info->board->must_hwid)
+	if (!mxser_16550A_or_MUST(info))
 		__mxser_stop_tx(info);
 }
 
@@ -626,7 +630,7 @@ static void mxser_change_speed(struct tty_struct *tty)
 	tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
 	if (cflag & CRTSCTS) {
 		info->IER |= UART_IER_MSI;
-		if ((info->type == PORT_16550A) || (info->board->must_hwid)) {
+		if (mxser_16550A_or_MUST(info)) {
 			info->MCR |= UART_MCR_AFE;
 		} else {
 			mxser_handle_cts(tty, info,
@@ -962,11 +966,10 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
 		total += c;
 	}
 
-	if (info->xmit_cnt && !tty->flow.stopped) {
-		if (!tty->hw_stopped || info->type == PORT_16550A ||
-				info->board->must_hwid)
+	if (info->xmit_cnt && !tty->flow.stopped)
+		if (!tty->hw_stopped || mxser_16550A_or_MUST(info))
 			mxser_start_tx(info);
-	}
+
 	return total;
 }
 
@@ -996,8 +999,7 @@ static void mxser_flush_chars(struct tty_struct *tty)
 	struct mxser_port *info = tty->driver_data;
 
 	if (!info->xmit_cnt || tty->flow.stopped || !info->port.xmit_buf ||
-			(tty->hw_stopped && info->type != PORT_16550A &&
-			 !info->board->must_hwid))
+			(tty->hw_stopped && !mxser_16550A_or_MUST(info)))
 		return;
 
 	mxser_start_tx(info);
@@ -1655,9 +1657,7 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 		return;
 
 	if (!port->xmit_cnt || tty->flow.stopped ||
-			(tty->hw_stopped &&
-			(port->type != PORT_16550A) &&
-			(!port->board->must_hwid))) {
+			(tty->hw_stopped && !mxser_16550A_or_MUST(port))) {
 		__mxser_stop_tx(port);
 		return;
 	}
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 67/70] mxser: Documentation, remove traces of callout device
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (65 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 66/70] mxser: introduce mxser_16550A_or_MUST helper Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 68/70] mxser: Documentation, make the docs up-to-date Jiri Slaby
                   ` (3 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Callout devices are ancient history, so remove its traces from mxser's
documentation.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 .../driver-api/serial/moxa-smartio.rst        | 46 +++++--------------
 1 file changed, 12 insertions(+), 34 deletions(-)

diff --git a/Documentation/driver-api/serial/moxa-smartio.rst b/Documentation/driver-api/serial/moxa-smartio.rst
index aedda2546242..3a0a8b502898 100644
--- a/Documentation/driver-api/serial/moxa-smartio.rst
+++ b/Documentation/driver-api/serial/moxa-smartio.rst
@@ -147,13 +147,7 @@ or::
    run the driver. If you prefer module driver, please refer to 3.4.
    If static driver is required, please refer to 3.5.
 
-Dialin and callout port
------------------------
-
-   This driver remains traditional serial device properties. There are
-   two special file name for each serial port. One is dial-in port
-   which is named "ttyMxx". For callout port, the naming convention
-   is "cumxx".
+   The device node is named "ttyMxx".
 
 Device naming when more than 2 boards installed
 -----------------------------------------------
@@ -161,18 +155,13 @@ Device naming when more than 2 boards installed
    Naming convention for each Smartio/Industio multiport board is
    pre-defined as below.
 
-   ============ ===============       ==============
-   Board Num.	 Dial-in Port	      Callout port
-   1st board	ttyM0  - ttyM7	      cum0  - cum7
-   2nd board	ttyM8  - ttyM15       cum8  - cum15
-   3rd board	ttyM16 - ttyM23       cum16 - cum23
-   4th board	ttyM24 - ttym31       cum24 - cum31
-   ============ ===============       ==============
-
-.. note::
-
-   Under Kernel 2.6 and upper, the cum Device is Obsolete. So use ttyM*
-   device instead.
+   ============ ===============
+   Board Num.	Device node
+   1st board	ttyM0  - ttyM7
+   2nd board	ttyM8  - ttyM15
+   3rd board	ttyM16 - ttyM23
+   4th board	ttyM24 - ttyM31
+   ============ ===============
 
 3.4 Module driver configuration
 ===============================
@@ -204,13 +193,10 @@ Device naming when more than 2 boards installed
 	 # cd /moxa/mxser/driver
 	 # ./msmknod
 
-   This shell script will require the major number for dial-in
-   device and callout device to create tty device. You also need
-   to specify the total installed MOXA board number. Default major
-   numbers for dial-in device and callout device are 30, 35. If
-   you need to change to other number, please refer section "3.7"
-   for more detailed procedure.
-   Msmknod will delete any special files occupying the same device
+   This shell script will require the major number for the device. You also
+   need to specify the total installed MOXA board number. If you need to
+   change to other number, please refer section "3.7" for more detailed
+   procedure. Msmknod will delete any special files occupying the same device
    naming.
 
 3.4.2 Build the MOXA driver and utilities
@@ -516,11 +502,3 @@ msterm - Terminal Emulation
    Load Moxa driver fail, the major number may conflict with other devices.
    Please refer to previous section 3.7 to change a free major number for
    Moxa driver.
-
-   Error msg:
-              Couldn't install MOXA Smartio/Industio family callout driver!
-
-   Solution:
-   Load Moxa callout driver fail, the callout device major number may
-   conflict with other devices. Please refer to previous section 3.7 to
-   change a free callout device major number for Moxa driver.
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 68/70] mxser: Documentation, make the docs up-to-date
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (66 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 67/70] mxser: Documentation, remove traces of callout device Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 69/70] mxser: Documentation, fix typos Jiri Slaby
                   ` (2 subsequent siblings)
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Remove all the obsolete information from the documentation of mxser
driver. Either it was about the out-of-tree driver, or it was superseded
by udev et al.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 .../driver-api/serial/moxa-smartio.rst        | 325 +-----------------
 1 file changed, 9 insertions(+), 316 deletions(-)

diff --git a/Documentation/driver-api/serial/moxa-smartio.rst b/Documentation/driver-api/serial/moxa-smartio.rst
index 3a0a8b502898..838888f81b6d 100644
--- a/Documentation/driver-api/serial/moxa-smartio.rst
+++ b/Documentation/driver-api/serial/moxa-smartio.rst
@@ -2,14 +2,8 @@
 MOXA Smartio/Industio Family Device Driver Installation Guide
 =============================================================
 
-.. note::
-
-   This file is outdated. It needs some care in order to make it
-   updated to Kernel 5.0 and upper
-
 Copyright (C) 2008, Moxa Inc.
-
-Date: 01/21/2008
+Copyright (C) 2021, Jiri Slaby
 
 .. Content
 
@@ -17,12 +11,7 @@ Date: 01/21/2008
    2. System Requirement
    3. Installation
       3.1 Hardware installation
-      3.2 Driver files
-      3.3 Device naming convention
-      3.4 Module driver configuration
-      3.5 Static driver configuration for Linux kernel 2.4.x and 2.6.x.
-      3.6 Custom configuration
-      3.7 Verify driver installation
+      3.2 Device naming convention
    4. Utilities
    5. Setserial
    6. Troubleshooting
@@ -56,11 +45,8 @@ Date: 01/21/2008
 	C168H/PCI,
 	CB-108
 
-   This driver and installation procedure have been developed upon Linux Kernel
-   2.4.x and 2.6.x. This driver supports Intel x86 hardware platform. In order
-   to maintain compatibility, this version has also been properly tested with
-   RedHat, Mandrake, Fedora and S.u.S.E Linux. However, if compatibility problem
-   occurs, please contact Moxa at support@moxa.com.tw.
+   If a compatibility problem occurs, please contact Moxa at
+   support@moxa.com.tw.
 
    In addition to device driver, useful utilities are also provided in this
    version. They are:
@@ -77,14 +63,14 @@ Date: 01/21/2008
    GNU General Public License in this version. Please refer to GNU General
    Public License announcement in each source code file for more detail.
 
-   In Moxa's Web sites, you may always find latest driver at http://www.moxa.com/.
+   In Moxa's Web sites, you may always find latest driver at
+   https://www.moxa.com/.
 
    This version of driver can be installed as Loadable Module (Module driver)
-   or built-in into kernel (Static driver). You may refer to following
-   installation procedure for suitable one. Before you install the driver,
+   or built-in into kernel (Static driver). Before you install the driver,
    please refer to hardware installation procedure in the User's Manual.
 
-   We assume the user should be familiar with following documents.
+   We assume the user should be familiar with following documents:
 
    - Serial-HOWTO
    - Kernel-HOWTO
@@ -92,9 +78,6 @@ Date: 01/21/2008
 2. System Requirement
 ^^^^^^^^^^^^^^^^^^^^^
 
-   - Hardware platform: Intel x86 machine
-   - Kernel version: 2.4.x or 2.6.x
-   - gcc version 2.72 or later
    - Maximum 4 boards can be installed in combination
 
 3. Installation
@@ -118,35 +101,10 @@ PCI IRQ Sharing
    together on one system and they can share the same IRQ.
 
 
-3.2 Driver files
-================
-
-   The driver file may be obtained from ftp, CD-ROM or floppy disk. The
-   first step, anyway, is to copy driver file "mxser.tgz" into specified
-   directory. e.g. /moxa. The execute commands as below::
-
-       # cd /
-       # mkdir moxa
-       # cd /moxa
-       # tar xvf /dev/fd0
-
-or::
-
-       # cd /
-       # mkdir moxa
-       # cd /moxa
-       # cp /mnt/cdrom/<driver directory>/mxser.tgz .
-       # tar xvfz mxser.tgz
 
-
-3.3 Device naming convention
+3.2 Device naming convention
 ============================
 
-   You may find all the driver and utilities files in /moxa/mxser.
-   Following installation procedure depends on the model you'd like to
-   run the driver. If you prefer module driver, please refer to 3.4.
-   If static driver is required, please refer to 3.5.
-
    The device node is named "ttyMxx".
 
 Device naming when more than 2 boards installed
@@ -163,245 +121,6 @@ Device naming when more than 2 boards installed
    4th board	ttyM24 - ttyM31
    ============ ===============
 
-3.4 Module driver configuration
-===============================
-
-   Module driver is easiest way to install. If you prefer static driver
-   installation, please skip this paragraph.
-
-
-   ------------- Prepare to use the MOXA driver --------------------
-
-3.4.1 Create tty device with correct major number
--------------------------------------------------
-
-   Before using MOXA driver, your system must have the tty devices
-   which are created with driver's major number. We offer one shell
-   script "msmknod" to simplify the procedure.
-   This step is only needed to be executed once. But you still
-   need to do this procedure when:
-
-   a. You change the driver's major number. Please refer the "3.7"
-      section.
-   b. Your total installed MOXA boards number is changed. Maybe you
-      add/delete one MOXA board.
-   c. You want to change the tty name. This needs to modify the
-      shell script "msmknod"
-
-   The procedure is::
-
-	 # cd /moxa/mxser/driver
-	 # ./msmknod
-
-   This shell script will require the major number for the device. You also
-   need to specify the total installed MOXA board number. If you need to
-   change to other number, please refer section "3.7" for more detailed
-   procedure. Msmknod will delete any special files occupying the same device
-   naming.
-
-3.4.2 Build the MOXA driver and utilities
------------------------------------------
-
-   Before using the MOXA driver and utilities, you need compile the
-   all the source code. This step is only need to be executed once.
-   But you still re-compile the source code if you modify the source
-   code. For example, if you change the driver's major number (see
-   "3.7" section), then you need to do this step again.
-
-   Find "Makefile" in /moxa/mxser, then run
-
-	 # make clean; make install
-
-   ..note::
-
-	 For Red Hat 9, Red Hat Enterprise Linux AS3/ES3/WS3 & Fedora Core1:
-	 # make clean; make installsp1
-
-	 For Red Hat Enterprise Linux AS4/ES4/WS4:
-	 # make clean; make installsp2
-
-   The driver files "mxser.o" and utilities will be properly compiled
-   and copied to system directories respectively.
-
-------------- Load MOXA driver--------------------
-
-3.4.3 Load the MOXA driver
---------------------------
-
-   ::
-
-	 # modprobe mxser
-
-   will activate the module driver. You may run "lsmod" to check
-   if "mxser" is activated.
-
-------------- Load MOXA driver on boot --------------------
-
-3.4.4 Load the mxser driver
----------------------------
-
-
-   For the above description, you may manually execute
-   "modprobe mxser" to activate this driver and run
-   "rmmod mxser" to remove it.
-
-   However, it's better to have a boot time configuration to
-   eliminate manual operation. Boot time configuration can be
-   achieved by rc file. We offer one "rc.mxser" file to simplify
-   the procedure under "moxa/mxser/driver".
-
-   Run following command for setting rc files::
-
-	 # cd /moxa/mxser/driver
-	 # cp ./rc.mxser /etc/rc.d
-	 # cd /etc/rc.d
-
-   Check "rc.serial" is existed or not. If "rc.serial" doesn't exist,
-   create it by vi, run "chmod 755 rc.serial" to change the permission.
-
-   Add "/etc/rc.d/rc.mxser" in last line.
-
-   Reboot and check if moxa.o activated by "lsmod" command.
-
-3.5 Static driver configuration for Linux kernel 2.4.x and 2.6.x
-================================================================
-
-    Note:
-          To use static driver, you must install the linux kernel
-          source package.
-
-3.5.1 Backup the built-in driver in the kernel
-----------------------------------------------
-
-    ::
-
-       # cd /usr/src/linux/drivers/char
-       # mv mxser.c mxser.c.old
-
-       For Red Hat 7.x user, you need to create link:
-       # cd /usr/src
-       # ln -s linux-2.4 linux
-
-3.5.2 Create link
------------------
-    ::
-
-	  # cd /usr/src/linux/drivers/char
-	  # ln -s /moxa/mxser/driver/mxser.c mxser.c
-
-3.5.3 Setup kernel configuration
---------------------------------
-
-    Configure the kernel::
-
-      # cd /usr/src/linux
-      # make menuconfig
-
-    You will go into a menu-driven system. Please select [Character
-    devices][Non-standard serial port support], enable the [Moxa
-    SmartIO support] driver with "[*]" for built-in (not "[M]"), then
-    select [Exit] to exit this program.
-
-3.5.4 Rebuild kernel
---------------------
-
-    The following are for Linux kernel rebuilding, for your
-    reference only.
-
-    For appropriate details, please refer to the Linux document:
-
-        a. Run the following commands::
-
-	     cd /usr/src/linux
-	     make clean		     # take a few minutes
-	     make dep		     # take a few minutes
-	     make bzImage	     # take probably 10-20 minutes
-	     make install	     # copy boot image to correct position
-
-	f. Please make sure the boot kernel (vmlinuz) is in the
-	   correct position.
-	g. If you use 'lilo' utility, you should check /etc/lilo.conf
-	   'image' item specified the path which is the 'vmlinuz' path,
-	   or you will load wrong (or old) boot kernel image (vmlinuz).
-	   After checking /etc/lilo.conf, please run "lilo".
-
-	  Note that if the result of "make bzImage" is ERROR, then you have to
-	  go back to Linux configuration Setup. Type "make menuconfig" in
-          directory /usr/src/linux.
-
-
-3.5.5 Make tty device and special file
---------------------------------------
-
-    ::
-       # cd /moxa/mxser/driver
-       # ./msmknod
-
-3.5.6 Make utility
-------------------
-
-    ::
-
-	  # cd /moxa/mxser/utility
-	  # make clean; make install
-
-3.5.7 Reboot
-------------
-
-
-
-3.6 Custom configuration
-========================
-
-    Although this driver already provides you default configuration, you
-    still can change the device name and major number. The instruction to
-    change these parameters are shown as below.
-
-a. Change Device name
-
-    If you'd like to use other device names instead of default naming
-    convention, all you have to do is to modify the internal code
-    within the shell script "msmknod". First, you have to open "msmknod"
-    by vi. Locate each line contains "ttyM" and "cum" and change them
-    to the device name you desired. "msmknod" creates the device names
-    you need next time executed.
-
-b. Change Major number
-
-    If major number 30 and 35 had been occupied, you may have to select
-    2 free major numbers for this driver. There are 3 steps to change
-    major numbers.
-
-3.6.1 Find free major numbers
------------------------------
-
-    In /proc/devices, you may find all the major numbers occupied
-    in the system. Please select 2 major numbers that are available.
-    e.g. 40, 45.
-
-3.6.2 Create special files
---------------------------
-
-   Run /moxa/mxser/driver/msmknod to create special files with
-   specified major numbers.
-
-3.6.3 Modify driver with new major number
------------------------------------------
-
-   Run vi to open /moxa/mxser/driver/mxser.c. Locate the line
-   contains "MXSERMAJOR". Change the content as below::
-
-	  #define	  MXSERMAJOR		  40
-	  #define	  MXSERCUMAJOR		  45
-
-    3.6.4 Run "make clean; make install" in /moxa/mxser/driver.
-
-3.7 Verify driver installation
-==============================
-
-    You may refer to /var/log/messages to check the latest status
-    log reported by this driver whenever it's activated.
-
 4. Utilities
 ^^^^^^^^^^^^
 
@@ -409,9 +128,6 @@ b. Change Major number
    msterm. These 3 utilities are released in form of source code. They should
    be compiled into executable file and copied into /usr/bin.
 
-   Before using these utilities, please load driver (refer 3.4 & 3.5) and
-   make sure you had run the "msmknod" utility.
-
 msdiag - Diagnostic
 ===================
 
@@ -479,26 +195,3 @@ msterm - Terminal Emulation
    Solution:
    To avoid this problem, please unplug fifth and after board, because Moxa
    driver supports up to 4 boards.
-
-   Error msg:
-	      Request_irq fail, IRQ(?) may be conflict with another device.
-
-   Solution:
-   Other PCI or ISA devices occupy the assigned IRQ. If you are not sure
-   which device causes the situation, please check /proc/interrupts to find
-   free IRQ and simply change another free IRQ for Moxa board.
-
-   Error msg:
-	      Board #: C1xx Series(CAP=xxx) interrupt number invalid.
-
-   Solution:
-   Each port within the same multiport board shares the same IRQ. Please set
-   one IRQ (IRQ doesn't equal to zero) for one Moxa board.
-
-   Error msg:
-              Couldn't install MOXA Smartio/Industio family driver!
-
-   Solution:
-   Load Moxa driver fail, the major number may conflict with other devices.
-   Please refer to previous section 3.7 to change a free major number for
-   Moxa driver.
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 69/70] mxser: Documentation, fix typos
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (67 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 68/70] mxser: Documentation, make the docs up-to-date Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18  6:15 ` [PATCH 70/70] MAINTAINERS: add me back as mxser maintainer Jiri Slaby
  2021-06-18 11:10 ` [PATCH 00/69] mxser: cleanup Greg KH
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Fix some typos in the mxser's documentation.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 .../driver-api/serial/moxa-smartio.rst        | 42 +++++++++----------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/Documentation/driver-api/serial/moxa-smartio.rst b/Documentation/driver-api/serial/moxa-smartio.rst
index 838888f81b6d..af25bc5cc3e6 100644
--- a/Documentation/driver-api/serial/moxa-smartio.rst
+++ b/Documentation/driver-api/serial/moxa-smartio.rst
@@ -20,7 +20,7 @@ Copyright (C) 2021, Jiri Slaby
 ^^^^^^^^^^^^^^^
 
    The Smartio/Industio/UPCI family Linux driver supports following multiport
-   boards.
+   boards:
 
     - 2 ports multiport board
 	CP-102U, CP-102UL, CP-102UF
@@ -63,10 +63,10 @@ Copyright (C) 2021, Jiri Slaby
    GNU General Public License in this version. Please refer to GNU General
    Public License announcement in each source code file for more detail.
 
-   In Moxa's Web sites, you may always find latest driver at
+   In Moxa's Web sites, you may always find the latest driver at
    https://www.moxa.com/.
 
-   This version of driver can be installed as Loadable Module (Module driver)
+   This version of driver can be installed as a Loadable Module (Module driver)
    or built-in into kernel (Static driver). Before you install the driver,
    please refer to hardware installation procedure in the User's Manual.
 
@@ -89,9 +89,9 @@ Copyright (C) 2021, Jiri Slaby
 PCI/UPCI board
 --------------
 
-   You may need to adjust IRQ usage in BIOS to avoid from IRQ conflict
-   with other ISA devices. Please refer to hardware installation
-   procedure in User's Manual in advance.
+   You may need to adjust IRQ usage in BIOS to avoid IRQ conflict with other
+   ISA devices. Please refer to hardware installation procedure in User's
+   Manual in advance.
 
 PCI IRQ Sharing
 ---------------
@@ -132,7 +132,7 @@ msdiag - Diagnostic
 ===================
 
    This utility provides the function to display what Moxa Smartio/Industio
-   board found by driver in the system.
+   board was found by the driver in the system.
 
 msmon - Port Monitoring
 =======================
@@ -162,23 +162,23 @@ msterm - Terminal Emulation
 
    Supported Setserial parameters are listed as below.
 
-   ============== =========================================================
-   uart		  set UART type(16450-->disable FIFO, 16550A-->enable FIFO)
-   close_delay	  set the amount of time(in 1/100 of a second) that DTR
+   ============== =============================================================
+   uart		  set UART type(16450 --> disable FIFO, 16550A --> enable FIFO)
+   close_delay	  set the amount of time (in 1/100 of a second) that DTR
 		  should be kept low while being closed.
-   closing_wait   set the amount of time(in 1/100 of a second) that the
+   closing_wait   set the amount of time (in 1/100 of a second) that the
 		  serial port should wait for data to be drained while
-		  being closed, before the receiver is disable.
-   spd_hi	  Use  57.6kb  when  the application requests 38.4kb.
-   spd_vhi	  Use  115.2kb	when  the application requests 38.4kb.
-   spd_shi	  Use  230.4kb	when  the application requests 38.4kb.
-   spd_warp	  Use  460.8kb	when  the application requests 38.4kb.
-   spd_normal	  Use  38.4kb  when  the application requests 38.4kb.
-   spd_cust	  Use  the custom divisor to set the speed when  the
+		  being closed, before the receiver is disabled.
+   spd_hi	  Use 57.6kb when the application requests 38.4kb.
+   spd_vhi	  Use 115.2kb when the application requests 38.4kb.
+   spd_shi	  Use 230.4kb when the application requests 38.4kb.
+   spd_warp	  Use 460.8kb when the application requests 38.4kb.
+   spd_normal	  Use 38.4kb when the application requests 38.4kb.
+   spd_cust	  Use the custom divisor to set the speed when the
 		  application requests 38.4kb.
-   divisor	  This option set the custom division.
-   baud_base	  This option set the base baud rate.
-   ============== =========================================================
+   divisor	  This option sets the custom division.
+   baud_base	  This option sets the base baud rate.
+   ============== =============================================================
 
 6. Troubleshooting
 ^^^^^^^^^^^^^^^^^^
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH 70/70] MAINTAINERS: add me back as mxser maintainer
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (68 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 69/70] mxser: Documentation, fix typos Jiri Slaby
@ 2021-06-18  6:15 ` Jiri Slaby
  2021-06-18 11:10 ` [PATCH 00/69] mxser: cleanup Greg KH
  70 siblings, 0 replies; 72+ messages in thread
From: Jiri Slaby @ 2021-06-18  6:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

I was given a few cards from MOXA (thanks a lot). Provided I can now
test changes, I cleaned up the driver a bit and can continue maintaining
it.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index cff342847673..314207ccc82a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12498,7 +12498,8 @@ S:	Maintained
 F:	drivers/net/phy/motorcomm.c
 
 MOXA SMARTIO/INDUSTIO/INTELLIO SERIAL CARD
-S:	Orphan
+M:	Jiri Slaby <jirislaby@kernel.org>
+S:	Maintained
 F:	Documentation/driver-api/serial/moxa-smartio.rst
 F:	drivers/tty/mxser.*
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* Re: [PATCH 00/69] mxser: cleanup
  2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
                   ` (69 preceding siblings ...)
  2021-06-18  6:15 ` [PATCH 70/70] MAINTAINERS: add me back as mxser maintainer Jiri Slaby
@ 2021-06-18 11:10 ` Greg KH
  70 siblings, 0 replies; 72+ messages in thread
From: Greg KH @ 2021-06-18 11:10 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: linux-serial, linux-kernel

On Fri, Jun 18, 2021 at 08:14:06AM +0200, Jiri Slaby wrote:
> I was given a few cards from MOXA (thanks a lot). So I cleaned up the
> driver and can continue maintaining it.
> 
> A long term goal is to convert the driver to serial_core.
> 
> Jiri Slaby (70):
>   mxser: drop ISA support
>   mxser: renumber mxser_cards
>   mxser: remove info printout from init
>   mxser: integrate mxser.h into .c
>   mxser: cleanup Gpci_uart_info struct
>   mxser: rename CheckIsMoxaMust to mxser_get_must_hwid
>   mxser: rename mxser_board::chip_flag to must_hwid
>   mxser: introduce enum mxser_must_hwid
>   mxser: drop constant board::uart_type
>   mxser: move max_baud from port to board
>   mxser: remove nonsense from ISR
>   mxser: cleanup LSR handling in mxser_receive_chars
>   mxser: extract port ISR
>   mxser: simplify mxser_interrupt and drop mxser_board::vector_mask
>   mxser: extract mxser_receive_chars_new
>   mxser: extract mxser_receive_chars_old
>   mxser: remove else from LSR bits checks
>   mxser: correct types for uart variables
>   mxser: make xmit ring buffer variables unsigned
>   mxser: drop UART_MCR_AFE and UART_LSR_SPECIAL defines
>   mxser: drop unused MOXA_DIAGNOSE macro
>   mxser: remove MOXA_GET_MAJOR deprecated ioctl
>   mxser: remove MOXA_SET_BAUD_METHOD ioctl
>   mxser: remove MOXA_ASPP_MON and friends
>   mxser: remove MOXA_ASPP_LSTATUS ioctl
>   mxser: remove MOXA_CHKPORTENABLE ioctl
>   mxser: remove MOXA_GETDATACOUNT ioctl
>   mxser: remove MOXA_GETMSTATUS ioctl
>   mxser: remove MOXA_ASPP_OQUEUE ioctl
>   mxser: remove MOXA_HighSpeedOn ioctl
>   mxser: remove cnt from mxser_receive_chars
>   mxser: don't allocate MXSER_PORTS + 1
>   mxser: drop unused mxser_port::normal_termios
>   mxser: remove unused mxser_port::stop_rx
>   mxser: drop mxser_port::baud_base
>   mxser: drop mxser_port::custom_divisor
>   mxser: cleanup mxser_change_speed
>   mxser: extract mxser_ioctl_op_mode
>   mxser: simplify mxser_ioctl_op_mode
>   mxser: dedup mxser_must_set_enhance_mode
>   mxser: introduce mxser_must_select_bank and use it
>   mxser: clean up the rest of MUST helpers
>   mxser: move board init into mxser_initbrd
>   mxser: inline mxser_board_remove into mxser_remove
>   mxser: pci, switch to managed resources
>   mxser: move request irq to probe and switch to managed
>   mxser: remove info message from probe
>   mxser: remove mxser_cardinfo
>   mxser: cleanup mxser_process_txrx_fifo
>   mxser: rework and simplify mxser_open
>   mxser: make mxser_board::idx really an index
>   mxser: alloc struct mxser_board dynamically
>   mxser: alloc only needed # of ports
>   mxser: remove pointless ioaddr checks
>   mxser: cleanup mxser_rs_break
>   mxser: cleanup mxser_dtr_rts
>   mxser: don't start TX from tty_operations::put_char
>   mxser: extract and dedup CTS handling
>   mxser: introduce and use start/stop_tx helpers
>   mxser: remove xmit_cnt < 0 tests
>   mxser: decrypt FCR values
>   mxser: fix typos around enhanced mode
>   mxser: access info->MCR under info->slock
>   mxser: use port variable in mxser_set_serial_info
>   mxser: rename flags to old_speed in mxser_set_serial_info
>   mxser: introduce mxser_16550A_or_MUST helper
>   mxser: Documentation, remove traces of callout device
>   mxser: Documentation, make the docs up-to-date
>   mxser: Documentation, fix typos
>   MAINTAINERS: add me back as mxser maintainer
> 
>  .../driver-api/serial/moxa-smartio.rst        |  496 +----
>  MAINTAINERS                                   |    3 +-
>  drivers/tty/Kconfig                           |    2 +-
>  drivers/tty/mxser.c                           | 1950 +++++------------
>  drivers/tty/mxser.h                           |  151 --
>  5 files changed, 622 insertions(+), 1980 deletions(-)
>  delete mode 100644 drivers/tty/mxser.h

Nice cleanups, thanks for doing this!

greg k-h

^ permalink raw reply	[flat|nested] 72+ messages in thread

end of thread, other threads:[~2021-06-18 11:10 UTC | newest]

Thread overview: 72+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18  6:14 [PATCH 00/69] mxser: cleanup Jiri Slaby
2021-06-18  6:14 ` [PATCH 01/70] mxser: drop ISA support Jiri Slaby
2021-06-18  6:14 ` [PATCH 02/70] mxser: renumber mxser_cards Jiri Slaby
2021-06-18  6:14 ` [PATCH 03/70] mxser: remove info printout from init Jiri Slaby
2021-06-18  6:14 ` [PATCH 04/70] mxser: integrate mxser.h into .c Jiri Slaby
2021-06-18  6:14 ` [PATCH 05/70] mxser: cleanup Gpci_uart_info struct Jiri Slaby
2021-06-18  6:14 ` [PATCH 06/70] mxser: rename CheckIsMoxaMust to mxser_get_must_hwid Jiri Slaby
2021-06-18  6:14 ` [PATCH 07/70] mxser: rename mxser_board::chip_flag to must_hwid Jiri Slaby
2021-06-18  6:14 ` [PATCH 08/70] mxser: introduce enum mxser_must_hwid Jiri Slaby
2021-06-18  6:14 ` [PATCH 09/70] mxser: drop constant board::uart_type Jiri Slaby
2021-06-18  6:14 ` [PATCH 10/70] mxser: move max_baud from port to board Jiri Slaby
2021-06-18  6:14 ` [PATCH 11/70] mxser: remove nonsense from ISR Jiri Slaby
2021-06-18  6:14 ` [PATCH 12/70] mxser: cleanup LSR handling in mxser_receive_chars Jiri Slaby
2021-06-18  6:14 ` [PATCH 13/70] mxser: extract port ISR Jiri Slaby
2021-06-18  6:14 ` [PATCH 14/70] mxser: simplify mxser_interrupt and drop mxser_board::vector_mask Jiri Slaby
2021-06-18  6:14 ` [PATCH 15/70] mxser: extract mxser_receive_chars_new Jiri Slaby
2021-06-18  6:14 ` [PATCH 16/70] mxser: extract mxser_receive_chars_old Jiri Slaby
2021-06-18  6:14 ` [PATCH 17/70] mxser: remove else from LSR bits checks Jiri Slaby
2021-06-18  6:14 ` [PATCH 18/70] mxser: correct types for uart variables Jiri Slaby
2021-06-18  6:14 ` [PATCH 19/70] mxser: make xmit ring buffer variables unsigned Jiri Slaby
2021-06-18  6:14 ` [PATCH 20/70] mxser: drop UART_MCR_AFE and UART_LSR_SPECIAL defines Jiri Slaby
2021-06-18  6:14 ` [PATCH 21/70] mxser: drop unused MOXA_DIAGNOSE macro Jiri Slaby
2021-06-18  6:14 ` [PATCH 22/70] mxser: remove MOXA_GET_MAJOR deprecated ioctl Jiri Slaby
2021-06-18  6:14 ` [PATCH 23/70] mxser: remove MOXA_SET_BAUD_METHOD ioctl Jiri Slaby
2021-06-18  6:14 ` [PATCH 24/70] mxser: remove MOXA_ASPP_MON and friends Jiri Slaby
2021-06-18  6:14 ` [PATCH 25/70] mxser: remove MOXA_ASPP_LSTATUS ioctl Jiri Slaby
2021-06-18  6:14 ` [PATCH 26/70] mxser: remove MOXA_CHKPORTENABLE ioctl Jiri Slaby
2021-06-18  6:14 ` [PATCH 27/70] mxser: remove MOXA_GETDATACOUNT ioctl Jiri Slaby
2021-06-18  6:14 ` [PATCH 28/70] mxser: remove MOXA_GETMSTATUS ioctl Jiri Slaby
2021-06-18  6:14 ` [PATCH 29/70] mxser: remove MOXA_ASPP_OQUEUE ioctl Jiri Slaby
2021-06-18  6:14 ` [PATCH 30/70] mxser: remove MOXA_HighSpeedOn ioctl Jiri Slaby
2021-06-18  6:14 ` [PATCH 31/70] mxser: remove cnt from mxser_receive_chars Jiri Slaby
2021-06-18  6:14 ` [PATCH 32/70] mxser: don't allocate MXSER_PORTS + 1 Jiri Slaby
2021-06-18  6:14 ` [PATCH 33/70] mxser: drop unused mxser_port::normal_termios Jiri Slaby
2021-06-18  6:14 ` [PATCH 34/70] mxser: remove unused mxser_port::stop_rx Jiri Slaby
2021-06-18  6:14 ` [PATCH 35/70] mxser: drop mxser_port::baud_base Jiri Slaby
2021-06-18  6:14 ` [PATCH 36/70] mxser: drop mxser_port::custom_divisor Jiri Slaby
2021-06-18  6:14 ` [PATCH 37/70] mxser: cleanup mxser_change_speed Jiri Slaby
2021-06-18  6:14 ` [PATCH 38/70] mxser: extract mxser_ioctl_op_mode Jiri Slaby
2021-06-18  6:14 ` [PATCH 39/70] mxser: simplify mxser_ioctl_op_mode Jiri Slaby
2021-06-18  6:14 ` [PATCH 40/70] mxser: dedup mxser_must_set_enhance_mode Jiri Slaby
2021-06-18  6:14 ` [PATCH 41/70] mxser: introduce mxser_must_select_bank and use it Jiri Slaby
2021-06-18  6:14 ` [PATCH 42/70] mxser: clean up the rest of MUST helpers Jiri Slaby
2021-06-18  6:14 ` [PATCH 43/70] mxser: move board init into mxser_initbrd Jiri Slaby
2021-06-18  6:14 ` [PATCH 44/70] mxser: inline mxser_board_remove into mxser_remove Jiri Slaby
2021-06-18  6:14 ` [PATCH 45/70] mxser: pci, switch to managed resources Jiri Slaby
2021-06-18  6:14 ` [PATCH 46/70] mxser: move request irq to probe and switch to managed Jiri Slaby
2021-06-18  6:14 ` [PATCH 47/70] mxser: remove info message from probe Jiri Slaby
2021-06-18  6:14 ` [PATCH 48/70] mxser: remove mxser_cardinfo Jiri Slaby
2021-06-18  6:14 ` [PATCH 49/70] mxser: cleanup mxser_process_txrx_fifo Jiri Slaby
2021-06-18  6:14 ` [PATCH 50/70] mxser: rework and simplify mxser_open Jiri Slaby
2021-06-18  6:14 ` [PATCH 51/70] mxser: make mxser_board::idx really an index Jiri Slaby
2021-06-18  6:14 ` [PATCH 52/70] mxser: alloc struct mxser_board dynamically Jiri Slaby
2021-06-18  6:14 ` [PATCH 53/70] mxser: alloc only needed # of ports Jiri Slaby
2021-06-18  6:15 ` [PATCH 54/70] mxser: remove pointless ioaddr checks Jiri Slaby
2021-06-18  6:15 ` [PATCH 55/70] mxser: cleanup mxser_rs_break Jiri Slaby
2021-06-18  6:15 ` [PATCH 56/70] mxser: cleanup mxser_dtr_rts Jiri Slaby
2021-06-18  6:15 ` [PATCH 57/70] mxser: don't start TX from tty_operations::put_char Jiri Slaby
2021-06-18  6:15 ` [PATCH 58/70] mxser: extract and dedup CTS handling Jiri Slaby
2021-06-18  6:15 ` [PATCH 59/70] mxser: introduce and use start/stop_tx helpers Jiri Slaby
2021-06-18  6:15 ` [PATCH 60/70] mxser: remove xmit_cnt < 0 tests Jiri Slaby
2021-06-18  6:15 ` [PATCH 61/70] mxser: decrypt FCR values Jiri Slaby
2021-06-18  6:15 ` [PATCH 62/70] mxser: fix typos around enhanced mode Jiri Slaby
2021-06-18  6:15 ` [PATCH 63/70] mxser: access info->MCR under info->slock Jiri Slaby
2021-06-18  6:15 ` [PATCH 64/70] mxser: use port variable in mxser_set_serial_info Jiri Slaby
2021-06-18  6:15 ` [PATCH 65/70] mxser: rename flags to old_speed " Jiri Slaby
2021-06-18  6:15 ` [PATCH 66/70] mxser: introduce mxser_16550A_or_MUST helper Jiri Slaby
2021-06-18  6:15 ` [PATCH 67/70] mxser: Documentation, remove traces of callout device Jiri Slaby
2021-06-18  6:15 ` [PATCH 68/70] mxser: Documentation, make the docs up-to-date Jiri Slaby
2021-06-18  6:15 ` [PATCH 69/70] mxser: Documentation, fix typos Jiri Slaby
2021-06-18  6:15 ` [PATCH 70/70] MAINTAINERS: add me back as mxser maintainer Jiri Slaby
2021-06-18 11:10 ` [PATCH 00/69] mxser: cleanup Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).