diff options
-rw-r--r-- | drivers/char/stallion.c | 222 |
1 files changed, 91 insertions, 131 deletions
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index c476da100b00..a547c0c8fb2a 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c | |||
@@ -450,51 +450,11 @@ static unsigned int stl_baudrates[] = { | |||
450 | * Declare all those functions in this driver! | 450 | * Declare all those functions in this driver! |
451 | */ | 451 | */ |
452 | 452 | ||
453 | static void stl_argbrds(void); | ||
454 | static int stl_parsebrd(struct stlconf *confp, char **argp); | ||
455 | |||
456 | static unsigned long stl_atol(char *str); | ||
457 | |||
458 | static int stl_open(struct tty_struct *tty, struct file *filp); | ||
459 | static void stl_close(struct tty_struct *tty, struct file *filp); | ||
460 | static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count); | ||
461 | static void stl_putchar(struct tty_struct *tty, unsigned char ch); | ||
462 | static void stl_flushchars(struct tty_struct *tty); | ||
463 | static int stl_writeroom(struct tty_struct *tty); | ||
464 | static int stl_charsinbuffer(struct tty_struct *tty); | ||
465 | static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); | ||
466 | static void stl_settermios(struct tty_struct *tty, struct termios *old); | ||
467 | static void stl_throttle(struct tty_struct *tty); | ||
468 | static void stl_unthrottle(struct tty_struct *tty); | ||
469 | static void stl_stop(struct tty_struct *tty); | ||
470 | static void stl_start(struct tty_struct *tty); | ||
471 | static void stl_flushbuffer(struct tty_struct *tty); | ||
472 | static void stl_breakctl(struct tty_struct *tty, int state); | ||
473 | static void stl_waituntilsent(struct tty_struct *tty, int timeout); | ||
474 | static void stl_sendxchar(struct tty_struct *tty, char ch); | ||
475 | static void stl_hangup(struct tty_struct *tty); | ||
476 | static int stl_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg); | 453 | static int stl_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg); |
477 | static int stl_portinfo(struct stlport *portp, int portnr, char *pos); | ||
478 | static int stl_readproc(char *page, char **start, off_t off, int count, int *eof, void *data); | ||
479 | |||
480 | static int stl_brdinit(struct stlbrd *brdp); | 454 | static int stl_brdinit(struct stlbrd *brdp); |
481 | static int stl_initports(struct stlbrd *brdp, struct stlpanel *panelp); | ||
482 | static int stl_getserial(struct stlport *portp, struct serial_struct __user *sp); | ||
483 | static int stl_setserial(struct stlport *portp, struct serial_struct __user *sp); | ||
484 | static int stl_getbrdstats(combrd_t __user *bp); | ||
485 | static int stl_getportstats(struct stlport *portp, comstats_t __user *cp); | 455 | static int stl_getportstats(struct stlport *portp, comstats_t __user *cp); |
486 | static int stl_clrportstats(struct stlport *portp, comstats_t __user *cp); | 456 | static int stl_clrportstats(struct stlport *portp, comstats_t __user *cp); |
487 | static int stl_getportstruct(struct stlport __user *arg); | ||
488 | static int stl_getbrdstruct(struct stlbrd __user *arg); | ||
489 | static int stl_waitcarrier(struct stlport *portp, struct file *filp); | 457 | static int stl_waitcarrier(struct stlport *portp, struct file *filp); |
490 | static int stl_eiointr(struct stlbrd *brdp); | ||
491 | static int stl_echatintr(struct stlbrd *brdp); | ||
492 | static int stl_echmcaintr(struct stlbrd *brdp); | ||
493 | static int stl_echpciintr(struct stlbrd *brdp); | ||
494 | static int stl_echpci64intr(struct stlbrd *brdp); | ||
495 | static void stl_offintr(struct work_struct *); | ||
496 | static struct stlbrd *stl_allocbrd(void); | ||
497 | static struct stlport *stl_getport(int brdnr, int panelnr, int portnr); | ||
498 | 458 | ||
499 | /* | 459 | /* |
500 | * CD1400 uart specific handling functions. | 460 | * CD1400 uart specific handling functions. |
@@ -700,31 +660,6 @@ static struct class *stallion_class; | |||
700 | * Check for any arguments passed in on the module load command line. | 660 | * Check for any arguments passed in on the module load command line. |
701 | */ | 661 | */ |
702 | 662 | ||
703 | static void __init stl_argbrds(void) | ||
704 | { | ||
705 | struct stlconf conf; | ||
706 | struct stlbrd *brdp; | ||
707 | int i; | ||
708 | |||
709 | pr_debug("stl_argbrds()\n"); | ||
710 | |||
711 | for (i = stl_nrbrds; (i < stl_nargs); i++) { | ||
712 | memset(&conf, 0, sizeof(conf)); | ||
713 | if (stl_parsebrd(&conf, stl_brdsp[i]) == 0) | ||
714 | continue; | ||
715 | if ((brdp = stl_allocbrd()) == NULL) | ||
716 | continue; | ||
717 | stl_nrbrds = i + 1; | ||
718 | brdp->brdnr = i; | ||
719 | brdp->brdtype = conf.brdtype; | ||
720 | brdp->ioaddr1 = conf.ioaddr1; | ||
721 | brdp->ioaddr2 = conf.ioaddr2; | ||
722 | brdp->irq = conf.irq; | ||
723 | brdp->irqtype = conf.irqtype; | ||
724 | stl_brdinit(brdp); | ||
725 | } | ||
726 | } | ||
727 | |||
728 | /*****************************************************************************/ | 663 | /*****************************************************************************/ |
729 | 664 | ||
730 | /* | 665 | /* |
@@ -826,6 +761,31 @@ static struct stlbrd *stl_allocbrd(void) | |||
826 | return brdp; | 761 | return brdp; |
827 | } | 762 | } |
828 | 763 | ||
764 | static void __init stl_argbrds(void) | ||
765 | { | ||
766 | struct stlconf conf; | ||
767 | struct stlbrd *brdp; | ||
768 | int i; | ||
769 | |||
770 | pr_debug("stl_argbrds()\n"); | ||
771 | |||
772 | for (i = stl_nrbrds; (i < stl_nargs); i++) { | ||
773 | memset(&conf, 0, sizeof(conf)); | ||
774 | if (stl_parsebrd(&conf, stl_brdsp[i]) == 0) | ||
775 | continue; | ||
776 | if ((brdp = stl_allocbrd()) == NULL) | ||
777 | continue; | ||
778 | stl_nrbrds = i + 1; | ||
779 | brdp->brdnr = i; | ||
780 | brdp->brdtype = conf.brdtype; | ||
781 | brdp->ioaddr1 = conf.ioaddr1; | ||
782 | brdp->ioaddr2 = conf.ioaddr2; | ||
783 | brdp->irq = conf.irq; | ||
784 | brdp->irqtype = conf.irqtype; | ||
785 | stl_brdinit(brdp); | ||
786 | } | ||
787 | } | ||
788 | |||
829 | /*****************************************************************************/ | 789 | /*****************************************************************************/ |
830 | 790 | ||
831 | static int stl_open(struct tty_struct *tty, struct file *filp) | 791 | static int stl_open(struct tty_struct *tty, struct file *filp) |
@@ -972,6 +932,52 @@ static int stl_waitcarrier(struct stlport *portp, struct file *filp) | |||
972 | 932 | ||
973 | /*****************************************************************************/ | 933 | /*****************************************************************************/ |
974 | 934 | ||
935 | static void stl_flushbuffer(struct tty_struct *tty) | ||
936 | { | ||
937 | struct stlport *portp; | ||
938 | |||
939 | pr_debug("stl_flushbuffer(tty=%p)\n", tty); | ||
940 | |||
941 | if (tty == NULL) | ||
942 | return; | ||
943 | portp = tty->driver_data; | ||
944 | if (portp == NULL) | ||
945 | return; | ||
946 | |||
947 | stl_flush(portp); | ||
948 | tty_wakeup(tty); | ||
949 | } | ||
950 | |||
951 | /*****************************************************************************/ | ||
952 | |||
953 | static void stl_waituntilsent(struct tty_struct *tty, int timeout) | ||
954 | { | ||
955 | struct stlport *portp; | ||
956 | unsigned long tend; | ||
957 | |||
958 | pr_debug("stl_waituntilsent(tty=%p,timeout=%d)\n", tty, timeout); | ||
959 | |||
960 | if (tty == NULL) | ||
961 | return; | ||
962 | portp = tty->driver_data; | ||
963 | if (portp == NULL) | ||
964 | return; | ||
965 | |||
966 | if (timeout == 0) | ||
967 | timeout = HZ; | ||
968 | tend = jiffies + timeout; | ||
969 | |||
970 | while (stl_datastate(portp)) { | ||
971 | if (signal_pending(current)) | ||
972 | break; | ||
973 | msleep_interruptible(20); | ||
974 | if (time_after_eq(jiffies, tend)) | ||
975 | break; | ||
976 | } | ||
977 | } | ||
978 | |||
979 | /*****************************************************************************/ | ||
980 | |||
975 | static void stl_close(struct tty_struct *tty, struct file *filp) | 981 | static void stl_close(struct tty_struct *tty, struct file *filp) |
976 | { | 982 | { |
977 | struct stlport *portp; | 983 | struct stlport *portp; |
@@ -1401,6 +1407,26 @@ static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd | |||
1401 | 1407 | ||
1402 | /*****************************************************************************/ | 1408 | /*****************************************************************************/ |
1403 | 1409 | ||
1410 | /* | ||
1411 | * Start the transmitter again. Just turn TX interrupts back on. | ||
1412 | */ | ||
1413 | |||
1414 | static void stl_start(struct tty_struct *tty) | ||
1415 | { | ||
1416 | struct stlport *portp; | ||
1417 | |||
1418 | pr_debug("stl_start(tty=%p)\n", tty); | ||
1419 | |||
1420 | if (tty == NULL) | ||
1421 | return; | ||
1422 | portp = tty->driver_data; | ||
1423 | if (portp == NULL) | ||
1424 | return; | ||
1425 | stl_startrxtx(portp, -1, 1); | ||
1426 | } | ||
1427 | |||
1428 | /*****************************************************************************/ | ||
1429 | |||
1404 | static void stl_settermios(struct tty_struct *tty, struct termios *old) | 1430 | static void stl_settermios(struct tty_struct *tty, struct termios *old) |
1405 | { | 1431 | { |
1406 | struct stlport *portp; | 1432 | struct stlport *portp; |
@@ -1495,26 +1521,6 @@ static void stl_stop(struct tty_struct *tty) | |||
1495 | /*****************************************************************************/ | 1521 | /*****************************************************************************/ |
1496 | 1522 | ||
1497 | /* | 1523 | /* |
1498 | * Start the transmitter again. Just turn TX interrupts back on. | ||
1499 | */ | ||
1500 | |||
1501 | static void stl_start(struct tty_struct *tty) | ||
1502 | { | ||
1503 | struct stlport *portp; | ||
1504 | |||
1505 | pr_debug("stl_start(tty=%p)\n", tty); | ||
1506 | |||
1507 | if (tty == NULL) | ||
1508 | return; | ||
1509 | portp = tty->driver_data; | ||
1510 | if (portp == NULL) | ||
1511 | return; | ||
1512 | stl_startrxtx(portp, -1, 1); | ||
1513 | } | ||
1514 | |||
1515 | /*****************************************************************************/ | ||
1516 | |||
1517 | /* | ||
1518 | * Hangup this port. This is pretty much like closing the port, only | 1524 | * Hangup this port. This is pretty much like closing the port, only |
1519 | * a little more brutal. No waiting for data to drain. Shutdown the | 1525 | * a little more brutal. No waiting for data to drain. Shutdown the |
1520 | * port and maybe drop signals. | 1526 | * port and maybe drop signals. |
@@ -1554,24 +1560,6 @@ static void stl_hangup(struct tty_struct *tty) | |||
1554 | 1560 | ||
1555 | /*****************************************************************************/ | 1561 | /*****************************************************************************/ |
1556 | 1562 | ||
1557 | static void stl_flushbuffer(struct tty_struct *tty) | ||
1558 | { | ||
1559 | struct stlport *portp; | ||
1560 | |||
1561 | pr_debug("stl_flushbuffer(tty=%p)\n", tty); | ||
1562 | |||
1563 | if (tty == NULL) | ||
1564 | return; | ||
1565 | portp = tty->driver_data; | ||
1566 | if (portp == NULL) | ||
1567 | return; | ||
1568 | |||
1569 | stl_flush(portp); | ||
1570 | tty_wakeup(tty); | ||
1571 | } | ||
1572 | |||
1573 | /*****************************************************************************/ | ||
1574 | |||
1575 | static void stl_breakctl(struct tty_struct *tty, int state) | 1563 | static void stl_breakctl(struct tty_struct *tty, int state) |
1576 | { | 1564 | { |
1577 | struct stlport *portp; | 1565 | struct stlport *portp; |
@@ -1589,34 +1577,6 @@ static void stl_breakctl(struct tty_struct *tty, int state) | |||
1589 | 1577 | ||
1590 | /*****************************************************************************/ | 1578 | /*****************************************************************************/ |
1591 | 1579 | ||
1592 | static void stl_waituntilsent(struct tty_struct *tty, int timeout) | ||
1593 | { | ||
1594 | struct stlport *portp; | ||
1595 | unsigned long tend; | ||
1596 | |||
1597 | pr_debug("stl_waituntilsent(tty=%p,timeout=%d)\n", tty, timeout); | ||
1598 | |||
1599 | if (tty == NULL) | ||
1600 | return; | ||
1601 | portp = tty->driver_data; | ||
1602 | if (portp == NULL) | ||
1603 | return; | ||
1604 | |||
1605 | if (timeout == 0) | ||
1606 | timeout = HZ; | ||
1607 | tend = jiffies + timeout; | ||
1608 | |||
1609 | while (stl_datastate(portp)) { | ||
1610 | if (signal_pending(current)) | ||
1611 | break; | ||
1612 | msleep_interruptible(20); | ||
1613 | if (time_after_eq(jiffies, tend)) | ||
1614 | break; | ||
1615 | } | ||
1616 | } | ||
1617 | |||
1618 | /*****************************************************************************/ | ||
1619 | |||
1620 | static void stl_sendxchar(struct tty_struct *tty, char ch) | 1580 | static void stl_sendxchar(struct tty_struct *tty, char ch) |
1621 | { | 1581 | { |
1622 | struct stlport *portp; | 1582 | struct stlport *portp; |