mxser/mxser_new: first pass over termios reporting for the mxser cards

Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Alan Cox 2008-02-07 00:16:41 -08:00 committed by Linus Torvalds
parent b98e70de78
commit f29e37c076
2 changed files with 28 additions and 15 deletions

View file

@ -1391,7 +1391,8 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
long baud; long baud;
if (get_user(baud, (long __user *)argp)) if (get_user(baud, (long __user *)argp))
return -EFAULT; return -EFAULT;
mxser_set_baud(info, baud); if (mxser_set_baud(info, baud) == -1)
return -1;
return 0; return 0;
} }
case MOXA_ASPP_GETBAUD: case MOXA_ASPP_GETBAUD:
@ -2517,7 +2518,13 @@ static int mxser_change_speed(struct mxser_struct *info, struct ktermios *old_te
#endif #endif
if (mxser_set_baud_method[info->port] == 0) { if (mxser_set_baud_method[info->port] == 0) {
baud = tty_get_baud_rate(info->tty); 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 */ /* byte size and parity */
@ -2691,27 +2698,31 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
{ {
int quot = 0; int quot = 0;
unsigned char cval; unsigned char cval;
int ret = 0;
unsigned long flags; unsigned long flags;
unsigned int baud;
if (!info->tty || !info->tty->termios) if (!info->tty || !info->tty->termios)
return ret; return -1;
if (!(info->base)) if (!(info->base))
return ret; return -1;
if (newspd > info->MaxCanSetBaudRate) if (newspd > info->MaxCanSetBaudRate)
return 0; return -1;
info->realbaud = newspd; info->realbaud = newspd;
if (newspd == 134) { if (newspd == 134) {
quot = (2 * info->baud_base / 269); quot = (2 * info->baud_base / 269);
tty_encode_baud_rate(info->tty, 134, 134);
} else if (newspd) { } else if (newspd) {
quot = info->baud_base / newspd; quot = info->baud_base / newspd;
if (quot == 0) if (quot == 0)
quot = 1; quot = 1;
baud = info->baud_base / quot;
tty_encode_baud_rate(info->tty, baud, baud);
} else { } else {
quot = 0; quot = 0;
tty_encode_baud_rate(info->tty, 0, 0);
} }
info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base); info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base);
@ -2727,7 +2738,7 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
info->MCR &= ~UART_MCR_DTR; info->MCR &= ~UART_MCR_DTR;
outb(info->MCR, info->base + UART_MCR); outb(info->MCR, info->base + UART_MCR);
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
return ret; return 0;
} }
cval = inb(info->base + UART_LCR); cval = inb(info->base + UART_LCR);
@ -2739,7 +2750,7 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
outb(cval, info->base + UART_LCR); /* reset DLAB */ outb(cval, info->base + UART_LCR); /* reset DLAB */
return ret; return 0;
} }
/* /*

View file

@ -452,18 +452,17 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
static int mxser_set_baud(struct mxser_port *info, long newspd) static int mxser_set_baud(struct mxser_port *info, long newspd)
{ {
unsigned int i; unsigned int i;
int quot = 0; int quot = 0, baud;
unsigned char cval; unsigned char cval;
int ret = 0;
if (!info->tty || !info->tty->termios) if (!info->tty || !info->tty->termios)
return ret; return -1;
if (!(info->ioaddr)) if (!(info->ioaddr))
return ret; return -1;
if (newspd > info->max_baud) if (newspd > info->max_baud)
return 0; return -1;
info->realbaud = newspd; info->realbaud = newspd;
for (i = 0; i < BAUD_TABLE_NO; i++) for (i = 0; i < BAUD_TABLE_NO; i++)
@ -476,10 +475,13 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
} else { } else {
if (newspd == 134) { if (newspd == 134) {
quot = (2 * info->baud_base / 269); quot = (2 * info->baud_base / 269);
tty_encode_baud_rate(info->tty, 134, 134);
} else if (newspd) { } else if (newspd) {
quot = info->baud_base / newspd; quot = info->baud_base / newspd;
if (quot == 0) if (quot == 0)
quot = 1; quot = 1;
baud = info->baud_base/quot;
tty_encode_baud_rate(info->tty, baud, baud);
} else { } else {
quot = 0; quot = 0;
} }
@ -494,7 +496,7 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
} else { } else {
info->MCR &= ~UART_MCR_DTR; info->MCR &= ~UART_MCR_DTR;
outb(info->MCR, info->ioaddr + UART_MCR); outb(info->MCR, info->ioaddr + UART_MCR);
return ret; return 0;
} }
cval = inb(info->ioaddr + UART_LCR); cval = inb(info->ioaddr + UART_LCR);
@ -518,7 +520,7 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
} else } else
SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0); SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0);
return ret; return 0;
} }
/* /*