diff options
Diffstat (limited to 'drivers/usb/serial/io_edgeport.c')
-rw-r--r-- | drivers/usb/serial/io_edgeport.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index bfa508ddb0fe..611f97fd62f1 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -600,6 +600,7 @@ static void edge_interrupt_callback(struct urb *urb) | |||
600 | struct edgeport_serial *edge_serial = urb->context; | 600 | struct edgeport_serial *edge_serial = urb->context; |
601 | struct edgeport_port *edge_port; | 601 | struct edgeport_port *edge_port; |
602 | struct usb_serial_port *port; | 602 | struct usb_serial_port *port; |
603 | struct tty_struct *tty; | ||
603 | unsigned char *data = urb->transfer_buffer; | 604 | unsigned char *data = urb->transfer_buffer; |
604 | int length = urb->actual_length; | 605 | int length = urb->actual_length; |
605 | int bytes_avail; | 606 | int bytes_avail; |
@@ -675,9 +676,12 @@ static void edge_interrupt_callback(struct urb *urb) | |||
675 | 676 | ||
676 | /* tell the tty driver that something | 677 | /* tell the tty driver that something |
677 | has changed */ | 678 | has changed */ |
678 | if (edge_port->port->port.tty) | 679 | tty = tty_port_tty_get( |
679 | tty_wakeup(edge_port->port->port.tty); | 680 | &edge_port->port->port); |
680 | 681 | if (tty) { | |
682 | tty_wakeup(tty); | ||
683 | tty_kref_put(tty); | ||
684 | } | ||
681 | /* Since we have more credit, check | 685 | /* Since we have more credit, check |
682 | if more data can be sent */ | 686 | if more data can be sent */ |
683 | send_more_port_data(edge_serial, | 687 | send_more_port_data(edge_serial, |
@@ -778,13 +782,14 @@ static void edge_bulk_out_data_callback(struct urb *urb) | |||
778 | __func__, status); | 782 | __func__, status); |
779 | } | 783 | } |
780 | 784 | ||
781 | tty = edge_port->port->port.tty; | 785 | tty = tty_port_tty_get(&edge_port->port->port); |
782 | 786 | ||
783 | if (tty && edge_port->open) { | 787 | if (tty && edge_port->open) { |
784 | /* let the tty driver wakeup if it has a special | 788 | /* let the tty driver wakeup if it has a special |
785 | write_wakeup function */ | 789 | write_wakeup function */ |
786 | tty_wakeup(tty); | 790 | tty_wakeup(tty); |
787 | } | 791 | } |
792 | tty_kref_put(tty); | ||
788 | 793 | ||
789 | /* Release the Write URB */ | 794 | /* Release the Write URB */ |
790 | edge_port->write_in_progress = false; | 795 | edge_port->write_in_progress = false; |
@@ -826,11 +831,12 @@ static void edge_bulk_out_cmd_callback(struct urb *urb) | |||
826 | } | 831 | } |
827 | 832 | ||
828 | /* Get pointer to tty */ | 833 | /* Get pointer to tty */ |
829 | tty = edge_port->port->port.tty; | 834 | tty = tty_port_tty_get(&edge_port->port->port); |
830 | 835 | ||
831 | /* tell the tty driver that something has changed */ | 836 | /* tell the tty driver that something has changed */ |
832 | if (tty && edge_port->open) | 837 | if (tty && edge_port->open) |
833 | tty_wakeup(tty); | 838 | tty_wakeup(tty); |
839 | tty_kref_put(tty); | ||
834 | 840 | ||
835 | /* we have completed the command */ | 841 | /* we have completed the command */ |
836 | edge_port->commandPending = false; | 842 | edge_port->commandPending = false; |
@@ -1932,11 +1938,13 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, | |||
1932 | edge_serial->rxPort]; | 1938 | edge_serial->rxPort]; |
1933 | edge_port = usb_get_serial_port_data(port); | 1939 | edge_port = usb_get_serial_port_data(port); |
1934 | if (edge_port->open) { | 1940 | if (edge_port->open) { |
1935 | tty = edge_port->port->port.tty; | 1941 | tty = tty_port_tty_get( |
1942 | &edge_port->port->port); | ||
1936 | if (tty) { | 1943 | if (tty) { |
1937 | dbg("%s - Sending %d bytes to TTY for port %d", | 1944 | dbg("%s - Sending %d bytes to TTY for port %d", |
1938 | __func__, rxLen, edge_serial->rxPort); | 1945 | __func__, rxLen, edge_serial->rxPort); |
1939 | edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); | 1946 | edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); |
1947 | tty_kref_put(tty); | ||
1940 | } | 1948 | } |
1941 | edge_port->icount.rx += rxLen; | 1949 | edge_port->icount.rx += rxLen; |
1942 | } | 1950 | } |
@@ -1971,6 +1979,7 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial, | |||
1971 | { | 1979 | { |
1972 | struct usb_serial_port *port; | 1980 | struct usb_serial_port *port; |
1973 | struct edgeport_port *edge_port; | 1981 | struct edgeport_port *edge_port; |
1982 | struct tty_struct *tty; | ||
1974 | __u8 code = edge_serial->rxStatusCode; | 1983 | __u8 code = edge_serial->rxStatusCode; |
1975 | 1984 | ||
1976 | /* switch the port pointer to the one being currently talked about */ | 1985 | /* switch the port pointer to the one being currently talked about */ |
@@ -2020,10 +2029,12 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial, | |||
2020 | 2029 | ||
2021 | /* send the current line settings to the port so we are | 2030 | /* send the current line settings to the port so we are |
2022 | in sync with any further termios calls */ | 2031 | in sync with any further termios calls */ |
2023 | /* FIXME: locking on tty */ | 2032 | tty = tty_port_tty_get(&edge_port->port->port); |
2024 | if (edge_port->port->port.tty) | 2033 | if (tty) { |
2025 | change_port_settings(edge_port->port->port.tty, | 2034 | change_port_settings(tty, |
2026 | edge_port, edge_port->port->port.tty->termios); | 2035 | edge_port, tty->termios); |
2036 | tty_kref_put(tty); | ||
2037 | } | ||
2027 | 2038 | ||
2028 | /* we have completed the open */ | 2039 | /* we have completed the open */ |
2029 | edge_port->openPending = false; | 2040 | edge_port->openPending = false; |
@@ -2163,10 +2174,14 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, | |||
2163 | } | 2174 | } |
2164 | 2175 | ||
2165 | /* Place LSR data byte into Rx buffer */ | 2176 | /* Place LSR data byte into Rx buffer */ |
2166 | if (lsrData && edge_port->port->port.tty) | 2177 | if (lsrData) { |
2167 | edge_tty_recv(&edge_port->port->dev, | 2178 | struct tty_struct *tty = |
2168 | edge_port->port->port.tty, &data, 1); | 2179 | tty_port_tty_get(&edge_port->port->port); |
2169 | 2180 | if (tty) { | |
2181 | edge_tty_recv(&edge_port->port->dev, tty, &data, 1); | ||
2182 | tty_kref_put(tty); | ||
2183 | } | ||
2184 | } | ||
2170 | /* update input line counters */ | 2185 | /* update input line counters */ |
2171 | icount = &edge_port->icount; | 2186 | icount = &edge_port->icount; |
2172 | if (newLsr & LSR_BREAK) | 2187 | if (newLsr & LSR_BREAK) |