Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 83925
b: refs/heads/master
c: f29e37c
h: refs/heads/master
i:
  83923: 65a0a31
v: v3
  • Loading branch information
Alan Cox authored and Linus Torvalds committed Feb 7, 2008
1 parent 9d0e718 commit 6842bc6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b98e70de7836cf0ea49b6714b2455381865b1260
refs/heads/master: f29e37c076cd08004e31297d205d54ac38cf7a20
27 changes: 19 additions & 8 deletions trunk/drivers/char/mxser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,8 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
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:
Expand Down Expand Up @@ -2517,7 +2518,13 @@ static int mxser_change_speed(struct mxser_struct *info, struct ktermios *old_te
#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 */
Expand Down Expand Up @@ -2691,27 +2698,31 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
{
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);
Expand All @@ -2727,7 +2738,7 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
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);
Expand All @@ -2739,7 +2750,7 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
outb(cval, info->base + UART_LCR); /* reset DLAB */


return ret;
return 0;
}

/*
Expand Down
16 changes: 9 additions & 7 deletions trunk/drivers/char/mxser_new.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
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++)
Expand All @@ -476,10 +475,13 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
} 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;
}
Expand All @@ -494,7 +496,7 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
} else {
info->MCR &= ~UART_MCR_DTR;
outb(info->MCR, info->ioaddr + UART_MCR);
return ret;
return 0;
}

cval = inb(info->ioaddr + UART_LCR);
Expand All @@ -518,7 +520,7 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
} else
SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0);

return ret;
return 0;
}

/*
Expand Down

0 comments on commit 6842bc6

Please sign in to comment.