aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/moxa.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/moxa.c')
-rw-r--r--drivers/char/moxa.c235
1 files changed, 116 insertions, 119 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index c440ec542686..b2f3de0195c9 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -104,7 +104,7 @@ static struct moxa_board_conf {
104 int numPorts; 104 int numPorts;
105 int busType; 105 int busType;
106 106
107 int loadstat; 107 unsigned int ready;
108 108
109 struct moxa_port *ports; 109 struct moxa_port *ports;
110 110
@@ -142,7 +142,6 @@ struct moxa_port {
142 142
143 struct timer_list emptyTimer; 143 struct timer_list emptyTimer;
144 144
145 char chkPort;
146 char lineCtrl; 145 char lineCtrl;
147 void __iomem *tableAddr; 146 void __iomem *tableAddr;
148 char DCDState; 147 char DCDState;
@@ -162,7 +161,6 @@ struct moxa_port {
162#define WAKEUP_CHARS 256 161#define WAKEUP_CHARS 256
163 162
164static int ttymajor = MOXAMAJOR; 163static int ttymajor = MOXAMAJOR;
165static int moxaCard;
166/* Variables for insmod */ 164/* Variables for insmod */
167#ifdef MODULE 165#ifdef MODULE
168static unsigned long baseaddr[MAX_BOARDS]; 166static unsigned long baseaddr[MAX_BOARDS];
@@ -218,7 +216,6 @@ static void moxa_receive_data(struct moxa_port *);
218static int MoxaDriverIoctl(struct tty_struct *, unsigned int, unsigned long); 216static int MoxaDriverIoctl(struct tty_struct *, unsigned int, unsigned long);
219static int MoxaDriverPoll(void); 217static int MoxaDriverPoll(void);
220static int MoxaPortsOfCard(int); 218static int MoxaPortsOfCard(int);
221static int MoxaPortIsValid(int);
222static void MoxaPortEnable(struct moxa_port *); 219static void MoxaPortEnable(struct moxa_port *);
223static void MoxaPortDisable(struct moxa_port *); 220static void MoxaPortDisable(struct moxa_port *);
224static int MoxaPortSetTermio(struct moxa_port *, struct ktermios *, speed_t); 221static int MoxaPortSetTermio(struct moxa_port *, struct ktermios *, speed_t);
@@ -263,7 +260,6 @@ static const struct tty_operations moxa_ops = {
263}; 260};
264 261
265static struct tty_driver *moxaDriver; 262static struct tty_driver *moxaDriver;
266static struct moxa_port moxa_ports[MAX_PORTS];
267static DEFINE_TIMER(moxaTimer, moxa_poll, 0, 0); 263static DEFINE_TIMER(moxaTimer, moxa_poll, 0, 0);
268static DEFINE_SPINLOCK(moxa_lock); 264static DEFINE_SPINLOCK(moxa_lock);
269 265
@@ -480,7 +476,6 @@ static int moxa_real_load_code(struct moxa_board_conf *brd, const void *ptr,
480 if (readw(baseAddr + Magic_no) != Magic_code) 476 if (readw(baseAddr + Magic_no) != Magic_code)
481 return -EIO; 477 return -EIO;
482 } 478 }
483 moxaCard = 1;
484 brd->intNdx = baseAddr + IRQindex; 479 brd->intNdx = baseAddr + IRQindex;
485 brd->intPend = baseAddr + IRQpending; 480 brd->intPend = baseAddr + IRQpending;
486 brd->intTable = baseAddr + IRQtable; 481 brd->intTable = baseAddr + IRQtable;
@@ -511,7 +506,6 @@ static int moxa_load_code(struct moxa_board_conf *brd, const void *ptr,
511 port = brd->ports; 506 port = brd->ports;
512 for (i = 0; i < brd->numPorts; i++, port++) { 507 for (i = 0; i < brd->numPorts; i++, port++) {
513 port->board = brd; 508 port->board = brd;
514 port->chkPort = 1;
515 port->DCDState = 0; 509 port->DCDState = 0;
516 port->tableAddr = baseAddr + Extern_table + 510 port->tableAddr = baseAddr + Extern_table +
517 Extern_size * i; 511 Extern_size * i;
@@ -530,7 +524,6 @@ static int moxa_load_code(struct moxa_board_conf *brd, const void *ptr,
530 port = brd->ports; 524 port = brd->ports;
531 for (i = 0; i < brd->numPorts; i++, port++) { 525 for (i = 0; i < brd->numPorts; i++, port++) {
532 port->board = brd; 526 port->board = brd;
533 port->chkPort = 1;
534 port->DCDState = 0; 527 port->DCDState = 0;
535 port->tableAddr = baseAddr + Extern_table + 528 port->tableAddr = baseAddr + Extern_table +
536 Extern_size * i; 529 Extern_size * i;
@@ -575,7 +568,6 @@ static int moxa_load_code(struct moxa_board_conf *brd, const void *ptr,
575 } 568 }
576 break; 569 break;
577 } 570 }
578 brd->loadstat = 1;
579 return 0; 571 return 0;
580} 572}
581 573
@@ -672,8 +664,29 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
672{ 664{
673 const struct firmware *fw; 665 const struct firmware *fw;
674 const char *file; 666 const char *file;
667 struct moxa_port *p;
668 unsigned int i;
675 int ret; 669 int ret;
676 670
671 brd->ports = kcalloc(MAX_PORTS_PER_BOARD, sizeof(*brd->ports),
672 GFP_KERNEL);
673 if (brd->ports == NULL) {
674 printk(KERN_ERR "cannot allocate memory for ports\n");
675 ret = -ENOMEM;
676 goto err;
677 }
678
679 for (i = 0, p = brd->ports; i < MAX_PORTS_PER_BOARD; i++, p++) {
680 p->type = PORT_16550A;
681 p->close_delay = 5 * HZ / 10;
682 p->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
683 init_waitqueue_head(&p->open_wait);
684 init_completion(&p->close_wait);
685
686 setup_timer(&p->emptyTimer, moxa_check_xmit_empty,
687 (unsigned long)p);
688 }
689
677 switch (brd->boardType) { 690 switch (brd->boardType) {
678 case MOXA_BOARD_C218_ISA: 691 case MOXA_BOARD_C218_ISA:
679 case MOXA_BOARD_C218_PCI: 692 case MOXA_BOARD_C218_PCI:
@@ -690,16 +703,38 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
690 ret = request_firmware(&fw, file, dev); 703 ret = request_firmware(&fw, file, dev);
691 if (ret) { 704 if (ret) {
692 printk(KERN_ERR "request_firmware failed\n"); 705 printk(KERN_ERR "request_firmware failed\n");
693 goto end; 706 goto err_free;
694 } 707 }
695 708
696 ret = moxa_load_fw(brd, fw); 709 ret = moxa_load_fw(brd, fw);
697 710
698 release_firmware(fw); 711 release_firmware(fw);
699end: 712
713 if (ret)
714 goto err_free;
715
716 brd->ready = 1;
717
718 return 0;
719err_free:
720 kfree(brd->ports);
721err:
700 return ret; 722 return ret;
701} 723}
702 724
725static void moxa_board_deinit(struct moxa_board_conf *brd)
726{
727 unsigned int i;
728
729 brd->ready = 0;
730 for (i = 0; i < MAX_PORTS_PER_BOARD; i++)
731 del_timer_sync(&brd->ports[i].emptyTimer);
732
733 iounmap(brd->basemem);
734 brd->basemem = NULL;
735 kfree(brd->ports);
736}
737
703#ifdef CONFIG_PCI 738#ifdef CONFIG_PCI
704static int __devinit moxa_pci_probe(struct pci_dev *pdev, 739static int __devinit moxa_pci_probe(struct pci_dev *pdev,
705 const struct pci_device_id *ent) 740 const struct pci_device_id *ent)
@@ -727,7 +762,6 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev,
727 } 762 }
728 763
729 board = &moxa_boards[i]; 764 board = &moxa_boards[i];
730 board->ports = &moxa_ports[i * MAX_PORTS_PER_BOARD];
731 765
732 retval = pci_request_region(pdev, 2, "moxa-base"); 766 retval = pci_request_region(pdev, 2, "moxa-base");
733 if (retval) { 767 if (retval) {
@@ -777,8 +811,8 @@ static void __devexit moxa_pci_remove(struct pci_dev *pdev)
777{ 811{
778 struct moxa_board_conf *brd = pci_get_drvdata(pdev); 812 struct moxa_board_conf *brd = pci_get_drvdata(pdev);
779 813
780 iounmap(brd->basemem); 814 moxa_board_deinit(brd);
781 brd->basemem = NULL; 815
782 pci_release_region(pdev, 2); 816 pci_release_region(pdev, 2);
783} 817}
784 818
@@ -792,8 +826,7 @@ static struct pci_driver moxa_pci_driver = {
792 826
793static int __init moxa_init(void) 827static int __init moxa_init(void)
794{ 828{
795 struct moxa_port *ch; 829 unsigned int isabrds = 0;
796 unsigned int i, isabrds = 0;
797 int retval = 0; 830 int retval = 0;
798 831
799 printk(KERN_INFO "MOXA Intellio family driver version %s\n", 832 printk(KERN_INFO "MOXA Intellio family driver version %s\n",
@@ -815,17 +848,6 @@ static int __init moxa_init(void)
815 moxaDriver->flags = TTY_DRIVER_REAL_RAW; 848 moxaDriver->flags = TTY_DRIVER_REAL_RAW;
816 tty_set_operations(moxaDriver, &moxa_ops); 849 tty_set_operations(moxaDriver, &moxa_ops);
817 850
818 for (i = 0, ch = moxa_ports; i < MAX_PORTS; i++, ch++) {
819 ch->type = PORT_16550A;
820 ch->close_delay = 5 * HZ / 10;
821 ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
822 init_waitqueue_head(&ch->open_wait);
823 init_completion(&ch->close_wait);
824
825 setup_timer(&ch->emptyTimer, moxa_check_xmit_empty,
826 (unsigned long)ch);
827 }
828
829 pr_debug("Moxa tty devices major number = %d\n", ttymajor); 851 pr_debug("Moxa tty devices major number = %d\n", ttymajor);
830 852
831 if (tty_register_driver(moxaDriver)) { 853 if (tty_register_driver(moxaDriver)) {
@@ -840,6 +862,7 @@ static int __init moxa_init(void)
840#ifdef MODULE 862#ifdef MODULE
841 { 863 {
842 struct moxa_board_conf *brd = moxa_boards; 864 struct moxa_board_conf *brd = moxa_boards;
865 unsigned int i;
843 for (i = 0; i < MAX_BOARDS; i++) { 866 for (i = 0; i < MAX_BOARDS; i++) {
844 if (!baseaddr[i]) 867 if (!baseaddr[i])
845 break; 868 break;
@@ -849,7 +872,6 @@ static int __init moxa_init(void)
849 isabrds + 1, moxa_brdname[type[i] - 1], 872 isabrds + 1, moxa_brdname[type[i] - 1],
850 baseaddr[i]); 873 baseaddr[i]);
851 brd->boardType = type[i]; 874 brd->boardType = type[i];
852 brd->ports = &moxa_ports[isabrds * MAX_PORTS_PER_BOARD];
853 brd->numPorts = type[i] == MOXA_BOARD_C218_ISA ? 8 : 875 brd->numPorts = type[i] == MOXA_BOARD_C218_ISA ? 8 :
854 numports[i]; 876 numports[i];
855 brd->busType = MOXA_BUS_TYPE_ISA; 877 brd->busType = MOXA_BUS_TYPE_ISA;
@@ -890,9 +912,6 @@ static void __exit moxa_exit(void)
890 912
891 del_timer_sync(&moxaTimer); 913 del_timer_sync(&moxaTimer);
892 914
893 for (i = 0; i < MAX_PORTS; i++)
894 del_timer_sync(&moxa_ports[i].emptyTimer);
895
896 if (tty_unregister_driver(moxaDriver)) 915 if (tty_unregister_driver(moxaDriver))
897 printk(KERN_ERR "Couldn't unregister MOXA Intellio family " 916 printk(KERN_ERR "Couldn't unregister MOXA Intellio family "
898 "serial driver\n"); 917 "serial driver\n");
@@ -902,9 +921,9 @@ static void __exit moxa_exit(void)
902 pci_unregister_driver(&moxa_pci_driver); 921 pci_unregister_driver(&moxa_pci_driver);
903#endif 922#endif
904 923
905 for (i = 0; i < MAX_BOARDS; i++) 924 for (i = 0; i < MAX_BOARDS; i++) /* ISA boards */
906 if (moxa_boards[i].basemem) 925 if (moxa_boards[i].ready)
907 iounmap(moxa_boards[i].basemem); 926 moxa_board_deinit(&moxa_boards[i]);
908} 927}
909 928
910module_init(moxa_init); 929module_init(moxa_init);
@@ -912,6 +931,7 @@ module_exit(moxa_exit);
912 931
913static int moxa_open(struct tty_struct *tty, struct file *filp) 932static int moxa_open(struct tty_struct *tty, struct file *filp)
914{ 933{
934 struct moxa_board_conf *brd;
915 struct moxa_port *ch; 935 struct moxa_port *ch;
916 int port; 936 int port;
917 int retval; 937 int retval;
@@ -920,12 +940,11 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
920 if (port == MAX_PORTS) { 940 if (port == MAX_PORTS) {
921 return (0); 941 return (0);
922 } 942 }
923 if (!MoxaPortIsValid(port)) { 943 brd = &moxa_boards[port / MAX_PORTS_PER_BOARD];
924 tty->driver_data = NULL; 944 if (!brd->ready)
925 return (-ENODEV); 945 return -ENODEV;
926 }
927 946
928 ch = &moxa_ports[port]; 947 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
929 ch->count++; 948 ch->count++;
930 tty->driver_data = ch; 949 tty->driver_data = ch;
931 ch->tty = tty; 950 ch->tty = tty;
@@ -958,11 +977,6 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
958 if (port == MAX_PORTS) { 977 if (port == MAX_PORTS) {
959 return; 978 return;
960 } 979 }
961 if (!MoxaPortIsValid(port)) {
962 pr_debug("Invalid portno in moxa_close\n");
963 tty->driver_data = NULL;
964 return;
965 }
966 if (tty->driver_data == NULL) { 980 if (tty->driver_data == NULL) {
967 return; 981 return;
968 } 982 }
@@ -1285,7 +1299,7 @@ static void moxa_poll(unsigned long ignored)
1285 for (card = 0; card < MAX_BOARDS; card++) { 1299 for (card = 0; card < MAX_BOARDS; card++) {
1286 if ((ports = MoxaPortsOfCard(card)) <= 0) 1300 if ((ports = MoxaPortsOfCard(card)) <= 0)
1287 continue; 1301 continue;
1288 ch = &moxa_ports[card * MAX_PORTS_PER_BOARD]; 1302 ch = moxa_boards[card].ports;
1289 for (i = 0; i < ports; i++, ch++) { 1303 for (i = 0; i < ports; i++, ch++) {
1290 if ((ch->asyncflags & ASYNC_INITIALIZED) == 0) 1304 if ((ch->asyncflags & ASYNC_INITIALIZED) == 0)
1291 continue; 1305 continue;
@@ -1589,17 +1603,22 @@ static int MoxaDriverIoctl(struct tty_struct *tty, unsigned int cmd,
1589 case MOXA_GET_IOQUEUE: { 1603 case MOXA_GET_IOQUEUE: {
1590 struct moxaq_str __user *argm = argp; 1604 struct moxaq_str __user *argm = argp;
1591 struct moxaq_str tmp; 1605 struct moxaq_str tmp;
1592 1606 struct moxa_port *p;
1593 for (i = 0; i < MAX_PORTS; i++, argm++) { 1607 unsigned int j;
1594 memset(&tmp, 0, sizeof(tmp)); 1608
1595 if (moxa_ports[i].chkPort) { 1609 for (i = 0; i < MAX_BOARDS; i++) {
1596 tmp.inq = MoxaPortRxQueue(&moxa_ports[i]); 1610 p = moxa_boards[i].ports;
1597 tmp.outq = MoxaPortTxQueue(&moxa_ports[i]); 1611 for (j = 0; j < MAX_PORTS_PER_BOARD; j++, p++, argm++) {
1612 memset(&tmp, 0, sizeof(tmp));
1613 if (moxa_boards[i].ready) {
1614 tmp.inq = MoxaPortRxQueue(p);
1615 tmp.outq = MoxaPortTxQueue(p);
1616 }
1617 if (copy_to_user(argm, &tmp, sizeof(tmp)))
1618 return -EFAULT;
1598 } 1619 }
1599 if (copy_to_user(argm, &tmp, sizeof(tmp)))
1600 return -EFAULT;
1601 } 1620 }
1602 return (0); 1621 return 0;
1603 } case MOXA_GET_OQUEUE: 1622 } case MOXA_GET_OQUEUE:
1604 i = MoxaPortTxQueue(port); 1623 i = MoxaPortTxQueue(port);
1605 return put_user(i, (unsigned long __user *)argp); 1624 return put_user(i, (unsigned long __user *)argp);
@@ -1619,13 +1638,15 @@ static int MoxaDriverIoctl(struct tty_struct *tty, unsigned int cmd,
1619 struct mxser_mstatus __user *argm = argp; 1638 struct mxser_mstatus __user *argm = argp;
1620 struct mxser_mstatus tmp; 1639 struct mxser_mstatus tmp;
1621 struct moxa_port *p; 1640 struct moxa_port *p;
1641 unsigned int j;
1642
1643 for (i = 0; i < MAX_BOARDS; i++) {
1644 p = moxa_boards[i].ports;
1645 for (j = 0; j < MAX_PORTS_PER_BOARD; j++, p++, argm++) {
1646 memset(&tmp, 0, sizeof(tmp));
1647 if (!moxa_boards[i].ready)
1648 goto copy;
1622 1649
1623 for (i = 0; i < MAX_PORTS; i++, argm++) {
1624 p = &moxa_ports[i];
1625 memset(&tmp, 0, sizeof(tmp));
1626 if (!p->chkPort) {
1627 goto copy;
1628 } else {
1629 status = MoxaPortLineStatus(p); 1650 status = MoxaPortLineStatus(p);
1630 if (status & 1) 1651 if (status & 1)
1631 tmp.cts = 1; 1652 tmp.cts = 1;
@@ -1633,15 +1654,15 @@ static int MoxaDriverIoctl(struct tty_struct *tty, unsigned int cmd,
1633 tmp.dsr = 1; 1654 tmp.dsr = 1;
1634 if (status & 4) 1655 if (status & 4)
1635 tmp.dcd = 1; 1656 tmp.dcd = 1;
1636 }
1637 1657
1638 if (!p->tty || !p->tty->termios) 1658 if (!p->tty || !p->tty->termios)
1639 tmp.cflag = p->cflag; 1659 tmp.cflag = p->cflag;
1640 else 1660 else
1641 tmp.cflag = p->tty->termios->c_cflag; 1661 tmp.cflag = p->tty->termios->c_cflag;
1642copy: 1662copy:
1643 if (copy_to_user(argm, &tmp, sizeof(tmp))) 1663 if (copy_to_user(argm, &tmp, sizeof(tmp)))
1644 return -EFAULT; 1664 return -EFAULT;
1665 }
1645 } 1666 }
1646 return 0; 1667 return 0;
1647 } 1668 }
@@ -1653,53 +1674,55 @@ copy:
1653int MoxaDriverPoll(void) 1674int MoxaDriverPoll(void)
1654{ 1675{
1655 struct moxa_board_conf *brd; 1676 struct moxa_board_conf *brd;
1677 struct moxa_port *p;
1656 register ushort temp; 1678 register ushort temp;
1657 register int card; 1679 register int card;
1658 void __iomem *ofsAddr; 1680 void __iomem *ofsAddr;
1659 void __iomem *ip; 1681 void __iomem *ip;
1660 int port, p, ports; 1682 int port, ports;
1661 1683
1662 if (moxaCard == 0)
1663 return (-1);
1664 for (card = 0; card < MAX_BOARDS; card++) { 1684 for (card = 0; card < MAX_BOARDS; card++) {
1665 brd = &moxa_boards[card]; 1685 brd = &moxa_boards[card];
1666 if (brd->loadstat == 0) 1686 if (brd->ready == 0)
1667 continue; 1687 continue;
1668 if ((ports = brd->numPorts) == 0) 1688 if ((ports = brd->numPorts) == 0)
1669 continue; 1689 continue;
1670 if (readb(brd->intPend) == 0xff) { 1690 if (readb(brd->intPend) == 0xff) {
1671 ip = brd->intTable + readb(brd->intNdx); 1691 ip = brd->intTable + readb(brd->intNdx);
1672 p = card * MAX_PORTS_PER_BOARD; 1692 p = brd->ports;
1673 ports <<= 1; 1693 ports <<= 1;
1674 for (port = 0; port < ports; port += 2, p++) { 1694 for (port = 0; port < ports; port += 2, p++) {
1675 if ((temp = readw(ip + port)) != 0) { 1695 temp = readw(ip + port);
1676 writew(0, ip + port); 1696 if (temp == 0)
1677 ofsAddr = moxa_ports[p].tableAddr; 1697 continue;
1678 if (temp & IntrTx) 1698
1679 writew(readw(ofsAddr + HostStat) & ~WakeupTx, ofsAddr + HostStat); 1699 writew(0, ip + port);
1680 if (temp & IntrBreak) { 1700 ofsAddr = p->tableAddr;
1681 moxa_ports[p].breakCnt++; 1701 if (temp & IntrTx)
1682 } 1702 writew(readw(ofsAddr + HostStat) &
1683 if (temp & IntrLine) { 1703 ~WakeupTx, ofsAddr + HostStat);
1684 if (readb(ofsAddr + FlagStat) & DCD_state) { 1704 if (temp & IntrBreak)
1685 if ((moxa_ports[p].DCDState & DCD_oldstate) == 0) 1705 p->breakCnt++;
1686 moxa_ports[p].DCDState = (DCD_oldstate | 1706
1687 DCD_changed); 1707 if (temp & IntrLine) {
1688 } else { 1708 if (readb(ofsAddr + FlagStat) & DCD_state) {
1689 if (moxa_ports[p].DCDState & DCD_oldstate) 1709 if ((p->DCDState & DCD_oldstate) == 0)
1690 moxa_ports[p].DCDState = DCD_changed; 1710 p->DCDState = (DCD_oldstate |
1691 } 1711 DCD_changed);
1712 } else {
1713 if (p->DCDState & DCD_oldstate)
1714 p->DCDState = DCD_changed;
1692 } 1715 }
1693 } 1716 }
1694 } 1717 }
1695 writeb(0, brd->intPend); 1718 writeb(0, brd->intPend);
1696 } 1719 }
1697 if (moxaLowWaterChk) { 1720 if (moxaLowWaterChk) {
1698 p = card * MAX_PORTS_PER_BOARD; 1721 p = brd->ports;
1699 for (port = 0; port < ports; port++, p++) { 1722 for (port = 0; port < ports; port++, p++) {
1700 if (moxa_ports[p].lowChkFlag) { 1723 if (p->lowChkFlag) {
1701 moxa_ports[p].lowChkFlag = 0; 1724 p->lowChkFlag = 0;
1702 ofsAddr = moxa_ports[p].tableAddr; 1725 ofsAddr = p->tableAddr;
1703 moxa_low_water_check(ofsAddr); 1726 moxa_low_water_check(ofsAddr);
1704 } 1727 }
1705 } 1728 }
@@ -1723,7 +1746,6 @@ int MoxaPortsOfCard(int cardno)
1723 1746
1724/***************************************************************************** 1747/*****************************************************************************
1725 * Port level functions: * 1748 * Port level functions: *
1726 * 1. MoxaPortIsValid(int port); *
1727 * 2. MoxaPortEnable(int port); * 1749 * 2. MoxaPortEnable(int port); *
1728 * 3. MoxaPortDisable(int port); * 1750 * 3. MoxaPortDisable(int port); *
1729 * 4. MoxaPortGetMaxBaud(int port); * 1751 * 4. MoxaPortGetMaxBaud(int port); *
@@ -1800,15 +1822,6 @@ int MoxaPortsOfCard(int cardno)
1800 * 8/16/24/32 1822 * 8/16/24/32
1801 * 1823 *
1802 * 1824 *
1803 * Function 5: Check this port is valid or invalid
1804 * Syntax:
1805 * int MoxaPortIsValid(int port);
1806 * int port : port number (0 - 127, ref port description)
1807 *
1808 * return: 0 : this port is invalid
1809 * 1 : this port is valid
1810 *
1811 *
1812 * Function 6: Enable this port to start Tx/Rx data. 1825 * Function 6: Enable this port to start Tx/Rx data.
1813 * Syntax: 1826 * Syntax:
1814 * void MoxaPortEnable(int port); 1827 * void MoxaPortEnable(int port);
@@ -2000,14 +2013,6 @@ int MoxaPortsOfCard(int cardno)
2000 * send out a about 250 ms BREAK signal. 2013 * send out a about 250 ms BREAK signal.
2001 * 2014 *
2002 */ 2015 */
2003static int MoxaPortIsValid(int port)
2004{
2005 if (moxaCard == 0)
2006 return (0);
2007 if (moxa_ports[port].chkPort == 0)
2008 return (0);
2009 return (1);
2010}
2011 2016
2012static void MoxaPortEnable(struct moxa_port *port) 2017static void MoxaPortEnable(struct moxa_port *port)
2013{ 2018{
@@ -2081,8 +2086,6 @@ static int MoxaPortSetTermio(struct moxa_port *port, struct ktermios *termio,
2081 tcflag_t cflag; 2086 tcflag_t cflag;
2082 tcflag_t mode = 0; 2087 tcflag_t mode = 0;
2083 2088
2084 if (port->chkPort == 0 || termio == 0)
2085 return (-1);
2086 ofsAddr = port->tableAddr; 2089 ofsAddr = port->tableAddr;
2087 cflag = termio->c_cflag; /* termio->c_cflag */ 2090 cflag = termio->c_cflag; /* termio->c_cflag */
2088 2091
@@ -2135,8 +2138,6 @@ static int MoxaPortGetLineOut(struct moxa_port *port, int *dtrState,
2135 int *rtsState) 2138 int *rtsState)
2136{ 2139{
2137 2140
2138 if (!MoxaPortIsValid(port->tty->index))
2139 return (-1);
2140 if (dtrState) 2141 if (dtrState)
2141 *dtrState = !!(port->lineCtrl & DTR_ON); 2142 *dtrState = !!(port->lineCtrl & DTR_ON);
2142 if (rtsState) 2143 if (rtsState)
@@ -2205,8 +2206,6 @@ static int MoxaPortDCDChange(struct moxa_port *port)
2205{ 2206{
2206 int n; 2207 int n;
2207 2208
2208 if (port->chkPort == 0)
2209 return (0);
2210 n = port->DCDState; 2209 n = port->DCDState;
2211 port->DCDState &= ~DCD_changed; 2210 port->DCDState &= ~DCD_changed;
2212 n &= DCD_changed; 2211 n &= DCD_changed;
@@ -2217,8 +2216,6 @@ static int MoxaPortDCDON(struct moxa_port *port)
2217{ 2216{
2218 int n; 2217 int n;
2219 2218
2220 if (port->chkPort == 0)
2221 return (0);
2222 if (port->DCDState & DCD_oldstate) 2219 if (port->DCDState & DCD_oldstate)
2223 n = 1; 2220 n = 1;
2224 else 2221 else