diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2008-04-30 03:53:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-30 11:29:43 -0400 |
commit | eaa95a8da6366c34d3a61e93109e5f8f8a4e72a0 (patch) | |
tree | 9e42c6345bfa6ea86955751b049c38db6a71cc18 /drivers/char/moxa.c | |
parent | a8f5cda067e2eeefe49fe386caf0f61fc5c825e0 (diff) |
Char: moxa, little cleanup
Cleanup of
- whitespace
- macros
- useless casts
- return (sth); -> return sth;
- types
- superfluous parenthesis and braces
- init tmp directly in moxa_get_serial_info
- commented defunct code
- commented prototypes
- MOXA/moxa printk case
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Tested-by: Oyvind Aabling <Oyvind.Aabling@uni-c.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/moxa.c')
-rw-r--r-- | drivers/char/moxa.c | 172 |
1 files changed, 62 insertions, 110 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index af8077c25cbe..876c79b1cee0 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -54,7 +54,6 @@ | |||
54 | #define MOXA_FW_HDRLEN 32 | 54 | #define MOXA_FW_HDRLEN 32 |
55 | 55 | ||
56 | #define MOXAMAJOR 172 | 56 | #define MOXAMAJOR 172 |
57 | #define MOXACUMAJOR 173 | ||
58 | 57 | ||
59 | #define MAX_BOARDS 4 /* Don't change this value */ | 58 | #define MAX_BOARDS 4 /* Don't change this value */ |
60 | #define MAX_PORTS_PER_BOARD 32 /* Don't change this value */ | 59 | #define MAX_PORTS_PER_BOARD 32 /* Don't change this value */ |
@@ -246,7 +245,7 @@ static void moxa_wait_finish(void __iomem *ofsAddr) | |||
246 | printk(KERN_WARNING "moxa function expired\n"); | 245 | printk(KERN_WARNING "moxa function expired\n"); |
247 | } | 246 | } |
248 | 247 | ||
249 | static void moxafunc(void __iomem *ofsAddr, int cmd, ushort arg) | 248 | static void moxafunc(void __iomem *ofsAddr, u16 cmd, u16 arg) |
250 | { | 249 | { |
251 | writew(arg, ofsAddr + FuncArg); | 250 | writew(arg, ofsAddr + FuncArg); |
252 | writew(cmd, ofsAddr + FuncCode); | 251 | writew(cmd, ofsAddr + FuncCode); |
@@ -478,7 +477,7 @@ static int moxa_load_bios(struct moxa_board_conf *brd, const u8 *buf, | |||
478 | goto err; | 477 | goto err; |
479 | tmp = readw(baseAddr + C320_status); | 478 | tmp = readw(baseAddr + C320_status); |
480 | if (tmp != STS_init) { | 479 | if (tmp != STS_init) { |
481 | printk(KERN_ERR "moxa: bios upload failed -- CPU/Basic " | 480 | printk(KERN_ERR "MOXA: bios upload failed -- CPU/Basic " |
482 | "module not found\n"); | 481 | "module not found\n"); |
483 | return -EIO; | 482 | return -EIO; |
484 | } | 483 | } |
@@ -487,7 +486,7 @@ static int moxa_load_bios(struct moxa_board_conf *brd, const u8 *buf, | |||
487 | 486 | ||
488 | return 0; | 487 | return 0; |
489 | err: | 488 | err: |
490 | printk(KERN_ERR "moxa: bios upload failed -- board not found\n"); | 489 | printk(KERN_ERR "MOXA: bios upload failed -- board not found\n"); |
491 | return -EIO; | 490 | return -EIO; |
492 | } | 491 | } |
493 | 492 | ||
@@ -497,7 +496,7 @@ static int moxa_load_320b(struct moxa_board_conf *brd, const u8 *ptr, | |||
497 | void __iomem *baseAddr = brd->basemem; | 496 | void __iomem *baseAddr = brd->basemem; |
498 | 497 | ||
499 | if (len < 7168) { | 498 | if (len < 7168) { |
500 | printk(KERN_ERR "moxa: invalid 320 bios -- too short\n"); | 499 | printk(KERN_ERR "MOXA: invalid 320 bios -- too short\n"); |
501 | return -EINVAL; | 500 | return -EINVAL; |
502 | } | 501 | } |
503 | 502 | ||
@@ -642,7 +641,7 @@ static int moxa_load_code(struct moxa_board_conf *brd, const void *ptr, | |||
642 | int retval, i; | 641 | int retval, i; |
643 | 642 | ||
644 | if (len % 2) { | 643 | if (len % 2) { |
645 | printk(KERN_ERR "moxa: bios length is not even\n"); | 644 | printk(KERN_ERR "MOXA: bios length is not even\n"); |
646 | return -EINVAL; | 645 | return -EINVAL; |
647 | } | 646 | } |
648 | 647 | ||
@@ -764,7 +763,7 @@ static int moxa_load_fw(struct moxa_board_conf *brd, const struct firmware *fw) | |||
764 | lens[a] = le16_to_cpu(hdr->len[a]); | 763 | lens[a] = le16_to_cpu(hdr->len[a]); |
765 | if (lens[a] && len + lens[a] <= fw->size && | 764 | if (lens[a] && len + lens[a] <= fw->size && |
766 | moxa_check_fw(&fw->data[len])) | 765 | moxa_check_fw(&fw->data[len])) |
767 | printk(KERN_WARNING "moxa firmware: unexpected input " | 766 | printk(KERN_WARNING "MOXA firmware: unexpected input " |
768 | "at offset %u, but going on\n", (u32)len); | 767 | "at offset %u, but going on\n", (u32)len); |
769 | if (!lens[a] && a < lencnt) { | 768 | if (!lens[a] && a < lencnt) { |
770 | sprintf(rsn, "too few entries in fw file"); | 769 | sprintf(rsn, "too few entries in fw file"); |
@@ -965,7 +964,7 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev, | |||
965 | 964 | ||
966 | pci_set_drvdata(pdev, board); | 965 | pci_set_drvdata(pdev, board); |
967 | 966 | ||
968 | return (0); | 967 | return 0; |
969 | err_base: | 968 | err_base: |
970 | iounmap(board->basemem); | 969 | iounmap(board->basemem); |
971 | board->basemem = NULL; | 970 | board->basemem = NULL; |
@@ -1016,10 +1015,8 @@ static int __init moxa_init(void) | |||
1016 | moxaDriver->flags = TTY_DRIVER_REAL_RAW; | 1015 | moxaDriver->flags = TTY_DRIVER_REAL_RAW; |
1017 | tty_set_operations(moxaDriver, &moxa_ops); | 1016 | tty_set_operations(moxaDriver, &moxa_ops); |
1018 | 1017 | ||
1019 | pr_debug("Moxa tty devices major number = %d\n", ttymajor); | ||
1020 | |||
1021 | if (tty_register_driver(moxaDriver)) { | 1018 | if (tty_register_driver(moxaDriver)) { |
1022 | printk(KERN_ERR "Couldn't install MOXA Smartio family driver !\n"); | 1019 | printk(KERN_ERR "can't register MOXA Smartio tty driver!\n"); |
1023 | put_tty_driver(moxaDriver); | 1020 | put_tty_driver(moxaDriver); |
1024 | return -1; | 1021 | return -1; |
1025 | } | 1022 | } |
@@ -1043,7 +1040,7 @@ static int __init moxa_init(void) | |||
1043 | brd->busType = MOXA_BUS_TYPE_ISA; | 1040 | brd->busType = MOXA_BUS_TYPE_ISA; |
1044 | brd->basemem = ioremap(baseaddr[i], 0x4000); | 1041 | brd->basemem = ioremap(baseaddr[i], 0x4000); |
1045 | if (!brd->basemem) { | 1042 | if (!brd->basemem) { |
1046 | printk(KERN_ERR "moxa: can't remap %lx\n", | 1043 | printk(KERN_ERR "MOXA: can't remap %lx\n", |
1047 | baseaddr[i]); | 1044 | baseaddr[i]); |
1048 | continue; | 1045 | continue; |
1049 | } | 1046 | } |
@@ -1063,7 +1060,7 @@ static int __init moxa_init(void) | |||
1063 | #ifdef CONFIG_PCI | 1060 | #ifdef CONFIG_PCI |
1064 | retval = pci_register_driver(&moxa_pci_driver); | 1061 | retval = pci_register_driver(&moxa_pci_driver); |
1065 | if (retval) { | 1062 | if (retval) { |
1066 | printk(KERN_ERR "Can't register moxa pci driver!\n"); | 1063 | printk(KERN_ERR "Can't register MOXA pci driver!\n"); |
1067 | if (isabrds) | 1064 | if (isabrds) |
1068 | retval = 0; | 1065 | retval = 0; |
1069 | } | 1066 | } |
@@ -1074,7 +1071,7 @@ static int __init moxa_init(void) | |||
1074 | 1071 | ||
1075 | static void __exit moxa_exit(void) | 1072 | static void __exit moxa_exit(void) |
1076 | { | 1073 | { |
1077 | int i; | 1074 | unsigned int i; |
1078 | 1075 | ||
1079 | #ifdef CONFIG_PCI | 1076 | #ifdef CONFIG_PCI |
1080 | pci_unregister_driver(&moxa_pci_driver); | 1077 | pci_unregister_driver(&moxa_pci_driver); |
@@ -1236,12 +1233,8 @@ static int moxa_write(struct tty_struct *tty, | |||
1236 | len = MoxaPortWriteData(ch, buf, count); | 1233 | len = MoxaPortWriteData(ch, buf, count); |
1237 | spin_unlock_bh(&moxa_lock); | 1234 | spin_unlock_bh(&moxa_lock); |
1238 | 1235 | ||
1239 | /********************************************* | ||
1240 | if ( !(ch->statusflags & LOWWAIT) && | ||
1241 | ((len != count) || (MoxaPortTxFree(port) <= 100)) ) | ||
1242 | ************************************************/ | ||
1243 | ch->statusflags |= LOWWAIT; | 1236 | ch->statusflags |= LOWWAIT; |
1244 | return (len); | 1237 | return len; |
1245 | } | 1238 | } |
1246 | 1239 | ||
1247 | static int moxa_write_room(struct tty_struct *tty) | 1240 | static int moxa_write_room(struct tty_struct *tty) |
@@ -1249,10 +1242,10 @@ static int moxa_write_room(struct tty_struct *tty) | |||
1249 | struct moxa_port *ch; | 1242 | struct moxa_port *ch; |
1250 | 1243 | ||
1251 | if (tty->stopped) | 1244 | if (tty->stopped) |
1252 | return (0); | 1245 | return 0; |
1253 | ch = tty->driver_data; | 1246 | ch = tty->driver_data; |
1254 | if (ch == NULL) | 1247 | if (ch == NULL) |
1255 | return (0); | 1248 | return 0; |
1256 | return MoxaPortTxFree(ch); | 1249 | return MoxaPortTxFree(ch); |
1257 | } | 1250 | } |
1258 | 1251 | ||
@@ -1278,7 +1271,7 @@ static int moxa_chars_in_buffer(struct tty_struct *tty) | |||
1278 | * routine. And since the open() failed, we return 0 here. TDJ | 1271 | * routine. And since the open() failed, we return 0 here. TDJ |
1279 | */ | 1272 | */ |
1280 | if (ch == NULL) | 1273 | if (ch == NULL) |
1281 | return (0); | 1274 | return 0; |
1282 | chars = MoxaPortTxQueue(ch); | 1275 | chars = MoxaPortTxQueue(ch); |
1283 | if (chars) { | 1276 | if (chars) { |
1284 | /* | 1277 | /* |
@@ -1288,7 +1281,7 @@ static int moxa_chars_in_buffer(struct tty_struct *tty) | |||
1288 | if (!(ch->statusflags & EMPTYWAIT)) | 1281 | if (!(ch->statusflags & EMPTYWAIT)) |
1289 | moxa_setup_empty_event(tty); | 1282 | moxa_setup_empty_event(tty); |
1290 | } | 1283 | } |
1291 | return (chars); | 1284 | return chars; |
1292 | } | 1285 | } |
1293 | 1286 | ||
1294 | static void moxa_flush_chars(struct tty_struct *tty) | 1287 | static void moxa_flush_chars(struct tty_struct *tty) |
@@ -1308,9 +1301,7 @@ static void moxa_put_char(struct tty_struct *tty, unsigned char c) | |||
1308 | spin_lock_bh(&moxa_lock); | 1301 | spin_lock_bh(&moxa_lock); |
1309 | MoxaPortWriteData(ch, &c, 1); | 1302 | MoxaPortWriteData(ch, &c, 1); |
1310 | spin_unlock_bh(&moxa_lock); | 1303 | spin_unlock_bh(&moxa_lock); |
1311 | /************************************************ | 1304 | |
1312 | if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) ) | ||
1313 | *************************************************/ | ||
1314 | ch->statusflags |= LOWWAIT; | 1305 | ch->statusflags |= LOWWAIT; |
1315 | } | 1306 | } |
1316 | 1307 | ||
@@ -1373,34 +1364,33 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file, | |||
1373 | 1364 | ||
1374 | static void moxa_throttle(struct tty_struct *tty) | 1365 | static void moxa_throttle(struct tty_struct *tty) |
1375 | { | 1366 | { |
1376 | struct moxa_port *ch = (struct moxa_port *) tty->driver_data; | 1367 | struct moxa_port *ch = tty->driver_data; |
1377 | 1368 | ||
1378 | ch->statusflags |= THROTTLE; | 1369 | ch->statusflags |= THROTTLE; |
1379 | } | 1370 | } |
1380 | 1371 | ||
1381 | static void moxa_unthrottle(struct tty_struct *tty) | 1372 | static void moxa_unthrottle(struct tty_struct *tty) |
1382 | { | 1373 | { |
1383 | struct moxa_port *ch = (struct moxa_port *) tty->driver_data; | 1374 | struct moxa_port *ch = tty->driver_data; |
1384 | 1375 | ||
1385 | ch->statusflags &= ~THROTTLE; | 1376 | ch->statusflags &= ~THROTTLE; |
1386 | } | 1377 | } |
1387 | 1378 | ||
1388 | static void moxa_set_termios(struct tty_struct *tty, | 1379 | static void moxa_set_termios(struct tty_struct *tty, |
1389 | struct ktermios *old_termios) | 1380 | struct ktermios *old_termios) |
1390 | { | 1381 | { |
1391 | struct moxa_port *ch = (struct moxa_port *) tty->driver_data; | 1382 | struct moxa_port *ch = tty->driver_data; |
1392 | 1383 | ||
1393 | if (ch == NULL) | 1384 | if (ch == NULL) |
1394 | return; | 1385 | return; |
1395 | moxa_set_tty_param(tty, old_termios); | 1386 | moxa_set_tty_param(tty, old_termios); |
1396 | if (!(old_termios->c_cflag & CLOCAL) && | 1387 | if (!(old_termios->c_cflag & CLOCAL) && C_CLOCAL(tty)) |
1397 | (tty->termios->c_cflag & CLOCAL)) | ||
1398 | wake_up_interruptible(&ch->open_wait); | 1388 | wake_up_interruptible(&ch->open_wait); |
1399 | } | 1389 | } |
1400 | 1390 | ||
1401 | static void moxa_stop(struct tty_struct *tty) | 1391 | static void moxa_stop(struct tty_struct *tty) |
1402 | { | 1392 | { |
1403 | struct moxa_port *ch = (struct moxa_port *) tty->driver_data; | 1393 | struct moxa_port *ch = tty->driver_data; |
1404 | 1394 | ||
1405 | if (ch == NULL) | 1395 | if (ch == NULL) |
1406 | return; | 1396 | return; |
@@ -1411,7 +1401,7 @@ static void moxa_stop(struct tty_struct *tty) | |||
1411 | 1401 | ||
1412 | static void moxa_start(struct tty_struct *tty) | 1402 | static void moxa_start(struct tty_struct *tty) |
1413 | { | 1403 | { |
1414 | struct moxa_port *ch = (struct moxa_port *) tty->driver_data; | 1404 | struct moxa_port *ch = tty->driver_data; |
1415 | 1405 | ||
1416 | if (ch == NULL) | 1406 | if (ch == NULL) |
1417 | return; | 1407 | return; |
@@ -1444,7 +1434,7 @@ static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd) | |||
1444 | { | 1434 | { |
1445 | dcd = !!dcd; | 1435 | dcd = !!dcd; |
1446 | 1436 | ||
1447 | if ((dcd != p->DCDState) && p->tty && C_CLOCAL(p->tty)) { | 1437 | if (dcd != p->DCDState && p->tty && C_CLOCAL(p->tty)) { |
1448 | if (!dcd) | 1438 | if (!dcd) |
1449 | tty_hangup(p->tty); | 1439 | tty_hangup(p->tty); |
1450 | } | 1440 | } |
@@ -1552,12 +1542,10 @@ static void moxa_poll(unsigned long ignored) | |||
1552 | 1542 | ||
1553 | static void moxa_set_tty_param(struct tty_struct *tty, struct ktermios *old_termios) | 1543 | static void moxa_set_tty_param(struct tty_struct *tty, struct ktermios *old_termios) |
1554 | { | 1544 | { |
1555 | register struct ktermios *ts; | 1545 | register struct ktermios *ts = tty->termios; |
1556 | struct moxa_port *ch; | 1546 | struct moxa_port *ch = tty->driver_data; |
1557 | int rts, cts, txflow, rxflow, xany, baud; | 1547 | int rts, cts, txflow, rxflow, xany, baud; |
1558 | 1548 | ||
1559 | ch = (struct moxa_port *) tty->driver_data; | ||
1560 | ts = tty->termios; | ||
1561 | rts = cts = txflow = rxflow = xany = 0; | 1549 | rts = cts = txflow = rxflow = xany = 0; |
1562 | if (ts->c_cflag & CRTSCTS) | 1550 | if (ts->c_cflag & CRTSCTS) |
1563 | rts = cts = 1; | 1551 | rts = cts = 1; |
@@ -1614,7 +1602,7 @@ static void moxa_shut_down(struct moxa_port *ch) | |||
1614 | static void MoxaPortFlushData(struct moxa_port *port, int mode) | 1602 | static void MoxaPortFlushData(struct moxa_port *port, int mode) |
1615 | { | 1603 | { |
1616 | void __iomem *ofsAddr; | 1604 | void __iomem *ofsAddr; |
1617 | if ((mode < 0) || (mode > 2)) | 1605 | if (mode < 0 || mode > 2) |
1618 | return; | 1606 | return; |
1619 | ofsAddr = port->tableAddr; | 1607 | ofsAddr = port->tableAddr; |
1620 | moxafunc(ofsAddr, FC_FlushQueue, mode); | 1608 | moxafunc(ofsAddr, FC_FlushQueue, mode); |
@@ -1624,27 +1612,6 @@ static void MoxaPortFlushData(struct moxa_port *port, int mode) | |||
1624 | } | 1612 | } |
1625 | } | 1613 | } |
1626 | 1614 | ||
1627 | /***************************************************************************** | ||
1628 | * Port level functions: * | ||
1629 | * 2. MoxaPortEnable(int port); * | ||
1630 | * 3. MoxaPortDisable(int port); * | ||
1631 | * 4. MoxaPortGetMaxBaud(int port); * | ||
1632 | * 6. MoxaPortSetBaud(int port, long baud); * | ||
1633 | * 8. MoxaPortSetTermio(int port, unsigned char *termio); * | ||
1634 | * 9. MoxaPortGetLineOut(int port, int *dtrState, int *rtsState); * | ||
1635 | * 10. MoxaPortLineCtrl(int port, int dtrState, int rtsState); * | ||
1636 | * 11. MoxaPortFlowCtrl(int port, int rts, int cts, int rx, int tx,int xany); * | ||
1637 | * 12. MoxaPortLineStatus(int port); * | ||
1638 | * 15. MoxaPortFlushData(int port, int mode); * | ||
1639 | * 16. MoxaPortWriteData(int port, unsigned char * buffer, int length); * | ||
1640 | * 17. MoxaPortReadData(int port, struct tty_struct *tty); * | ||
1641 | * 20. MoxaPortTxQueue(int port); * | ||
1642 | * 21. MoxaPortTxFree(int port); * | ||
1643 | * 22. MoxaPortRxQueue(int port); * | ||
1644 | * 24. MoxaPortTxDisable(int port); * | ||
1645 | * 25. MoxaPortTxEnable(int port); * | ||
1646 | * 27. MoxaPortResetBrkCnt(int port); * | ||
1647 | *****************************************************************************/ | ||
1648 | /* | 1615 | /* |
1649 | * Moxa Port Number Description: | 1616 | * Moxa Port Number Description: |
1650 | * | 1617 | * |
@@ -1849,16 +1816,16 @@ static void MoxaPortFlushData(struct moxa_port *port, int mode) | |||
1849 | static void MoxaPortEnable(struct moxa_port *port) | 1816 | static void MoxaPortEnable(struct moxa_port *port) |
1850 | { | 1817 | { |
1851 | void __iomem *ofsAddr; | 1818 | void __iomem *ofsAddr; |
1852 | short lowwater = 512; | 1819 | u16 lowwater = 512; |
1853 | 1820 | ||
1854 | ofsAddr = port->tableAddr; | 1821 | ofsAddr = port->tableAddr; |
1855 | writew(lowwater, ofsAddr + Low_water); | 1822 | writew(lowwater, ofsAddr + Low_water); |
1856 | if (port->board->boardType == MOXA_BOARD_C320_ISA || | 1823 | if (port->board->boardType == MOXA_BOARD_C320_ISA || |
1857 | port->board->boardType == MOXA_BOARD_C320_PCI) { | 1824 | port->board->boardType == MOXA_BOARD_C320_PCI) |
1858 | moxafunc(ofsAddr, FC_SetBreakIrq, 0); | 1825 | moxafunc(ofsAddr, FC_SetBreakIrq, 0); |
1859 | } else { | 1826 | else |
1860 | writew(readw(ofsAddr + HostStat) | WakeupBreak, ofsAddr + HostStat); | 1827 | writew(readw(ofsAddr + HostStat) | WakeupBreak, |
1861 | } | 1828 | ofsAddr + HostStat); |
1862 | 1829 | ||
1863 | moxafunc(ofsAddr, FC_SetLineIrq, Magic_code); | 1830 | moxafunc(ofsAddr, FC_SetLineIrq, Magic_code); |
1864 | moxafunc(ofsAddr, FC_FlushQueue, 2); | 1831 | moxafunc(ofsAddr, FC_FlushQueue, 2); |
@@ -1881,9 +1848,9 @@ static long MoxaPortGetMaxBaud(struct moxa_port *port) | |||
1881 | { | 1848 | { |
1882 | if (port->board->boardType == MOXA_BOARD_C320_ISA || | 1849 | if (port->board->boardType == MOXA_BOARD_C320_ISA || |
1883 | port->board->boardType == MOXA_BOARD_C320_PCI) | 1850 | port->board->boardType == MOXA_BOARD_C320_PCI) |
1884 | return (460800L); | 1851 | return 460800L; |
1885 | else | 1852 | else |
1886 | return (921600L); | 1853 | return 921600L; |
1887 | } | 1854 | } |
1888 | 1855 | ||
1889 | 1856 | ||
@@ -1893,8 +1860,8 @@ static long MoxaPortSetBaud(struct moxa_port *port, long baud) | |||
1893 | long max, clock; | 1860 | long max, clock; |
1894 | unsigned int val; | 1861 | unsigned int val; |
1895 | 1862 | ||
1896 | if ((baud < 50L) || ((max = MoxaPortGetMaxBaud(port)) == 0)) | 1863 | if (baud < 50L || (max = MoxaPortGetMaxBaud(port)) == 0) |
1897 | return (0); | 1864 | return 0; |
1898 | ofsAddr = port->tableAddr; | 1865 | ofsAddr = port->tableAddr; |
1899 | if (baud > max) | 1866 | if (baud > max) |
1900 | baud = max; | 1867 | baud = max; |
@@ -1907,7 +1874,7 @@ static long MoxaPortSetBaud(struct moxa_port *port, long baud) | |||
1907 | val = clock / baud; | 1874 | val = clock / baud; |
1908 | moxafunc(ofsAddr, FC_SetBaud, val); | 1875 | moxafunc(ofsAddr, FC_SetBaud, val); |
1909 | baud = clock / val; | 1876 | baud = clock / val; |
1910 | return (baud); | 1877 | return baud; |
1911 | } | 1878 | } |
1912 | 1879 | ||
1913 | static int MoxaPortSetTermio(struct moxa_port *port, struct ktermios *termio, | 1880 | static int MoxaPortSetTermio(struct moxa_port *port, struct ktermios *termio, |
@@ -1946,12 +1913,12 @@ static int MoxaPortSetTermio(struct moxa_port *port, struct ktermios *termio, | |||
1946 | } else | 1913 | } else |
1947 | mode |= MX_PARNONE; | 1914 | mode |= MX_PARNONE; |
1948 | 1915 | ||
1949 | moxafunc(ofsAddr, FC_SetDataMode, (ushort) mode); | 1916 | moxafunc(ofsAddr, FC_SetDataMode, (u16)mode); |
1950 | 1917 | ||
1951 | if (port->board->boardType == MOXA_BOARD_C320_ISA || | 1918 | if (port->board->boardType == MOXA_BOARD_C320_ISA || |
1952 | port->board->boardType == MOXA_BOARD_C320_PCI) { | 1919 | port->board->boardType == MOXA_BOARD_C320_PCI) { |
1953 | if (baud >= 921600L) | 1920 | if (baud >= 921600L) |
1954 | return (-1); | 1921 | return -1; |
1955 | } | 1922 | } |
1956 | baud = MoxaPortSetBaud(port, baud); | 1923 | baud = MoxaPortSetBaud(port, baud); |
1957 | 1924 | ||
@@ -1962,24 +1929,23 @@ static int MoxaPortSetTermio(struct moxa_port *port, struct ktermios *termio, | |||
1962 | moxa_wait_finish(ofsAddr); | 1929 | moxa_wait_finish(ofsAddr); |
1963 | 1930 | ||
1964 | } | 1931 | } |
1965 | return (baud); | 1932 | return baud; |
1966 | } | 1933 | } |
1967 | 1934 | ||
1968 | static int MoxaPortGetLineOut(struct moxa_port *port, int *dtrState, | 1935 | static int MoxaPortGetLineOut(struct moxa_port *port, int *dtrState, |
1969 | int *rtsState) | 1936 | int *rtsState) |
1970 | { | 1937 | { |
1971 | |||
1972 | if (dtrState) | 1938 | if (dtrState) |
1973 | *dtrState = !!(port->lineCtrl & DTR_ON); | 1939 | *dtrState = !!(port->lineCtrl & DTR_ON); |
1974 | if (rtsState) | 1940 | if (rtsState) |
1975 | *rtsState = !!(port->lineCtrl & RTS_ON); | 1941 | *rtsState = !!(port->lineCtrl & RTS_ON); |
1976 | 1942 | ||
1977 | return (0); | 1943 | return 0; |
1978 | } | 1944 | } |
1979 | 1945 | ||
1980 | static void MoxaPortLineCtrl(struct moxa_port *port, int dtr, int rts) | 1946 | static void MoxaPortLineCtrl(struct moxa_port *port, int dtr, int rts) |
1981 | { | 1947 | { |
1982 | int mode = 0; | 1948 | u8 mode = 0; |
1983 | 1949 | ||
1984 | if (dtr) | 1950 | if (dtr) |
1985 | mode |= DTR_ON; | 1951 | mode |= DTR_ON; |
@@ -2193,60 +2159,46 @@ static void MoxaPortTxEnable(struct moxa_port *port) | |||
2193 | } | 2159 | } |
2194 | 2160 | ||
2195 | static int moxa_get_serial_info(struct moxa_port *info, | 2161 | static int moxa_get_serial_info(struct moxa_port *info, |
2196 | struct serial_struct __user *retinfo) | 2162 | struct serial_struct __user *retinfo) |
2197 | { | 2163 | { |
2198 | struct serial_struct tmp; | 2164 | struct serial_struct tmp = { |
2199 | 2165 | .type = info->type, | |
2200 | memset(&tmp, 0, sizeof(tmp)); | 2166 | .line = info->tty->index, |
2201 | tmp.type = info->type; | 2167 | .flags = info->asyncflags, |
2202 | tmp.line = info->tty->index; | 2168 | .baud_base = 921600, |
2203 | tmp.port = 0; | 2169 | .close_delay = info->close_delay |
2204 | tmp.irq = 0; | 2170 | }; |
2205 | tmp.flags = info->asyncflags; | 2171 | return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0; |
2206 | tmp.baud_base = 921600; | ||
2207 | tmp.close_delay = info->close_delay; | ||
2208 | tmp.custom_divisor = 0; | ||
2209 | tmp.hub6 = 0; | ||
2210 | if(copy_to_user(retinfo, &tmp, sizeof(*retinfo))) | ||
2211 | return -EFAULT; | ||
2212 | return (0); | ||
2213 | } | 2172 | } |
2214 | 2173 | ||
2215 | 2174 | ||
2216 | static int moxa_set_serial_info(struct moxa_port *info, | 2175 | static int moxa_set_serial_info(struct moxa_port *info, |
2217 | struct serial_struct __user *new_info) | 2176 | struct serial_struct __user *new_info) |
2218 | { | 2177 | { |
2219 | struct serial_struct new_serial; | 2178 | struct serial_struct new_serial; |
2220 | 2179 | ||
2221 | if(copy_from_user(&new_serial, new_info, sizeof(new_serial))) | 2180 | if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) |
2222 | return -EFAULT; | 2181 | return -EFAULT; |
2223 | 2182 | ||
2224 | if ((new_serial.irq != 0) || | 2183 | if (new_serial.irq != 0 || new_serial.port != 0 || |
2225 | (new_serial.port != 0) || | 2184 | new_serial.custom_divisor != 0 || |
2226 | // (new_serial.type != info->type) || | 2185 | new_serial.baud_base != 921600) |
2227 | (new_serial.custom_divisor != 0) || | 2186 | return -EPERM; |
2228 | (new_serial.baud_base != 921600)) | ||
2229 | return (-EPERM); | ||
2230 | 2187 | ||
2231 | if (!capable(CAP_SYS_ADMIN)) { | 2188 | if (!capable(CAP_SYS_ADMIN)) { |
2232 | if (((new_serial.flags & ~ASYNC_USR_MASK) != | 2189 | if (((new_serial.flags & ~ASYNC_USR_MASK) != |
2233 | (info->asyncflags & ~ASYNC_USR_MASK))) | 2190 | (info->asyncflags & ~ASYNC_USR_MASK))) |
2234 | return (-EPERM); | 2191 | return -EPERM; |
2235 | } else { | 2192 | } else |
2236 | info->close_delay = new_serial.close_delay * HZ / 100; | 2193 | info->close_delay = new_serial.close_delay * HZ / 100; |
2237 | } | ||
2238 | 2194 | ||
2239 | new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS); | 2195 | new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS); |
2240 | new_serial.flags |= (info->asyncflags & ASYNC_FLAGS); | 2196 | new_serial.flags |= (info->asyncflags & ASYNC_FLAGS); |
2241 | 2197 | ||
2242 | if (new_serial.type == PORT_16550A) { | 2198 | MoxaSetFifo(info, new_serial.type == PORT_16550A); |
2243 | MoxaSetFifo(info, 1); | ||
2244 | } else { | ||
2245 | MoxaSetFifo(info, 0); | ||
2246 | } | ||
2247 | 2199 | ||
2248 | info->type = new_serial.type; | 2200 | info->type = new_serial.type; |
2249 | return (0); | 2201 | return 0; |
2250 | } | 2202 | } |
2251 | 2203 | ||
2252 | 2204 | ||