diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/mxser.c | 27 | ||||
-rw-r--r-- | drivers/char/mxser_new.c | 16 |
2 files changed, 28 insertions, 15 deletions
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 5d7901096048..35ff7a245540 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c | |||
@@ -1391,7 +1391,8 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c | |||
1391 | long baud; | 1391 | long baud; |
1392 | if (get_user(baud, (long __user *)argp)) | 1392 | if (get_user(baud, (long __user *)argp)) |
1393 | return -EFAULT; | 1393 | return -EFAULT; |
1394 | mxser_set_baud(info, baud); | 1394 | if (mxser_set_baud(info, baud) == -1) |
1395 | return -1; | ||
1395 | return 0; | 1396 | return 0; |
1396 | } | 1397 | } |
1397 | case MOXA_ASPP_GETBAUD: | 1398 | case MOXA_ASPP_GETBAUD: |
@@ -2517,7 +2518,13 @@ static int mxser_change_speed(struct mxser_struct *info, struct ktermios *old_te | |||
2517 | #endif | 2518 | #endif |
2518 | if (mxser_set_baud_method[info->port] == 0) { | 2519 | if (mxser_set_baud_method[info->port] == 0) { |
2519 | baud = tty_get_baud_rate(info->tty); | 2520 | baud = tty_get_baud_rate(info->tty); |
2520 | mxser_set_baud(info, baud); | 2521 | if (mxser_set_baud(info, baud) == -1) { |
2522 | /* Use previous rate on a failure */ | ||
2523 | if (old_termios) { | ||
2524 | baud = tty_termios_baud_rate(old_termios); | ||
2525 | tty_encode_baud_rate(info->tty, baud, baud); | ||
2526 | } | ||
2527 | } | ||
2521 | } | 2528 | } |
2522 | 2529 | ||
2523 | /* byte size and parity */ | 2530 | /* byte size and parity */ |
@@ -2691,27 +2698,31 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd) | |||
2691 | { | 2698 | { |
2692 | int quot = 0; | 2699 | int quot = 0; |
2693 | unsigned char cval; | 2700 | unsigned char cval; |
2694 | int ret = 0; | ||
2695 | unsigned long flags; | 2701 | unsigned long flags; |
2702 | unsigned int baud; | ||
2696 | 2703 | ||
2697 | if (!info->tty || !info->tty->termios) | 2704 | if (!info->tty || !info->tty->termios) |
2698 | return ret; | 2705 | return -1; |
2699 | 2706 | ||
2700 | if (!(info->base)) | 2707 | if (!(info->base)) |
2701 | return ret; | 2708 | return -1; |
2702 | 2709 | ||
2703 | if (newspd > info->MaxCanSetBaudRate) | 2710 | if (newspd > info->MaxCanSetBaudRate) |
2704 | return 0; | 2711 | return -1; |
2705 | 2712 | ||
2706 | info->realbaud = newspd; | 2713 | info->realbaud = newspd; |
2707 | if (newspd == 134) { | 2714 | if (newspd == 134) { |
2708 | quot = (2 * info->baud_base / 269); | 2715 | quot = (2 * info->baud_base / 269); |
2716 | tty_encode_baud_rate(info->tty, 134, 134); | ||
2709 | } else if (newspd) { | 2717 | } else if (newspd) { |
2710 | quot = info->baud_base / newspd; | 2718 | quot = info->baud_base / newspd; |
2711 | if (quot == 0) | 2719 | if (quot == 0) |
2712 | quot = 1; | 2720 | quot = 1; |
2721 | baud = info->baud_base / quot; | ||
2722 | tty_encode_baud_rate(info->tty, baud, baud); | ||
2713 | } else { | 2723 | } else { |
2714 | quot = 0; | 2724 | quot = 0; |
2725 | tty_encode_baud_rate(info->tty, 0, 0); | ||
2715 | } | 2726 | } |
2716 | 2727 | ||
2717 | info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base); | 2728 | 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) | |||
2727 | info->MCR &= ~UART_MCR_DTR; | 2738 | info->MCR &= ~UART_MCR_DTR; |
2728 | outb(info->MCR, info->base + UART_MCR); | 2739 | outb(info->MCR, info->base + UART_MCR); |
2729 | spin_unlock_irqrestore(&info->slock, flags); | 2740 | spin_unlock_irqrestore(&info->slock, flags); |
2730 | return ret; | 2741 | return 0; |
2731 | } | 2742 | } |
2732 | 2743 | ||
2733 | cval = inb(info->base + UART_LCR); | 2744 | cval = inb(info->base + UART_LCR); |
@@ -2739,7 +2750,7 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd) | |||
2739 | outb(cval, info->base + UART_LCR); /* reset DLAB */ | 2750 | outb(cval, info->base + UART_LCR); /* reset DLAB */ |
2740 | 2751 | ||
2741 | 2752 | ||
2742 | return ret; | 2753 | return 0; |
2743 | } | 2754 | } |
2744 | 2755 | ||
2745 | /* | 2756 | /* |
diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c index a4358acb1b2b..f74734b3407b 100644 --- a/drivers/char/mxser_new.c +++ b/drivers/char/mxser_new.c | |||
@@ -452,18 +452,17 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, | |||
452 | static int mxser_set_baud(struct mxser_port *info, long newspd) | 452 | static int mxser_set_baud(struct mxser_port *info, long newspd) |
453 | { | 453 | { |
454 | unsigned int i; | 454 | unsigned int i; |
455 | int quot = 0; | 455 | int quot = 0, baud; |
456 | unsigned char cval; | 456 | unsigned char cval; |
457 | int ret = 0; | ||
458 | 457 | ||
459 | if (!info->tty || !info->tty->termios) | 458 | if (!info->tty || !info->tty->termios) |
460 | return ret; | 459 | return -1; |
461 | 460 | ||
462 | if (!(info->ioaddr)) | 461 | if (!(info->ioaddr)) |
463 | return ret; | 462 | return -1; |
464 | 463 | ||
465 | if (newspd > info->max_baud) | 464 | if (newspd > info->max_baud) |
466 | return 0; | 465 | return -1; |
467 | 466 | ||
468 | info->realbaud = newspd; | 467 | info->realbaud = newspd; |
469 | for (i = 0; i < BAUD_TABLE_NO; i++) | 468 | for (i = 0; i < BAUD_TABLE_NO; i++) |
@@ -476,10 +475,13 @@ static int mxser_set_baud(struct mxser_port *info, long newspd) | |||
476 | } else { | 475 | } else { |
477 | if (newspd == 134) { | 476 | if (newspd == 134) { |
478 | quot = (2 * info->baud_base / 269); | 477 | quot = (2 * info->baud_base / 269); |
478 | tty_encode_baud_rate(info->tty, 134, 134); | ||
479 | } else if (newspd) { | 479 | } else if (newspd) { |
480 | quot = info->baud_base / newspd; | 480 | quot = info->baud_base / newspd; |
481 | if (quot == 0) | 481 | if (quot == 0) |
482 | quot = 1; | 482 | quot = 1; |
483 | baud = info->baud_base/quot; | ||
484 | tty_encode_baud_rate(info->tty, baud, baud); | ||
483 | } else { | 485 | } else { |
484 | quot = 0; | 486 | quot = 0; |
485 | } | 487 | } |
@@ -494,7 +496,7 @@ static int mxser_set_baud(struct mxser_port *info, long newspd) | |||
494 | } else { | 496 | } else { |
495 | info->MCR &= ~UART_MCR_DTR; | 497 | info->MCR &= ~UART_MCR_DTR; |
496 | outb(info->MCR, info->ioaddr + UART_MCR); | 498 | outb(info->MCR, info->ioaddr + UART_MCR); |
497 | return ret; | 499 | return 0; |
498 | } | 500 | } |
499 | 501 | ||
500 | cval = inb(info->ioaddr + UART_LCR); | 502 | cval = inb(info->ioaddr + UART_LCR); |
@@ -518,7 +520,7 @@ static int mxser_set_baud(struct mxser_port *info, long newspd) | |||
518 | } else | 520 | } else |
519 | SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0); | 521 | SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0); |
520 | 522 | ||
521 | return ret; | 523 | return 0; |
522 | } | 524 | } |
523 | 525 | ||
524 | /* | 526 | /* |