[PATCH] mxser/mxser_new: First pass over termios reporting for the mxser cards

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Alan Cox <[email protected]>

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.24-rc2-mm1/drivers/char/mxser.c linux-2.6.24-rc2-mm1/drivers/char/mxser.c
--- linux.vanilla-2.6.24-rc2-mm1/drivers/char/mxser.c	2007-11-16 17:55:11.000000000 +0000
+++ linux-2.6.24-rc2-mm1/drivers/char/mxser.c	2007-11-16 18:19:13.000000000 +0000
@@ -1391,7 +1391,8 @@
 			long baud;
 			if (get_user(baud, (long __user *)argp))
 				return -EFAULT;
-			mxser_set_baud(info, baud);
+			if (mxser_set_baud(info, baud) == -1)
+				return -1;
 			return 0;
 		}
 	case MOXA_ASPP_GETBAUD:
@@ -2517,7 +2518,13 @@
 #endif
 	if (mxser_set_baud_method[info->port] == 0) {
 		baud = tty_get_baud_rate(info->tty);
-		mxser_set_baud(info, baud);
+		if (mxser_set_baud(info, baud) == -1) {
+			/* Use previous rate on a failure */
+			if (old_termios) {
+				baud = tty_termios_baud_rate(old_termios);
+				tty_encode_baud_rate(info->tty, baud, baud);
+			}
+		}
 	}
 
 	/* byte size and parity */
@@ -2691,27 +2698,31 @@
 {
 	int quot = 0;
 	unsigned char cval;
-	int ret = 0;
 	unsigned long flags;
+	unsigned int baud;
 
 	if (!info->tty || !info->tty->termios)
-		return ret;
+		return -1;
 
 	if (!(info->base))
-		return ret;
+		return -1;
 
 	if (newspd > info->MaxCanSetBaudRate)
-		return 0;
+		return -1;
 
 	info->realbaud = newspd;
 	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;
+		tty_encode_baud_rate(info->tty, 0, 0);
 	}
 
 	info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base);
@@ -2727,7 +2738,7 @@
 		info->MCR &= ~UART_MCR_DTR;
 		outb(info->MCR, info->base + UART_MCR);
 		spin_unlock_irqrestore(&info->slock, flags);
-		return ret;
+		return 0;
 	}
 
 	cval = inb(info->base + UART_LCR);
@@ -2739,7 +2750,7 @@
 	outb(cval, info->base + UART_LCR);	/* reset DLAB */
 
 
-	return ret;
+	return 0;
 }
 
 /*
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.24-rc2-mm1/drivers/char/mxser_new.c linux-2.6.24-rc2-mm1/drivers/char/mxser_new.c
--- linux.vanilla-2.6.24-rc2-mm1/drivers/char/mxser_new.c	2007-11-16 17:55:11.000000000 +0000
+++ linux-2.6.24-rc2-mm1/drivers/char/mxser_new.c	2007-11-16 18:19:21.000000000 +0000
@@ -452,18 +452,17 @@
 static int mxser_set_baud(struct mxser_port *info, long newspd)
 {
 	unsigned int i;
-	int quot = 0;
+	int quot = 0, baud;
 	unsigned char cval;
-	int ret = 0;
 
 	if (!info->tty || !info->tty->termios)
-		return ret;
+		return -1;
 
 	if (!(info->ioaddr))
-		return ret;
+		return -1;
 
 	if (newspd > info->max_baud)
-		return 0;
+		return -1;
 
 	info->realbaud = newspd;
 	for (i = 0; i < BAUD_TABLE_NO; i++)
@@ -476,10 +475,13 @@
 	} 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;
 		}
@@ -494,7 +496,7 @@
 	} else {
 		info->MCR &= ~UART_MCR_DTR;
 		outb(info->MCR, info->ioaddr + UART_MCR);
-		return ret;
+		return 0;
 	}
 
 	cval = inb(info->ioaddr + UART_LCR);
@@ -518,7 +520,7 @@
 	} else
 		SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0);
 
-	return ret;
+	return 0;
 }
 
 /*
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux