Commit 8f1e672344c39465b58cf3ffcf348afb2539ced9
Committed by
Greg Kroah-Hartman
1 parent
44e4909e45
Exists in
master
and in
7 other branches
tty: riscom8: switch to the tty_port_open API
Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Showing 1 changed file with 41 additions and 48 deletions Side-by-side Diff
drivers/char/riscom8.c
... | ... | @@ -793,26 +793,21 @@ |
793 | 793 | } |
794 | 794 | |
795 | 795 | /* Must be called with interrupts enabled */ |
796 | -static int rc_setup_port(struct tty_struct *tty, struct riscom_board *bp, | |
797 | - struct riscom_port *port) | |
796 | +static int rc_activate_port(struct tty_port *port, struct tty_struct *tty) | |
798 | 797 | { |
798 | + struct riscom_port *rp = container_of(port, struct riscom_port, port); | |
799 | + struct riscom_board *bp = port_Board(rp); | |
799 | 800 | unsigned long flags; |
800 | 801 | |
801 | - if (port->port.flags & ASYNC_INITIALIZED) | |
802 | - return 0; | |
803 | - | |
804 | - if (tty_port_alloc_xmit_buf(&port->port) < 0) | |
802 | + if (tty_port_alloc_xmit_buf(port) < 0) | |
805 | 803 | return -ENOMEM; |
806 | 804 | |
807 | 805 | spin_lock_irqsave(&riscom_lock, flags); |
808 | 806 | |
809 | 807 | clear_bit(TTY_IO_ERROR, &tty->flags); |
810 | - if (port->port.count == 1) | |
811 | - bp->count++; | |
812 | - port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; | |
813 | - rc_change_speed(tty, bp, port); | |
814 | - port->port.flags |= ASYNC_INITIALIZED; | |
815 | - | |
808 | + bp->count++; | |
809 | + rp->xmit_cnt = rp->xmit_head = rp->xmit_tail = 0; | |
810 | + rc_change_speed(tty, bp, rp); | |
816 | 811 | spin_unlock_irqrestore(&riscom_lock, flags); |
817 | 812 | return 0; |
818 | 813 | } |
... | ... | @@ -821,9 +816,6 @@ |
821 | 816 | static void rc_shutdown_port(struct tty_struct *tty, |
822 | 817 | struct riscom_board *bp, struct riscom_port *port) |
823 | 818 | { |
824 | - if (!(port->port.flags & ASYNC_INITIALIZED)) | |
825 | - return; | |
826 | - | |
827 | 819 | #ifdef RC_REPORT_OVERRUN |
828 | 820 | printk(KERN_INFO "rc%d: port %d: Total %ld overruns were detected.\n", |
829 | 821 | board_No(bp), port_No(port), port->overrun); |
... | ... | @@ -840,11 +832,6 @@ |
840 | 832 | } |
841 | 833 | #endif |
842 | 834 | tty_port_free_xmit_buf(&port->port); |
843 | - if (C_HUPCL(tty)) { | |
844 | - /* Drop DTR */ | |
845 | - bp->DTR |= (1u << port_No(port)); | |
846 | - rc_out(bp, RC_DTR, bp->DTR); | |
847 | - } | |
848 | 835 | |
849 | 836 | /* Select port */ |
850 | 837 | rc_out(bp, CD180_CAR, port_No(port)); |
... | ... | @@ -856,7 +843,6 @@ |
856 | 843 | rc_out(bp, CD180_IER, port->IER); |
857 | 844 | |
858 | 845 | set_bit(TTY_IO_ERROR, &tty->flags); |
859 | - port->port.flags &= ~ASYNC_INITIALIZED; | |
860 | 846 | |
861 | 847 | if (--bp->count < 0) { |
862 | 848 | printk(KERN_INFO "rc%d: rc_shutdown_port: " |
... | ... | @@ -889,6 +875,20 @@ |
889 | 875 | return CD; |
890 | 876 | } |
891 | 877 | |
878 | +static void dtr_rts(struct tty_port *port, int onoff) | |
879 | +{ | |
880 | + struct riscom_port *p = container_of(port, struct riscom_port, port); | |
881 | + struct riscom_board *bp = port_Board(p); | |
882 | + unsigned long flags; | |
883 | + | |
884 | + spin_lock_irqsave(&riscom_lock, flags); | |
885 | + bp->DTR &= ~(1u << port_No(p)); | |
886 | + if (onoff == 0) | |
887 | + bp->DTR |= (1u << port_No(p)); | |
888 | + rc_out(bp, RC_DTR, bp->DTR); | |
889 | + spin_unlock_irqrestore(&riscom_lock, flags); | |
890 | +} | |
891 | + | |
892 | 892 | static int rc_open(struct tty_struct *tty, struct file *filp) |
893 | 893 | { |
894 | 894 | int board; |
... | ... | @@ -909,14 +909,7 @@ |
909 | 909 | if (error) |
910 | 910 | return error; |
911 | 911 | |
912 | - port->port.count++; | |
913 | - tty->driver_data = port; | |
914 | - tty_port_tty_set(&port->port, tty); | |
915 | - | |
916 | - error = rc_setup_port(tty, bp, port); | |
917 | - if (error == 0) | |
918 | - error = tty_port_block_til_ready(&port->port, tty, filp); | |
919 | - return error; | |
912 | + return tty_port_open(&port->port, tty, filp); | |
920 | 913 | } |
921 | 914 | |
922 | 915 | static void rc_flush_buffer(struct tty_struct *tty) |
... | ... | @@ -950,24 +943,23 @@ |
950 | 943 | |
951 | 944 | spin_lock_irqsave(&riscom_lock, flags); |
952 | 945 | rp->IER &= ~IER_RXD; |
953 | - if (port->flags & ASYNC_INITIALIZED) { | |
954 | - rp->IER &= ~IER_TXRDY; | |
955 | - rp->IER |= IER_TXEMPTY; | |
956 | - rc_out(bp, CD180_CAR, port_No(rp)); | |
957 | - rc_out(bp, CD180_IER, rp->IER); | |
958 | - /* | |
959 | - * Before we drop DTR, make sure the UART transmitter | |
960 | - * has completely drained; this is especially | |
961 | - * important if there is a transmit FIFO! | |
962 | - */ | |
963 | - timeout = jiffies + HZ; | |
964 | - while (rp->IER & IER_TXEMPTY) { | |
965 | - spin_unlock_irqrestore(&riscom_lock, flags); | |
966 | - msleep_interruptible(jiffies_to_msecs(rp->timeout)); | |
967 | - spin_lock_irqsave(&riscom_lock, flags); | |
968 | - if (time_after(jiffies, timeout)) | |
969 | - break; | |
970 | - } | |
946 | + | |
947 | + rp->IER &= ~IER_TXRDY; | |
948 | + rp->IER |= IER_TXEMPTY; | |
949 | + rc_out(bp, CD180_CAR, port_No(rp)); | |
950 | + rc_out(bp, CD180_IER, rp->IER); | |
951 | + /* | |
952 | + * Before we drop DTR, make sure the UART transmitter | |
953 | + * has completely drained; this is especially | |
954 | + * important if there is a transmit FIFO! | |
955 | + */ | |
956 | + timeout = jiffies + HZ; | |
957 | + while (rp->IER & IER_TXEMPTY) { | |
958 | + spin_unlock_irqrestore(&riscom_lock, flags); | |
959 | + msleep_interruptible(jiffies_to_msecs(rp->timeout)); | |
960 | + spin_lock_irqsave(&riscom_lock, flags); | |
961 | + if (time_after(jiffies, timeout)) | |
962 | + break; | |
971 | 963 | } |
972 | 964 | rc_shutdown_port(port->tty, bp, rp); |
973 | 965 | spin_unlock_irqrestore(&riscom_lock, flags); |
... | ... | @@ -1354,7 +1346,6 @@ |
1354 | 1346 | if (rc_paranoia_check(port, tty->name, "rc_hangup")) |
1355 | 1347 | return; |
1356 | 1348 | |
1357 | - rc_shutdown_port(tty, port_Board(port), port); | |
1358 | 1349 | tty_port_hangup(&port->port); |
1359 | 1350 | } |
1360 | 1351 | |
1361 | 1352 | |
... | ... | @@ -1401,7 +1392,9 @@ |
1401 | 1392 | |
1402 | 1393 | static const struct tty_port_operations riscom_port_ops = { |
1403 | 1394 | .carrier_raised = carrier_raised, |
1395 | + .dtr_rts = dtr_rts, | |
1404 | 1396 | .shutdown = rc_close_port, |
1397 | + .activate = rc_activate_port, | |
1405 | 1398 | }; |
1406 | 1399 | |
1407 | 1400 |