Skip to contentSkip to conversation

mxser, remove it

PATCH In review Jiri Slaby 3 participants 5 messages Dec 28, 2007 – Dec 29, 2007

Subsystems (3)
lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

PATCH 1/1 mxser, remove it

(Old) mxser is obsoleted by mxser_new and scheduled for removal on Dec 2007. Remove it by renaming mxser_new to mxser.

---
 Documentation/feature-removal-schedule.txt |    8 -
 drivers/char/Kconfig                       |   13 +-
 drivers/char/Makefile                      |    1 -
 drivers/char/mxser.c                       | 3893 +++++++++++++---------------
 drivers/char/mxser.h                       |  476 ++---
 drivers/char/mxser_new.c                   | 2818 --------------------
 drivers/char/mxser_new.h                   |  293 ---
 7 files changed, 1950 insertions(+), 5552 deletions(-)
 delete mode 100644 drivers/char/mxser_new.c
 delete mode 100644 drivers/char/mxser_new.h
Documentation/feature-removal-schedule.txt +0 -8
index 5092585..165c664 100644
@@ -6,14 +6,6 @@ be removed from this file.
 
 ---------------------------
 
-What:	MXSER
-When:	December 2007
-Why:	Old mxser driver is obsoleted by the mxser_new. Give it some time yet
-	and remove it.
-Who:	Jiri Slaby <[email protected]>
-
----------------------------
-
 What:	dev->power.power_state
 When:	July 2007
 Why:	Broken design for runtime control over driver power states, confusing
drivers/char/Kconfig +1 -12
index 967bfc2..9ac60d9 100644
@@ -194,17 +194,6 @@ config MOXA_INTELLIO
 	  module will be called moxa.
 
 config MOXA_SMARTIO
-	tristate "Moxa SmartIO support (OBSOLETE)"
-	depends on SERIAL_NONSTANDARD
-	help
-	  Say Y here if you have a Moxa SmartIO multiport serial card.
-
-	  This driver can also be built as a module ( = code which can be
-	  inserted in and removed from the running kernel whenever you want).
-	  The module will be called mxser. If you want to do that, say M
-	  here.
-
-config MOXA_SMARTIO_NEW
 	tristate "Moxa SmartIO support v. 2.0"
 	depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA)
 	help
@@ -215,7 +204,7 @@ config MOXA_SMARTIO_NEW
 	  changes finally resulting in PCI probing.
 
 	  This driver can also be built as a module. The module will be called
-	  mxser_new. If you want to do that, say M here.
+	  mxser. If you want to do that, say M here.
 
 config ISI
 	tristate "Multi-Tech multiport card support (EXPERIMENTAL)"
drivers/char/Makefile +0 -1
index 2f02662..f096f7c 100644
@@ -33,7 +33,6 @@ obj-$(CONFIG_MOXA_INTELLIO)	+= moxa.o
 obj-$(CONFIG_A2232)		+= ser_a2232.o generic_serial.o
 obj-$(CONFIG_ATARI_DSP56K)	+= dsp56k.o
 obj-$(CONFIG_MOXA_SMARTIO)	+= mxser.o
-obj-$(CONFIG_MOXA_SMARTIO_NEW)	+= mxser_new.o
 obj-$(CONFIG_COMPUTONE)		+= ip2/
 obj-$(CONFIG_RISCOM8)		+= riscom8.o
 obj-$(CONFIG_ISI)		+= isicom.o
drivers/char/mxser.c +1785 -2108

2,954 lines not on this page · raw message

drivers/char/mxser.h +164 -312

476 lines not on this page · raw message

drivers/char/mxser_new.c deleted +0 -2818

2,818 lines not on this page · raw message

drivers/char/mxser_new.h deleted +0 -293

293 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.5.3.6

Part of the diff is not shown here. View the raw message.

#1 lore raw

drivers/char/mxser.c struct mxpciuart_info { · line 112

Quoted 6 lines · Jiri Slaby
drivers/char/mxser.c +5 -0
+struct mxser_cardinfo {
+	unsigned int nports;
+	char *name;
+	unsigned int flags;
+};

const char *name. Maybe name could also be put at the front to get closer struct packing on 64-bit?

drivers/char/mxser.c struct mxpciuart_info { · line 183

Quoted 9 lines
drivers/char/mxser.c +8 -0
+static int mxvar_baud_table[] = {
+	0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
+	4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
+};
+static unsigned int mxvar_baud_table1[] = {
+	0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400,
+	B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800, B921600
+};

Constify both, if possible?

Quoted 13 lines
drivers/char/mxser.c +7 -0
+struct mxser_port {
+	struct mxser_board *board;
+	struct tty_struct *tty;
+
+	unsigned long ioaddr;
+	unsigned long opmode_ioaddr;
+	int max_baud;
	int rx_high_water;
	int rx_trigger;		/* Rx fifo trigger level */
	int rx_low_water;
	int baud_base;		/* max. speed */
drivers/char/mxser.c +1 -0
+	long realbaud;
Quoted 1 line
	int type;		/* UART type */

realbaud could also be reordered one up or one down. There are probably more fields around.

Quoted 6 lines
drivers/char/mxser.c +1 -1
-static int CheckIsMoxaMust(int io)
+static int __devinit CheckIsMoxaMust(unsigned long io)
{
	u8 oldmcr, hwid;
	int i;

drivers/char/mxser.c static int CheckIsMoxaMust(int io) · line 341

Quoted 8 lines
drivers/char/mxser.c +2 -2
@@ -434,90 +336,15 @@ static int CheckIsMoxaMust(int io)
 	}
 
 	GET_MOXA_MUST_HARDWARE_ID(io, &hwid);
-	for (i = 0; i < UART_TYPE_NUM; i++) {
-		if (hwid == Gmoxa_uart_id[i])
+	for (i = 1; i < UART_INFO_NUM; i++) { /* 0 = OTHER_UART */
+		if (hwid == Gpci_uart_info[i].type)
 			return (int)hwid;

I do not think a cast is necessary, hwid is implicitly upconverted to int.

Quoted 15 lines
drivers/char/mxser.c +12 -2
+static int mxser_get_serial_info(struct mxser_port *info,
+		struct serial_struct __user *retinfo)
 {
-	struct mxser_struct *info = tty->driver_data;
-	int retval;
+	struct serial_struct tmp;
+
+	if (!retinfo)
+		return -EFAULT;
+	memset(&tmp, 0, sizeof(tmp));
+	tmp.type = info->type;
+	tmp.line = info->tty->index;
+	tmp.port = info->ioaddr;
+	tmp.irq = info->board->irq;
+	tmp.flags = info->flags;

drivers/char/mxser.c static void mxser_flush_buffer(struct tty_struct *tty) · line 1219

Quoted 10 lines
drivers/char/mxser.c +10 -0
+	tmp.baud_base = info->baud_base;
+	tmp.close_delay = info->close_delay;
+	tmp.closing_wait = info->closing_wait;
+	tmp.custom_divisor = info->custom_divisor;
+	tmp.hub6 = 0;
+	if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
+		return -EFAULT;
+	return 0;
+}
+

Maybe without the extra memcpy?:

static int mxser_get_serial_info(struct mxser_port *info,
struct serial_struct __user *retinfo)

{
	struct mxser_struct *info = tty->driver_data;
	int retval;
	struct serial_struct tmp = {
		.type = info->type,
		.line = info->tty->index,
		.port = info->ioaddr,
		.irq = info->board->irq,
		.flags = info->flags,
		.baud_base = info->baud_base,
		.close_delay = info->close_delay,
		.closing_wait = info->closing_wait,
		.custom_divisor = info->custom_divisor,
		.hub6 = 0,
	};
	if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
		return -EFAULT;
	return 0;
}
#2 lore raw
Quoted 11 lines

drivers/char/mxser.c struct mxpciuart_info { · line 183

Quoted 9 lines
drivers/char/mxser.c +8 -0
+static int mxvar_baud_table[] = {
+	0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
+	4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
+};
+static unsigned int mxvar_baud_table1[] = {
+	0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400,
+	B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800, B921600
+};

Constify both, if possible?

These are not portable - baud rate tables vary for some platforms. No driver should be touching Bxxx coding itself any more. Use the tty_ functions to decode and encode baud rates.

author
#3 lore raw
Quoted 10 lines · Alan Cox
Quoted 9 lines

drivers/char/mxser.c struct mxpciuart_info { · line 183

Quoted 8 lines
drivers/char/mxser.c +8 -0
+static int mxvar_baud_table[] = {
+	0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
+	4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
+};
+static unsigned int mxvar_baud_table1[] = {
+	0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400,
+	B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800, B921600
+};

Constify both, if possible?

Quoted 3 lines

These are not portable - baud rate tables vary for some platforms. No driver should be touching Bxxx coding itself any more. Use the tty_ functions to decode and encode baud rates.

Thanks for reviews, I'll post fixes for all the issues as separate patches.

#4 lore raw
In reply to Jiri Slaby

drivers/char/mxser.c static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c · line 1693

Quoted 7 lines
drivers/char/mxser.c +7 -0
+	if (cmd == MOXA_SET_SPECIAL_BAUD_RATE) {
+		int speed;
+
+		if (get_user(speed, (int __user *)argp))
+			return -EFAULT;
+		if (speed <= 0 || speed > info->max_baud)
+			return -EFAULT;

-EINVAL

Review

Quoted 2 lines
(quoted diff) +2 -0
+		if (!info->tty || !info->tty->termios || !info->ioaddr)
+			return 0;

!info->tty and !info->tty->termios can't happen

drivers/char/mxser.c static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c · line 1696

Quoted 1 line
drivers/char/mxser.c +1 -0
+		info->tty->termios->c_cflag &= ~(CBAUD | CBAUDEX);

No...

drivers/char/mxser.c static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c · line 1703

Quoted 7 lines
drivers/char/mxser.c +7 -0
+		for (i = 0; i < BAUD_TABLE_NO; i++)
+			if (speed == mxvar_baud_table[i])
+				break;
+		if (i == BAUD_TABLE_NO) {
+			info->tty->termios->c_cflag |= B_SPEC;
+		} else if (speed != 0)
+			info->tty->termios->c_cflag |= mxvar_baud_table1[i];

Replace all the above mess with a single tty_encode_baud_rate call