public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] Char: mxser, remove special baudrate processing
@ 2007-12-30 13:58 Jiri Slaby
  2007-12-30 13:58 ` [PATCH 2/5] Char: mxser, 0 to NULL in pointer Jiri Slaby
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Jiri Slaby @ 2007-12-30 13:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Jiri Slaby, Sergei Organov, Alan Cox

If you, Sergei, can test it, it would be great. [Note, that this is actually
a patch for mxser_new after renaming.]

--

Let it on the tty layer. Also remove set/get_special_rate ioctls introduced
in commit f64c84a1668930d1ca2b7dbaa92146c2139cb508, since it is no longer
needed.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Sergei Organov <osv@javad.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
---
 drivers/char/mxser.c |  120 ++++++++++----------------------------------------
 drivers/char/mxser.h |    4 --
 2 files changed, 23 insertions(+), 101 deletions(-)

diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 0270fa0..fe7944c 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -173,18 +173,6 @@ static struct pci_device_id mxser_pcibrds[] = {
 };
 MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
 
-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
-};
-#define BAUD_TABLE_NO ARRAY_SIZE(mxvar_baud_table)
-
-#define B_SPEC	B2000000
-
 static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 };
 static int ttymajor = MXSERMAJOR;
 static int calloutmajor = MXSERCUMAJOR;
@@ -243,10 +231,8 @@ struct mxser_port {
 	int rx_trigger;		/* Rx fifo trigger level */
 	int rx_low_water;
 	int baud_base;		/* max. speed */
-	long realbaud;
 	int type;		/* UART type */
 	int flags;		/* defined in tty.h */
-	int speed;
 
 	int x_char;		/* xon/xoff character */
 	int IER;		/* Interrupt Enable Register */
@@ -451,7 +437,6 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
 
 static int mxser_set_baud(struct mxser_port *info, long newspd)
 {
-	unsigned int i;
 	int quot = 0, baud;
 	unsigned char cval;
 
@@ -464,27 +449,17 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
 	if (newspd > info->max_baud)
 		return -1;
 
-	info->realbaud = newspd;
-	for (i = 0; i < BAUD_TABLE_NO; i++)
-	       if (newspd == mxvar_baud_table[i])
-		       break;
-	if (i == BAUD_TABLE_NO) {
-		quot = info->baud_base / info->speed;
-		if (info->speed <= 0 || info->speed > info->max_baud)
-			quot = 0;
+	if (newspd == 134) {
+		quot = 2 * info->baud_base / 269;
+		tty_encode_baud_rate(info->tty, 134, 134);
+	} else if (newspd) {
+		quot = info->baud_base / newspd;
+		if (quot == 0)
+			quot = 1;
+		baud = info->baud_base/quot;
+		tty_encode_baud_rate(info->tty, baud, baud);
 	} else {
-		if (newspd == 134) {
-			quot = (2 * info->baud_base / 269);
-			tty_encode_baud_rate(info->tty, 134, 134);
-		} else if (newspd) {
-			quot = info->baud_base / newspd;
-			if (quot == 0)
-				quot = 1;
-			baud = info->baud_base/quot;
-			tty_encode_baud_rate(info->tty, baud, baud);
-		} else {
-			quot = 0;
-		}
+		quot = 0;
 	}
 
 	info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base);
@@ -507,17 +482,19 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
 	outb(quot >> 8, info->ioaddr + UART_DLM);	/* MS of divisor */
 	outb(cval, info->ioaddr + UART_LCR);	/* reset DLAB */
 
-	if (i == BAUD_TABLE_NO) {
-		quot = info->baud_base % info->speed;
+#ifdef BOTHER
+	if (C_BAUD(info->tty) == BOTHER) {
+		quot = info->baud_base % newspd;
 		quot *= 8;
-		if ((quot % info->speed) > (info->speed / 2)) {
-			quot /= info->speed;
+		if (quot % newspd > newspd / 2) {
+			quot /= newspd;
 			quot++;
-		} else {
-			quot /= info->speed;
-		}
+		} else
+			quot /= newspd;
+
 		SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, quot);
 	} else
+#endif
 		SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0);
 
 	return 0;
@@ -533,7 +510,6 @@ static int mxser_change_speed(struct mxser_port *info,
 	unsigned cflag, cval, fcr;
 	int ret = 0;
 	unsigned char status;
-	long baud;
 
 	if (!info->tty || !info->tty->termios)
 		return ret;
@@ -541,13 +517,8 @@ static int mxser_change_speed(struct mxser_port *info,
 	if (!(info->ioaddr))
 		return ret;
 
-	if (mxser_set_baud_method[info->tty->index] == 0) {
-		if ((cflag & CBAUD) == B_SPEC)
-			baud = info->speed;
-		else
-			baud = tty_get_baud_rate(info->tty);
-		mxser_set_baud(info, baud);
-	}
+	if (mxser_set_baud_method[info->tty->index] == 0)
+		mxser_set_baud(info, tty_get_baud_rate(info->tty));
 
 	/* byte size and parity */
 	switch (cflag & CSIZE) {
@@ -1587,7 +1558,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
 					port->mon_data.up_txcnt;
 				mon_data_ext.modem_status[i] =
 					port->mon_data.modem_status;
-				mon_data_ext.baudrate[i] = port->realbaud;
+				mon_data_ext.baudrate[i] =
+					tty_get_baud_rate(port->tty);
 
 				if (!port->tty || !port->tty->termios) {
 					cflag = port->normal_termios.c_cflag;
@@ -1645,7 +1617,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
 	struct serial_icounter_struct __user *p_cuser;
 	unsigned long templ;
 	unsigned long flags;
-	unsigned int i;
 	void __user *argp = (void __user *)arg;
 	int retval;
 
@@ -1684,36 +1655,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
 		return 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;
-		if (!info->tty || !info->tty->termios || !info->ioaddr)
-			return 0;
-		info->tty->termios->c_cflag &= ~(CBAUD | CBAUDEX);
-		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];
-
-		info->speed = speed;
-		spin_lock_irqsave(&info->slock, flags);
-		mxser_change_speed(info, NULL);
-		spin_unlock_irqrestore(&info->slock, flags);
-
-		return 0;
-	} else if (cmd == MOXA_GET_SPECIAL_BAUD_RATE) {
-		if (copy_to_user(argp, &info->speed, sizeof(int)))
-		     return -EFAULT;
-		return 0;
-	}
-
 	if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && cmd != TIOCGICOUNT &&
 			test_bit(TTY_IO_ERROR, &tty->flags))
 		return -EIO;
@@ -1807,20 +1748,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
 		info->mon_data.rxcnt = 0;
 		info->mon_data.txcnt = 0;
 		return 0;
-	case MOXA_ASPP_SETBAUD:{
-		long baud;
-		if (get_user(baud, (long __user *)argp))
-			return -EFAULT;
-		spin_lock_irqsave(&info->slock, flags);
-		mxser_set_baud(info, baud);
-		spin_unlock_irqrestore(&info->slock, flags);
-		return 0;
-	}
-	case MOXA_ASPP_GETBAUD:
-		if (copy_to_user(argp, &info->realbaud, sizeof(long)))
-			return -EFAULT;
-
-		return 0;
 
 	case MOXA_ASPP_OQUEUE:{
 		int len, lsr;
@@ -2434,7 +2361,6 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
 		info->normal_termios = mxvar_sdriver->init_termios;
 		init_waitqueue_head(&info->open_wait);
 		init_waitqueue_head(&info->delta_msr_wait);
-		info->speed = 9600;
 		memset(&info->mon_data, 0, sizeof(struct mxser_mon));
 		info->err_shadow = 0;
 		spin_lock_init(&info->slock);
diff --git a/drivers/char/mxser.h b/drivers/char/mxser.h
index d42f776..7f7b4a7 100644
--- a/drivers/char/mxser.h
+++ b/drivers/char/mxser.h
@@ -29,14 +29,10 @@
 
 #define MOXA_SDS_RSTICOUNTER	(MOXA + 69)
 #define MOXA_ASPP_OQUEUE  	(MOXA + 70)
-#define MOXA_ASPP_SETBAUD 	(MOXA + 71)
-#define MOXA_ASPP_GETBAUD 	(MOXA + 72)
 #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 MOXA_SET_SPECIAL_BAUD_RATE	(MOXA + 77)
-#define MOXA_GET_SPECIAL_BAUD_RATE	(MOXA + 78)
 
 /* --------------------------------------------------- */
 
-- 
1.5.3.6


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

* [PATCH 2/5] Char: mxser, 0 to NULL in pointer
  2007-12-30 13:58 [PATCH 1/5] Char: mxser, remove special baudrate processing Jiri Slaby
@ 2007-12-30 13:58 ` Jiri Slaby
  2007-12-30 13:58 ` [PATCH 3/5] Char: mxser, reorder mxser_cardinfo fields Jiri Slaby
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Jiri Slaby @ 2007-12-30 13:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Jiri Slaby

Don't test a pointer against 0. Use NULL instead.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
 drivers/char/mxser.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index fe7944c..a66ae57 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -2153,7 +2153,7 @@ static void mxser_transmit_chars(struct mxser_port *port)
 		return;
 	}
 
-	if (port->xmit_buf == 0)
+	if (port->xmit_buf == NULL)
 		return;
 
 	if ((port->xmit_cnt <= 0) || port->tty->stopped ||
-- 
1.5.3.6


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

* [PATCH 3/5] Char: mxser, reorder mxser_cardinfo fields
  2007-12-30 13:58 [PATCH 1/5] Char: mxser, remove special baudrate processing Jiri Slaby
  2007-12-30 13:58 ` [PATCH 2/5] Char: mxser, 0 to NULL in pointer Jiri Slaby
@ 2007-12-30 13:58 ` Jiri Slaby
  2007-12-30 13:58 ` [PATCH 4/5] Char: mxser, simplify mxser_get_serial_info Jiri Slaby
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Jiri Slaby @ 2007-12-30 13:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Jiri Slaby, Jan Engelhardt

Reorder fields to save some memory and code on 64bit due to alignment as
suggested by Jan.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Jan Engelhardt <jengelh@computergmbh.de>
---
 drivers/char/mxser.c |   60 +++++++++++++++++++++++++-------------------------
 1 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index a66ae57..7003855 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -106,41 +106,41 @@ static const struct {
 #define UART_INFO_NUM	ARRAY_SIZE(Gpci_uart_info)
 
 struct mxser_cardinfo {
-	unsigned int nports;
 	char *name;
+	unsigned int nports;
 	unsigned int flags;
 };
 
 static const struct mxser_cardinfo mxser_cards[] = {
-/* 0*/	{ 8, "C168 series", },
-	{ 4, "C104 series", },
-	{ 4, "CI-104J series", },
-	{ 8, "C168H/PCI series", },
-	{ 4, "C104H/PCI series", },
-/* 5*/	{ 4, "C102 series", MXSER_HAS2 },	/* C102-ISA */
-	{ 4, "CI-132 series", MXSER_HAS2 },
-	{ 4, "CI-134 series", },
-	{ 2, "CP-132 series", },
-	{ 4, "CP-114 series", },
-/*10*/	{ 4, "CT-114 series", },
-	{ 2, "CP-102 series", MXSER_HIGHBAUD },
-	{ 4, "CP-104U series", },
-	{ 8, "CP-168U series", },
-	{ 2, "CP-132U series", },
-/*15*/	{ 4, "CP-134U series", },
-	{ 4, "CP-104JU series", },
-	{ 8, "Moxa UC7000 Serial", },		/* RC7000 */
-	{ 8, "CP-118U series", },
-	{ 2, "CP-102UL series", },
-/*20*/	{ 2, "CP-102U series", },
-	{ 8, "CP-118EL series", },
-	{ 8, "CP-168EL series", },
-	{ 4, "CP-104EL series", },
-	{ 8, "CB-108 series", },
-/*25*/	{ 4, "CB-114 series", },
-	{ 4, "CB-134I series", },
-	{ 8, "CP-138U series", },
-	{ 4, "POS-104UL series", }
+/* 0*/	{ "C168 series",	8, },
+	{ "C104 series",	4, },
+	{ "CI-104J series",	4, },
+	{ "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, },
+	{ "CP-132 series",	2, },
+	{ "CP-114 series",	4, },
+/*10*/	{ "CT-114 series",	4, },
+	{ "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, },
+	{ "Moxa UC7000 Serial",	8, },		/* RC7000 */
+	{ "CP-118U series",	8, },
+	{ "CP-102UL series",	2, },
+/*20*/	{ "CP-102U series",	2, },
+	{ "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, },
+	{ "CP-138U series",	8, },
+	{ "POS-104UL series",	4, }
 };
 
 /* driver_data correspond to the lines in the structure above
-- 
1.5.3.6


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

* [PATCH 4/5] Char: mxser, simplify mxser_get_serial_info
  2007-12-30 13:58 [PATCH 1/5] Char: mxser, remove special baudrate processing Jiri Slaby
  2007-12-30 13:58 ` [PATCH 2/5] Char: mxser, 0 to NULL in pointer Jiri Slaby
  2007-12-30 13:58 ` [PATCH 3/5] Char: mxser, reorder mxser_cardinfo fields Jiri Slaby
@ 2007-12-30 13:58 ` Jiri Slaby
  2007-12-30 13:58 ` [PATCH 5/5] Char: mxser, ioctl cleanup Jiri Slaby
  2008-01-15 15:30 ` [PATCH 1/5] Char: mxser, remove special baudrate processing Sergei Organov
  4 siblings, 0 replies; 7+ messages in thread
From: Jiri Slaby @ 2007-12-30 13:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Jiri Slaby, Jan Engelhardt

Initialize temp structure directly with proper values without first zeroing
it and setting later as suggested by Jan.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Jan Engelhardt <jengelh@computergmbh.de>
---
 drivers/char/mxser.c |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 7003855..c6651f3 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -1168,21 +1168,18 @@ static void mxser_flush_buffer(struct tty_struct *tty)
 static int mxser_get_serial_info(struct mxser_port *info,
 		struct serial_struct __user *retinfo)
 {
-	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;
-	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;
+	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;
-- 
1.5.3.6


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

* [PATCH 5/5] Char: mxser, ioctl cleanup
  2007-12-30 13:58 [PATCH 1/5] Char: mxser, remove special baudrate processing Jiri Slaby
                   ` (2 preceding siblings ...)
  2007-12-30 13:58 ` [PATCH 4/5] Char: mxser, simplify mxser_get_serial_info Jiri Slaby
@ 2007-12-30 13:58 ` Jiri Slaby
  2008-01-15 15:30 ` [PATCH 1/5] Char: mxser, remove special baudrate processing Sergei Organov
  4 siblings, 0 replies; 7+ messages in thread
From: Jiri Slaby @ 2007-12-30 13:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Jiri Slaby, Alan Cox

- remove dead MOXA_GET_CONF (always returned -ENXIO)
- remove useless MOXA_GET_CUMAJOR (unused)
- use get/put_user instead of copy_from/to_user for simple types
- cleanup TIOCMIWAIT -- return -ERESTARTSYS on signal, move condition into
  separate function

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
---
 drivers/char/mxser.c |   74 +++++++++++++++++++++-----------------------------
 drivers/char/mxser.h |    2 -
 2 files changed, 31 insertions(+), 45 deletions(-)

diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index c6651f3..dd1b0ab 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -175,7 +175,6 @@ MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
 
 static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 };
 static int ttymajor = MXSERMAJOR;
-static int calloutmajor = MXSERCUMAJOR;
 
 /* Variables for insmod */
 
@@ -1454,21 +1453,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
 	unsigned int i, j;
 
 	switch (cmd) {
-	case MOXA_GET_CONF:
-/*		if (copy_to_user(argp, mxsercfg,
-				sizeof(struct mxser_hwconf) * 4))
-			return -EFAULT;
-		return 0;*/
-		return -ENXIO;
 	case MOXA_GET_MAJOR:
-		if (copy_to_user(argp, &ttymajor, sizeof(int)))
-			return -EFAULT;
-		return 0;
-
-	case MOXA_GET_CUMAJOR:
-		if (copy_to_user(argp, &calloutmajor, sizeof(int)))
-			return -EFAULT;
-		return 0;
+		return put_user(ttymajor, (int __user *)argp);
 
 	case MOXA_CHKPORTENABLE:
 		result = 0;
@@ -1606,13 +1592,33 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
 	return 0;
 }
 
+static int mxser_cflags_changed(struct mxser_port *info, unsigned long arg,
+		struct async_icount *cprev)
+{
+	struct async_icount cnow;
+	unsigned long flags;
+	int ret;
+
+	spin_lock_irqsave(&info->slock, flags);
+	cnow = info->icount;	/* atomic copy */
+	spin_unlock_irqrestore(&info->slock, flags);
+
+	ret =	((arg & TIOCM_RNG) && (cnow.rng != cprev->rng)) ||
+		((arg & TIOCM_DSR) && (cnow.dsr != cprev->dsr)) ||
+		((arg & TIOCM_CD)  && (cnow.dcd != cprev->dcd)) ||
+		((arg & TIOCM_CTS) && (cnow.cts != cprev->cts));
+
+	*cprev = cnow;
+
+	return ret;
+}
+
 static int mxser_ioctl(struct tty_struct *tty, struct file *file,
 		unsigned int cmd, unsigned long arg)
 {
 	struct mxser_port *info = tty->driver_data;
-	struct async_icount cprev, cnow;	/* kernel counter temps */
+	struct async_icount cnow;
 	struct serial_icounter_struct __user *p_cuser;
-	unsigned long templ;
 	unsigned long flags;
 	void __user *argp = (void __user *)arg;
 	int retval;
@@ -1646,7 +1652,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
 			shiftbit = p * 2;
 			opmode = inb(info->opmode_ioaddr) >> shiftbit;
 			opmode &= OP_MODE_MASK;
-			if (copy_to_user(argp, &opmode, sizeof(int)))
+			if (put_user(opmode, (int __user *)argp))
 				return -EFAULT;
 		}
 		return 0;
@@ -1673,11 +1679,10 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
 		mxser_send_break(info, arg ? arg * (HZ / 10) : HZ / 4);
 		return 0;
 	case TIOCGSOFTCAR:
-		return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *)argp);
+		return put_user(!!C_CLOCAL(tty), (unsigned long __user *)argp);
 	case TIOCSSOFTCAR:
-		if (get_user(templ, (unsigned long __user *) argp))
+		if (get_user(arg, (unsigned long __user *)argp))
 			return -EFAULT;
-		arg = templ;
 		tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0));
 		return 0;
 	case TIOCGSERIAL:
@@ -1697,18 +1702,8 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
 		cnow = info->icount;	/* note the counters on entry */
 		spin_unlock_irqrestore(&info->slock, flags);
 
-		wait_event_interruptible(info->delta_msr_wait, ({
-			cprev = cnow;
-			spin_lock_irqsave(&info->slock, flags);
-			cnow = info->icount;	/* atomic copy */
-			spin_unlock_irqrestore(&info->slock, flags);
-
-			((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
-			((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
-			((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
-			((arg & TIOCM_CTS) && (cnow.cts != cprev.cts));
-		}));
-		break;
+		return wait_event_interruptible(info->delta_msr_wait,
+				mxser_cflags_changed(info, arg, &cnow));
 	/*
 	 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
 	 * Return: write counters to the user passed counter struct
@@ -1755,10 +1750,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
 
 		len += (lsr ? 0 : 1);
 
-		if (copy_to_user(argp, &len, sizeof(int)))
-			return -EFAULT;
-
-		return 0;
+		return put_user(len, (int __user *)argp);
 	}
 	case MOXA_ASPP_MON: {
 		int mcr, status;
@@ -1789,8 +1781,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
 		return 0;
 	}
 	case MOXA_ASPP_LSTATUS: {
-		if (copy_to_user(argp, &info->err_shadow,
-				sizeof(unsigned char)))
+		if (put_user(info->err_shadow, (unsigned char __user *)argp))
 			return -EFAULT;
 
 		info->err_shadow = 0;
@@ -1802,10 +1793,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
 		if (get_user(method, (int __user *)argp))
 			return -EFAULT;
 		mxser_set_baud_method[tty->index] = method;
-		if (copy_to_user(argp, &method, sizeof(int)))
-			return -EFAULT;
-
-		return 0;
+		return put_user(method, (int __user *)argp);
 	}
 	default:
 		return -ENOIOCTLCMD;
diff --git a/drivers/char/mxser.h b/drivers/char/mxser.h
index 7f7b4a7..8441711 100644
--- a/drivers/char/mxser.h
+++ b/drivers/char/mxser.h
@@ -11,12 +11,10 @@
 
 #define MOXA			0x400
 #define MOXA_GETDATACOUNT	(MOXA + 23)
-#define	MOXA_GET_CONF		(MOXA + 35)
 #define MOXA_DIAGNOSE		(MOXA + 50)
 #define MOXA_CHKPORTENABLE	(MOXA + 60)
 #define MOXA_HighSpeedOn	(MOXA + 61)
 #define MOXA_GET_MAJOR		(MOXA + 63)
-#define MOXA_GET_CUMAJOR	(MOXA + 64)
 #define MOXA_GETMSTATUS		(MOXA + 65)
 #define MOXA_SET_OP_MODE	(MOXA + 66)
 #define MOXA_GET_OP_MODE	(MOXA + 67)
-- 
1.5.3.6


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

* Re: [PATCH 1/5] Char: mxser, remove special baudrate processing
  2007-12-30 13:58 [PATCH 1/5] Char: mxser, remove special baudrate processing Jiri Slaby
                   ` (3 preceding siblings ...)
  2007-12-30 13:58 ` [PATCH 5/5] Char: mxser, ioctl cleanup Jiri Slaby
@ 2008-01-15 15:30 ` Sergei Organov
  2008-01-17 10:14   ` Jiri Slaby
  4 siblings, 1 reply; 7+ messages in thread
From: Sergei Organov @ 2008-01-15 15:30 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Andrew Morton, linux-kernel, Alan Cox

Jiri Slaby <jirislaby@gmail.com> writes:
> If you, Sergei, can test it, it would be great. [Note, that this is actually
> a patch for mxser_new after renaming.]

Where is the reference git tree for this patch? Or, in other words,
which tree do I use if I want to test this patch (I'm afraid the latest
I've ever built, 2.6.19.1, is too old for this material)?

I've also checked

git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git

and it seems it doesn't have commit that renames mxser_new to mxser.

-- 
Sergei.


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

* Re: [PATCH 1/5] Char: mxser, remove special baudrate processing
  2008-01-15 15:30 ` [PATCH 1/5] Char: mxser, remove special baudrate processing Sergei Organov
@ 2008-01-17 10:14   ` Jiri Slaby
  0 siblings, 0 replies; 7+ messages in thread
From: Jiri Slaby @ 2008-01-17 10:14 UTC (permalink / raw)
  To: Sergei Organov; +Cc: Andrew Morton, linux-kernel, Alan Cox

On 01/15/2008 04:30 PM, Sergei Organov wrote:
> Jiri Slaby <jirislaby@gmail.com> writes:
>> If you, Sergei, can test it, it would be great. [Note, that this is actually
>> a patch for mxser_new after renaming.]
> 
> Where is the reference git tree for this patch? Or, in other words,
> which tree do I use if I want to test this patch (I'm afraid the latest
> I've ever built, 2.6.19.1, is too old for this material)?

Ah sorry, at least 2.6.20 is needed for that stuff. Nevermind, anyway thanks a 
lot for your time.

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

end of thread, other threads:[~2008-01-17 10:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-30 13:58 [PATCH 1/5] Char: mxser, remove special baudrate processing Jiri Slaby
2007-12-30 13:58 ` [PATCH 2/5] Char: mxser, 0 to NULL in pointer Jiri Slaby
2007-12-30 13:58 ` [PATCH 3/5] Char: mxser, reorder mxser_cardinfo fields Jiri Slaby
2007-12-30 13:58 ` [PATCH 4/5] Char: mxser, simplify mxser_get_serial_info Jiri Slaby
2007-12-30 13:58 ` [PATCH 5/5] Char: mxser, ioctl cleanup Jiri Slaby
2008-01-15 15:30 ` [PATCH 1/5] Char: mxser, remove special baudrate processing Sergei Organov
2008-01-17 10:14   ` Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox