diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2008-02-07 03:16:42 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-07 11:42:34 -0500 |
commit | d7f549fa14ed7e3d72927e89dec721eeff4a0159 (patch) | |
tree | c0f189e162d0245452a281ef6e0ecc52565f2ed3 /drivers/char | |
parent | f29e37c076cd08004e31297d205d54ac38cf7a20 (diff) |
Char: mxser, remove special baudrate processing
Let the special baudrate processing 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>
Reviewed-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/mxser_new.c | 120 | ||||
-rw-r--r-- | drivers/char/mxser_new.h | 4 |
2 files changed, 23 insertions, 101 deletions
diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c index f74734b3407b..0b25457cda05 100644 --- a/drivers/char/mxser_new.c +++ b/drivers/char/mxser_new.c | |||
@@ -173,18 +173,6 @@ static struct pci_device_id mxser_pcibrds[] = { | |||
173 | }; | 173 | }; |
174 | MODULE_DEVICE_TABLE(pci, mxser_pcibrds); | 174 | MODULE_DEVICE_TABLE(pci, mxser_pcibrds); |
175 | 175 | ||
176 | static int mxvar_baud_table[] = { | ||
177 | 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, | ||
178 | 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600 | ||
179 | }; | ||
180 | static unsigned int mxvar_baud_table1[] = { | ||
181 | 0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400, | ||
182 | B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800, B921600 | ||
183 | }; | ||
184 | #define BAUD_TABLE_NO ARRAY_SIZE(mxvar_baud_table) | ||
185 | |||
186 | #define B_SPEC B2000000 | ||
187 | |||
188 | static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 }; | 176 | static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 }; |
189 | static int ttymajor = MXSERMAJOR; | 177 | static int ttymajor = MXSERMAJOR; |
190 | static int calloutmajor = MXSERCUMAJOR; | 178 | static int calloutmajor = MXSERCUMAJOR; |
@@ -243,10 +231,8 @@ struct mxser_port { | |||
243 | int rx_trigger; /* Rx fifo trigger level */ | 231 | int rx_trigger; /* Rx fifo trigger level */ |
244 | int rx_low_water; | 232 | int rx_low_water; |
245 | int baud_base; /* max. speed */ | 233 | int baud_base; /* max. speed */ |
246 | long realbaud; | ||
247 | int type; /* UART type */ | 234 | int type; /* UART type */ |
248 | int flags; /* defined in tty.h */ | 235 | int flags; /* defined in tty.h */ |
249 | int speed; | ||
250 | 236 | ||
251 | int x_char; /* xon/xoff character */ | 237 | int x_char; /* xon/xoff character */ |
252 | int IER; /* Interrupt Enable Register */ | 238 | int IER; /* Interrupt Enable Register */ |
@@ -451,7 +437,6 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, | |||
451 | 437 | ||
452 | static int mxser_set_baud(struct mxser_port *info, long newspd) | 438 | static int mxser_set_baud(struct mxser_port *info, long newspd) |
453 | { | 439 | { |
454 | unsigned int i; | ||
455 | int quot = 0, baud; | 440 | int quot = 0, baud; |
456 | unsigned char cval; | 441 | unsigned char cval; |
457 | 442 | ||
@@ -464,27 +449,17 @@ static int mxser_set_baud(struct mxser_port *info, long newspd) | |||
464 | if (newspd > info->max_baud) | 449 | if (newspd > info->max_baud) |
465 | return -1; | 450 | return -1; |
466 | 451 | ||
467 | info->realbaud = newspd; | 452 | if (newspd == 134) { |
468 | for (i = 0; i < BAUD_TABLE_NO; i++) | 453 | quot = 2 * info->baud_base / 269; |
469 | if (newspd == mxvar_baud_table[i]) | 454 | tty_encode_baud_rate(info->tty, 134, 134); |
470 | break; | 455 | } else if (newspd) { |
471 | if (i == BAUD_TABLE_NO) { | 456 | quot = info->baud_base / newspd; |
472 | quot = info->baud_base / info->speed; | 457 | if (quot == 0) |
473 | if (info->speed <= 0 || info->speed > info->max_baud) | 458 | quot = 1; |
474 | quot = 0; | 459 | baud = info->baud_base/quot; |
460 | tty_encode_baud_rate(info->tty, baud, baud); | ||
475 | } else { | 461 | } else { |
476 | if (newspd == 134) { | 462 | quot = 0; |
477 | quot = (2 * info->baud_base / 269); | ||
478 | tty_encode_baud_rate(info->tty, 134, 134); | ||
479 | } else if (newspd) { | ||
480 | quot = info->baud_base / newspd; | ||
481 | if (quot == 0) | ||
482 | quot = 1; | ||
483 | baud = info->baud_base/quot; | ||
484 | tty_encode_baud_rate(info->tty, baud, baud); | ||
485 | } else { | ||
486 | quot = 0; | ||
487 | } | ||
488 | } | 463 | } |
489 | 464 | ||
490 | info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base); | 465 | 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) | |||
507 | outb(quot >> 8, info->ioaddr + UART_DLM); /* MS of divisor */ | 482 | outb(quot >> 8, info->ioaddr + UART_DLM); /* MS of divisor */ |
508 | outb(cval, info->ioaddr + UART_LCR); /* reset DLAB */ | 483 | outb(cval, info->ioaddr + UART_LCR); /* reset DLAB */ |
509 | 484 | ||
510 | if (i == BAUD_TABLE_NO) { | 485 | #ifdef BOTHER |
511 | quot = info->baud_base % info->speed; | 486 | if (C_BAUD(info->tty) == BOTHER) { |
487 | quot = info->baud_base % newspd; | ||
512 | quot *= 8; | 488 | quot *= 8; |
513 | if ((quot % info->speed) > (info->speed / 2)) { | 489 | if (quot % newspd > newspd / 2) { |
514 | quot /= info->speed; | 490 | quot /= newspd; |
515 | quot++; | 491 | quot++; |
516 | } else { | 492 | } else |
517 | quot /= info->speed; | 493 | quot /= newspd; |
518 | } | 494 | |
519 | SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, quot); | 495 | SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, quot); |
520 | } else | 496 | } else |
497 | #endif | ||
521 | SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0); | 498 | SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0); |
522 | 499 | ||
523 | return 0; | 500 | return 0; |
@@ -533,7 +510,6 @@ static int mxser_change_speed(struct mxser_port *info, | |||
533 | unsigned cflag, cval, fcr; | 510 | unsigned cflag, cval, fcr; |
534 | int ret = 0; | 511 | int ret = 0; |
535 | unsigned char status; | 512 | unsigned char status; |
536 | long baud; | ||
537 | 513 | ||
538 | if (!info->tty || !info->tty->termios) | 514 | if (!info->tty || !info->tty->termios) |
539 | return ret; | 515 | return ret; |
@@ -541,13 +517,8 @@ static int mxser_change_speed(struct mxser_port *info, | |||
541 | if (!(info->ioaddr)) | 517 | if (!(info->ioaddr)) |
542 | return ret; | 518 | return ret; |
543 | 519 | ||
544 | if (mxser_set_baud_method[info->tty->index] == 0) { | 520 | if (mxser_set_baud_method[info->tty->index] == 0) |
545 | if ((cflag & CBAUD) == B_SPEC) | 521 | mxser_set_baud(info, tty_get_baud_rate(info->tty)); |
546 | baud = info->speed; | ||
547 | else | ||
548 | baud = tty_get_baud_rate(info->tty); | ||
549 | mxser_set_baud(info, baud); | ||
550 | } | ||
551 | 522 | ||
552 | /* byte size and parity */ | 523 | /* byte size and parity */ |
553 | switch (cflag & CSIZE) { | 524 | switch (cflag & CSIZE) { |
@@ -1587,7 +1558,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) | |||
1587 | port->mon_data.up_txcnt; | 1558 | port->mon_data.up_txcnt; |
1588 | mon_data_ext.modem_status[i] = | 1559 | mon_data_ext.modem_status[i] = |
1589 | port->mon_data.modem_status; | 1560 | port->mon_data.modem_status; |
1590 | mon_data_ext.baudrate[i] = port->realbaud; | 1561 | mon_data_ext.baudrate[i] = |
1562 | tty_get_baud_rate(port->tty); | ||
1591 | 1563 | ||
1592 | if (!port->tty || !port->tty->termios) { | 1564 | if (!port->tty || !port->tty->termios) { |
1593 | cflag = port->normal_termios.c_cflag; | 1565 | cflag = port->normal_termios.c_cflag; |
@@ -1645,7 +1617,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, | |||
1645 | struct serial_icounter_struct __user *p_cuser; | 1617 | struct serial_icounter_struct __user *p_cuser; |
1646 | unsigned long templ; | 1618 | unsigned long templ; |
1647 | unsigned long flags; | 1619 | unsigned long flags; |
1648 | unsigned int i; | ||
1649 | void __user *argp = (void __user *)arg; | 1620 | void __user *argp = (void __user *)arg; |
1650 | int retval; | 1621 | int retval; |
1651 | 1622 | ||
@@ -1684,36 +1655,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, | |||
1684 | return 0; | 1655 | return 0; |
1685 | } | 1656 | } |
1686 | 1657 | ||
1687 | if (cmd == MOXA_SET_SPECIAL_BAUD_RATE) { | ||
1688 | int speed; | ||
1689 | |||
1690 | if (get_user(speed, (int __user *)argp)) | ||
1691 | return -EFAULT; | ||
1692 | if (speed <= 0 || speed > info->max_baud) | ||
1693 | return -EFAULT; | ||
1694 | if (!info->tty || !info->tty->termios || !info->ioaddr) | ||
1695 | return 0; | ||
1696 | info->tty->termios->c_cflag &= ~(CBAUD | CBAUDEX); | ||
1697 | for (i = 0; i < BAUD_TABLE_NO; i++) | ||
1698 | if (speed == mxvar_baud_table[i]) | ||
1699 | break; | ||
1700 | if (i == BAUD_TABLE_NO) { | ||
1701 | info->tty->termios->c_cflag |= B_SPEC; | ||
1702 | } else if (speed != 0) | ||
1703 | info->tty->termios->c_cflag |= mxvar_baud_table1[i]; | ||
1704 | |||
1705 | info->speed = speed; | ||
1706 | spin_lock_irqsave(&info->slock, flags); | ||
1707 | mxser_change_speed(info, NULL); | ||
1708 | spin_unlock_irqrestore(&info->slock, flags); | ||
1709 | |||
1710 | return 0; | ||
1711 | } else if (cmd == MOXA_GET_SPECIAL_BAUD_RATE) { | ||
1712 | if (copy_to_user(argp, &info->speed, sizeof(int))) | ||
1713 | return -EFAULT; | ||
1714 | return 0; | ||
1715 | } | ||
1716 | |||
1717 | if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && cmd != TIOCGICOUNT && | 1658 | if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && cmd != TIOCGICOUNT && |
1718 | test_bit(TTY_IO_ERROR, &tty->flags)) | 1659 | test_bit(TTY_IO_ERROR, &tty->flags)) |
1719 | return -EIO; | 1660 | return -EIO; |
@@ -1807,20 +1748,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, | |||
1807 | info->mon_data.rxcnt = 0; | 1748 | info->mon_data.rxcnt = 0; |
1808 | info->mon_data.txcnt = 0; | 1749 | info->mon_data.txcnt = 0; |
1809 | return 0; | 1750 | return 0; |
1810 | case MOXA_ASPP_SETBAUD:{ | ||
1811 | long baud; | ||
1812 | if (get_user(baud, (long __user *)argp)) | ||
1813 | return -EFAULT; | ||
1814 | spin_lock_irqsave(&info->slock, flags); | ||
1815 | mxser_set_baud(info, baud); | ||
1816 | spin_unlock_irqrestore(&info->slock, flags); | ||
1817 | return 0; | ||
1818 | } | ||
1819 | case MOXA_ASPP_GETBAUD: | ||
1820 | if (copy_to_user(argp, &info->realbaud, sizeof(long))) | ||
1821 | return -EFAULT; | ||
1822 | |||
1823 | return 0; | ||
1824 | 1751 | ||
1825 | case MOXA_ASPP_OQUEUE:{ | 1752 | case MOXA_ASPP_OQUEUE:{ |
1826 | int len, lsr; | 1753 | int len, lsr; |
@@ -2434,7 +2361,6 @@ static int __devinit mxser_initbrd(struct mxser_board *brd, | |||
2434 | info->normal_termios = mxvar_sdriver->init_termios; | 2361 | info->normal_termios = mxvar_sdriver->init_termios; |
2435 | init_waitqueue_head(&info->open_wait); | 2362 | init_waitqueue_head(&info->open_wait); |
2436 | init_waitqueue_head(&info->delta_msr_wait); | 2363 | init_waitqueue_head(&info->delta_msr_wait); |
2437 | info->speed = 9600; | ||
2438 | memset(&info->mon_data, 0, sizeof(struct mxser_mon)); | 2364 | memset(&info->mon_data, 0, sizeof(struct mxser_mon)); |
2439 | info->err_shadow = 0; | 2365 | info->err_shadow = 0; |
2440 | spin_lock_init(&info->slock); | 2366 | spin_lock_init(&info->slock); |
diff --git a/drivers/char/mxser_new.h b/drivers/char/mxser_new.h index d42f7766c652..7f7b4a711cfc 100644 --- a/drivers/char/mxser_new.h +++ b/drivers/char/mxser_new.h | |||
@@ -29,14 +29,10 @@ | |||
29 | 29 | ||
30 | #define MOXA_SDS_RSTICOUNTER (MOXA + 69) | 30 | #define MOXA_SDS_RSTICOUNTER (MOXA + 69) |
31 | #define MOXA_ASPP_OQUEUE (MOXA + 70) | 31 | #define MOXA_ASPP_OQUEUE (MOXA + 70) |
32 | #define MOXA_ASPP_SETBAUD (MOXA + 71) | ||
33 | #define MOXA_ASPP_GETBAUD (MOXA + 72) | ||
34 | #define MOXA_ASPP_MON (MOXA + 73) | 32 | #define MOXA_ASPP_MON (MOXA + 73) |
35 | #define MOXA_ASPP_LSTATUS (MOXA + 74) | 33 | #define MOXA_ASPP_LSTATUS (MOXA + 74) |
36 | #define MOXA_ASPP_MON_EXT (MOXA + 75) | 34 | #define MOXA_ASPP_MON_EXT (MOXA + 75) |
37 | #define MOXA_SET_BAUD_METHOD (MOXA + 76) | 35 | #define MOXA_SET_BAUD_METHOD (MOXA + 76) |
38 | #define MOXA_SET_SPECIAL_BAUD_RATE (MOXA + 77) | ||
39 | #define MOXA_GET_SPECIAL_BAUD_RATE (MOXA + 78) | ||
40 | 36 | ||
41 | /* --------------------------------------------------- */ | 37 | /* --------------------------------------------------- */ |
42 | 38 | ||