diff options
77 files changed, 1194 insertions, 1152 deletions
diff --git a/Documentation/devicetree/bindings/tty/serial/of-serial.txt b/Documentation/devicetree/bindings/tty/serial/of-serial.txt index 8f01cb190f25..1928a3e83cd0 100644 --- a/Documentation/devicetree/bindings/tty/serial/of-serial.txt +++ b/Documentation/devicetree/bindings/tty/serial/of-serial.txt | |||
@@ -33,6 +33,10 @@ Optional properties: | |||
33 | RTAS and should not be registered. | 33 | RTAS and should not be registered. |
34 | - no-loopback-test: set to indicate that the port does not implements loopback | 34 | - no-loopback-test: set to indicate that the port does not implements loopback |
35 | test mode | 35 | test mode |
36 | - fifo-size: the fifo size of the UART. | ||
37 | - auto-flow-control: one way to enable automatic flow control support. The | ||
38 | driver is allowed to detect support for the capability even without this | ||
39 | property. | ||
36 | 40 | ||
37 | Example: | 41 | Example: |
38 | 42 | ||
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c index da2f319fb71d..e70cadec7ce6 100644 --- a/arch/ia64/hp/sim/simserial.c +++ b/arch/ia64/hp/sim/simserial.c | |||
@@ -142,8 +142,7 @@ static void transmit_chars(struct tty_struct *tty, struct serial_state *info, | |||
142 | goto out; | 142 | goto out; |
143 | } | 143 | } |
144 | 144 | ||
145 | if (info->xmit.head == info->xmit.tail || tty->stopped || | 145 | if (info->xmit.head == info->xmit.tail || tty->stopped) { |
146 | tty->hw_stopped) { | ||
147 | #ifdef SIMSERIAL_DEBUG | 146 | #ifdef SIMSERIAL_DEBUG |
148 | printk("transmit_chars: head=%d, tail=%d, stopped=%d\n", | 147 | printk("transmit_chars: head=%d, tail=%d, stopped=%d\n", |
149 | info->xmit.head, info->xmit.tail, tty->stopped); | 148 | info->xmit.head, info->xmit.tail, tty->stopped); |
@@ -181,7 +180,7 @@ static void rs_flush_chars(struct tty_struct *tty) | |||
181 | struct serial_state *info = tty->driver_data; | 180 | struct serial_state *info = tty->driver_data; |
182 | 181 | ||
183 | if (info->xmit.head == info->xmit.tail || tty->stopped || | 182 | if (info->xmit.head == info->xmit.tail || tty->stopped || |
184 | tty->hw_stopped || !info->xmit.buf) | 183 | !info->xmit.buf) |
185 | return; | 184 | return; |
186 | 185 | ||
187 | transmit_chars(tty, info, NULL); | 186 | transmit_chars(tty, info, NULL); |
@@ -217,7 +216,7 @@ static int rs_write(struct tty_struct * tty, | |||
217 | * Hey, we transmit directly from here in our case | 216 | * Hey, we transmit directly from here in our case |
218 | */ | 217 | */ |
219 | if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) && | 218 | if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) && |
220 | !tty->stopped && !tty->hw_stopped) | 219 | !tty->stopped) |
221 | transmit_chars(tty, info, NULL); | 220 | transmit_chars(tty, info, NULL); |
222 | 221 | ||
223 | return ret; | 222 | return ret; |
@@ -325,14 +324,6 @@ static int rs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) | |||
325 | 324 | ||
326 | #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) | 325 | #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) |
327 | 326 | ||
328 | static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | ||
329 | { | ||
330 | /* Handle turning off CRTSCTS */ | ||
331 | if ((old_termios->c_cflag & CRTSCTS) && | ||
332 | !(tty->termios.c_cflag & CRTSCTS)) { | ||
333 | tty->hw_stopped = 0; | ||
334 | } | ||
335 | } | ||
336 | /* | 327 | /* |
337 | * This routine will shutdown a serial port; interrupts are disabled, and | 328 | * This routine will shutdown a serial port; interrupts are disabled, and |
338 | * DTR is dropped if the hangup on close termio flag is on. | 329 | * DTR is dropped if the hangup on close termio flag is on. |
@@ -481,7 +472,6 @@ static const struct tty_operations hp_ops = { | |||
481 | .throttle = rs_throttle, | 472 | .throttle = rs_throttle, |
482 | .unthrottle = rs_unthrottle, | 473 | .unthrottle = rs_unthrottle, |
483 | .send_xchar = rs_send_xchar, | 474 | .send_xchar = rs_send_xchar, |
484 | .set_termios = rs_set_termios, | ||
485 | .hangup = rs_hangup, | 475 | .hangup = rs_hangup, |
486 | .proc_fops = &rs_proc_fops, | 476 | .proc_fops = &rs_proc_fops, |
487 | }; | 477 | }; |
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index 80b47cb71e0a..acbe6c67afba 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c | |||
@@ -568,11 +568,7 @@ void chan_interrupt(struct line *line, int irq) | |||
568 | reactivate_fd(chan->fd, irq); | 568 | reactivate_fd(chan->fd, irq); |
569 | if (err == -EIO) { | 569 | if (err == -EIO) { |
570 | if (chan->primary) { | 570 | if (chan->primary) { |
571 | struct tty_struct *tty = tty_port_tty_get(&line->port); | 571 | tty_port_tty_hangup(&line->port, false); |
572 | if (tty != NULL) { | ||
573 | tty_hangup(tty); | ||
574 | tty_kref_put(tty); | ||
575 | } | ||
576 | if (line->chan_out != chan) | 572 | if (line->chan_out != chan) |
577 | close_one_chan(line->chan_out, 1); | 573 | close_one_chan(line->chan_out, 1); |
578 | } | 574 | } |
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index be541cf69fd2..8035145f043b 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c | |||
@@ -248,7 +248,6 @@ static irqreturn_t line_write_interrupt(int irq, void *data) | |||
248 | { | 248 | { |
249 | struct chan *chan = data; | 249 | struct chan *chan = data; |
250 | struct line *line = chan->line; | 250 | struct line *line = chan->line; |
251 | struct tty_struct *tty; | ||
252 | int err; | 251 | int err; |
253 | 252 | ||
254 | /* | 253 | /* |
@@ -267,12 +266,7 @@ static irqreturn_t line_write_interrupt(int irq, void *data) | |||
267 | } | 266 | } |
268 | spin_unlock(&line->lock); | 267 | spin_unlock(&line->lock); |
269 | 268 | ||
270 | tty = tty_port_tty_get(&line->port); | 269 | tty_port_tty_wakeup(&line->port); |
271 | if (tty == NULL) | ||
272 | return IRQ_NONE; | ||
273 | |||
274 | tty_wakeup(tty); | ||
275 | tty_kref_put(tty); | ||
276 | 270 | ||
277 | return IRQ_HANDLED; | 271 | return IRQ_HANDLED; |
278 | } | 272 | } |
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index 89562a845f6a..ac6f72b455d1 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c | |||
@@ -569,7 +569,6 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb) | |||
569 | { | 569 | { |
570 | struct capidev *cdev = ap->private; | 570 | struct capidev *cdev = ap->private; |
571 | #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE | 571 | #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE |
572 | struct tty_struct *tty; | ||
573 | struct capiminor *mp; | 572 | struct capiminor *mp; |
574 | u16 datahandle; | 573 | u16 datahandle; |
575 | struct capincci *np; | 574 | struct capincci *np; |
@@ -627,11 +626,7 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb) | |||
627 | CAPIMSG_U16(skb->data, CAPIMSG_BASELEN + 4 + 2)); | 626 | CAPIMSG_U16(skb->data, CAPIMSG_BASELEN + 4 + 2)); |
628 | kfree_skb(skb); | 627 | kfree_skb(skb); |
629 | capiminor_del_ack(mp, datahandle); | 628 | capiminor_del_ack(mp, datahandle); |
630 | tty = tty_port_tty_get(&mp->port); | 629 | tty_port_tty_wakeup(&mp->port); |
631 | if (tty) { | ||
632 | tty_wakeup(tty); | ||
633 | tty_kref_put(tty); | ||
634 | } | ||
635 | handle_minor_send(mp); | 630 | handle_minor_send(mp); |
636 | 631 | ||
637 | } else { | 632 | } else { |
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index e2b539675b66..600c79b030cd 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c | |||
@@ -487,12 +487,8 @@ static const struct tty_operations if_ops = { | |||
487 | static void if_wake(unsigned long data) | 487 | static void if_wake(unsigned long data) |
488 | { | 488 | { |
489 | struct cardstate *cs = (struct cardstate *)data; | 489 | struct cardstate *cs = (struct cardstate *)data; |
490 | struct tty_struct *tty = tty_port_tty_get(&cs->port); | ||
491 | 490 | ||
492 | if (tty) { | 491 | tty_port_tty_wakeup(&cs->port); |
493 | tty_wakeup(tty); | ||
494 | tty_kref_put(tty); | ||
495 | } | ||
496 | } | 492 | } |
497 | 493 | ||
498 | /*** interface to common ***/ | 494 | /*** interface to common ***/ |
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index ebaebdf30f98..b72afd81a7bb 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c | |||
@@ -1472,9 +1472,6 @@ isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
1472 | tty->termios.c_ospeed == old_termios->c_ospeed) | 1472 | tty->termios.c_ospeed == old_termios->c_ospeed) |
1473 | return; | 1473 | return; |
1474 | isdn_tty_change_speed(info); | 1474 | isdn_tty_change_speed(info); |
1475 | if ((old_termios->c_cflag & CRTSCTS) && | ||
1476 | !(tty->termios.c_cflag & CRTSCTS)) | ||
1477 | tty->hw_stopped = 0; | ||
1478 | } | 1475 | } |
1479 | } | 1476 | } |
1480 | 1477 | ||
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c index c931dfe6a59c..f093cea0d060 100644 --- a/drivers/mmc/card/sdio_uart.c +++ b/drivers/mmc/card/sdio_uart.c | |||
@@ -134,7 +134,6 @@ static void sdio_uart_port_put(struct sdio_uart_port *port) | |||
134 | static void sdio_uart_port_remove(struct sdio_uart_port *port) | 134 | static void sdio_uart_port_remove(struct sdio_uart_port *port) |
135 | { | 135 | { |
136 | struct sdio_func *func; | 136 | struct sdio_func *func; |
137 | struct tty_struct *tty; | ||
138 | 137 | ||
139 | BUG_ON(sdio_uart_table[port->index] != port); | 138 | BUG_ON(sdio_uart_table[port->index] != port); |
140 | 139 | ||
@@ -155,12 +154,8 @@ static void sdio_uart_port_remove(struct sdio_uart_port *port) | |||
155 | sdio_claim_host(func); | 154 | sdio_claim_host(func); |
156 | port->func = NULL; | 155 | port->func = NULL; |
157 | mutex_unlock(&port->func_lock); | 156 | mutex_unlock(&port->func_lock); |
158 | tty = tty_port_tty_get(&port->port); | ||
159 | /* tty_hangup is async so is this safe as is ?? */ | 157 | /* tty_hangup is async so is this safe as is ?? */ |
160 | if (tty) { | 158 | tty_port_tty_hangup(&port->port, false); |
161 | tty_hangup(tty); | ||
162 | tty_kref_put(tty); | ||
163 | } | ||
164 | mutex_unlock(&port->port.mutex); | 159 | mutex_unlock(&port->port.mutex); |
165 | sdio_release_irq(func); | 160 | sdio_release_irq(func); |
166 | sdio_disable_func(func); | 161 | sdio_disable_func(func); |
@@ -492,11 +487,7 @@ static void sdio_uart_check_modem_status(struct sdio_uart_port *port) | |||
492 | wake_up_interruptible(&port->port.open_wait); | 487 | wake_up_interruptible(&port->port.open_wait); |
493 | else { | 488 | else { |
494 | /* DCD drop - hang up if tty attached */ | 489 | /* DCD drop - hang up if tty attached */ |
495 | tty = tty_port_tty_get(&port->port); | 490 | tty_port_tty_hangup(&port->port, false); |
496 | if (tty) { | ||
497 | tty_hangup(tty); | ||
498 | tty_kref_put(tty); | ||
499 | } | ||
500 | } | 491 | } |
501 | } | 492 | } |
502 | if (status & UART_MSR_DCTS) { | 493 | if (status & UART_MSR_DCTS) { |
diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c index 666891a9a248..be90debc7cd1 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c | |||
@@ -88,11 +88,9 @@ static inline void update_tty_status(struct ser_device *ser) | |||
88 | { | 88 | { |
89 | ser->tty_status = | 89 | ser->tty_status = |
90 | ser->tty->stopped << 5 | | 90 | ser->tty->stopped << 5 | |
91 | ser->tty->hw_stopped << 4 | | ||
92 | ser->tty->flow_stopped << 3 | | 91 | ser->tty->flow_stopped << 3 | |
93 | ser->tty->packet << 2 | | 92 | ser->tty->packet << 2 | |
94 | ser->tty->port->low_latency << 1 | | 93 | ser->tty->port->low_latency << 1; |
95 | ser->tty->warned; | ||
96 | } | 94 | } |
97 | static inline void debugfs_init(struct ser_device *ser, struct tty_struct *tty) | 95 | static inline void debugfs_init(struct ser_device *ser, struct tty_struct *tty) |
98 | { | 96 | { |
diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c index a031f6b456b4..9c889e0303dd 100644 --- a/drivers/net/ppp/ppp_async.c +++ b/drivers/net/ppp/ppp_async.c | |||
@@ -314,7 +314,7 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file, | |||
314 | /* flush our buffers and the serial port's buffer */ | 314 | /* flush our buffers and the serial port's buffer */ |
315 | if (arg == TCIOFLUSH || arg == TCOFLUSH) | 315 | if (arg == TCIOFLUSH || arg == TCOFLUSH) |
316 | ppp_async_flush_output(ap); | 316 | ppp_async_flush_output(ap); |
317 | err = tty_perform_flush(tty, arg); | 317 | err = n_tty_ioctl_helper(tty, file, cmd, arg); |
318 | break; | 318 | break; |
319 | 319 | ||
320 | case FIONREAD: | 320 | case FIONREAD: |
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c index 1a12033d2efa..bdf3b13a71a8 100644 --- a/drivers/net/ppp/ppp_synctty.c +++ b/drivers/net/ppp/ppp_synctty.c | |||
@@ -355,7 +355,7 @@ ppp_synctty_ioctl(struct tty_struct *tty, struct file *file, | |||
355 | /* flush our buffers and the serial port's buffer */ | 355 | /* flush our buffers and the serial port's buffer */ |
356 | if (arg == TCIOFLUSH || arg == TCOFLUSH) | 356 | if (arg == TCIOFLUSH || arg == TCOFLUSH) |
357 | ppp_sync_flush_output(ap); | 357 | ppp_sync_flush_output(ap); |
358 | err = tty_perform_flush(tty, arg); | 358 | err = n_tty_ioctl_helper(tty, file, cmd, arg); |
359 | break; | 359 | break; |
360 | 360 | ||
361 | case FIONREAD: | 361 | case FIONREAD: |
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index e2dd3249b6bd..cba1d46e672e 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c | |||
@@ -1925,7 +1925,6 @@ static void hso_std_serial_write_bulk_callback(struct urb *urb) | |||
1925 | { | 1925 | { |
1926 | struct hso_serial *serial = urb->context; | 1926 | struct hso_serial *serial = urb->context; |
1927 | int status = urb->status; | 1927 | int status = urb->status; |
1928 | struct tty_struct *tty; | ||
1929 | 1928 | ||
1930 | /* sanity check */ | 1929 | /* sanity check */ |
1931 | if (!serial) { | 1930 | if (!serial) { |
@@ -1941,11 +1940,7 @@ static void hso_std_serial_write_bulk_callback(struct urb *urb) | |||
1941 | return; | 1940 | return; |
1942 | } | 1941 | } |
1943 | hso_put_activity(serial->parent); | 1942 | hso_put_activity(serial->parent); |
1944 | tty = tty_port_tty_get(&serial->port); | 1943 | tty_port_tty_wakeup(&serial->port); |
1945 | if (tty) { | ||
1946 | tty_wakeup(tty); | ||
1947 | tty_kref_put(tty); | ||
1948 | } | ||
1949 | hso_kick_transmit(serial); | 1944 | hso_kick_transmit(serial); |
1950 | 1945 | ||
1951 | D1(" "); | 1946 | D1(" "); |
@@ -2008,12 +2003,8 @@ static void ctrl_callback(struct urb *urb) | |||
2008 | put_rxbuf_data_and_resubmit_ctrl_urb(serial); | 2003 | put_rxbuf_data_and_resubmit_ctrl_urb(serial); |
2009 | spin_unlock(&serial->serial_lock); | 2004 | spin_unlock(&serial->serial_lock); |
2010 | } else { | 2005 | } else { |
2011 | struct tty_struct *tty = tty_port_tty_get(&serial->port); | ||
2012 | hso_put_activity(serial->parent); | 2006 | hso_put_activity(serial->parent); |
2013 | if (tty) { | 2007 | tty_port_tty_wakeup(&serial->port); |
2014 | tty_wakeup(tty); | ||
2015 | tty_kref_put(tty); | ||
2016 | } | ||
2017 | /* response to a write command */ | 2008 | /* response to a write command */ |
2018 | hso_kick_transmit(serial); | 2009 | hso_kick_transmit(serial); |
2019 | } | 2010 | } |
@@ -3133,18 +3124,13 @@ static void hso_serial_ref_free(struct kref *ref) | |||
3133 | static void hso_free_interface(struct usb_interface *interface) | 3124 | static void hso_free_interface(struct usb_interface *interface) |
3134 | { | 3125 | { |
3135 | struct hso_serial *hso_dev; | 3126 | struct hso_serial *hso_dev; |
3136 | struct tty_struct *tty; | ||
3137 | int i; | 3127 | int i; |
3138 | 3128 | ||
3139 | for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { | 3129 | for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { |
3140 | if (serial_table[i] && | 3130 | if (serial_table[i] && |
3141 | (serial_table[i]->interface == interface)) { | 3131 | (serial_table[i]->interface == interface)) { |
3142 | hso_dev = dev2ser(serial_table[i]); | 3132 | hso_dev = dev2ser(serial_table[i]); |
3143 | tty = tty_port_tty_get(&hso_dev->port); | 3133 | tty_port_tty_hangup(&hso_dev->port, false); |
3144 | if (tty) { | ||
3145 | tty_hangup(tty); | ||
3146 | tty_kref_put(tty); | ||
3147 | } | ||
3148 | mutex_lock(&hso_dev->parent->mutex); | 3134 | mutex_lock(&hso_dev->parent->mutex); |
3149 | hso_dev->parent->usb_gone = 1; | 3135 | hso_dev->parent->usb_gone = 1; |
3150 | mutex_unlock(&hso_dev->parent->mutex); | 3136 | mutex_unlock(&hso_dev->parent->mutex); |
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c index 14b4cb8abcc8..7ed7a5987816 100644 --- a/drivers/s390/char/sclp_tty.c +++ b/drivers/s390/char/sclp_tty.c | |||
@@ -107,7 +107,6 @@ sclp_tty_write_room (struct tty_struct *tty) | |||
107 | static void | 107 | static void |
108 | sclp_ttybuf_callback(struct sclp_buffer *buffer, int rc) | 108 | sclp_ttybuf_callback(struct sclp_buffer *buffer, int rc) |
109 | { | 109 | { |
110 | struct tty_struct *tty; | ||
111 | unsigned long flags; | 110 | unsigned long flags; |
112 | void *page; | 111 | void *page; |
113 | 112 | ||
@@ -125,12 +124,8 @@ sclp_ttybuf_callback(struct sclp_buffer *buffer, int rc) | |||
125 | struct sclp_buffer, list); | 124 | struct sclp_buffer, list); |
126 | spin_unlock_irqrestore(&sclp_tty_lock, flags); | 125 | spin_unlock_irqrestore(&sclp_tty_lock, flags); |
127 | } while (buffer && sclp_emit_buffer(buffer, sclp_ttybuf_callback)); | 126 | } while (buffer && sclp_emit_buffer(buffer, sclp_ttybuf_callback)); |
128 | /* check if the tty needs a wake up call */ | 127 | |
129 | tty = tty_port_tty_get(&sclp_port); | 128 | tty_port_tty_wakeup(&sclp_port); |
130 | if (tty != NULL) { | ||
131 | tty_wakeup(tty); | ||
132 | tty_kref_put(tty); | ||
133 | } | ||
134 | } | 129 | } |
135 | 130 | ||
136 | static inline void | 131 | static inline void |
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c index 6c92f62623be..5aaaa2ec8df4 100644 --- a/drivers/s390/char/sclp_vt220.c +++ b/drivers/s390/char/sclp_vt220.c | |||
@@ -114,7 +114,6 @@ static struct sclp_register sclp_vt220_register = { | |||
114 | static void | 114 | static void |
115 | sclp_vt220_process_queue(struct sclp_vt220_request *request) | 115 | sclp_vt220_process_queue(struct sclp_vt220_request *request) |
116 | { | 116 | { |
117 | struct tty_struct *tty; | ||
118 | unsigned long flags; | 117 | unsigned long flags; |
119 | void *page; | 118 | void *page; |
120 | 119 | ||
@@ -139,12 +138,7 @@ sclp_vt220_process_queue(struct sclp_vt220_request *request) | |||
139 | } while (__sclp_vt220_emit(request)); | 138 | } while (__sclp_vt220_emit(request)); |
140 | if (request == NULL && sclp_vt220_flush_later) | 139 | if (request == NULL && sclp_vt220_flush_later) |
141 | sclp_vt220_emit_current(); | 140 | sclp_vt220_emit_current(); |
142 | /* Check if the tty needs a wake up call */ | 141 | tty_port_tty_wakeup(&sclp_vt220_port); |
143 | tty = tty_port_tty_get(&sclp_vt220_port); | ||
144 | if (tty) { | ||
145 | tty_wakeup(tty); | ||
146 | tty_kref_put(tty); | ||
147 | } | ||
148 | } | 142 | } |
149 | 143 | ||
150 | #define SCLP_BUFFER_MAX_RETRY 1 | 144 | #define SCLP_BUFFER_MAX_RETRY 1 |
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index 5a6fb44f38a8..5c64e3a35b28 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c | |||
@@ -744,7 +744,6 @@ static void fwtty_tx_complete(struct fw_card *card, int rcode, | |||
744 | struct fwtty_transaction *txn) | 744 | struct fwtty_transaction *txn) |
745 | { | 745 | { |
746 | struct fwtty_port *port = txn->port; | 746 | struct fwtty_port *port = txn->port; |
747 | struct tty_struct *tty; | ||
748 | int len; | 747 | int len; |
749 | 748 | ||
750 | fwtty_dbg(port, "rcode: %d", rcode); | 749 | fwtty_dbg(port, "rcode: %d", rcode); |
@@ -769,13 +768,8 @@ static void fwtty_tx_complete(struct fw_card *card, int rcode, | |||
769 | port->stats.dropped += txn->dma_pended.len; | 768 | port->stats.dropped += txn->dma_pended.len; |
770 | } | 769 | } |
771 | 770 | ||
772 | if (len < WAKEUP_CHARS) { | 771 | if (len < WAKEUP_CHARS) |
773 | tty = tty_port_tty_get(&port->port); | 772 | tty_port_tty_wakeup(&port->port); |
774 | if (tty) { | ||
775 | tty_wakeup(tty); | ||
776 | tty_kref_put(tty); | ||
777 | } | ||
778 | } | ||
779 | } | 773 | } |
780 | 774 | ||
781 | static int fwtty_tx(struct fwtty_port *port, bool drain) | 775 | static int fwtty_tx(struct fwtty_port *port, bool drain) |
diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index b1bb1a6abe81..8a6e5ea476e1 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c | |||
@@ -264,7 +264,6 @@ static void ProcessRxChar(struct usb_serial_port *port, unsigned char data) | |||
264 | 264 | ||
265 | static void qt_write_bulk_callback(struct urb *urb) | 265 | static void qt_write_bulk_callback(struct urb *urb) |
266 | { | 266 | { |
267 | struct tty_struct *tty; | ||
268 | int status; | 267 | int status; |
269 | struct quatech_port *quatech_port; | 268 | struct quatech_port *quatech_port; |
270 | 269 | ||
@@ -278,11 +277,7 @@ static void qt_write_bulk_callback(struct urb *urb) | |||
278 | 277 | ||
279 | quatech_port = urb->context; | 278 | quatech_port = urb->context; |
280 | 279 | ||
281 | tty = tty_port_tty_get(&quatech_port->port->port); | 280 | tty_port_tty_wakeup(&quatech_port->port->port); |
282 | |||
283 | if (tty) | ||
284 | tty_wakeup(tty); | ||
285 | tty_kref_put(tty); | ||
286 | } | 281 | } |
287 | 282 | ||
288 | static void qt_interrupt_callback(struct urb *urb) | 283 | static void qt_interrupt_callback(struct urb *urb) |
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index fc700342d43f..083710e02367 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c | |||
@@ -1798,19 +1798,7 @@ static struct platform_driver amiga_serial_driver = { | |||
1798 | }, | 1798 | }, |
1799 | }; | 1799 | }; |
1800 | 1800 | ||
1801 | static int __init amiga_serial_init(void) | 1801 | module_platform_driver_probe(amiga_serial_driver, amiga_serial_probe); |
1802 | { | ||
1803 | return platform_driver_probe(&amiga_serial_driver, amiga_serial_probe); | ||
1804 | } | ||
1805 | |||
1806 | module_init(amiga_serial_init); | ||
1807 | |||
1808 | static void __exit amiga_serial_exit(void) | ||
1809 | { | ||
1810 | platform_driver_unregister(&amiga_serial_driver); | ||
1811 | } | ||
1812 | |||
1813 | module_exit(amiga_serial_exit); | ||
1814 | 1802 | ||
1815 | 1803 | ||
1816 | #if defined(CONFIG_SERIAL_CONSOLE) && !defined(MODULE) | 1804 | #if defined(CONFIG_SERIAL_CONSOLE) && !defined(MODULE) |
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c index 345bd0e0884e..33f83fee9fae 100644 --- a/drivers/tty/cyclades.c +++ b/drivers/tty/cyclades.c | |||
@@ -1124,14 +1124,8 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo) | |||
1124 | readl(&info->u.cyz.ch_ctrl->rs_status); | 1124 | readl(&info->u.cyz.ch_ctrl->rs_status); |
1125 | if (dcd & C_RS_DCD) | 1125 | if (dcd & C_RS_DCD) |
1126 | wake_up_interruptible(&info->port.open_wait); | 1126 | wake_up_interruptible(&info->port.open_wait); |
1127 | else { | 1127 | else |
1128 | struct tty_struct *tty; | 1128 | tty_port_tty_hangup(&info->port, false); |
1129 | tty = tty_port_tty_get(&info->port); | ||
1130 | if (tty) { | ||
1131 | tty_hangup(tty); | ||
1132 | tty_kref_put(tty); | ||
1133 | } | ||
1134 | } | ||
1135 | } | 1129 | } |
1136 | break; | 1130 | break; |
1137 | case C_CM_MCTS: | 1131 | case C_CM_MCTS: |
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c index ed92622b8949..6d0c27cd03da 100644 --- a/drivers/tty/ehv_bytechan.c +++ b/drivers/tty/ehv_bytechan.c | |||
@@ -472,13 +472,9 @@ static void ehv_bc_tx_dequeue(struct ehv_bc_data *bc) | |||
472 | static irqreturn_t ehv_bc_tty_tx_isr(int irq, void *data) | 472 | static irqreturn_t ehv_bc_tty_tx_isr(int irq, void *data) |
473 | { | 473 | { |
474 | struct ehv_bc_data *bc = data; | 474 | struct ehv_bc_data *bc = data; |
475 | struct tty_struct *ttys = tty_port_tty_get(&bc->port); | ||
476 | 475 | ||
477 | ehv_bc_tx_dequeue(bc); | 476 | ehv_bc_tx_dequeue(bc); |
478 | if (ttys) { | 477 | tty_port_tty_wakeup(&bc->port); |
479 | tty_wakeup(ttys); | ||
480 | tty_kref_put(ttys); | ||
481 | } | ||
482 | 478 | ||
483 | return IRQ_HANDLED; | 479 | return IRQ_HANDLED; |
484 | } | 480 | } |
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c index ef95a154854a..41901997c0d6 100644 --- a/drivers/tty/hvc/hvsi.c +++ b/drivers/tty/hvc/hvsi.c | |||
@@ -861,7 +861,6 @@ static void hvsi_write_worker(struct work_struct *work) | |||
861 | { | 861 | { |
862 | struct hvsi_struct *hp = | 862 | struct hvsi_struct *hp = |
863 | container_of(work, struct hvsi_struct, writer.work); | 863 | container_of(work, struct hvsi_struct, writer.work); |
864 | struct tty_struct *tty; | ||
865 | unsigned long flags; | 864 | unsigned long flags; |
866 | #ifdef DEBUG | 865 | #ifdef DEBUG |
867 | static long start_j = 0; | 866 | static long start_j = 0; |
@@ -895,11 +894,7 @@ static void hvsi_write_worker(struct work_struct *work) | |||
895 | start_j = 0; | 894 | start_j = 0; |
896 | #endif /* DEBUG */ | 895 | #endif /* DEBUG */ |
897 | wake_up_all(&hp->emptyq); | 896 | wake_up_all(&hp->emptyq); |
898 | tty = tty_port_tty_get(&hp->port); | 897 | tty_port_tty_wakeup(&hp->port); |
899 | if (tty) { | ||
900 | tty_wakeup(tty); | ||
901 | tty_kref_put(tty); | ||
902 | } | ||
903 | } | 898 | } |
904 | 899 | ||
905 | out: | 900 | out: |
diff --git a/drivers/tty/ipwireless/hardware.c b/drivers/tty/ipwireless/hardware.c index 97a511f4185d..2c14842541dd 100644 --- a/drivers/tty/ipwireless/hardware.c +++ b/drivers/tty/ipwireless/hardware.c | |||
@@ -1732,8 +1732,7 @@ void ipwireless_hardware_free(struct ipw_hardware *hw) | |||
1732 | flush_work(&hw->work_rx); | 1732 | flush_work(&hw->work_rx); |
1733 | 1733 | ||
1734 | for (i = 0; i < NL_NUM_OF_ADDRESSES; i++) | 1734 | for (i = 0; i < NL_NUM_OF_ADDRESSES; i++) |
1735 | if (hw->packet_assembler[i] != NULL) | 1735 | kfree(hw->packet_assembler[i]); |
1736 | kfree(hw->packet_assembler[i]); | ||
1737 | 1736 | ||
1738 | for (i = 0; i < NL_NUM_OF_PRIORITIES; i++) | 1737 | for (i = 0; i < NL_NUM_OF_PRIORITIES; i++) |
1739 | list_for_each_entry_safe(tp, tq, &hw->tx_queue[i], queue) { | 1738 | list_for_each_entry_safe(tp, tq, &hw->tx_queue[i], queue) { |
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c index adeac255e526..1deaca4674e4 100644 --- a/drivers/tty/moxa.c +++ b/drivers/tty/moxa.c | |||
@@ -913,16 +913,12 @@ static void moxa_board_deinit(struct moxa_board_conf *brd) | |||
913 | 913 | ||
914 | /* pci hot-un-plug support */ | 914 | /* pci hot-un-plug support */ |
915 | for (a = 0; a < brd->numPorts; a++) | 915 | for (a = 0; a < brd->numPorts; a++) |
916 | if (brd->ports[a].port.flags & ASYNC_INITIALIZED) { | 916 | if (brd->ports[a].port.flags & ASYNC_INITIALIZED) |
917 | struct tty_struct *tty = tty_port_tty_get( | 917 | tty_port_tty_hangup(&brd->ports[a].port, false); |
918 | &brd->ports[a].port); | 918 | |
919 | if (tty) { | ||
920 | tty_hangup(tty); | ||
921 | tty_kref_put(tty); | ||
922 | } | ||
923 | } | ||
924 | for (a = 0; a < MAX_PORTS_PER_BOARD; a++) | 919 | for (a = 0; a < MAX_PORTS_PER_BOARD; a++) |
925 | tty_port_destroy(&brd->ports[a].port); | 920 | tty_port_destroy(&brd->ports[a].port); |
921 | |||
926 | while (1) { | 922 | while (1) { |
927 | opened = 0; | 923 | opened = 0; |
928 | for (a = 0; a < brd->numPorts; a++) | 924 | for (a = 0; a < brd->numPorts; a++) |
@@ -1365,7 +1361,6 @@ static void moxa_hangup(struct tty_struct *tty) | |||
1365 | 1361 | ||
1366 | static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd) | 1362 | static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd) |
1367 | { | 1363 | { |
1368 | struct tty_struct *tty; | ||
1369 | unsigned long flags; | 1364 | unsigned long flags; |
1370 | dcd = !!dcd; | 1365 | dcd = !!dcd; |
1371 | 1366 | ||
@@ -1373,10 +1368,8 @@ static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd) | |||
1373 | if (dcd != p->DCDState) { | 1368 | if (dcd != p->DCDState) { |
1374 | p->DCDState = dcd; | 1369 | p->DCDState = dcd; |
1375 | spin_unlock_irqrestore(&p->port.lock, flags); | 1370 | spin_unlock_irqrestore(&p->port.lock, flags); |
1376 | tty = tty_port_tty_get(&p->port); | 1371 | if (!dcd) |
1377 | if (tty && !C_CLOCAL(tty) && !dcd) | 1372 | tty_port_tty_hangup(&p->port, true); |
1378 | tty_hangup(tty); | ||
1379 | tty_kref_put(tty); | ||
1380 | } | 1373 | } |
1381 | else | 1374 | else |
1382 | spin_unlock_irqrestore(&p->port.lock, flags); | 1375 | spin_unlock_irqrestore(&p->port.lock, flags); |
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index 484b6a3c9b03..d996038eacfd 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c | |||
@@ -1084,6 +1084,10 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) | |||
1084 | mutex_lock(&port->mutex); | 1084 | mutex_lock(&port->mutex); |
1085 | mxser_close_port(port); | 1085 | mxser_close_port(port); |
1086 | mxser_flush_buffer(tty); | 1086 | mxser_flush_buffer(tty); |
1087 | if (test_bit(ASYNCB_INITIALIZED, &port->flags)) { | ||
1088 | if (C_HUPCL(tty)) | ||
1089 | tty_port_lower_dtr_rts(port); | ||
1090 | } | ||
1087 | mxser_shutdown_port(port); | 1091 | mxser_shutdown_port(port); |
1088 | clear_bit(ASYNCB_INITIALIZED, &port->flags); | 1092 | clear_bit(ASYNCB_INITIALIZED, &port->flags); |
1089 | mutex_unlock(&port->mutex); | 1093 | mutex_unlock(&port->mutex); |
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 4a43ef5d7962..642239015b46 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c | |||
@@ -1418,11 +1418,7 @@ static void gsm_dlci_close(struct gsm_dlci *dlci) | |||
1418 | pr_debug("DLCI %d goes closed.\n", dlci->addr); | 1418 | pr_debug("DLCI %d goes closed.\n", dlci->addr); |
1419 | dlci->state = DLCI_CLOSED; | 1419 | dlci->state = DLCI_CLOSED; |
1420 | if (dlci->addr != 0) { | 1420 | if (dlci->addr != 0) { |
1421 | struct tty_struct *tty = tty_port_tty_get(&dlci->port); | 1421 | tty_port_tty_hangup(&dlci->port, false); |
1422 | if (tty) { | ||
1423 | tty_hangup(tty); | ||
1424 | tty_kref_put(tty); | ||
1425 | } | ||
1426 | kfifo_reset(dlci->fifo); | 1422 | kfifo_reset(dlci->fifo); |
1427 | } else | 1423 | } else |
1428 | dlci->gsm->dead = 1; | 1424 | dlci->gsm->dead = 1; |
@@ -2968,6 +2964,10 @@ static void gsmtty_close(struct tty_struct *tty, struct file *filp) | |||
2968 | if (tty_port_close_start(&dlci->port, tty, filp) == 0) | 2964 | if (tty_port_close_start(&dlci->port, tty, filp) == 0) |
2969 | goto out; | 2965 | goto out; |
2970 | gsm_dlci_begin_close(dlci); | 2966 | gsm_dlci_begin_close(dlci); |
2967 | if (test_bit(ASYNCB_INITIALIZED, &dlci->port.flags)) { | ||
2968 | if (C_HUPCL(tty)) | ||
2969 | tty_port_lower_dtr_rts(&dlci->port); | ||
2970 | } | ||
2971 | tty_port_close_end(&dlci->port, tty); | 2971 | tty_port_close_end(&dlci->port, tty); |
2972 | tty_port_tty_set(&dlci->port, NULL); | 2972 | tty_port_tty_set(&dlci->port, NULL); |
2973 | out: | 2973 | out: |
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 05e72bea9b07..d655416087b7 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c | |||
@@ -153,6 +153,12 @@ static void n_tty_set_room(struct tty_struct *tty) | |||
153 | if (left && !old_left) { | 153 | if (left && !old_left) { |
154 | WARN_RATELIMIT(tty->port->itty == NULL, | 154 | WARN_RATELIMIT(tty->port->itty == NULL, |
155 | "scheduling with invalid itty\n"); | 155 | "scheduling with invalid itty\n"); |
156 | /* see if ldisc has been killed - if so, this means that | ||
157 | * even though the ldisc has been halted and ->buf.work | ||
158 | * cancelled, ->buf.work is about to be rescheduled | ||
159 | */ | ||
160 | WARN_RATELIMIT(test_bit(TTY_LDISC_HALTED, &tty->flags), | ||
161 | "scheduling buffer work for halted ldisc\n"); | ||
156 | schedule_work(&tty->port->buf.work); | 162 | schedule_work(&tty->port->buf.work); |
157 | } | 163 | } |
158 | } | 164 | } |
@@ -189,34 +195,17 @@ static void put_tty_queue(unsigned char c, struct n_tty_data *ldata) | |||
189 | } | 195 | } |
190 | 196 | ||
191 | /** | 197 | /** |
192 | * check_unthrottle - allow new receive data | ||
193 | * @tty; tty device | ||
194 | * | ||
195 | * Check whether to call the driver unthrottle functions | ||
196 | * | ||
197 | * Can sleep, may be called under the atomic_read_lock mutex but | ||
198 | * this is not guaranteed. | ||
199 | */ | ||
200 | static void check_unthrottle(struct tty_struct *tty) | ||
201 | { | ||
202 | if (tty->count) | ||
203 | tty_unthrottle(tty); | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * reset_buffer_flags - reset buffer state | 198 | * reset_buffer_flags - reset buffer state |
208 | * @tty: terminal to reset | 199 | * @tty: terminal to reset |
209 | * | 200 | * |
210 | * Reset the read buffer counters, clear the flags, | 201 | * Reset the read buffer counters and clear the flags. |
211 | * and make sure the driver is unthrottled. Called | 202 | * Called from n_tty_open() and n_tty_flush_buffer(). |
212 | * from n_tty_open() and n_tty_flush_buffer(). | ||
213 | * | 203 | * |
214 | * Locking: tty_read_lock for read fields. | 204 | * Locking: tty_read_lock for read fields. |
215 | */ | 205 | */ |
216 | 206 | ||
217 | static void reset_buffer_flags(struct tty_struct *tty) | 207 | static void reset_buffer_flags(struct n_tty_data *ldata) |
218 | { | 208 | { |
219 | struct n_tty_data *ldata = tty->disc_data; | ||
220 | unsigned long flags; | 209 | unsigned long flags; |
221 | 210 | ||
222 | raw_spin_lock_irqsave(&ldata->read_lock, flags); | 211 | raw_spin_lock_irqsave(&ldata->read_lock, flags); |
@@ -229,36 +218,38 @@ static void reset_buffer_flags(struct tty_struct *tty) | |||
229 | 218 | ||
230 | ldata->canon_head = ldata->canon_data = ldata->erasing = 0; | 219 | ldata->canon_head = ldata->canon_data = ldata->erasing = 0; |
231 | bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE); | 220 | bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE); |
232 | n_tty_set_room(tty); | 221 | } |
222 | |||
223 | static void n_tty_packet_mode_flush(struct tty_struct *tty) | ||
224 | { | ||
225 | unsigned long flags; | ||
226 | |||
227 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
228 | if (tty->link->packet) { | ||
229 | tty->ctrl_status |= TIOCPKT_FLUSHREAD; | ||
230 | wake_up_interruptible(&tty->link->read_wait); | ||
231 | } | ||
232 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
233 | } | 233 | } |
234 | 234 | ||
235 | /** | 235 | /** |
236 | * n_tty_flush_buffer - clean input queue | 236 | * n_tty_flush_buffer - clean input queue |
237 | * @tty: terminal device | 237 | * @tty: terminal device |
238 | * | 238 | * |
239 | * Flush the input buffer. Called when the line discipline is | 239 | * Flush the input buffer. Called when the tty layer wants the |
240 | * being closed, when the tty layer wants the buffer flushed (eg | 240 | * buffer flushed (eg at hangup) or when the N_TTY line discipline |
241 | * at hangup) or when the N_TTY line discipline internally has to | 241 | * internally has to clean the pending queue (for example some signals). |
242 | * clean the pending queue (for example some signals). | ||
243 | * | 242 | * |
244 | * Locking: ctrl_lock, read_lock. | 243 | * Locking: ctrl_lock, read_lock. |
245 | */ | 244 | */ |
246 | 245 | ||
247 | static void n_tty_flush_buffer(struct tty_struct *tty) | 246 | static void n_tty_flush_buffer(struct tty_struct *tty) |
248 | { | 247 | { |
249 | unsigned long flags; | 248 | reset_buffer_flags(tty->disc_data); |
250 | /* clear everything and unthrottle the driver */ | 249 | n_tty_set_room(tty); |
251 | reset_buffer_flags(tty); | ||
252 | |||
253 | if (!tty->link) | ||
254 | return; | ||
255 | 250 | ||
256 | spin_lock_irqsave(&tty->ctrl_lock, flags); | 251 | if (tty->link) |
257 | if (tty->link->packet) { | 252 | n_tty_packet_mode_flush(tty); |
258 | tty->ctrl_status |= TIOCPKT_FLUSHREAD; | ||
259 | wake_up_interruptible(&tty->link->read_wait); | ||
260 | } | ||
261 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
262 | } | 253 | } |
263 | 254 | ||
264 | /** | 255 | /** |
@@ -1032,23 +1023,19 @@ static void eraser(unsigned char c, struct tty_struct *tty) | |||
1032 | * isig - handle the ISIG optio | 1023 | * isig - handle the ISIG optio |
1033 | * @sig: signal | 1024 | * @sig: signal |
1034 | * @tty: terminal | 1025 | * @tty: terminal |
1035 | * @flush: force flush | ||
1036 | * | 1026 | * |
1037 | * Called when a signal is being sent due to terminal input. This | 1027 | * Called when a signal is being sent due to terminal input. |
1038 | * may caus terminal flushing to take place according to the termios | 1028 | * Called from the driver receive_buf path so serialized. |
1039 | * settings and character used. Called from the driver receive_buf | ||
1040 | * path so serialized. | ||
1041 | * | 1029 | * |
1042 | * Locking: ctrl_lock, read_lock (both via flush buffer) | 1030 | * Locking: ctrl_lock |
1043 | */ | 1031 | */ |
1044 | 1032 | ||
1045 | static inline void isig(int sig, struct tty_struct *tty, int flush) | 1033 | static inline void isig(int sig, struct tty_struct *tty) |
1046 | { | 1034 | { |
1047 | if (tty->pgrp) | 1035 | struct pid *tty_pgrp = tty_get_pgrp(tty); |
1048 | kill_pgrp(tty->pgrp, sig, 1); | 1036 | if (tty_pgrp) { |
1049 | if (flush || !L_NOFLSH(tty)) { | 1037 | kill_pgrp(tty_pgrp, sig, 1); |
1050 | n_tty_flush_buffer(tty); | 1038 | put_pid(tty_pgrp); |
1051 | tty_driver_flush_buffer(tty); | ||
1052 | } | 1039 | } |
1053 | } | 1040 | } |
1054 | 1041 | ||
@@ -1069,7 +1056,11 @@ static inline void n_tty_receive_break(struct tty_struct *tty) | |||
1069 | if (I_IGNBRK(tty)) | 1056 | if (I_IGNBRK(tty)) |
1070 | return; | 1057 | return; |
1071 | if (I_BRKINT(tty)) { | 1058 | if (I_BRKINT(tty)) { |
1072 | isig(SIGINT, tty, 1); | 1059 | isig(SIGINT, tty); |
1060 | if (!L_NOFLSH(tty)) { | ||
1061 | n_tty_flush_buffer(tty); | ||
1062 | tty_driver_flush_buffer(tty); | ||
1063 | } | ||
1073 | return; | 1064 | return; |
1074 | } | 1065 | } |
1075 | if (I_PARMRK(tty)) { | 1066 | if (I_PARMRK(tty)) { |
@@ -1236,11 +1227,6 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) | |||
1236 | signal = SIGTSTP; | 1227 | signal = SIGTSTP; |
1237 | if (c == SUSP_CHAR(tty)) { | 1228 | if (c == SUSP_CHAR(tty)) { |
1238 | send_signal: | 1229 | send_signal: |
1239 | /* | ||
1240 | * Note that we do not use isig() here because we want | ||
1241 | * the order to be: | ||
1242 | * 1) flush, 2) echo, 3) signal | ||
1243 | */ | ||
1244 | if (!L_NOFLSH(tty)) { | 1230 | if (!L_NOFLSH(tty)) { |
1245 | n_tty_flush_buffer(tty); | 1231 | n_tty_flush_buffer(tty); |
1246 | tty_driver_flush_buffer(tty); | 1232 | tty_driver_flush_buffer(tty); |
@@ -1251,8 +1237,7 @@ send_signal: | |||
1251 | echo_char(c, tty); | 1237 | echo_char(c, tty); |
1252 | process_echoes(tty); | 1238 | process_echoes(tty); |
1253 | } | 1239 | } |
1254 | if (tty->pgrp) | 1240 | isig(signal, tty); |
1255 | kill_pgrp(tty->pgrp, signal, 1); | ||
1256 | return; | 1241 | return; |
1257 | } | 1242 | } |
1258 | } | 1243 | } |
@@ -1483,14 +1468,14 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, | |||
1483 | * mode. We don't want to throttle the driver if we're in | 1468 | * mode. We don't want to throttle the driver if we're in |
1484 | * canonical mode and don't have a newline yet! | 1469 | * canonical mode and don't have a newline yet! |
1485 | */ | 1470 | */ |
1486 | if (tty->receive_room < TTY_THRESHOLD_THROTTLE) | 1471 | while (1) { |
1487 | tty_throttle(tty); | 1472 | tty_set_flow_change(tty, TTY_THROTTLE_SAFE); |
1488 | 1473 | if (tty->receive_room >= TTY_THRESHOLD_THROTTLE) | |
1489 | /* FIXME: there is a tiny race here if the receive room check runs | 1474 | break; |
1490 | before the other work executes and empties the buffer (upping | 1475 | if (!tty_throttle_safe(tty)) |
1491 | the receiving room and unthrottling. We then throttle and get | 1476 | break; |
1492 | stuck. This has been observed and traced down by Vincent Pillet/ | 1477 | } |
1493 | We need to address this when we sort out out the rx path locking */ | 1478 | __tty_set_flow_change(tty, 0); |
1494 | } | 1479 | } |
1495 | 1480 | ||
1496 | int is_ignored(int sig) | 1481 | int is_ignored(int sig) |
@@ -1607,7 +1592,9 @@ static void n_tty_close(struct tty_struct *tty) | |||
1607 | { | 1592 | { |
1608 | struct n_tty_data *ldata = tty->disc_data; | 1593 | struct n_tty_data *ldata = tty->disc_data; |
1609 | 1594 | ||
1610 | n_tty_flush_buffer(tty); | 1595 | if (tty->link) |
1596 | n_tty_packet_mode_flush(tty); | ||
1597 | |||
1611 | kfree(ldata->read_buf); | 1598 | kfree(ldata->read_buf); |
1612 | kfree(ldata->echo_buf); | 1599 | kfree(ldata->echo_buf); |
1613 | kfree(ldata); | 1600 | kfree(ldata); |
@@ -1645,12 +1632,14 @@ static int n_tty_open(struct tty_struct *tty) | |||
1645 | goto err_free_bufs; | 1632 | goto err_free_bufs; |
1646 | 1633 | ||
1647 | tty->disc_data = ldata; | 1634 | tty->disc_data = ldata; |
1648 | reset_buffer_flags(tty); | 1635 | reset_buffer_flags(tty->disc_data); |
1649 | tty_unthrottle(tty); | ||
1650 | ldata->column = 0; | 1636 | ldata->column = 0; |
1651 | n_tty_set_termios(tty, NULL); | ||
1652 | tty->minimum_to_wake = 1; | 1637 | tty->minimum_to_wake = 1; |
1653 | tty->closing = 0; | 1638 | tty->closing = 0; |
1639 | /* indicate buffer work may resume */ | ||
1640 | clear_bit(TTY_LDISC_HALTED, &tty->flags); | ||
1641 | n_tty_set_termios(tty, NULL); | ||
1642 | tty_unthrottle(tty); | ||
1654 | 1643 | ||
1655 | return 0; | 1644 | return 0; |
1656 | err_free_bufs: | 1645 | err_free_bufs: |
@@ -1740,10 +1729,9 @@ extern ssize_t redirected_tty_write(struct file *, const char __user *, | |||
1740 | * and if appropriate send any needed signals and return a negative | 1729 | * and if appropriate send any needed signals and return a negative |
1741 | * error code if action should be taken. | 1730 | * error code if action should be taken. |
1742 | * | 1731 | * |
1743 | * FIXME: | 1732 | * Locking: redirected write test is safe |
1744 | * Locking: None - redirected write test is safe, testing | 1733 | * current->signal->tty check is safe |
1745 | * current->signal should possibly lock current->sighand | 1734 | * ctrl_lock to safely reference tty->pgrp |
1746 | * pgrp locking ? | ||
1747 | */ | 1735 | */ |
1748 | 1736 | ||
1749 | static int job_control(struct tty_struct *tty, struct file *file) | 1737 | static int job_control(struct tty_struct *tty, struct file *file) |
@@ -1753,19 +1741,22 @@ static int job_control(struct tty_struct *tty, struct file *file) | |||
1753 | /* NOTE: not yet done after every sleep pending a thorough | 1741 | /* NOTE: not yet done after every sleep pending a thorough |
1754 | check of the logic of this change. -- jlc */ | 1742 | check of the logic of this change. -- jlc */ |
1755 | /* don't stop on /dev/console */ | 1743 | /* don't stop on /dev/console */ |
1756 | if (file->f_op->write != redirected_tty_write && | 1744 | if (file->f_op->write == redirected_tty_write || |
1757 | current->signal->tty == tty) { | 1745 | current->signal->tty != tty) |
1758 | if (!tty->pgrp) | 1746 | return 0; |
1759 | printk(KERN_ERR "n_tty_read: no tty->pgrp!\n"); | 1747 | |
1760 | else if (task_pgrp(current) != tty->pgrp) { | 1748 | spin_lock_irq(&tty->ctrl_lock); |
1761 | if (is_ignored(SIGTTIN) || | 1749 | if (!tty->pgrp) |
1762 | is_current_pgrp_orphaned()) | 1750 | printk(KERN_ERR "n_tty_read: no tty->pgrp!\n"); |
1763 | return -EIO; | 1751 | else if (task_pgrp(current) != tty->pgrp) { |
1764 | kill_pgrp(task_pgrp(current), SIGTTIN, 1); | 1752 | spin_unlock_irq(&tty->ctrl_lock); |
1765 | set_thread_flag(TIF_SIGPENDING); | 1753 | if (is_ignored(SIGTTIN) || is_current_pgrp_orphaned()) |
1766 | return -ERESTARTSYS; | 1754 | return -EIO; |
1767 | } | 1755 | kill_pgrp(task_pgrp(current), SIGTTIN, 1); |
1756 | set_thread_flag(TIF_SIGPENDING); | ||
1757 | return -ERESTARTSYS; | ||
1768 | } | 1758 | } |
1759 | spin_unlock_irq(&tty->ctrl_lock); | ||
1769 | return 0; | 1760 | return 0; |
1770 | } | 1761 | } |
1771 | 1762 | ||
@@ -1959,10 +1950,17 @@ do_it_again: | |||
1959 | * longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode, | 1950 | * longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode, |
1960 | * we won't get any more characters. | 1951 | * we won't get any more characters. |
1961 | */ | 1952 | */ |
1962 | if (n_tty_chars_in_buffer(tty) <= TTY_THRESHOLD_UNTHROTTLE) { | 1953 | while (1) { |
1954 | tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE); | ||
1955 | if (n_tty_chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE) | ||
1956 | break; | ||
1957 | if (!tty->count) | ||
1958 | break; | ||
1963 | n_tty_set_room(tty); | 1959 | n_tty_set_room(tty); |
1964 | check_unthrottle(tty); | 1960 | if (!tty_unthrottle_safe(tty)) |
1961 | break; | ||
1965 | } | 1962 | } |
1963 | __tty_set_flow_change(tty, 0); | ||
1966 | 1964 | ||
1967 | if (b - buf >= minimum) | 1965 | if (b - buf >= minimum) |
1968 | break; | 1966 | break; |
diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index 2dff19796157..d6080c3831ef 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c | |||
@@ -791,7 +791,6 @@ static int send_data(enum port_type index, struct nozomi *dc) | |||
791 | const u8 toggle = port->toggle_ul; | 791 | const u8 toggle = port->toggle_ul; |
792 | void __iomem *addr = port->ul_addr[toggle]; | 792 | void __iomem *addr = port->ul_addr[toggle]; |
793 | const u32 ul_size = port->ul_size[toggle]; | 793 | const u32 ul_size = port->ul_size[toggle]; |
794 | struct tty_struct *tty = tty_port_tty_get(&port->port); | ||
795 | 794 | ||
796 | /* Get data from tty and place in buf for now */ | 795 | /* Get data from tty and place in buf for now */ |
797 | size = kfifo_out(&port->fifo_ul, dc->send_buf, | 796 | size = kfifo_out(&port->fifo_ul, dc->send_buf, |
@@ -799,7 +798,6 @@ static int send_data(enum port_type index, struct nozomi *dc) | |||
799 | 798 | ||
800 | if (size == 0) { | 799 | if (size == 0) { |
801 | DBG4("No more data to send, disable link:"); | 800 | DBG4("No more data to send, disable link:"); |
802 | tty_kref_put(tty); | ||
803 | return 0; | 801 | return 0; |
804 | } | 802 | } |
805 | 803 | ||
@@ -809,10 +807,8 @@ static int send_data(enum port_type index, struct nozomi *dc) | |||
809 | write_mem32(addr, (u32 *) &size, 4); | 807 | write_mem32(addr, (u32 *) &size, 4); |
810 | write_mem32(addr + 4, (u32 *) dc->send_buf, size); | 808 | write_mem32(addr + 4, (u32 *) dc->send_buf, size); |
811 | 809 | ||
812 | if (tty) | 810 | tty_port_tty_wakeup(&port->port); |
813 | tty_wakeup(tty); | ||
814 | 811 | ||
815 | tty_kref_put(tty); | ||
816 | return 1; | 812 | return 1; |
817 | } | 813 | } |
818 | 814 | ||
@@ -1505,12 +1501,9 @@ static void tty_exit(struct nozomi *dc) | |||
1505 | 1501 | ||
1506 | DBG1(" "); | 1502 | DBG1(" "); |
1507 | 1503 | ||
1508 | for (i = 0; i < MAX_PORT; ++i) { | 1504 | for (i = 0; i < MAX_PORT; ++i) |
1509 | struct tty_struct *tty = tty_port_tty_get(&dc->port[i].port); | 1505 | tty_port_tty_hangup(&dc->port[i].port, false); |
1510 | if (tty && list_empty(&tty->hangup_work.entry)) | 1506 | |
1511 | tty_hangup(tty); | ||
1512 | tty_kref_put(tty); | ||
1513 | } | ||
1514 | /* Racy below - surely should wait for scheduled work to be done or | 1507 | /* Racy below - surely should wait for scheduled work to be done or |
1515 | complete off a hangup method ? */ | 1508 | complete off a hangup method ? */ |
1516 | while (dc->open_ttys) | 1509 | while (dc->open_ttys) |
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index c24b4db243b9..71e456aa6367 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
@@ -413,7 +413,6 @@ static void pty_unix98_shutdown(struct tty_struct *tty) | |||
413 | 413 | ||
414 | static void pty_cleanup(struct tty_struct *tty) | 414 | static void pty_cleanup(struct tty_struct *tty) |
415 | { | 415 | { |
416 | tty->port->itty = NULL; | ||
417 | tty_port_put(tty->port); | 416 | tty_port_put(tty->port); |
418 | } | 417 | } |
419 | 418 | ||
diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c index 1d270034bfc3..f5abc2888821 100644 --- a/drivers/tty/rocket.c +++ b/drivers/tty/rocket.c | |||
@@ -449,7 +449,7 @@ static void rp_do_transmit(struct r_port *info) | |||
449 | 449 | ||
450 | /* Loop sending data to FIFO until done or FIFO full */ | 450 | /* Loop sending data to FIFO until done or FIFO full */ |
451 | while (1) { | 451 | while (1) { |
452 | if (tty->stopped || tty->hw_stopped) | 452 | if (tty->stopped) |
453 | break; | 453 | break; |
454 | c = min(info->xmit_fifo_room, info->xmit_cnt); | 454 | c = min(info->xmit_fifo_room, info->xmit_cnt); |
455 | c = min(c, XMIT_BUF_SIZE - info->xmit_tail); | 455 | c = min(c, XMIT_BUF_SIZE - info->xmit_tail); |
@@ -521,15 +521,10 @@ static void rp_handle_port(struct r_port *info) | |||
521 | (ChanStatus & CD_ACT) ? "on" : "off"); | 521 | (ChanStatus & CD_ACT) ? "on" : "off"); |
522 | #endif | 522 | #endif |
523 | if (!(ChanStatus & CD_ACT) && info->cd_status) { | 523 | if (!(ChanStatus & CD_ACT) && info->cd_status) { |
524 | struct tty_struct *tty; | ||
525 | #ifdef ROCKET_DEBUG_HANGUP | 524 | #ifdef ROCKET_DEBUG_HANGUP |
526 | printk(KERN_INFO "CD drop, calling hangup.\n"); | 525 | printk(KERN_INFO "CD drop, calling hangup.\n"); |
527 | #endif | 526 | #endif |
528 | tty = tty_port_tty_get(&info->port); | 527 | tty_port_tty_hangup(&info->port, false); |
529 | if (tty) { | ||
530 | tty_hangup(tty); | ||
531 | tty_kref_put(tty); | ||
532 | } | ||
533 | } | 528 | } |
534 | info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0; | 529 | info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0; |
535 | wake_up_interruptible(&info->port.open_wait); | 530 | wake_up_interruptible(&info->port.open_wait); |
@@ -1111,15 +1106,12 @@ static void rp_set_termios(struct tty_struct *tty, | |||
1111 | 1106 | ||
1112 | /* Handle transition away from B0 status */ | 1107 | /* Handle transition away from B0 status */ |
1113 | if (!(old_termios->c_cflag & CBAUD) && (tty->termios.c_cflag & CBAUD)) { | 1108 | if (!(old_termios->c_cflag & CBAUD) && (tty->termios.c_cflag & CBAUD)) { |
1114 | if (!tty->hw_stopped || !(tty->termios.c_cflag & CRTSCTS)) | 1109 | sSetRTS(cp); |
1115 | sSetRTS(cp); | ||
1116 | sSetDTR(cp); | 1110 | sSetDTR(cp); |
1117 | } | 1111 | } |
1118 | 1112 | ||
1119 | if ((old_termios->c_cflag & CRTSCTS) && !(tty->termios.c_cflag & CRTSCTS)) { | 1113 | if ((old_termios->c_cflag & CRTSCTS) && !(tty->termios.c_cflag & CRTSCTS)) |
1120 | tty->hw_stopped = 0; | ||
1121 | rp_start(tty); | 1114 | rp_start(tty); |
1122 | } | ||
1123 | } | 1115 | } |
1124 | 1116 | ||
1125 | static int rp_break(struct tty_struct *tty, int break_state) | 1117 | static int rp_break(struct tty_struct *tty, int break_state) |
@@ -1575,10 +1567,10 @@ static int rp_put_char(struct tty_struct *tty, unsigned char ch) | |||
1575 | spin_lock_irqsave(&info->slock, flags); | 1567 | spin_lock_irqsave(&info->slock, flags); |
1576 | cp = &info->channel; | 1568 | cp = &info->channel; |
1577 | 1569 | ||
1578 | if (!tty->stopped && !tty->hw_stopped && info->xmit_fifo_room == 0) | 1570 | if (!tty->stopped && info->xmit_fifo_room == 0) |
1579 | info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp); | 1571 | info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp); |
1580 | 1572 | ||
1581 | if (tty->stopped || tty->hw_stopped || info->xmit_fifo_room == 0 || info->xmit_cnt != 0) { | 1573 | if (tty->stopped || info->xmit_fifo_room == 0 || info->xmit_cnt != 0) { |
1582 | info->xmit_buf[info->xmit_head++] = ch; | 1574 | info->xmit_buf[info->xmit_head++] = ch; |
1583 | info->xmit_head &= XMIT_BUF_SIZE - 1; | 1575 | info->xmit_head &= XMIT_BUF_SIZE - 1; |
1584 | info->xmit_cnt++; | 1576 | info->xmit_cnt++; |
@@ -1619,14 +1611,14 @@ static int rp_write(struct tty_struct *tty, | |||
1619 | #endif | 1611 | #endif |
1620 | cp = &info->channel; | 1612 | cp = &info->channel; |
1621 | 1613 | ||
1622 | if (!tty->stopped && !tty->hw_stopped && info->xmit_fifo_room < count) | 1614 | if (!tty->stopped && info->xmit_fifo_room < count) |
1623 | info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp); | 1615 | info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp); |
1624 | 1616 | ||
1625 | /* | 1617 | /* |
1626 | * If the write queue for the port is empty, and there is FIFO space, stuff bytes | 1618 | * If the write queue for the port is empty, and there is FIFO space, stuff bytes |
1627 | * into FIFO. Use the write queue for temp storage. | 1619 | * into FIFO. Use the write queue for temp storage. |
1628 | */ | 1620 | */ |
1629 | if (!tty->stopped && !tty->hw_stopped && info->xmit_cnt == 0 && info->xmit_fifo_room > 0) { | 1621 | if (!tty->stopped && info->xmit_cnt == 0 && info->xmit_fifo_room > 0) { |
1630 | c = min(count, info->xmit_fifo_room); | 1622 | c = min(count, info->xmit_fifo_room); |
1631 | b = buf; | 1623 | b = buf; |
1632 | 1624 | ||
@@ -1674,7 +1666,7 @@ static int rp_write(struct tty_struct *tty, | |||
1674 | retval += c; | 1666 | retval += c; |
1675 | } | 1667 | } |
1676 | 1668 | ||
1677 | if ((retval > 0) && !tty->stopped && !tty->hw_stopped) | 1669 | if ((retval > 0) && !tty->stopped) |
1678 | set_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); | 1670 | set_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); |
1679 | 1671 | ||
1680 | end: | 1672 | end: |
diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c index 49399470794d..ef2e08e9b590 100644 --- a/drivers/tty/serial/68328serial.c +++ b/drivers/tty/serial/68328serial.c | |||
@@ -630,8 +630,7 @@ static void rs_flush_chars(struct tty_struct *tty) | |||
630 | /* Enable transmitter */ | 630 | /* Enable transmitter */ |
631 | local_irq_save(flags); | 631 | local_irq_save(flags); |
632 | 632 | ||
633 | if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || | 633 | if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf) { |
634 | !info->xmit_buf) { | ||
635 | local_irq_restore(flags); | 634 | local_irq_restore(flags); |
636 | return; | 635 | return; |
637 | } | 636 | } |
@@ -697,7 +696,7 @@ static int rs_write(struct tty_struct * tty, | |||
697 | total += c; | 696 | total += c; |
698 | } | 697 | } |
699 | 698 | ||
700 | if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) { | 699 | if (info->xmit_cnt && !tty->stopped) { |
701 | /* Enable transmitter */ | 700 | /* Enable transmitter */ |
702 | local_irq_disable(); | 701 | local_irq_disable(); |
703 | #ifndef USE_INTS | 702 | #ifndef USE_INTS |
@@ -978,10 +977,8 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
978 | change_speed(info, tty); | 977 | change_speed(info, tty); |
979 | 978 | ||
980 | if ((old_termios->c_cflag & CRTSCTS) && | 979 | if ((old_termios->c_cflag & CRTSCTS) && |
981 | !(tty->termios.c_cflag & CRTSCTS)) { | 980 | !(tty->termios.c_cflag & CRTSCTS)) |
982 | tty->hw_stopped = 0; | ||
983 | rs_start(tty); | 981 | rs_start(tty); |
984 | } | ||
985 | 982 | ||
986 | } | 983 | } |
987 | 984 | ||
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index 34eb676916fe..1ebf8538b4fa 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h | |||
@@ -117,13 +117,6 @@ static inline void serial_dl_write(struct uart_8250_port *up, int value) | |||
117 | * is cleared, the machine locks up with endless interrupts. | 117 | * is cleared, the machine locks up with endless interrupts. |
118 | */ | 118 | */ |
119 | #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1) | 119 | #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1) |
120 | #elif defined(CONFIG_SBC8560) | ||
121 | /* | ||
122 | * WindRiver did something similarly broken on their SBC8560 board. The | ||
123 | * UART tristates its IRQ output while OUT2 is clear, but they pulled | ||
124 | * the interrupt line _up_ instead of down, so if we register the IRQ | ||
125 | * while the UART is in that state, we die in an IRQ storm. */ | ||
126 | #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2) | ||
127 | #else | 120 | #else |
128 | #define ALPHA_KLUDGE_MCR 0 | 121 | #define ALPHA_KLUDGE_MCR 0 |
129 | #endif | 122 | #endif |
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c index 35f9c96aada9..46528d57be72 100644 --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c | |||
@@ -2755,7 +2755,7 @@ static void __init serial8250_isa_init_ports(void) | |||
2755 | if (nr_uarts > UART_NR) | 2755 | if (nr_uarts > UART_NR) |
2756 | nr_uarts = UART_NR; | 2756 | nr_uarts = UART_NR; |
2757 | 2757 | ||
2758 | for (i = 0; i < nr_uarts; i++) { | 2758 | for (i = 0; i < UART_NR; i++) { |
2759 | struct uart_8250_port *up = &serial8250_ports[i]; | 2759 | struct uart_8250_port *up = &serial8250_ports[i]; |
2760 | struct uart_port *port = &up->port; | 2760 | struct uart_port *port = &up->port; |
2761 | 2761 | ||
@@ -2916,7 +2916,7 @@ static int __init serial8250_console_setup(struct console *co, char *options) | |||
2916 | * if so, search for the first available port that does have | 2916 | * if so, search for the first available port that does have |
2917 | * console support. | 2917 | * console support. |
2918 | */ | 2918 | */ |
2919 | if (co->index >= nr_uarts) | 2919 | if (co->index >= UART_NR) |
2920 | co->index = 0; | 2920 | co->index = 0; |
2921 | port = &serial8250_ports[co->index].port; | 2921 | port = &serial8250_ports[co->index].port; |
2922 | if (!port->iobase && !port->membase) | 2922 | if (!port->iobase && !port->membase) |
@@ -2957,7 +2957,7 @@ int serial8250_find_port(struct uart_port *p) | |||
2957 | int line; | 2957 | int line; |
2958 | struct uart_port *port; | 2958 | struct uart_port *port; |
2959 | 2959 | ||
2960 | for (line = 0; line < nr_uarts; line++) { | 2960 | for (line = 0; line < UART_NR; line++) { |
2961 | port = &serial8250_ports[line].port; | 2961 | port = &serial8250_ports[line].port; |
2962 | if (uart_match_port(p, port)) | 2962 | if (uart_match_port(p, port)) |
2963 | return line; | 2963 | return line; |
@@ -3110,7 +3110,7 @@ static int serial8250_remove(struct platform_device *dev) | |||
3110 | { | 3110 | { |
3111 | int i; | 3111 | int i; |
3112 | 3112 | ||
3113 | for (i = 0; i < nr_uarts; i++) { | 3113 | for (i = 0; i < UART_NR; i++) { |
3114 | struct uart_8250_port *up = &serial8250_ports[i]; | 3114 | struct uart_8250_port *up = &serial8250_ports[i]; |
3115 | 3115 | ||
3116 | if (up->port.dev == &dev->dev) | 3116 | if (up->port.dev == &dev->dev) |
@@ -3178,7 +3178,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port * | |||
3178 | /* | 3178 | /* |
3179 | * First, find a port entry which matches. | 3179 | * First, find a port entry which matches. |
3180 | */ | 3180 | */ |
3181 | for (i = 0; i < nr_uarts; i++) | 3181 | for (i = 0; i < UART_NR; i++) |
3182 | if (uart_match_port(&serial8250_ports[i].port, port)) | 3182 | if (uart_match_port(&serial8250_ports[i].port, port)) |
3183 | return &serial8250_ports[i]; | 3183 | return &serial8250_ports[i]; |
3184 | 3184 | ||
@@ -3187,7 +3187,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port * | |||
3187 | * free entry. We look for one which hasn't been previously | 3187 | * free entry. We look for one which hasn't been previously |
3188 | * used (indicated by zero iobase). | 3188 | * used (indicated by zero iobase). |
3189 | */ | 3189 | */ |
3190 | for (i = 0; i < nr_uarts; i++) | 3190 | for (i = 0; i < UART_NR; i++) |
3191 | if (serial8250_ports[i].port.type == PORT_UNKNOWN && | 3191 | if (serial8250_ports[i].port.type == PORT_UNKNOWN && |
3192 | serial8250_ports[i].port.iobase == 0) | 3192 | serial8250_ports[i].port.iobase == 0) |
3193 | return &serial8250_ports[i]; | 3193 | return &serial8250_ports[i]; |
@@ -3196,7 +3196,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port * | |||
3196 | * That also failed. Last resort is to find any entry which | 3196 | * That also failed. Last resort is to find any entry which |
3197 | * doesn't have a real port associated with it. | 3197 | * doesn't have a real port associated with it. |
3198 | */ | 3198 | */ |
3199 | for (i = 0; i < nr_uarts; i++) | 3199 | for (i = 0; i < UART_NR; i++) |
3200 | if (serial8250_ports[i].port.type == PORT_UNKNOWN) | 3200 | if (serial8250_ports[i].port.type == PORT_UNKNOWN) |
3201 | return &serial8250_ports[i]; | 3201 | return &serial8250_ports[i]; |
3202 | 3202 | ||
@@ -3247,6 +3247,10 @@ int serial8250_register_8250_port(struct uart_8250_port *up) | |||
3247 | uart->tx_loadsz = up->tx_loadsz; | 3247 | uart->tx_loadsz = up->tx_loadsz; |
3248 | uart->capabilities = up->capabilities; | 3248 | uart->capabilities = up->capabilities; |
3249 | 3249 | ||
3250 | /* Take tx_loadsz from fifosize if it wasn't set separately */ | ||
3251 | if (uart->port.fifosize && !uart->tx_loadsz) | ||
3252 | uart->tx_loadsz = uart->port.fifosize; | ||
3253 | |||
3250 | if (up->port.dev) | 3254 | if (up->port.dev) |
3251 | uart->port.dev = up->port.dev; | 3255 | uart->port.dev = up->port.dev; |
3252 | 3256 | ||
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index db0e66f6dd0e..3dedd2470db1 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/acpi.h> | 28 | #include <linux/acpi.h> |
29 | #include <linux/clk.h> | ||
29 | 30 | ||
30 | #include "8250.h" | 31 | #include "8250.h" |
31 | 32 | ||
@@ -55,8 +56,9 @@ | |||
55 | 56 | ||
56 | 57 | ||
57 | struct dw8250_data { | 58 | struct dw8250_data { |
58 | int last_lcr; | 59 | int last_lcr; |
59 | int line; | 60 | int line; |
61 | struct clk *clk; | ||
60 | }; | 62 | }; |
61 | 63 | ||
62 | static void dw8250_serial_out(struct uart_port *p, int offset, int value) | 64 | static void dw8250_serial_out(struct uart_port *p, int offset, int value) |
@@ -136,8 +138,13 @@ static int dw8250_probe_of(struct uart_port *p) | |||
136 | if (!of_property_read_u32(np, "reg-shift", &val)) | 138 | if (!of_property_read_u32(np, "reg-shift", &val)) |
137 | p->regshift = val; | 139 | p->regshift = val; |
138 | 140 | ||
141 | /* clock got configured through clk api, all done */ | ||
142 | if (p->uartclk) | ||
143 | return 0; | ||
144 | |||
145 | /* try to find out clock frequency from DT as fallback */ | ||
139 | if (of_property_read_u32(np, "clock-frequency", &val)) { | 146 | if (of_property_read_u32(np, "clock-frequency", &val)) { |
140 | dev_err(p->dev, "no clock-frequency property set\n"); | 147 | dev_err(p->dev, "clk or clock-frequency not defined\n"); |
141 | return -EINVAL; | 148 | return -EINVAL; |
142 | } | 149 | } |
143 | p->uartclk = val; | 150 | p->uartclk = val; |
@@ -294,9 +301,20 @@ static int dw8250_probe(struct platform_device *pdev) | |||
294 | if (!uart.port.membase) | 301 | if (!uart.port.membase) |
295 | return -ENOMEM; | 302 | return -ENOMEM; |
296 | 303 | ||
304 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | ||
305 | if (!data) | ||
306 | return -ENOMEM; | ||
307 | |||
308 | data->clk = devm_clk_get(&pdev->dev, NULL); | ||
309 | if (!IS_ERR(data->clk)) { | ||
310 | clk_prepare_enable(data->clk); | ||
311 | uart.port.uartclk = clk_get_rate(data->clk); | ||
312 | } | ||
313 | |||
297 | uart.port.iotype = UPIO_MEM; | 314 | uart.port.iotype = UPIO_MEM; |
298 | uart.port.serial_in = dw8250_serial_in; | 315 | uart.port.serial_in = dw8250_serial_in; |
299 | uart.port.serial_out = dw8250_serial_out; | 316 | uart.port.serial_out = dw8250_serial_out; |
317 | uart.port.private_data = data; | ||
300 | 318 | ||
301 | dw8250_setup_port(&uart); | 319 | dw8250_setup_port(&uart); |
302 | 320 | ||
@@ -312,12 +330,6 @@ static int dw8250_probe(struct platform_device *pdev) | |||
312 | return -ENODEV; | 330 | return -ENODEV; |
313 | } | 331 | } |
314 | 332 | ||
315 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | ||
316 | if (!data) | ||
317 | return -ENOMEM; | ||
318 | |||
319 | uart.port.private_data = data; | ||
320 | |||
321 | data->line = serial8250_register_8250_port(&uart); | 333 | data->line = serial8250_register_8250_port(&uart); |
322 | if (data->line < 0) | 334 | if (data->line < 0) |
323 | return data->line; | 335 | return data->line; |
@@ -333,6 +345,9 @@ static int dw8250_remove(struct platform_device *pdev) | |||
333 | 345 | ||
334 | serial8250_unregister_port(data->line); | 346 | serial8250_unregister_port(data->line); |
335 | 347 | ||
348 | if (!IS_ERR(data->clk)) | ||
349 | clk_disable_unprepare(data->clk); | ||
350 | |||
336 | return 0; | 351 | return 0; |
337 | } | 352 | } |
338 | 353 | ||
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 3ea5408fcbeb..b031abf43a7a 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c | |||
@@ -29,6 +29,7 @@ | |||
29 | * and hooked into this driver. | 29 | * and hooked into this driver. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | |||
32 | #if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | 33 | #if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) |
33 | #define SUPPORT_SYSRQ | 34 | #define SUPPORT_SYSRQ |
34 | #endif | 35 | #endif |
@@ -117,6 +118,12 @@ struct pl011_dmarx_data { | |||
117 | struct pl011_sgbuf sgbuf_b; | 118 | struct pl011_sgbuf sgbuf_b; |
118 | dma_cookie_t cookie; | 119 | dma_cookie_t cookie; |
119 | bool running; | 120 | bool running; |
121 | struct timer_list timer; | ||
122 | unsigned int last_residue; | ||
123 | unsigned long last_jiffies; | ||
124 | bool auto_poll_rate; | ||
125 | unsigned int poll_rate; | ||
126 | unsigned int poll_timeout; | ||
120 | }; | 127 | }; |
121 | 128 | ||
122 | struct pl011_dmatx_data { | 129 | struct pl011_dmatx_data { |
@@ -223,16 +230,18 @@ static int pl011_fifo_to_tty(struct uart_amba_port *uap) | |||
223 | static int pl011_sgbuf_init(struct dma_chan *chan, struct pl011_sgbuf *sg, | 230 | static int pl011_sgbuf_init(struct dma_chan *chan, struct pl011_sgbuf *sg, |
224 | enum dma_data_direction dir) | 231 | enum dma_data_direction dir) |
225 | { | 232 | { |
226 | sg->buf = kmalloc(PL011_DMA_BUFFER_SIZE, GFP_KERNEL); | 233 | dma_addr_t dma_addr; |
234 | |||
235 | sg->buf = dma_alloc_coherent(chan->device->dev, | ||
236 | PL011_DMA_BUFFER_SIZE, &dma_addr, GFP_KERNEL); | ||
227 | if (!sg->buf) | 237 | if (!sg->buf) |
228 | return -ENOMEM; | 238 | return -ENOMEM; |
229 | 239 | ||
230 | sg_init_one(&sg->sg, sg->buf, PL011_DMA_BUFFER_SIZE); | 240 | sg_init_table(&sg->sg, 1); |
241 | sg_set_page(&sg->sg, phys_to_page(dma_addr), | ||
242 | PL011_DMA_BUFFER_SIZE, offset_in_page(dma_addr)); | ||
243 | sg_dma_address(&sg->sg) = dma_addr; | ||
231 | 244 | ||
232 | if (dma_map_sg(chan->device->dev, &sg->sg, 1, dir) != 1) { | ||
233 | kfree(sg->buf); | ||
234 | return -EINVAL; | ||
235 | } | ||
236 | return 0; | 245 | return 0; |
237 | } | 246 | } |
238 | 247 | ||
@@ -240,8 +249,9 @@ static void pl011_sgbuf_free(struct dma_chan *chan, struct pl011_sgbuf *sg, | |||
240 | enum dma_data_direction dir) | 249 | enum dma_data_direction dir) |
241 | { | 250 | { |
242 | if (sg->buf) { | 251 | if (sg->buf) { |
243 | dma_unmap_sg(chan->device->dev, &sg->sg, 1, dir); | 252 | dma_free_coherent(chan->device->dev, |
244 | kfree(sg->buf); | 253 | PL011_DMA_BUFFER_SIZE, sg->buf, |
254 | sg_dma_address(&sg->sg)); | ||
245 | } | 255 | } |
246 | } | 256 | } |
247 | 257 | ||
@@ -300,6 +310,29 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) | |||
300 | dmaengine_slave_config(chan, &rx_conf); | 310 | dmaengine_slave_config(chan, &rx_conf); |
301 | uap->dmarx.chan = chan; | 311 | uap->dmarx.chan = chan; |
302 | 312 | ||
313 | if (plat->dma_rx_poll_enable) { | ||
314 | /* Set poll rate if specified. */ | ||
315 | if (plat->dma_rx_poll_rate) { | ||
316 | uap->dmarx.auto_poll_rate = false; | ||
317 | uap->dmarx.poll_rate = plat->dma_rx_poll_rate; | ||
318 | } else { | ||
319 | /* | ||
320 | * 100 ms defaults to poll rate if not | ||
321 | * specified. This will be adjusted with | ||
322 | * the baud rate at set_termios. | ||
323 | */ | ||
324 | uap->dmarx.auto_poll_rate = true; | ||
325 | uap->dmarx.poll_rate = 100; | ||
326 | } | ||
327 | /* 3 secs defaults poll_timeout if not specified. */ | ||
328 | if (plat->dma_rx_poll_timeout) | ||
329 | uap->dmarx.poll_timeout = | ||
330 | plat->dma_rx_poll_timeout; | ||
331 | else | ||
332 | uap->dmarx.poll_timeout = 3000; | ||
333 | } else | ||
334 | uap->dmarx.auto_poll_rate = false; | ||
335 | |||
303 | dev_info(uap->port.dev, "DMA channel RX %s\n", | 336 | dev_info(uap->port.dev, "DMA channel RX %s\n", |
304 | dma_chan_name(uap->dmarx.chan)); | 337 | dma_chan_name(uap->dmarx.chan)); |
305 | } | 338 | } |
@@ -701,24 +734,30 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap, | |||
701 | struct tty_port *port = &uap->port.state->port; | 734 | struct tty_port *port = &uap->port.state->port; |
702 | struct pl011_sgbuf *sgbuf = use_buf_b ? | 735 | struct pl011_sgbuf *sgbuf = use_buf_b ? |
703 | &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a; | 736 | &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a; |
704 | struct device *dev = uap->dmarx.chan->device->dev; | ||
705 | int dma_count = 0; | 737 | int dma_count = 0; |
706 | u32 fifotaken = 0; /* only used for vdbg() */ | 738 | u32 fifotaken = 0; /* only used for vdbg() */ |
707 | 739 | ||
708 | /* Pick everything from the DMA first */ | 740 | struct pl011_dmarx_data *dmarx = &uap->dmarx; |
741 | int dmataken = 0; | ||
742 | |||
743 | if (uap->dmarx.poll_rate) { | ||
744 | /* The data can be taken by polling */ | ||
745 | dmataken = sgbuf->sg.length - dmarx->last_residue; | ||
746 | /* Recalculate the pending size */ | ||
747 | if (pending >= dmataken) | ||
748 | pending -= dmataken; | ||
749 | } | ||
750 | |||
751 | /* Pick the remain data from the DMA */ | ||
709 | if (pending) { | 752 | if (pending) { |
710 | /* Sync in buffer */ | ||
711 | dma_sync_sg_for_cpu(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE); | ||
712 | 753 | ||
713 | /* | 754 | /* |
714 | * First take all chars in the DMA pipe, then look in the FIFO. | 755 | * First take all chars in the DMA pipe, then look in the FIFO. |
715 | * Note that tty_insert_flip_buf() tries to take as many chars | 756 | * Note that tty_insert_flip_buf() tries to take as many chars |
716 | * as it can. | 757 | * as it can. |
717 | */ | 758 | */ |
718 | dma_count = tty_insert_flip_string(port, sgbuf->buf, pending); | 759 | dma_count = tty_insert_flip_string(port, sgbuf->buf + dmataken, |
719 | 760 | pending); | |
720 | /* Return buffer to device */ | ||
721 | dma_sync_sg_for_device(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE); | ||
722 | 761 | ||
723 | uap->port.icount.rx += dma_count; | 762 | uap->port.icount.rx += dma_count; |
724 | if (dma_count < pending) | 763 | if (dma_count < pending) |
@@ -726,6 +765,10 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap, | |||
726 | "couldn't insert all characters (TTY is full?)\n"); | 765 | "couldn't insert all characters (TTY is full?)\n"); |
727 | } | 766 | } |
728 | 767 | ||
768 | /* Reset the last_residue for Rx DMA poll */ | ||
769 | if (uap->dmarx.poll_rate) | ||
770 | dmarx->last_residue = sgbuf->sg.length; | ||
771 | |||
729 | /* | 772 | /* |
730 | * Only continue with trying to read the FIFO if all DMA chars have | 773 | * Only continue with trying to read the FIFO if all DMA chars have |
731 | * been taken first. | 774 | * been taken first. |
@@ -865,6 +908,57 @@ static inline void pl011_dma_rx_stop(struct uart_amba_port *uap) | |||
865 | writew(uap->dmacr, uap->port.membase + UART011_DMACR); | 908 | writew(uap->dmacr, uap->port.membase + UART011_DMACR); |
866 | } | 909 | } |
867 | 910 | ||
911 | /* | ||
912 | * Timer handler for Rx DMA polling. | ||
913 | * Every polling, It checks the residue in the dma buffer and transfer | ||
914 | * data to the tty. Also, last_residue is updated for the next polling. | ||
915 | */ | ||
916 | static void pl011_dma_rx_poll(unsigned long args) | ||
917 | { | ||
918 | struct uart_amba_port *uap = (struct uart_amba_port *)args; | ||
919 | struct tty_port *port = &uap->port.state->port; | ||
920 | struct pl011_dmarx_data *dmarx = &uap->dmarx; | ||
921 | struct dma_chan *rxchan = uap->dmarx.chan; | ||
922 | unsigned long flags = 0; | ||
923 | unsigned int dmataken = 0; | ||
924 | unsigned int size = 0; | ||
925 | struct pl011_sgbuf *sgbuf; | ||
926 | int dma_count; | ||
927 | struct dma_tx_state state; | ||
928 | |||
929 | sgbuf = dmarx->use_buf_b ? &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a; | ||
930 | rxchan->device->device_tx_status(rxchan, dmarx->cookie, &state); | ||
931 | if (likely(state.residue < dmarx->last_residue)) { | ||
932 | dmataken = sgbuf->sg.length - dmarx->last_residue; | ||
933 | size = dmarx->last_residue - state.residue; | ||
934 | dma_count = tty_insert_flip_string(port, sgbuf->buf + dmataken, | ||
935 | size); | ||
936 | if (dma_count == size) | ||
937 | dmarx->last_residue = state.residue; | ||
938 | dmarx->last_jiffies = jiffies; | ||
939 | } | ||
940 | tty_flip_buffer_push(port); | ||
941 | |||
942 | /* | ||
943 | * If no data is received in poll_timeout, the driver will fall back | ||
944 | * to interrupt mode. We will retrigger DMA at the first interrupt. | ||
945 | */ | ||
946 | if (jiffies_to_msecs(jiffies - dmarx->last_jiffies) | ||
947 | > uap->dmarx.poll_timeout) { | ||
948 | |||
949 | spin_lock_irqsave(&uap->port.lock, flags); | ||
950 | pl011_dma_rx_stop(uap); | ||
951 | spin_unlock_irqrestore(&uap->port.lock, flags); | ||
952 | |||
953 | uap->dmarx.running = false; | ||
954 | dmaengine_terminate_all(rxchan); | ||
955 | del_timer(&uap->dmarx.timer); | ||
956 | } else { | ||
957 | mod_timer(&uap->dmarx.timer, | ||
958 | jiffies + msecs_to_jiffies(uap->dmarx.poll_rate)); | ||
959 | } | ||
960 | } | ||
961 | |||
868 | static void pl011_dma_startup(struct uart_amba_port *uap) | 962 | static void pl011_dma_startup(struct uart_amba_port *uap) |
869 | { | 963 | { |
870 | int ret; | 964 | int ret; |
@@ -927,6 +1021,16 @@ skip_rx: | |||
927 | if (pl011_dma_rx_trigger_dma(uap)) | 1021 | if (pl011_dma_rx_trigger_dma(uap)) |
928 | dev_dbg(uap->port.dev, "could not trigger initial " | 1022 | dev_dbg(uap->port.dev, "could not trigger initial " |
929 | "RX DMA job, fall back to interrupt mode\n"); | 1023 | "RX DMA job, fall back to interrupt mode\n"); |
1024 | if (uap->dmarx.poll_rate) { | ||
1025 | init_timer(&(uap->dmarx.timer)); | ||
1026 | uap->dmarx.timer.function = pl011_dma_rx_poll; | ||
1027 | uap->dmarx.timer.data = (unsigned long)uap; | ||
1028 | mod_timer(&uap->dmarx.timer, | ||
1029 | jiffies + | ||
1030 | msecs_to_jiffies(uap->dmarx.poll_rate)); | ||
1031 | uap->dmarx.last_residue = PL011_DMA_BUFFER_SIZE; | ||
1032 | uap->dmarx.last_jiffies = jiffies; | ||
1033 | } | ||
930 | } | 1034 | } |
931 | } | 1035 | } |
932 | 1036 | ||
@@ -962,6 +1066,8 @@ static void pl011_dma_shutdown(struct uart_amba_port *uap) | |||
962 | /* Clean up the RX DMA */ | 1066 | /* Clean up the RX DMA */ |
963 | pl011_sgbuf_free(uap->dmarx.chan, &uap->dmarx.sgbuf_a, DMA_FROM_DEVICE); | 1067 | pl011_sgbuf_free(uap->dmarx.chan, &uap->dmarx.sgbuf_a, DMA_FROM_DEVICE); |
964 | pl011_sgbuf_free(uap->dmarx.chan, &uap->dmarx.sgbuf_b, DMA_FROM_DEVICE); | 1068 | pl011_sgbuf_free(uap->dmarx.chan, &uap->dmarx.sgbuf_b, DMA_FROM_DEVICE); |
1069 | if (uap->dmarx.poll_rate) | ||
1070 | del_timer_sync(&uap->dmarx.timer); | ||
965 | uap->using_rx_dma = false; | 1071 | uap->using_rx_dma = false; |
966 | } | 1072 | } |
967 | } | 1073 | } |
@@ -976,7 +1082,6 @@ static inline bool pl011_dma_rx_running(struct uart_amba_port *uap) | |||
976 | return uap->using_rx_dma && uap->dmarx.running; | 1082 | return uap->using_rx_dma && uap->dmarx.running; |
977 | } | 1083 | } |
978 | 1084 | ||
979 | |||
980 | #else | 1085 | #else |
981 | /* Blank functions if the DMA engine is not available */ | 1086 | /* Blank functions if the DMA engine is not available */ |
982 | static inline void pl011_dma_probe(struct uart_amba_port *uap) | 1087 | static inline void pl011_dma_probe(struct uart_amba_port *uap) |
@@ -1088,8 +1193,18 @@ static void pl011_rx_chars(struct uart_amba_port *uap) | |||
1088 | dev_dbg(uap->port.dev, "could not trigger RX DMA job " | 1193 | dev_dbg(uap->port.dev, "could not trigger RX DMA job " |
1089 | "fall back to interrupt mode again\n"); | 1194 | "fall back to interrupt mode again\n"); |
1090 | uap->im |= UART011_RXIM; | 1195 | uap->im |= UART011_RXIM; |
1091 | } else | 1196 | } else { |
1092 | uap->im &= ~UART011_RXIM; | 1197 | uap->im &= ~UART011_RXIM; |
1198 | /* Start Rx DMA poll */ | ||
1199 | if (uap->dmarx.poll_rate) { | ||
1200 | uap->dmarx.last_jiffies = jiffies; | ||
1201 | uap->dmarx.last_residue = PL011_DMA_BUFFER_SIZE; | ||
1202 | mod_timer(&uap->dmarx.timer, | ||
1203 | jiffies + | ||
1204 | msecs_to_jiffies(uap->dmarx.poll_rate)); | ||
1205 | } | ||
1206 | } | ||
1207 | |||
1093 | writew(uap->im, uap->port.membase + UART011_IMSC); | 1208 | writew(uap->im, uap->port.membase + UART011_IMSC); |
1094 | } | 1209 | } |
1095 | spin_lock(&uap->port.lock); | 1210 | spin_lock(&uap->port.lock); |
@@ -1164,7 +1279,6 @@ static irqreturn_t pl011_int(int irq, void *dev_id) | |||
1164 | unsigned int dummy_read; | 1279 | unsigned int dummy_read; |
1165 | 1280 | ||
1166 | spin_lock_irqsave(&uap->port.lock, flags); | 1281 | spin_lock_irqsave(&uap->port.lock, flags); |
1167 | |||
1168 | status = readw(uap->port.membase + UART011_MIS); | 1282 | status = readw(uap->port.membase + UART011_MIS); |
1169 | if (status) { | 1283 | if (status) { |
1170 | do { | 1284 | do { |
@@ -1551,6 +1665,11 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1551 | */ | 1665 | */ |
1552 | baud = uart_get_baud_rate(port, termios, old, 0, | 1666 | baud = uart_get_baud_rate(port, termios, old, 0, |
1553 | port->uartclk / clkdiv); | 1667 | port->uartclk / clkdiv); |
1668 | /* | ||
1669 | * Adjust RX DMA polling rate with baud rate if not specified. | ||
1670 | */ | ||
1671 | if (uap->dmarx.auto_poll_rate) | ||
1672 | uap->dmarx.poll_rate = DIV_ROUND_UP(10000000, baud); | ||
1554 | 1673 | ||
1555 | if (baud > port->uartclk/16) | 1674 | if (baud > port->uartclk/16) |
1556 | quot = DIV_ROUND_CLOSEST(port->uartclk * 8, baud); | 1675 | quot = DIV_ROUND_CLOSEST(port->uartclk * 8, baud); |
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index d97e194b6bc5..cbf1d155b7b2 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c | |||
@@ -162,7 +162,7 @@ static unsigned int arc_serial_tx_empty(struct uart_port *port) | |||
162 | /* | 162 | /* |
163 | * Driver internal routine, used by both tty(serial core) as well as tx-isr | 163 | * Driver internal routine, used by both tty(serial core) as well as tx-isr |
164 | * -Called under spinlock in either cases | 164 | * -Called under spinlock in either cases |
165 | * -also tty->stopped / tty->hw_stopped has already been checked | 165 | * -also tty->stopped has already been checked |
166 | * = by uart_start( ) before calling us | 166 | * = by uart_start( ) before calling us |
167 | * = tx_ist checks that too before calling | 167 | * = tx_ist checks that too before calling |
168 | */ | 168 | */ |
diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c index 12dceda9db33..26a3be7ced7d 100644 --- a/drivers/tty/serial/bfin_uart.c +++ b/drivers/tty/serial/bfin_uart.c | |||
@@ -1011,24 +1011,6 @@ static int bfin_serial_poll_get_char(struct uart_port *port) | |||
1011 | } | 1011 | } |
1012 | #endif | 1012 | #endif |
1013 | 1013 | ||
1014 | #if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \ | ||
1015 | defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE) | ||
1016 | static void bfin_kgdboc_port_shutdown(struct uart_port *port) | ||
1017 | { | ||
1018 | if (kgdboc_break_enabled) { | ||
1019 | kgdboc_break_enabled = 0; | ||
1020 | bfin_serial_shutdown(port); | ||
1021 | } | ||
1022 | } | ||
1023 | |||
1024 | static int bfin_kgdboc_port_startup(struct uart_port *port) | ||
1025 | { | ||
1026 | kgdboc_port_line = port->line; | ||
1027 | kgdboc_break_enabled = !bfin_serial_startup(port); | ||
1028 | return 0; | ||
1029 | } | ||
1030 | #endif | ||
1031 | |||
1032 | static struct uart_ops bfin_serial_pops = { | 1014 | static struct uart_ops bfin_serial_pops = { |
1033 | .tx_empty = bfin_serial_tx_empty, | 1015 | .tx_empty = bfin_serial_tx_empty, |
1034 | .set_mctrl = bfin_serial_set_mctrl, | 1016 | .set_mctrl = bfin_serial_set_mctrl, |
@@ -1047,11 +1029,6 @@ static struct uart_ops bfin_serial_pops = { | |||
1047 | .request_port = bfin_serial_request_port, | 1029 | .request_port = bfin_serial_request_port, |
1048 | .config_port = bfin_serial_config_port, | 1030 | .config_port = bfin_serial_config_port, |
1049 | .verify_port = bfin_serial_verify_port, | 1031 | .verify_port = bfin_serial_verify_port, |
1050 | #if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \ | ||
1051 | defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE) | ||
1052 | .kgdboc_port_startup = bfin_kgdboc_port_startup, | ||
1053 | .kgdboc_port_shutdown = bfin_kgdboc_port_shutdown, | ||
1054 | #endif | ||
1055 | #ifdef CONFIG_CONSOLE_POLL | 1032 | #ifdef CONFIG_CONSOLE_POLL |
1056 | .poll_put_char = bfin_serial_poll_put_char, | 1033 | .poll_put_char = bfin_serial_poll_put_char, |
1057 | .poll_get_char = bfin_serial_poll_get_char, | 1034 | .poll_get_char = bfin_serial_poll_get_char, |
diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index 5f37c31e32bc..477f22f773fc 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c | |||
@@ -169,7 +169,6 @@ static int get_lsr_info(struct e100_serial *info, unsigned int *value); | |||
169 | 169 | ||
170 | 170 | ||
171 | #define DEF_BAUD 115200 /* 115.2 kbit/s */ | 171 | #define DEF_BAUD 115200 /* 115.2 kbit/s */ |
172 | #define STD_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST) | ||
173 | #define DEF_RX 0x20 /* or SERIAL_CTRL_W >> 8 */ | 172 | #define DEF_RX 0x20 /* or SERIAL_CTRL_W >> 8 */ |
174 | /* Default value of tx_ctrl register: has txd(bit 7)=1 (idle) as default */ | 173 | /* Default value of tx_ctrl register: has txd(bit 7)=1 (idle) as default */ |
175 | #define DEF_TX 0x80 /* or SERIAL_CTRL_B */ | 174 | #define DEF_TX 0x80 /* or SERIAL_CTRL_B */ |
@@ -246,7 +245,6 @@ static struct e100_serial rs_table[] = { | |||
246 | .ifirstadr = R_DMA_CH7_FIRST, | 245 | .ifirstadr = R_DMA_CH7_FIRST, |
247 | .icmdadr = R_DMA_CH7_CMD, | 246 | .icmdadr = R_DMA_CH7_CMD, |
248 | .idescradr = R_DMA_CH7_DESCR, | 247 | .idescradr = R_DMA_CH7_DESCR, |
249 | .flags = STD_FLAGS, | ||
250 | .rx_ctrl = DEF_RX, | 248 | .rx_ctrl = DEF_RX, |
251 | .tx_ctrl = DEF_TX, | 249 | .tx_ctrl = DEF_TX, |
252 | .iseteop = 2, | 250 | .iseteop = 2, |
@@ -300,7 +298,6 @@ static struct e100_serial rs_table[] = { | |||
300 | .ifirstadr = R_DMA_CH9_FIRST, | 298 | .ifirstadr = R_DMA_CH9_FIRST, |
301 | .icmdadr = R_DMA_CH9_CMD, | 299 | .icmdadr = R_DMA_CH9_CMD, |
302 | .idescradr = R_DMA_CH9_DESCR, | 300 | .idescradr = R_DMA_CH9_DESCR, |
303 | .flags = STD_FLAGS, | ||
304 | .rx_ctrl = DEF_RX, | 301 | .rx_ctrl = DEF_RX, |
305 | .tx_ctrl = DEF_TX, | 302 | .tx_ctrl = DEF_TX, |
306 | .iseteop = 3, | 303 | .iseteop = 3, |
@@ -356,7 +353,6 @@ static struct e100_serial rs_table[] = { | |||
356 | .ifirstadr = R_DMA_CH3_FIRST, | 353 | .ifirstadr = R_DMA_CH3_FIRST, |
357 | .icmdadr = R_DMA_CH3_CMD, | 354 | .icmdadr = R_DMA_CH3_CMD, |
358 | .idescradr = R_DMA_CH3_DESCR, | 355 | .idescradr = R_DMA_CH3_DESCR, |
359 | .flags = STD_FLAGS, | ||
360 | .rx_ctrl = DEF_RX, | 356 | .rx_ctrl = DEF_RX, |
361 | .tx_ctrl = DEF_TX, | 357 | .tx_ctrl = DEF_TX, |
362 | .iseteop = 0, | 358 | .iseteop = 0, |
@@ -410,7 +406,6 @@ static struct e100_serial rs_table[] = { | |||
410 | .ifirstadr = R_DMA_CH5_FIRST, | 406 | .ifirstadr = R_DMA_CH5_FIRST, |
411 | .icmdadr = R_DMA_CH5_CMD, | 407 | .icmdadr = R_DMA_CH5_CMD, |
412 | .idescradr = R_DMA_CH5_DESCR, | 408 | .idescradr = R_DMA_CH5_DESCR, |
413 | .flags = STD_FLAGS, | ||
414 | .rx_ctrl = DEF_RX, | 409 | .rx_ctrl = DEF_RX, |
415 | .tx_ctrl = DEF_TX, | 410 | .tx_ctrl = DEF_TX, |
416 | .iseteop = 1, | 411 | .iseteop = 1, |
@@ -2263,8 +2258,7 @@ TODO: The break will be delayed until an F or V character is received. | |||
2263 | 2258 | ||
2264 | */ | 2259 | */ |
2265 | 2260 | ||
2266 | static | 2261 | static void handle_ser_rx_interrupt_no_dma(struct e100_serial *info) |
2267 | struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) | ||
2268 | { | 2262 | { |
2269 | unsigned long data_read; | 2263 | unsigned long data_read; |
2270 | 2264 | ||
@@ -2370,10 +2364,9 @@ more_data: | |||
2370 | } | 2364 | } |
2371 | 2365 | ||
2372 | tty_flip_buffer_push(&info->port); | 2366 | tty_flip_buffer_push(&info->port); |
2373 | return info; | ||
2374 | } | 2367 | } |
2375 | 2368 | ||
2376 | static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info) | 2369 | static void handle_ser_rx_interrupt(struct e100_serial *info) |
2377 | { | 2370 | { |
2378 | unsigned char rstat; | 2371 | unsigned char rstat; |
2379 | 2372 | ||
@@ -2382,7 +2375,8 @@ static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info) | |||
2382 | #endif | 2375 | #endif |
2383 | /* DEBUG_LOG(info->line, "ser_interrupt stat %03X\n", rstat | (i << 8)); */ | 2376 | /* DEBUG_LOG(info->line, "ser_interrupt stat %03X\n", rstat | (i << 8)); */ |
2384 | if (!info->uses_dma_in) { | 2377 | if (!info->uses_dma_in) { |
2385 | return handle_ser_rx_interrupt_no_dma(info); | 2378 | handle_ser_rx_interrupt_no_dma(info); |
2379 | return; | ||
2386 | } | 2380 | } |
2387 | /* DMA is used */ | 2381 | /* DMA is used */ |
2388 | rstat = info->ioport[REG_STATUS]; | 2382 | rstat = info->ioport[REG_STATUS]; |
@@ -2489,7 +2483,6 @@ static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info) | |||
2489 | /* Restarting the DMA never hurts */ | 2483 | /* Restarting the DMA never hurts */ |
2490 | *info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart); | 2484 | *info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart); |
2491 | START_FLUSH_FAST_TIMER(info, "ser_int"); | 2485 | START_FLUSH_FAST_TIMER(info, "ser_int"); |
2492 | return info; | ||
2493 | } /* handle_ser_rx_interrupt */ | 2486 | } /* handle_ser_rx_interrupt */ |
2494 | 2487 | ||
2495 | static void handle_ser_tx_interrupt(struct e100_serial *info) | 2488 | static void handle_ser_tx_interrupt(struct e100_serial *info) |
@@ -2534,8 +2527,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info) | |||
2534 | } | 2527 | } |
2535 | /* Normal char-by-char interrupt */ | 2528 | /* Normal char-by-char interrupt */ |
2536 | if (info->xmit.head == info->xmit.tail | 2529 | if (info->xmit.head == info->xmit.tail |
2537 | || info->port.tty->stopped | 2530 | || info->port.tty->stopped) { |
2538 | || info->port.tty->hw_stopped) { | ||
2539 | DFLOW(DEBUG_LOG(info->line, "tx_int: stopped %i\n", | 2531 | DFLOW(DEBUG_LOG(info->line, "tx_int: stopped %i\n", |
2540 | info->port.tty->stopped)); | 2532 | info->port.tty->stopped)); |
2541 | e100_disable_serial_tx_ready_irq(info); | 2533 | e100_disable_serial_tx_ready_irq(info); |
@@ -2722,7 +2714,7 @@ startup(struct e100_serial * info) | |||
2722 | 2714 | ||
2723 | /* if it was already initialized, skip this */ | 2715 | /* if it was already initialized, skip this */ |
2724 | 2716 | ||
2725 | if (info->flags & ASYNC_INITIALIZED) { | 2717 | if (info->port.flags & ASYNC_INITIALIZED) { |
2726 | local_irq_restore(flags); | 2718 | local_irq_restore(flags); |
2727 | free_page(xmit_page); | 2719 | free_page(xmit_page); |
2728 | return 0; | 2720 | return 0; |
@@ -2847,7 +2839,7 @@ startup(struct e100_serial * info) | |||
2847 | 2839 | ||
2848 | #endif /* CONFIG_SVINTO_SIM */ | 2840 | #endif /* CONFIG_SVINTO_SIM */ |
2849 | 2841 | ||
2850 | info->flags |= ASYNC_INITIALIZED; | 2842 | info->port.flags |= ASYNC_INITIALIZED; |
2851 | 2843 | ||
2852 | local_irq_restore(flags); | 2844 | local_irq_restore(flags); |
2853 | return 0; | 2845 | return 0; |
@@ -2892,7 +2884,7 @@ shutdown(struct e100_serial * info) | |||
2892 | 2884 | ||
2893 | #endif /* CONFIG_SVINTO_SIM */ | 2885 | #endif /* CONFIG_SVINTO_SIM */ |
2894 | 2886 | ||
2895 | if (!(info->flags & ASYNC_INITIALIZED)) | 2887 | if (!(info->port.flags & ASYNC_INITIALIZED)) |
2896 | return; | 2888 | return; |
2897 | 2889 | ||
2898 | #ifdef SERIAL_DEBUG_OPEN | 2890 | #ifdef SERIAL_DEBUG_OPEN |
@@ -2923,7 +2915,7 @@ shutdown(struct e100_serial * info) | |||
2923 | if (info->port.tty) | 2915 | if (info->port.tty) |
2924 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); | 2916 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); |
2925 | 2917 | ||
2926 | info->flags &= ~ASYNC_INITIALIZED; | 2918 | info->port.flags &= ~ASYNC_INITIALIZED; |
2927 | local_irq_restore(flags); | 2919 | local_irq_restore(flags); |
2928 | } | 2920 | } |
2929 | 2921 | ||
@@ -2948,7 +2940,7 @@ change_speed(struct e100_serial *info) | |||
2948 | /* possibly, the tx/rx should be disabled first to do this safely */ | 2940 | /* possibly, the tx/rx should be disabled first to do this safely */ |
2949 | 2941 | ||
2950 | /* change baud-rate and write it to the hardware */ | 2942 | /* change baud-rate and write it to the hardware */ |
2951 | if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) { | 2943 | if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) { |
2952 | /* Special baudrate */ | 2944 | /* Special baudrate */ |
2953 | u32 mask = 0xFF << (info->line*8); /* Each port has 8 bits */ | 2945 | u32 mask = 0xFF << (info->line*8); /* Each port has 8 bits */ |
2954 | unsigned long alt_source = | 2946 | unsigned long alt_source = |
@@ -3098,7 +3090,6 @@ rs_flush_chars(struct tty_struct *tty) | |||
3098 | if (info->tr_running || | 3090 | if (info->tr_running || |
3099 | info->xmit.head == info->xmit.tail || | 3091 | info->xmit.head == info->xmit.tail || |
3100 | tty->stopped || | 3092 | tty->stopped || |
3101 | tty->hw_stopped || | ||
3102 | !info->xmit.buf) | 3093 | !info->xmit.buf) |
3103 | return; | 3094 | return; |
3104 | 3095 | ||
@@ -3176,7 +3167,6 @@ static int rs_raw_write(struct tty_struct *tty, | |||
3176 | 3167 | ||
3177 | if (info->xmit.head != info->xmit.tail && | 3168 | if (info->xmit.head != info->xmit.tail && |
3178 | !tty->stopped && | 3169 | !tty->stopped && |
3179 | !tty->hw_stopped && | ||
3180 | !info->tr_running) { | 3170 | !info->tr_running) { |
3181 | start_transmit(info); | 3171 | start_transmit(info); |
3182 | } | 3172 | } |
@@ -3400,10 +3390,10 @@ get_serial_info(struct e100_serial * info, | |||
3400 | tmp.line = info->line; | 3390 | tmp.line = info->line; |
3401 | tmp.port = (int)info->ioport; | 3391 | tmp.port = (int)info->ioport; |
3402 | tmp.irq = info->irq; | 3392 | tmp.irq = info->irq; |
3403 | tmp.flags = info->flags; | 3393 | tmp.flags = info->port.flags; |
3404 | tmp.baud_base = info->baud_base; | 3394 | tmp.baud_base = info->baud_base; |
3405 | tmp.close_delay = info->close_delay; | 3395 | tmp.close_delay = info->port.close_delay; |
3406 | tmp.closing_wait = info->closing_wait; | 3396 | tmp.closing_wait = info->port.closing_wait; |
3407 | tmp.custom_divisor = info->custom_divisor; | 3397 | tmp.custom_divisor = info->custom_divisor; |
3408 | if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) | 3398 | if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) |
3409 | return -EFAULT; | 3399 | return -EFAULT; |
@@ -3425,16 +3415,16 @@ set_serial_info(struct e100_serial *info, | |||
3425 | 3415 | ||
3426 | if (!capable(CAP_SYS_ADMIN)) { | 3416 | if (!capable(CAP_SYS_ADMIN)) { |
3427 | if ((new_serial.type != info->type) || | 3417 | if ((new_serial.type != info->type) || |
3428 | (new_serial.close_delay != info->close_delay) || | 3418 | (new_serial.close_delay != info->port.close_delay) || |
3429 | ((new_serial.flags & ~ASYNC_USR_MASK) != | 3419 | ((new_serial.flags & ~ASYNC_USR_MASK) != |
3430 | (info->flags & ~ASYNC_USR_MASK))) | 3420 | (info->port.flags & ~ASYNC_USR_MASK))) |
3431 | return -EPERM; | 3421 | return -EPERM; |
3432 | info->flags = ((info->flags & ~ASYNC_USR_MASK) | | 3422 | info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) | |
3433 | (new_serial.flags & ASYNC_USR_MASK)); | 3423 | (new_serial.flags & ASYNC_USR_MASK)); |
3434 | goto check_and_exit; | 3424 | goto check_and_exit; |
3435 | } | 3425 | } |
3436 | 3426 | ||
3437 | if (info->count > 1) | 3427 | if (info->port.count > 1) |
3438 | return -EBUSY; | 3428 | return -EBUSY; |
3439 | 3429 | ||
3440 | /* | 3430 | /* |
@@ -3443,16 +3433,16 @@ set_serial_info(struct e100_serial *info, | |||
3443 | */ | 3433 | */ |
3444 | 3434 | ||
3445 | info->baud_base = new_serial.baud_base; | 3435 | info->baud_base = new_serial.baud_base; |
3446 | info->flags = ((info->flags & ~ASYNC_FLAGS) | | 3436 | info->port.flags = ((info->port.flags & ~ASYNC_FLAGS) | |
3447 | (new_serial.flags & ASYNC_FLAGS)); | 3437 | (new_serial.flags & ASYNC_FLAGS)); |
3448 | info->custom_divisor = new_serial.custom_divisor; | 3438 | info->custom_divisor = new_serial.custom_divisor; |
3449 | info->type = new_serial.type; | 3439 | info->type = new_serial.type; |
3450 | info->close_delay = new_serial.close_delay; | 3440 | info->port.close_delay = new_serial.close_delay; |
3451 | info->closing_wait = new_serial.closing_wait; | 3441 | info->port.closing_wait = new_serial.closing_wait; |
3452 | info->port.low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; | 3442 | info->port.low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; |
3453 | 3443 | ||
3454 | check_and_exit: | 3444 | check_and_exit: |
3455 | if (info->flags & ASYNC_INITIALIZED) { | 3445 | if (info->port.flags & ASYNC_INITIALIZED) { |
3456 | change_speed(info); | 3446 | change_speed(info); |
3457 | } else | 3447 | } else |
3458 | retval = startup(info); | 3448 | retval = startup(info); |
@@ -3733,10 +3723,8 @@ rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
3733 | 3723 | ||
3734 | /* Handle turning off CRTSCTS */ | 3724 | /* Handle turning off CRTSCTS */ |
3735 | if ((old_termios->c_cflag & CRTSCTS) && | 3725 | if ((old_termios->c_cflag & CRTSCTS) && |
3736 | !(tty->termios.c_cflag & CRTSCTS)) { | 3726 | !(tty->termios.c_cflag & CRTSCTS)) |
3737 | tty->hw_stopped = 0; | ||
3738 | rs_start(tty); | 3727 | rs_start(tty); |
3739 | } | ||
3740 | 3728 | ||
3741 | } | 3729 | } |
3742 | 3730 | ||
@@ -3772,7 +3760,7 @@ rs_close(struct tty_struct *tty, struct file * filp) | |||
3772 | printk("[%d] rs_close ttyS%d, count = %d\n", current->pid, | 3760 | printk("[%d] rs_close ttyS%d, count = %d\n", current->pid, |
3773 | info->line, info->count); | 3761 | info->line, info->count); |
3774 | #endif | 3762 | #endif |
3775 | if ((tty->count == 1) && (info->count != 1)) { | 3763 | if ((tty->count == 1) && (info->port.count != 1)) { |
3776 | /* | 3764 | /* |
3777 | * Uh, oh. tty->count is 1, which means that the tty | 3765 | * Uh, oh. tty->count is 1, which means that the tty |
3778 | * structure will be freed. Info->count should always | 3766 | * structure will be freed. Info->count should always |
@@ -3782,32 +3770,32 @@ rs_close(struct tty_struct *tty, struct file * filp) | |||
3782 | */ | 3770 | */ |
3783 | printk(KERN_ERR | 3771 | printk(KERN_ERR |
3784 | "rs_close: bad serial port count; tty->count is 1, " | 3772 | "rs_close: bad serial port count; tty->count is 1, " |
3785 | "info->count is %d\n", info->count); | 3773 | "info->count is %d\n", info->port.count); |
3786 | info->count = 1; | 3774 | info->port.count = 1; |
3787 | } | 3775 | } |
3788 | if (--info->count < 0) { | 3776 | if (--info->port.count < 0) { |
3789 | printk(KERN_ERR "rs_close: bad serial port count for ttyS%d: %d\n", | 3777 | printk(KERN_ERR "rs_close: bad serial port count for ttyS%d: %d\n", |
3790 | info->line, info->count); | 3778 | info->line, info->port.count); |
3791 | info->count = 0; | 3779 | info->port.count = 0; |
3792 | } | 3780 | } |
3793 | if (info->count) { | 3781 | if (info->port.count) { |
3794 | local_irq_restore(flags); | 3782 | local_irq_restore(flags); |
3795 | return; | 3783 | return; |
3796 | } | 3784 | } |
3797 | info->flags |= ASYNC_CLOSING; | 3785 | info->port.flags |= ASYNC_CLOSING; |
3798 | /* | 3786 | /* |
3799 | * Save the termios structure, since this port may have | 3787 | * Save the termios structure, since this port may have |
3800 | * separate termios for callout and dialin. | 3788 | * separate termios for callout and dialin. |
3801 | */ | 3789 | */ |
3802 | if (info->flags & ASYNC_NORMAL_ACTIVE) | 3790 | if (info->port.flags & ASYNC_NORMAL_ACTIVE) |
3803 | info->normal_termios = tty->termios; | 3791 | info->normal_termios = tty->termios; |
3804 | /* | 3792 | /* |
3805 | * Now we wait for the transmit buffer to clear; and we notify | 3793 | * Now we wait for the transmit buffer to clear; and we notify |
3806 | * the line discipline to only process XON/XOFF characters. | 3794 | * the line discipline to only process XON/XOFF characters. |
3807 | */ | 3795 | */ |
3808 | tty->closing = 1; | 3796 | tty->closing = 1; |
3809 | if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) | 3797 | if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) |
3810 | tty_wait_until_sent(tty, info->closing_wait); | 3798 | tty_wait_until_sent(tty, info->port.closing_wait); |
3811 | /* | 3799 | /* |
3812 | * At this point we stop accepting input. To do this, we | 3800 | * At this point we stop accepting input. To do this, we |
3813 | * disable the serial receiver and the DMA receive interrupt. | 3801 | * disable the serial receiver and the DMA receive interrupt. |
@@ -3820,7 +3808,7 @@ rs_close(struct tty_struct *tty, struct file * filp) | |||
3820 | e100_disable_rx(info); | 3808 | e100_disable_rx(info); |
3821 | e100_disable_rx_irq(info); | 3809 | e100_disable_rx_irq(info); |
3822 | 3810 | ||
3823 | if (info->flags & ASYNC_INITIALIZED) { | 3811 | if (info->port.flags & ASYNC_INITIALIZED) { |
3824 | /* | 3812 | /* |
3825 | * Before we drop DTR, make sure the UART transmitter | 3813 | * Before we drop DTR, make sure the UART transmitter |
3826 | * has completely drained; this is especially | 3814 | * has completely drained; this is especially |
@@ -3836,13 +3824,13 @@ rs_close(struct tty_struct *tty, struct file * filp) | |||
3836 | tty->closing = 0; | 3824 | tty->closing = 0; |
3837 | info->event = 0; | 3825 | info->event = 0; |
3838 | info->port.tty = NULL; | 3826 | info->port.tty = NULL; |
3839 | if (info->blocked_open) { | 3827 | if (info->port.blocked_open) { |
3840 | if (info->close_delay) | 3828 | if (info->port.close_delay) |
3841 | schedule_timeout_interruptible(info->close_delay); | 3829 | schedule_timeout_interruptible(info->port.close_delay); |
3842 | wake_up_interruptible(&info->open_wait); | 3830 | wake_up_interruptible(&info->port.open_wait); |
3843 | } | 3831 | } |
3844 | info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); | 3832 | info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); |
3845 | wake_up_interruptible(&info->close_wait); | 3833 | wake_up_interruptible(&info->port.close_wait); |
3846 | local_irq_restore(flags); | 3834 | local_irq_restore(flags); |
3847 | 3835 | ||
3848 | /* port closed */ | 3836 | /* port closed */ |
@@ -3935,10 +3923,10 @@ rs_hangup(struct tty_struct *tty) | |||
3935 | rs_flush_buffer(tty); | 3923 | rs_flush_buffer(tty); |
3936 | shutdown(info); | 3924 | shutdown(info); |
3937 | info->event = 0; | 3925 | info->event = 0; |
3938 | info->count = 0; | 3926 | info->port.count = 0; |
3939 | info->flags &= ~ASYNC_NORMAL_ACTIVE; | 3927 | info->port.flags &= ~ASYNC_NORMAL_ACTIVE; |
3940 | info->port.tty = NULL; | 3928 | info->port.tty = NULL; |
3941 | wake_up_interruptible(&info->open_wait); | 3929 | wake_up_interruptible(&info->port.open_wait); |
3942 | } | 3930 | } |
3943 | 3931 | ||
3944 | /* | 3932 | /* |
@@ -3960,11 +3948,11 @@ block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3960 | * until it's done, and then try again. | 3948 | * until it's done, and then try again. |
3961 | */ | 3949 | */ |
3962 | if (tty_hung_up_p(filp) || | 3950 | if (tty_hung_up_p(filp) || |
3963 | (info->flags & ASYNC_CLOSING)) { | 3951 | (info->port.flags & ASYNC_CLOSING)) { |
3964 | wait_event_interruptible_tty(tty, info->close_wait, | 3952 | wait_event_interruptible_tty(tty, info->port.close_wait, |
3965 | !(info->flags & ASYNC_CLOSING)); | 3953 | !(info->port.flags & ASYNC_CLOSING)); |
3966 | #ifdef SERIAL_DO_RESTART | 3954 | #ifdef SERIAL_DO_RESTART |
3967 | if (info->flags & ASYNC_HUP_NOTIFY) | 3955 | if (info->port.flags & ASYNC_HUP_NOTIFY) |
3968 | return -EAGAIN; | 3956 | return -EAGAIN; |
3969 | else | 3957 | else |
3970 | return -ERESTARTSYS; | 3958 | return -ERESTARTSYS; |
@@ -3979,7 +3967,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3979 | */ | 3967 | */ |
3980 | if ((filp->f_flags & O_NONBLOCK) || | 3968 | if ((filp->f_flags & O_NONBLOCK) || |
3981 | (tty->flags & (1 << TTY_IO_ERROR))) { | 3969 | (tty->flags & (1 << TTY_IO_ERROR))) { |
3982 | info->flags |= ASYNC_NORMAL_ACTIVE; | 3970 | info->port.flags |= ASYNC_NORMAL_ACTIVE; |
3983 | return 0; | 3971 | return 0; |
3984 | } | 3972 | } |
3985 | 3973 | ||
@@ -3990,23 +3978,23 @@ block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3990 | /* | 3978 | /* |
3991 | * Block waiting for the carrier detect and the line to become | 3979 | * Block waiting for the carrier detect and the line to become |
3992 | * free (i.e., not in use by the callout). While we are in | 3980 | * free (i.e., not in use by the callout). While we are in |
3993 | * this loop, info->count is dropped by one, so that | 3981 | * this loop, info->port.count is dropped by one, so that |
3994 | * rs_close() knows when to free things. We restore it upon | 3982 | * rs_close() knows when to free things. We restore it upon |
3995 | * exit, either normal or abnormal. | 3983 | * exit, either normal or abnormal. |
3996 | */ | 3984 | */ |
3997 | retval = 0; | 3985 | retval = 0; |
3998 | add_wait_queue(&info->open_wait, &wait); | 3986 | add_wait_queue(&info->port.open_wait, &wait); |
3999 | #ifdef SERIAL_DEBUG_OPEN | 3987 | #ifdef SERIAL_DEBUG_OPEN |
4000 | printk("block_til_ready before block: ttyS%d, count = %d\n", | 3988 | printk("block_til_ready before block: ttyS%d, count = %d\n", |
4001 | info->line, info->count); | 3989 | info->line, info->port.count); |
4002 | #endif | 3990 | #endif |
4003 | local_irq_save(flags); | 3991 | local_irq_save(flags); |
4004 | if (!tty_hung_up_p(filp)) { | 3992 | if (!tty_hung_up_p(filp)) { |
4005 | extra_count++; | 3993 | extra_count++; |
4006 | info->count--; | 3994 | info->port.count--; |
4007 | } | 3995 | } |
4008 | local_irq_restore(flags); | 3996 | local_irq_restore(flags); |
4009 | info->blocked_open++; | 3997 | info->port.blocked_open++; |
4010 | while (1) { | 3998 | while (1) { |
4011 | local_irq_save(flags); | 3999 | local_irq_save(flags); |
4012 | /* assert RTS and DTR */ | 4000 | /* assert RTS and DTR */ |
@@ -4015,9 +4003,9 @@ block_til_ready(struct tty_struct *tty, struct file * filp, | |||
4015 | local_irq_restore(flags); | 4003 | local_irq_restore(flags); |
4016 | set_current_state(TASK_INTERRUPTIBLE); | 4004 | set_current_state(TASK_INTERRUPTIBLE); |
4017 | if (tty_hung_up_p(filp) || | 4005 | if (tty_hung_up_p(filp) || |
4018 | !(info->flags & ASYNC_INITIALIZED)) { | 4006 | !(info->port.flags & ASYNC_INITIALIZED)) { |
4019 | #ifdef SERIAL_DO_RESTART | 4007 | #ifdef SERIAL_DO_RESTART |
4020 | if (info->flags & ASYNC_HUP_NOTIFY) | 4008 | if (info->port.flags & ASYNC_HUP_NOTIFY) |
4021 | retval = -EAGAIN; | 4009 | retval = -EAGAIN; |
4022 | else | 4010 | else |
4023 | retval = -ERESTARTSYS; | 4011 | retval = -ERESTARTSYS; |
@@ -4026,7 +4014,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp, | |||
4026 | #endif | 4014 | #endif |
4027 | break; | 4015 | break; |
4028 | } | 4016 | } |
4029 | if (!(info->flags & ASYNC_CLOSING) && do_clocal) | 4017 | if (!(info->port.flags & ASYNC_CLOSING) && do_clocal) |
4030 | /* && (do_clocal || DCD_IS_ASSERTED) */ | 4018 | /* && (do_clocal || DCD_IS_ASSERTED) */ |
4031 | break; | 4019 | break; |
4032 | if (signal_pending(current)) { | 4020 | if (signal_pending(current)) { |
@@ -4035,24 +4023,24 @@ block_til_ready(struct tty_struct *tty, struct file * filp, | |||
4035 | } | 4023 | } |
4036 | #ifdef SERIAL_DEBUG_OPEN | 4024 | #ifdef SERIAL_DEBUG_OPEN |
4037 | printk("block_til_ready blocking: ttyS%d, count = %d\n", | 4025 | printk("block_til_ready blocking: ttyS%d, count = %d\n", |
4038 | info->line, info->count); | 4026 | info->line, info->port.count); |
4039 | #endif | 4027 | #endif |
4040 | tty_unlock(tty); | 4028 | tty_unlock(tty); |
4041 | schedule(); | 4029 | schedule(); |
4042 | tty_lock(tty); | 4030 | tty_lock(tty); |
4043 | } | 4031 | } |
4044 | set_current_state(TASK_RUNNING); | 4032 | set_current_state(TASK_RUNNING); |
4045 | remove_wait_queue(&info->open_wait, &wait); | 4033 | remove_wait_queue(&info->port.open_wait, &wait); |
4046 | if (extra_count) | 4034 | if (extra_count) |
4047 | info->count++; | 4035 | info->port.count++; |
4048 | info->blocked_open--; | 4036 | info->port.blocked_open--; |
4049 | #ifdef SERIAL_DEBUG_OPEN | 4037 | #ifdef SERIAL_DEBUG_OPEN |
4050 | printk("block_til_ready after blocking: ttyS%d, count = %d\n", | 4038 | printk("block_til_ready after blocking: ttyS%d, count = %d\n", |
4051 | info->line, info->count); | 4039 | info->line, info->port.count); |
4052 | #endif | 4040 | #endif |
4053 | if (retval) | 4041 | if (retval) |
4054 | return retval; | 4042 | return retval; |
4055 | info->flags |= ASYNC_NORMAL_ACTIVE; | 4043 | info->port.flags |= ASYNC_NORMAL_ACTIVE; |
4056 | return 0; | 4044 | return 0; |
4057 | } | 4045 | } |
4058 | 4046 | ||
@@ -4086,24 +4074,24 @@ rs_open(struct tty_struct *tty, struct file * filp) | |||
4086 | 4074 | ||
4087 | #ifdef SERIAL_DEBUG_OPEN | 4075 | #ifdef SERIAL_DEBUG_OPEN |
4088 | printk("[%d] rs_open %s, count = %d\n", current->pid, tty->name, | 4076 | printk("[%d] rs_open %s, count = %d\n", current->pid, tty->name, |
4089 | info->count); | 4077 | info->port.count); |
4090 | #endif | 4078 | #endif |
4091 | 4079 | ||
4092 | info->count++; | 4080 | info->port.count++; |
4093 | tty->driver_data = info; | 4081 | tty->driver_data = info; |
4094 | info->port.tty = tty; | 4082 | info->port.tty = tty; |
4095 | 4083 | ||
4096 | info->port.low_latency = !!(info->flags & ASYNC_LOW_LATENCY); | 4084 | info->port.low_latency = !!(info->port.flags & ASYNC_LOW_LATENCY); |
4097 | 4085 | ||
4098 | /* | 4086 | /* |
4099 | * If the port is in the middle of closing, bail out now | 4087 | * If the port is in the middle of closing, bail out now |
4100 | */ | 4088 | */ |
4101 | if (tty_hung_up_p(filp) || | 4089 | if (tty_hung_up_p(filp) || |
4102 | (info->flags & ASYNC_CLOSING)) { | 4090 | (info->port.flags & ASYNC_CLOSING)) { |
4103 | wait_event_interruptible_tty(tty, info->close_wait, | 4091 | wait_event_interruptible_tty(tty, info->port.close_wait, |
4104 | !(info->flags & ASYNC_CLOSING)); | 4092 | !(info->port.flags & ASYNC_CLOSING)); |
4105 | #ifdef SERIAL_DO_RESTART | 4093 | #ifdef SERIAL_DO_RESTART |
4106 | return ((info->flags & ASYNC_HUP_NOTIFY) ? | 4094 | return ((info->port.flags & ASYNC_HUP_NOTIFY) ? |
4107 | -EAGAIN : -ERESTARTSYS); | 4095 | -EAGAIN : -ERESTARTSYS); |
4108 | #else | 4096 | #else |
4109 | return -EAGAIN; | 4097 | return -EAGAIN; |
@@ -4113,7 +4101,7 @@ rs_open(struct tty_struct *tty, struct file * filp) | |||
4113 | /* | 4101 | /* |
4114 | * If DMA is enabled try to allocate the irq's. | 4102 | * If DMA is enabled try to allocate the irq's. |
4115 | */ | 4103 | */ |
4116 | if (info->count == 1) { | 4104 | if (info->port.count == 1) { |
4117 | allocated_resources = 1; | 4105 | allocated_resources = 1; |
4118 | if (info->dma_in_enabled) { | 4106 | if (info->dma_in_enabled) { |
4119 | if (request_irq(info->dma_in_irq_nbr, | 4107 | if (request_irq(info->dma_in_irq_nbr, |
@@ -4186,7 +4174,7 @@ rs_open(struct tty_struct *tty, struct file * filp) | |||
4186 | if (allocated_resources) | 4174 | if (allocated_resources) |
4187 | deinit_port(info); | 4175 | deinit_port(info); |
4188 | 4176 | ||
4189 | /* FIXME Decrease count info->count here too? */ | 4177 | /* FIXME Decrease count info->port.count here too? */ |
4190 | return retval; | 4178 | return retval; |
4191 | } | 4179 | } |
4192 | 4180 | ||
@@ -4203,7 +4191,7 @@ rs_open(struct tty_struct *tty, struct file * filp) | |||
4203 | return retval; | 4191 | return retval; |
4204 | } | 4192 | } |
4205 | 4193 | ||
4206 | if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) { | 4194 | if ((info->port.count == 1) && (info->port.flags & ASYNC_SPLIT_TERMIOS)) { |
4207 | tty->termios = info->normal_termios; | 4195 | tty->termios = info->normal_termios; |
4208 | change_speed(info); | 4196 | change_speed(info); |
4209 | } | 4197 | } |
@@ -4256,9 +4244,6 @@ static void seq_line_info(struct seq_file *m, struct e100_serial *info) | |||
4256 | if (info->port.tty->stopped) | 4244 | if (info->port.tty->stopped) |
4257 | seq_printf(m, " stopped:%i", | 4245 | seq_printf(m, " stopped:%i", |
4258 | (int)info->port.tty->stopped); | 4246 | (int)info->port.tty->stopped); |
4259 | if (info->port.tty->hw_stopped) | ||
4260 | seq_printf(m, " hw_stopped:%i", | ||
4261 | (int)info->port.tty->hw_stopped); | ||
4262 | } | 4247 | } |
4263 | 4248 | ||
4264 | { | 4249 | { |
@@ -4455,16 +4440,9 @@ static int __init rs_init(void) | |||
4455 | info->forced_eop = 0; | 4440 | info->forced_eop = 0; |
4456 | info->baud_base = DEF_BAUD_BASE; | 4441 | info->baud_base = DEF_BAUD_BASE; |
4457 | info->custom_divisor = 0; | 4442 | info->custom_divisor = 0; |
4458 | info->flags = 0; | ||
4459 | info->close_delay = 5*HZ/10; | ||
4460 | info->closing_wait = 30*HZ; | ||
4461 | info->x_char = 0; | 4443 | info->x_char = 0; |
4462 | info->event = 0; | 4444 | info->event = 0; |
4463 | info->count = 0; | ||
4464 | info->blocked_open = 0; | ||
4465 | info->normal_termios = driver->init_termios; | 4445 | info->normal_termios = driver->init_termios; |
4466 | init_waitqueue_head(&info->open_wait); | ||
4467 | init_waitqueue_head(&info->close_wait); | ||
4468 | info->xmit.buf = NULL; | 4446 | info->xmit.buf = NULL; |
4469 | info->xmit.tail = info->xmit.head = 0; | 4447 | info->xmit.tail = info->xmit.head = 0; |
4470 | info->first_recv_buffer = info->last_recv_buffer = NULL; | 4448 | info->first_recv_buffer = info->last_recv_buffer = NULL; |
diff --git a/drivers/tty/serial/crisv10.h b/drivers/tty/serial/crisv10.h index ea0beb46a10d..7599014ae03f 100644 --- a/drivers/tty/serial/crisv10.h +++ b/drivers/tty/serial/crisv10.h | |||
@@ -53,8 +53,6 @@ struct e100_serial { | |||
53 | volatile u8 *icmdadr; /* adr to R_DMA_CHx_CMD */ | 53 | volatile u8 *icmdadr; /* adr to R_DMA_CHx_CMD */ |
54 | volatile u32 *idescradr; /* adr to R_DMA_CHx_DESCR */ | 54 | volatile u32 *idescradr; /* adr to R_DMA_CHx_DESCR */ |
55 | 55 | ||
56 | int flags; /* defined in tty.h */ | ||
57 | |||
58 | u8 rx_ctrl; /* shadow for R_SERIALx_REC_CTRL */ | 56 | u8 rx_ctrl; /* shadow for R_SERIALx_REC_CTRL */ |
59 | u8 tx_ctrl; /* shadow for R_SERIALx_TR_CTRL */ | 57 | u8 tx_ctrl; /* shadow for R_SERIALx_TR_CTRL */ |
60 | u8 iseteop; /* bit number for R_SET_EOP for the input dma */ | 58 | u8 iseteop; /* bit number for R_SET_EOP for the input dma */ |
@@ -88,19 +86,10 @@ struct e100_serial { | |||
88 | 86 | ||
89 | volatile int tr_running; /* 1 if output is running */ | 87 | volatile int tr_running; /* 1 if output is running */ |
90 | 88 | ||
91 | struct tty_struct *tty; | ||
92 | int read_status_mask; | ||
93 | int ignore_status_mask; | ||
94 | int x_char; /* xon/xoff character */ | 89 | int x_char; /* xon/xoff character */ |
95 | int close_delay; | ||
96 | unsigned short closing_wait; | ||
97 | unsigned short closing_wait2; | ||
98 | unsigned long event; | 90 | unsigned long event; |
99 | unsigned long last_active; | ||
100 | int line; | 91 | int line; |
101 | int type; /* PORT_ETRAX */ | 92 | int type; /* PORT_ETRAX */ |
102 | int count; /* # of fd on device */ | ||
103 | int blocked_open; /* # of blocked opens */ | ||
104 | struct circ_buf xmit; | 93 | struct circ_buf xmit; |
105 | struct etrax_recv_buffer *first_recv_buffer; | 94 | struct etrax_recv_buffer *first_recv_buffer; |
106 | struct etrax_recv_buffer *last_recv_buffer; | 95 | struct etrax_recv_buffer *last_recv_buffer; |
@@ -110,9 +99,6 @@ struct e100_serial { | |||
110 | struct work_struct work; | 99 | struct work_struct work; |
111 | struct async_icount icount; /* error-statistics etc.*/ | 100 | struct async_icount icount; /* error-statistics etc.*/ |
112 | struct ktermios normal_termios; | 101 | struct ktermios normal_termios; |
113 | struct ktermios callout_termios; | ||
114 | wait_queue_head_t open_wait; | ||
115 | wait_queue_head_t close_wait; | ||
116 | 102 | ||
117 | unsigned long char_time_usec; /* The time for 1 char, in usecs */ | 103 | unsigned long char_time_usec; /* The time for 1 char, in usecs */ |
118 | unsigned long flush_time_usec; /* How often we should flush */ | 104 | unsigned long flush_time_usec; /* How often we should flush */ |
diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c index bc9e6b017b05..18ed5aebb166 100644 --- a/drivers/tty/serial/icom.c +++ b/drivers/tty/serial/icom.c | |||
@@ -1415,8 +1415,7 @@ static int icom_alloc_adapter(struct icom_adapter | |||
1415 | struct icom_adapter *cur_adapter_entry; | 1415 | struct icom_adapter *cur_adapter_entry; |
1416 | struct list_head *tmp; | 1416 | struct list_head *tmp; |
1417 | 1417 | ||
1418 | icom_adapter = (struct icom_adapter *) | 1418 | icom_adapter = kzalloc(sizeof(struct icom_adapter), GFP_KERNEL); |
1419 | kzalloc(sizeof(struct icom_adapter), GFP_KERNEL); | ||
1420 | 1419 | ||
1421 | if (!icom_adapter) { | 1420 | if (!icom_adapter) { |
1422 | return -ENOMEM; | 1421 | return -ENOMEM; |
diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c index 68d7ce997ede..8b1534c424af 100644 --- a/drivers/tty/serial/ifx6x60.c +++ b/drivers/tty/serial/ifx6x60.c | |||
@@ -270,23 +270,6 @@ static void mrdy_assert(struct ifx_spi_device *ifx_dev) | |||
270 | } | 270 | } |
271 | 271 | ||
272 | /** | 272 | /** |
273 | * ifx_spi_hangup - hang up an IFX device | ||
274 | * @ifx_dev: our SPI device | ||
275 | * | ||
276 | * Hang up the tty attached to the IFX device if one is currently | ||
277 | * open. If not take no action | ||
278 | */ | ||
279 | static void ifx_spi_ttyhangup(struct ifx_spi_device *ifx_dev) | ||
280 | { | ||
281 | struct tty_port *pport = &ifx_dev->tty_port; | ||
282 | struct tty_struct *tty = tty_port_tty_get(pport); | ||
283 | if (tty) { | ||
284 | tty_hangup(tty); | ||
285 | tty_kref_put(tty); | ||
286 | } | ||
287 | } | ||
288 | |||
289 | /** | ||
290 | * ifx_spi_timeout - SPI timeout | 273 | * ifx_spi_timeout - SPI timeout |
291 | * @arg: our SPI device | 274 | * @arg: our SPI device |
292 | * | 275 | * |
@@ -298,7 +281,7 @@ static void ifx_spi_timeout(unsigned long arg) | |||
298 | struct ifx_spi_device *ifx_dev = (struct ifx_spi_device *)arg; | 281 | struct ifx_spi_device *ifx_dev = (struct ifx_spi_device *)arg; |
299 | 282 | ||
300 | dev_warn(&ifx_dev->spi_dev->dev, "*** SPI Timeout ***"); | 283 | dev_warn(&ifx_dev->spi_dev->dev, "*** SPI Timeout ***"); |
301 | ifx_spi_ttyhangup(ifx_dev); | 284 | tty_port_tty_hangup(&ifx_dev->tty_port, false); |
302 | mrdy_set_low(ifx_dev); | 285 | mrdy_set_low(ifx_dev); |
303 | clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags); | 286 | clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags); |
304 | } | 287 | } |
@@ -443,25 +426,6 @@ static void ifx_spi_setup_spi_header(unsigned char *txbuffer, int tx_count, | |||
443 | } | 426 | } |
444 | 427 | ||
445 | /** | 428 | /** |
446 | * ifx_spi_wakeup_serial - SPI space made | ||
447 | * @port_data: our SPI device | ||
448 | * | ||
449 | * We have emptied the FIFO enough that we want to get more data | ||
450 | * queued into it. Poke the line discipline via tty_wakeup so that | ||
451 | * it will feed us more bits | ||
452 | */ | ||
453 | static void ifx_spi_wakeup_serial(struct ifx_spi_device *ifx_dev) | ||
454 | { | ||
455 | struct tty_struct *tty; | ||
456 | |||
457 | tty = tty_port_tty_get(&ifx_dev->tty_port); | ||
458 | if (!tty) | ||
459 | return; | ||
460 | tty_wakeup(tty); | ||
461 | tty_kref_put(tty); | ||
462 | } | ||
463 | |||
464 | /** | ||
465 | * ifx_spi_prepare_tx_buffer - prepare transmit frame | 429 | * ifx_spi_prepare_tx_buffer - prepare transmit frame |
466 | * @ifx_dev: our SPI device | 430 | * @ifx_dev: our SPI device |
467 | * | 431 | * |
@@ -506,7 +470,7 @@ static int ifx_spi_prepare_tx_buffer(struct ifx_spi_device *ifx_dev) | |||
506 | tx_count += temp_count; | 470 | tx_count += temp_count; |
507 | if (temp_count == queue_length) | 471 | if (temp_count == queue_length) |
508 | /* poke port to get more data */ | 472 | /* poke port to get more data */ |
509 | ifx_spi_wakeup_serial(ifx_dev); | 473 | tty_port_tty_wakeup(&ifx_dev->tty_port); |
510 | else /* more data in port, use next SPI message */ | 474 | else /* more data in port, use next SPI message */ |
511 | ifx_dev->spi_more = 1; | 475 | ifx_dev->spi_more = 1; |
512 | } | 476 | } |
@@ -683,8 +647,6 @@ static void ifx_spi_insert_flip_string(struct ifx_spi_device *ifx_dev, | |||
683 | static void ifx_spi_complete(void *ctx) | 647 | static void ifx_spi_complete(void *ctx) |
684 | { | 648 | { |
685 | struct ifx_spi_device *ifx_dev = ctx; | 649 | struct ifx_spi_device *ifx_dev = ctx; |
686 | struct tty_struct *tty; | ||
687 | struct tty_ldisc *ldisc = NULL; | ||
688 | int length; | 650 | int length; |
689 | int actual_length; | 651 | int actual_length; |
690 | unsigned char more; | 652 | unsigned char more; |
@@ -762,15 +724,7 @@ complete_exit: | |||
762 | */ | 724 | */ |
763 | ifx_spi_power_state_clear(ifx_dev, | 725 | ifx_spi_power_state_clear(ifx_dev, |
764 | IFX_SPI_POWER_DATA_PENDING); | 726 | IFX_SPI_POWER_DATA_PENDING); |
765 | tty = tty_port_tty_get(&ifx_dev->tty_port); | 727 | tty_port_tty_wakeup(&ifx_dev->tty_port); |
766 | if (tty) { | ||
767 | ldisc = tty_ldisc_ref(tty); | ||
768 | if (ldisc) { | ||
769 | ldisc->ops->write_wakeup(tty); | ||
770 | tty_ldisc_deref(ldisc); | ||
771 | } | ||
772 | tty_kref_put(tty); | ||
773 | } | ||
774 | } | 728 | } |
775 | } | 729 | } |
776 | } | 730 | } |
@@ -962,7 +916,7 @@ static irqreturn_t ifx_spi_reset_interrupt(int irq, void *dev) | |||
962 | set_bit(MR_INPROGRESS, &ifx_dev->mdm_reset_state); | 916 | set_bit(MR_INPROGRESS, &ifx_dev->mdm_reset_state); |
963 | if (!solreset) { | 917 | if (!solreset) { |
964 | /* unsolicited reset */ | 918 | /* unsolicited reset */ |
965 | ifx_spi_ttyhangup(ifx_dev); | 919 | tty_port_tty_hangup(&ifx_dev->tty_port, false); |
966 | } | 920 | } |
967 | } else { | 921 | } else { |
968 | /* exited reset */ | 922 | /* exited reset */ |
@@ -1325,30 +1279,6 @@ static void ifx_spi_spi_shutdown(struct spi_device *spi) | |||
1325 | */ | 1279 | */ |
1326 | 1280 | ||
1327 | /** | 1281 | /** |
1328 | * ifx_spi_spi_suspend - suspend SPI on system suspend | ||
1329 | * @dev: device being suspended | ||
1330 | * | ||
1331 | * Suspend the SPI side. No action needed on Intel MID platforms, may | ||
1332 | * need extending for other systems. | ||
1333 | */ | ||
1334 | static int ifx_spi_spi_suspend(struct spi_device *spi, pm_message_t msg) | ||
1335 | { | ||
1336 | return 0; | ||
1337 | } | ||
1338 | |||
1339 | /** | ||
1340 | * ifx_spi_spi_resume - resume SPI side on system resume | ||
1341 | * @dev: device being suspended | ||
1342 | * | ||
1343 | * Suspend the SPI side. No action needed on Intel MID platforms, may | ||
1344 | * need extending for other systems. | ||
1345 | */ | ||
1346 | static int ifx_spi_spi_resume(struct spi_device *spi) | ||
1347 | { | ||
1348 | return 0; | ||
1349 | } | ||
1350 | |||
1351 | /** | ||
1352 | * ifx_spi_pm_suspend - suspend modem on system suspend | 1282 | * ifx_spi_pm_suspend - suspend modem on system suspend |
1353 | * @dev: device being suspended | 1283 | * @dev: device being suspended |
1354 | * | 1284 | * |
@@ -1437,8 +1367,6 @@ static struct spi_driver ifx_spi_driver = { | |||
1437 | .probe = ifx_spi_spi_probe, | 1367 | .probe = ifx_spi_spi_probe, |
1438 | .shutdown = ifx_spi_spi_shutdown, | 1368 | .shutdown = ifx_spi_spi_shutdown, |
1439 | .remove = ifx_spi_spi_remove, | 1369 | .remove = ifx_spi_spi_remove, |
1440 | .suspend = ifx_spi_spi_suspend, | ||
1441 | .resume = ifx_spi_spi_resume, | ||
1442 | .id_table = ifx_id_table | 1370 | .id_table = ifx_id_table |
1443 | }; | 1371 | }; |
1444 | 1372 | ||
diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c index 00f250ae14c5..27bb75070c96 100644 --- a/drivers/tty/serial/jsm/jsm_tty.c +++ b/drivers/tty/serial/jsm/jsm_tty.c | |||
@@ -596,12 +596,6 @@ void jsm_input(struct jsm_channel *ch) | |||
596 | 596 | ||
597 | jsm_dbg(READ, &ch->ch_bd->pci_dev, "start 2\n"); | 597 | jsm_dbg(READ, &ch->ch_bd->pci_dev, "start 2\n"); |
598 | 598 | ||
599 | if (data_len <= 0) { | ||
600 | spin_unlock_irqrestore(&ch->ch_lock, lock_flags); | ||
601 | jsm_dbg(READ, &ch->ch_bd->pci_dev, "jsm_input 1\n"); | ||
602 | return; | ||
603 | } | ||
604 | |||
605 | len = tty_buffer_request_room(port, data_len); | 599 | len = tty_buffer_request_room(port, data_len); |
606 | n = len; | 600 | n = len; |
607 | 601 | ||
diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 32517d4bceab..57da9bbaaab5 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c | |||
@@ -849,11 +849,11 @@ static int max3100_remove(struct spi_device *spi) | |||
849 | return 0; | 849 | return 0; |
850 | } | 850 | } |
851 | 851 | ||
852 | #ifdef CONFIG_PM | 852 | #ifdef CONFIG_PM_SLEEP |
853 | 853 | ||
854 | static int max3100_suspend(struct spi_device *spi, pm_message_t state) | 854 | static int max3100_suspend(struct device *dev) |
855 | { | 855 | { |
856 | struct max3100_port *s = dev_get_drvdata(&spi->dev); | 856 | struct max3100_port *s = dev_get_drvdata(dev); |
857 | 857 | ||
858 | dev_dbg(&s->spi->dev, "%s\n", __func__); | 858 | dev_dbg(&s->spi->dev, "%s\n", __func__); |
859 | 859 | ||
@@ -874,9 +874,9 @@ static int max3100_suspend(struct spi_device *spi, pm_message_t state) | |||
874 | return 0; | 874 | return 0; |
875 | } | 875 | } |
876 | 876 | ||
877 | static int max3100_resume(struct spi_device *spi) | 877 | static int max3100_resume(struct device *dev) |
878 | { | 878 | { |
879 | struct max3100_port *s = dev_get_drvdata(&spi->dev); | 879 | struct max3100_port *s = dev_get_drvdata(dev); |
880 | 880 | ||
881 | dev_dbg(&s->spi->dev, "%s\n", __func__); | 881 | dev_dbg(&s->spi->dev, "%s\n", __func__); |
882 | 882 | ||
@@ -894,21 +894,21 @@ static int max3100_resume(struct spi_device *spi) | |||
894 | return 0; | 894 | return 0; |
895 | } | 895 | } |
896 | 896 | ||
897 | static SIMPLE_DEV_PM_OPS(max3100_pm_ops, max3100_suspend, max3100_resume); | ||
898 | #define MAX3100_PM_OPS (&max3100_pm_ops) | ||
899 | |||
897 | #else | 900 | #else |
898 | #define max3100_suspend NULL | 901 | #define MAX3100_PM_OPS NULL |
899 | #define max3100_resume NULL | ||
900 | #endif | 902 | #endif |
901 | 903 | ||
902 | static struct spi_driver max3100_driver = { | 904 | static struct spi_driver max3100_driver = { |
903 | .driver = { | 905 | .driver = { |
904 | .name = "max3100", | 906 | .name = "max3100", |
905 | .owner = THIS_MODULE, | 907 | .owner = THIS_MODULE, |
908 | .pm = MAX3100_PM_OPS, | ||
906 | }, | 909 | }, |
907 | |||
908 | .probe = max3100_probe, | 910 | .probe = max3100_probe, |
909 | .remove = max3100_remove, | 911 | .remove = max3100_remove, |
910 | .suspend = max3100_suspend, | ||
911 | .resume = max3100_resume, | ||
912 | }; | 912 | }; |
913 | 913 | ||
914 | module_spi_driver(max3100_driver); | 914 | module_spi_driver(max3100_driver); |
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index 0c2422cb04ea..8941e6418942 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c | |||
@@ -881,12 +881,14 @@ static struct uart_ops max310x_ops = { | |||
881 | .verify_port = max310x_verify_port, | 881 | .verify_port = max310x_verify_port, |
882 | }; | 882 | }; |
883 | 883 | ||
884 | static int max310x_suspend(struct spi_device *spi, pm_message_t state) | 884 | #ifdef CONFIG_PM_SLEEP |
885 | |||
886 | static int max310x_suspend(struct device *dev) | ||
885 | { | 887 | { |
886 | int ret; | 888 | int ret; |
887 | struct max310x_port *s = dev_get_drvdata(&spi->dev); | 889 | struct max310x_port *s = dev_get_drvdata(dev); |
888 | 890 | ||
889 | dev_dbg(&spi->dev, "Suspend\n"); | 891 | dev_dbg(dev, "Suspend\n"); |
890 | 892 | ||
891 | ret = uart_suspend_port(&s->uart, &s->port); | 893 | ret = uart_suspend_port(&s->uart, &s->port); |
892 | 894 | ||
@@ -905,11 +907,11 @@ static int max310x_suspend(struct spi_device *spi, pm_message_t state) | |||
905 | return ret; | 907 | return ret; |
906 | } | 908 | } |
907 | 909 | ||
908 | static int max310x_resume(struct spi_device *spi) | 910 | static int max310x_resume(struct device *dev) |
909 | { | 911 | { |
910 | struct max310x_port *s = dev_get_drvdata(&spi->dev); | 912 | struct max310x_port *s = dev_get_drvdata(dev); |
911 | 913 | ||
912 | dev_dbg(&spi->dev, "Resume\n"); | 914 | dev_dbg(dev, "Resume\n"); |
913 | 915 | ||
914 | if (s->pdata->suspend) | 916 | if (s->pdata->suspend) |
915 | s->pdata->suspend(0); | 917 | s->pdata->suspend(0); |
@@ -928,6 +930,13 @@ static int max310x_resume(struct spi_device *spi) | |||
928 | return uart_resume_port(&s->uart, &s->port); | 930 | return uart_resume_port(&s->uart, &s->port); |
929 | } | 931 | } |
930 | 932 | ||
933 | static SIMPLE_DEV_PM_OPS(max310x_pm_ops, max310x_suspend, max310x_resume); | ||
934 | #define MAX310X_PM_OPS (&max310x_pm_ops) | ||
935 | |||
936 | #else | ||
937 | #define MAX310X_PM_OPS NULL | ||
938 | #endif | ||
939 | |||
931 | #ifdef CONFIG_GPIOLIB | 940 | #ifdef CONFIG_GPIOLIB |
932 | static int max310x_gpio_get(struct gpio_chip *chip, unsigned offset) | 941 | static int max310x_gpio_get(struct gpio_chip *chip, unsigned offset) |
933 | { | 942 | { |
@@ -1242,11 +1251,10 @@ static struct spi_driver max310x_driver = { | |||
1242 | .driver = { | 1251 | .driver = { |
1243 | .name = "max310x", | 1252 | .name = "max310x", |
1244 | .owner = THIS_MODULE, | 1253 | .owner = THIS_MODULE, |
1254 | .pm = MAX310X_PM_OPS, | ||
1245 | }, | 1255 | }, |
1246 | .probe = max310x_probe, | 1256 | .probe = max310x_probe, |
1247 | .remove = max310x_remove, | 1257 | .remove = max310x_remove, |
1248 | .suspend = max310x_suspend, | ||
1249 | .resume = max310x_resume, | ||
1250 | .id_table = max310x_id_table, | 1258 | .id_table = max310x_id_table, |
1251 | }; | 1259 | }; |
1252 | module_spi_driver(max310x_driver); | 1260 | module_spi_driver(max310x_driver); |
diff --git a/drivers/tty/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c index f641c232beca..9b6ef20420c0 100644 --- a/drivers/tty/serial/mrst_max3110.c +++ b/drivers/tty/serial/mrst_max3110.c | |||
@@ -743,9 +743,10 @@ static struct uart_driver serial_m3110_reg = { | |||
743 | .cons = &serial_m3110_console, | 743 | .cons = &serial_m3110_console, |
744 | }; | 744 | }; |
745 | 745 | ||
746 | #ifdef CONFIG_PM | 746 | #ifdef CONFIG_PM_SLEEP |
747 | static int serial_m3110_suspend(struct spi_device *spi, pm_message_t state) | 747 | static int serial_m3110_suspend(struct device *dev) |
748 | { | 748 | { |
749 | struct spi_device *spi = to_spi_device(dev); | ||
749 | struct uart_max3110 *max = spi_get_drvdata(spi); | 750 | struct uart_max3110 *max = spi_get_drvdata(spi); |
750 | 751 | ||
751 | disable_irq(max->irq); | 752 | disable_irq(max->irq); |
@@ -754,8 +755,9 @@ static int serial_m3110_suspend(struct spi_device *spi, pm_message_t state) | |||
754 | return 0; | 755 | return 0; |
755 | } | 756 | } |
756 | 757 | ||
757 | static int serial_m3110_resume(struct spi_device *spi) | 758 | static int serial_m3110_resume(struct device *dev) |
758 | { | 759 | { |
760 | struct spi_device *spi = to_spi_device(dev); | ||
759 | struct uart_max3110 *max = spi_get_drvdata(spi); | 761 | struct uart_max3110 *max = spi_get_drvdata(spi); |
760 | 762 | ||
761 | max3110_out(max, max->cur_conf); | 763 | max3110_out(max, max->cur_conf); |
@@ -763,9 +765,13 @@ static int serial_m3110_resume(struct spi_device *spi) | |||
763 | enable_irq(max->irq); | 765 | enable_irq(max->irq); |
764 | return 0; | 766 | return 0; |
765 | } | 767 | } |
768 | |||
769 | static SIMPLE_DEV_PM_OPS(serial_m3110_pm_ops, serial_m3110_suspend, | ||
770 | serial_m3110_resume); | ||
771 | #define SERIAL_M3110_PM_OPS (&serial_m3110_pm_ops) | ||
772 | |||
766 | #else | 773 | #else |
767 | #define serial_m3110_suspend NULL | 774 | #define SERIAL_M3110_PM_OPS NULL |
768 | #define serial_m3110_resume NULL | ||
769 | #endif | 775 | #endif |
770 | 776 | ||
771 | static int serial_m3110_probe(struct spi_device *spi) | 777 | static int serial_m3110_probe(struct spi_device *spi) |
@@ -872,11 +878,10 @@ static struct spi_driver uart_max3110_driver = { | |||
872 | .driver = { | 878 | .driver = { |
873 | .name = "spi_max3111", | 879 | .name = "spi_max3111", |
874 | .owner = THIS_MODULE, | 880 | .owner = THIS_MODULE, |
881 | .pm = SERIAL_M3110_PM_OPS, | ||
875 | }, | 882 | }, |
876 | .probe = serial_m3110_probe, | 883 | .probe = serial_m3110_probe, |
877 | .remove = serial_m3110_remove, | 884 | .remove = serial_m3110_remove, |
878 | .suspend = serial_m3110_suspend, | ||
879 | .resume = serial_m3110_resume, | ||
880 | }; | 885 | }; |
881 | 886 | ||
882 | static int __init serial_m3110_init(void) | 887 | static int __init serial_m3110_init(void) |
diff --git a/drivers/tty/serial/msm_serial_hs.c b/drivers/tty/serial/msm_serial_hs.c index 4a942c78347e..4ca2f64861e6 100644 --- a/drivers/tty/serial/msm_serial_hs.c +++ b/drivers/tty/serial/msm_serial_hs.c | |||
@@ -907,7 +907,6 @@ static void msm_hs_dmov_rx_callback(struct msm_dmov_cmd *cmd_ptr, | |||
907 | unsigned int error_f = 0; | 907 | unsigned int error_f = 0; |
908 | unsigned long flags; | 908 | unsigned long flags; |
909 | unsigned int flush; | 909 | unsigned int flush; |
910 | struct tty_struct *tty; | ||
911 | struct tty_port *port; | 910 | struct tty_port *port; |
912 | struct uart_port *uport; | 911 | struct uart_port *uport; |
913 | struct msm_hs_port *msm_uport; | 912 | struct msm_hs_port *msm_uport; |
@@ -919,7 +918,6 @@ static void msm_hs_dmov_rx_callback(struct msm_dmov_cmd *cmd_ptr, | |||
919 | clk_enable(msm_uport->clk); | 918 | clk_enable(msm_uport->clk); |
920 | 919 | ||
921 | port = &uport->state->port; | 920 | port = &uport->state->port; |
922 | tty = port->tty; | ||
923 | 921 | ||
924 | msm_hs_write(uport, UARTDM_CR_ADDR, STALE_EVENT_DISABLE); | 922 | msm_hs_write(uport, UARTDM_CR_ADDR, STALE_EVENT_DISABLE); |
925 | 923 | ||
diff --git a/drivers/tty/serial/msm_smd_tty.c b/drivers/tty/serial/msm_smd_tty.c index e722ff163d91..1238ac370bff 100644 --- a/drivers/tty/serial/msm_smd_tty.c +++ b/drivers/tty/serial/msm_smd_tty.c | |||
@@ -90,13 +90,13 @@ static void smd_tty_notify(void *priv, unsigned event) | |||
90 | 90 | ||
91 | static int smd_tty_port_activate(struct tty_port *tport, struct tty_struct *tty) | 91 | static int smd_tty_port_activate(struct tty_port *tport, struct tty_struct *tty) |
92 | { | 92 | { |
93 | struct smd_tty_info *info = container_of(tport, struct smd_tty_info, | ||
94 | port); | ||
93 | int i, res = 0; | 95 | int i, res = 0; |
94 | int n = tty->index; | ||
95 | const char *name = NULL; | 96 | const char *name = NULL; |
96 | struct smd_tty_info *info = smd_tty + n; | ||
97 | 97 | ||
98 | for (i = 0; i < smd_tty_channels_len; i++) { | 98 | for (i = 0; i < smd_tty_channels_len; i++) { |
99 | if (smd_tty_channels[i].id == n) { | 99 | if (smd_tty_channels[i].id == tty->index) { |
100 | name = smd_tty_channels[i].name; | 100 | name = smd_tty_channels[i].name; |
101 | break; | 101 | break; |
102 | } | 102 | } |
@@ -117,17 +117,13 @@ static int smd_tty_port_activate(struct tty_port *tport, struct tty_struct *tty) | |||
117 | 117 | ||
118 | static void smd_tty_port_shutdown(struct tty_port *tport) | 118 | static void smd_tty_port_shutdown(struct tty_port *tport) |
119 | { | 119 | { |
120 | struct smd_tty_info *info; | 120 | struct smd_tty_info *info = container_of(tport, struct smd_tty_info, |
121 | struct tty_struct *tty = tty_port_tty_get(tport); | 121 | port); |
122 | 122 | ||
123 | info = tty->driver_data; | ||
124 | if (info->ch) { | 123 | if (info->ch) { |
125 | smd_close(info->ch); | 124 | smd_close(info->ch); |
126 | info->ch = 0; | 125 | info->ch = 0; |
127 | } | 126 | } |
128 | |||
129 | tty->driver_data = 0; | ||
130 | tty_kref_put(tty); | ||
131 | } | 127 | } |
132 | 128 | ||
133 | static int smd_tty_open(struct tty_struct *tty, struct file *f) | 129 | static int smd_tty_open(struct tty_struct *tty, struct file *f) |
diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c index b025d5438275..39c7ea4cb14f 100644 --- a/drivers/tty/serial/of_serial.c +++ b/drivers/tty/serial/of_serial.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/serial_core.h> | 16 | #include <linux/serial_core.h> |
17 | #include <linux/serial_8250.h> | ||
18 | #include <linux/serial_reg.h> | 17 | #include <linux/serial_reg.h> |
19 | #include <linux/of_address.h> | 18 | #include <linux/of_address.h> |
20 | #include <linux/of_irq.h> | 19 | #include <linux/of_irq.h> |
@@ -22,6 +21,8 @@ | |||
22 | #include <linux/nwpserial.h> | 21 | #include <linux/nwpserial.h> |
23 | #include <linux/clk.h> | 22 | #include <linux/clk.h> |
24 | 23 | ||
24 | #include "8250/8250.h" | ||
25 | |||
25 | struct of_serial_info { | 26 | struct of_serial_info { |
26 | struct clk *clk; | 27 | struct clk *clk; |
27 | int type; | 28 | int type; |
@@ -97,6 +98,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev, | |||
97 | if (of_property_read_u32(np, "reg-shift", &prop) == 0) | 98 | if (of_property_read_u32(np, "reg-shift", &prop) == 0) |
98 | port->regshift = prop; | 99 | port->regshift = prop; |
99 | 100 | ||
101 | /* Check for fifo size */ | ||
102 | if (of_property_read_u32(np, "fifo-size", &prop) == 0) | ||
103 | port->fifosize = prop; | ||
104 | |||
100 | port->irq = irq_of_parse_and_map(np, 0); | 105 | port->irq = irq_of_parse_and_map(np, 0); |
101 | port->iotype = UPIO_MEM; | 106 | port->iotype = UPIO_MEM; |
102 | if (of_property_read_u32(np, "reg-io-width", &prop) == 0) { | 107 | if (of_property_read_u32(np, "reg-io-width", &prop) == 0) { |
@@ -167,11 +172,17 @@ static int of_platform_serial_probe(struct platform_device *ofdev) | |||
167 | #ifdef CONFIG_SERIAL_8250 | 172 | #ifdef CONFIG_SERIAL_8250 |
168 | case PORT_8250 ... PORT_MAX_8250: | 173 | case PORT_8250 ... PORT_MAX_8250: |
169 | { | 174 | { |
170 | /* For now the of bindings don't support the extra | ||
171 | 8250 specific bits */ | ||
172 | struct uart_8250_port port8250; | 175 | struct uart_8250_port port8250; |
173 | memset(&port8250, 0, sizeof(port8250)); | 176 | memset(&port8250, 0, sizeof(port8250)); |
174 | port8250.port = port; | 177 | port8250.port = port; |
178 | |||
179 | if (port.fifosize) | ||
180 | port8250.capabilities = UART_CAP_FIFO; | ||
181 | |||
182 | if (of_property_read_bool(ofdev->dev.of_node, | ||
183 | "auto-flow-control")) | ||
184 | port8250.capabilities |= UART_CAP_AFE; | ||
185 | |||
175 | ret = serial8250_register_8250_port(&port8250); | 186 | ret = serial8250_register_8250_port(&port8250); |
176 | break; | 187 | break; |
177 | } | 188 | } |
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index 7a6c989924b3..21a7e179edf3 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c | |||
@@ -1493,29 +1493,6 @@ static int pch_uart_verify_port(struct uart_port *port, | |||
1493 | return 0; | 1493 | return 0; |
1494 | } | 1494 | } |
1495 | 1495 | ||
1496 | static struct uart_ops pch_uart_ops = { | ||
1497 | .tx_empty = pch_uart_tx_empty, | ||
1498 | .set_mctrl = pch_uart_set_mctrl, | ||
1499 | .get_mctrl = pch_uart_get_mctrl, | ||
1500 | .stop_tx = pch_uart_stop_tx, | ||
1501 | .start_tx = pch_uart_start_tx, | ||
1502 | .stop_rx = pch_uart_stop_rx, | ||
1503 | .enable_ms = pch_uart_enable_ms, | ||
1504 | .break_ctl = pch_uart_break_ctl, | ||
1505 | .startup = pch_uart_startup, | ||
1506 | .shutdown = pch_uart_shutdown, | ||
1507 | .set_termios = pch_uart_set_termios, | ||
1508 | /* .pm = pch_uart_pm, Not supported yet */ | ||
1509 | /* .set_wake = pch_uart_set_wake, Not supported yet */ | ||
1510 | .type = pch_uart_type, | ||
1511 | .release_port = pch_uart_release_port, | ||
1512 | .request_port = pch_uart_request_port, | ||
1513 | .config_port = pch_uart_config_port, | ||
1514 | .verify_port = pch_uart_verify_port | ||
1515 | }; | ||
1516 | |||
1517 | #ifdef CONFIG_SERIAL_PCH_UART_CONSOLE | ||
1518 | |||
1519 | /* | 1496 | /* |
1520 | * Wait for transmitter & holding register to empty | 1497 | * Wait for transmitter & holding register to empty |
1521 | */ | 1498 | */ |
@@ -1547,6 +1524,84 @@ static void wait_for_xmitr(struct eg20t_port *up, int bits) | |||
1547 | } | 1524 | } |
1548 | } | 1525 | } |
1549 | 1526 | ||
1527 | #ifdef CONFIG_CONSOLE_POLL | ||
1528 | /* | ||
1529 | * Console polling routines for communicate via uart while | ||
1530 | * in an interrupt or debug context. | ||
1531 | */ | ||
1532 | static int pch_uart_get_poll_char(struct uart_port *port) | ||
1533 | { | ||
1534 | struct eg20t_port *priv = | ||
1535 | container_of(port, struct eg20t_port, port); | ||
1536 | u8 lsr = ioread8(priv->membase + UART_LSR); | ||
1537 | |||
1538 | if (!(lsr & UART_LSR_DR)) | ||
1539 | return NO_POLL_CHAR; | ||
1540 | |||
1541 | return ioread8(priv->membase + PCH_UART_RBR); | ||
1542 | } | ||
1543 | |||
1544 | |||
1545 | static void pch_uart_put_poll_char(struct uart_port *port, | ||
1546 | unsigned char c) | ||
1547 | { | ||
1548 | unsigned int ier; | ||
1549 | struct eg20t_port *priv = | ||
1550 | container_of(port, struct eg20t_port, port); | ||
1551 | |||
1552 | /* | ||
1553 | * First save the IER then disable the interrupts | ||
1554 | */ | ||
1555 | ier = ioread8(priv->membase + UART_IER); | ||
1556 | pch_uart_hal_disable_interrupt(priv, PCH_UART_HAL_ALL_INT); | ||
1557 | |||
1558 | wait_for_xmitr(priv, UART_LSR_THRE); | ||
1559 | /* | ||
1560 | * Send the character out. | ||
1561 | * If a LF, also do CR... | ||
1562 | */ | ||
1563 | iowrite8(c, priv->membase + PCH_UART_THR); | ||
1564 | if (c == 10) { | ||
1565 | wait_for_xmitr(priv, UART_LSR_THRE); | ||
1566 | iowrite8(13, priv->membase + PCH_UART_THR); | ||
1567 | } | ||
1568 | |||
1569 | /* | ||
1570 | * Finally, wait for transmitter to become empty | ||
1571 | * and restore the IER | ||
1572 | */ | ||
1573 | wait_for_xmitr(priv, BOTH_EMPTY); | ||
1574 | iowrite8(ier, priv->membase + UART_IER); | ||
1575 | } | ||
1576 | #endif /* CONFIG_CONSOLE_POLL */ | ||
1577 | |||
1578 | static struct uart_ops pch_uart_ops = { | ||
1579 | .tx_empty = pch_uart_tx_empty, | ||
1580 | .set_mctrl = pch_uart_set_mctrl, | ||
1581 | .get_mctrl = pch_uart_get_mctrl, | ||
1582 | .stop_tx = pch_uart_stop_tx, | ||
1583 | .start_tx = pch_uart_start_tx, | ||
1584 | .stop_rx = pch_uart_stop_rx, | ||
1585 | .enable_ms = pch_uart_enable_ms, | ||
1586 | .break_ctl = pch_uart_break_ctl, | ||
1587 | .startup = pch_uart_startup, | ||
1588 | .shutdown = pch_uart_shutdown, | ||
1589 | .set_termios = pch_uart_set_termios, | ||
1590 | /* .pm = pch_uart_pm, Not supported yet */ | ||
1591 | /* .set_wake = pch_uart_set_wake, Not supported yet */ | ||
1592 | .type = pch_uart_type, | ||
1593 | .release_port = pch_uart_release_port, | ||
1594 | .request_port = pch_uart_request_port, | ||
1595 | .config_port = pch_uart_config_port, | ||
1596 | .verify_port = pch_uart_verify_port, | ||
1597 | #ifdef CONFIG_CONSOLE_POLL | ||
1598 | .poll_get_char = pch_uart_get_poll_char, | ||
1599 | .poll_put_char = pch_uart_put_poll_char, | ||
1600 | #endif | ||
1601 | }; | ||
1602 | |||
1603 | #ifdef CONFIG_SERIAL_PCH_UART_CONSOLE | ||
1604 | |||
1550 | static void pch_console_putchar(struct uart_port *port, int ch) | 1605 | static void pch_console_putchar(struct uart_port *port, int ch) |
1551 | { | 1606 | { |
1552 | struct eg20t_port *priv = | 1607 | struct eg20t_port *priv = |
@@ -1655,7 +1710,7 @@ static struct console pch_console = { | |||
1655 | #define PCH_CONSOLE (&pch_console) | 1710 | #define PCH_CONSOLE (&pch_console) |
1656 | #else | 1711 | #else |
1657 | #define PCH_CONSOLE NULL | 1712 | #define PCH_CONSOLE NULL |
1658 | #endif | 1713 | #endif /* CONFIG_SERIAL_PCH_UART_CONSOLE */ |
1659 | 1714 | ||
1660 | static struct uart_driver pch_uart_driver = { | 1715 | static struct uart_driver pch_uart_driver = { |
1661 | .owner = THIS_MODULE, | 1716 | .owner = THIS_MODULE, |
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 2769a38d15b6..7883f11b8c53 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c | |||
@@ -446,6 +446,8 @@ static void s3c24xx_serial_shutdown(struct uart_port *port) | |||
446 | 446 | ||
447 | /* Clear pending interrupts and mask all interrupts */ | 447 | /* Clear pending interrupts and mask all interrupts */ |
448 | if (s3c24xx_serial_has_interrupt_mask(port)) { | 448 | if (s3c24xx_serial_has_interrupt_mask(port)) { |
449 | free_irq(port->irq, ourport); | ||
450 | |||
449 | wr_regl(port, S3C64XX_UINTP, 0xf); | 451 | wr_regl(port, S3C64XX_UINTP, 0xf); |
450 | wr_regl(port, S3C64XX_UINTM, 0xf); | 452 | wr_regl(port, S3C64XX_UINTM, 0xf); |
451 | } | 453 | } |
@@ -505,6 +507,8 @@ static int s3c64xx_serial_startup(struct uart_port *port) | |||
505 | dbg("s3c64xx_serial_startup: port=%p (%08lx,%p)\n", | 507 | dbg("s3c64xx_serial_startup: port=%p (%08lx,%p)\n", |
506 | port->mapbase, port->membase); | 508 | port->mapbase, port->membase); |
507 | 509 | ||
510 | wr_regl(port, S3C64XX_UINTM, 0xf); | ||
511 | |||
508 | ret = request_irq(port->irq, s3c64xx_serial_handle_irq, IRQF_SHARED, | 512 | ret = request_irq(port->irq, s3c64xx_serial_handle_irq, IRQF_SHARED, |
509 | s3c24xx_serial_portname(port), ourport); | 513 | s3c24xx_serial_portname(port), ourport); |
510 | if (ret) { | 514 | if (ret) { |
@@ -1307,9 +1311,29 @@ static int s3c24xx_serial_resume(struct device *dev) | |||
1307 | return 0; | 1311 | return 0; |
1308 | } | 1312 | } |
1309 | 1313 | ||
1314 | static int s3c24xx_serial_resume_noirq(struct device *dev) | ||
1315 | { | ||
1316 | struct uart_port *port = s3c24xx_dev_to_port(dev); | ||
1317 | |||
1318 | if (port) { | ||
1319 | /* restore IRQ mask */ | ||
1320 | if (s3c24xx_serial_has_interrupt_mask(port)) { | ||
1321 | unsigned int uintm = 0xf; | ||
1322 | if (tx_enabled(port)) | ||
1323 | uintm &= ~S3C64XX_UINTM_TXD_MSK; | ||
1324 | if (rx_enabled(port)) | ||
1325 | uintm &= ~S3C64XX_UINTM_RXD_MSK; | ||
1326 | wr_regl(port, S3C64XX_UINTM, uintm); | ||
1327 | } | ||
1328 | } | ||
1329 | |||
1330 | return 0; | ||
1331 | } | ||
1332 | |||
1310 | static const struct dev_pm_ops s3c24xx_serial_pm_ops = { | 1333 | static const struct dev_pm_ops s3c24xx_serial_pm_ops = { |
1311 | .suspend = s3c24xx_serial_suspend, | 1334 | .suspend = s3c24xx_serial_suspend, |
1312 | .resume = s3c24xx_serial_resume, | 1335 | .resume = s3c24xx_serial_resume, |
1336 | .resume_noirq = s3c24xx_serial_resume_noirq, | ||
1313 | }; | 1337 | }; |
1314 | #define SERIAL_SAMSUNG_PM_OPS (&s3c24xx_serial_pm_ops) | 1338 | #define SERIAL_SAMSUNG_PM_OPS (&s3c24xx_serial_pm_ops) |
1315 | 1339 | ||
@@ -1343,6 +1367,13 @@ s3c24xx_serial_console_txrdy(struct uart_port *port, unsigned int ufcon) | |||
1343 | return (utrstat & S3C2410_UTRSTAT_TXE) ? 1 : 0; | 1367 | return (utrstat & S3C2410_UTRSTAT_TXE) ? 1 : 0; |
1344 | } | 1368 | } |
1345 | 1369 | ||
1370 | static bool | ||
1371 | s3c24xx_port_configured(unsigned int ucon) | ||
1372 | { | ||
1373 | /* consider the serial port configured if the tx/rx mode set */ | ||
1374 | return (ucon & 0xf) != 0; | ||
1375 | } | ||
1376 | |||
1346 | #ifdef CONFIG_CONSOLE_POLL | 1377 | #ifdef CONFIG_CONSOLE_POLL |
1347 | /* | 1378 | /* |
1348 | * Console polling routines for writing and reading from the uart while | 1379 | * Console polling routines for writing and reading from the uart while |
@@ -1365,6 +1396,11 @@ static void s3c24xx_serial_put_poll_char(struct uart_port *port, | |||
1365 | unsigned char c) | 1396 | unsigned char c) |
1366 | { | 1397 | { |
1367 | unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); | 1398 | unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); |
1399 | unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON); | ||
1400 | |||
1401 | /* not possible to xmit on unconfigured port */ | ||
1402 | if (!s3c24xx_port_configured(ucon)) | ||
1403 | return; | ||
1368 | 1404 | ||
1369 | while (!s3c24xx_serial_console_txrdy(port, ufcon)) | 1405 | while (!s3c24xx_serial_console_txrdy(port, ufcon)) |
1370 | cpu_relax(); | 1406 | cpu_relax(); |
@@ -1377,6 +1413,12 @@ static void | |||
1377 | s3c24xx_serial_console_putchar(struct uart_port *port, int ch) | 1413 | s3c24xx_serial_console_putchar(struct uart_port *port, int ch) |
1378 | { | 1414 | { |
1379 | unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); | 1415 | unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); |
1416 | unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON); | ||
1417 | |||
1418 | /* not possible to xmit on unconfigured port */ | ||
1419 | if (!s3c24xx_port_configured(ucon)) | ||
1420 | return; | ||
1421 | |||
1380 | while (!s3c24xx_serial_console_txrdy(port, ufcon)) | 1422 | while (!s3c24xx_serial_console_txrdy(port, ufcon)) |
1381 | barrier(); | 1423 | barrier(); |
1382 | wr_regb(cons_uart, S3C2410_UTXH, ch); | 1424 | wr_regb(cons_uart, S3C2410_UTXH, ch); |
@@ -1409,9 +1451,7 @@ s3c24xx_serial_get_options(struct uart_port *port, int *baud, | |||
1409 | "registers: ulcon=%08x, ucon=%08x, ubdriv=%08x\n", | 1451 | "registers: ulcon=%08x, ucon=%08x, ubdriv=%08x\n", |
1410 | port, ulcon, ucon, ubrdiv); | 1452 | port, ulcon, ucon, ubrdiv); |
1411 | 1453 | ||
1412 | if ((ucon & 0xf) != 0) { | 1454 | if (s3c24xx_port_configured(ucon)) { |
1413 | /* consider the serial port configured if the tx/rx mode set */ | ||
1414 | |||
1415 | switch (ulcon & S3C2410_LCON_CSMASK) { | 1455 | switch (ulcon & S3C2410_LCON_CSMASK) { |
1416 | case S3C2410_LCON_CS5: | 1456 | case S3C2410_LCON_CS5: |
1417 | *bits = 5; | 1457 | *bits = 5; |
diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c index 372de8ade76a..9799d043a9bd 100644 --- a/drivers/tty/serial/serial-tegra.c +++ b/drivers/tty/serial/serial-tegra.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/dmaengine.h> | 26 | #include <linux/dmaengine.h> |
27 | #include <linux/dma-mapping.h> | 27 | #include <linux/dma-mapping.h> |
28 | #include <linux/dmapool.h> | 28 | #include <linux/dmapool.h> |
29 | #include <linux/err.h> | ||
29 | #include <linux/io.h> | 30 | #include <linux/io.h> |
30 | #include <linux/irq.h> | 31 | #include <linux/irq.h> |
31 | #include <linux/module.h> | 32 | #include <linux/module.h> |
@@ -1301,11 +1302,9 @@ static int tegra_uart_probe(struct platform_device *pdev) | |||
1301 | } | 1302 | } |
1302 | 1303 | ||
1303 | u->mapbase = resource->start; | 1304 | u->mapbase = resource->start; |
1304 | u->membase = devm_request_and_ioremap(&pdev->dev, resource); | 1305 | u->membase = devm_ioremap_resource(&pdev->dev, resource); |
1305 | if (!u->membase) { | 1306 | if (IS_ERR(u->membase)) |
1306 | dev_err(&pdev->dev, "memregion/iomap address req failed\n"); | 1307 | return PTR_ERR(u->membase); |
1307 | return -EADDRNOTAVAIL; | ||
1308 | } | ||
1309 | 1308 | ||
1310 | tup->uart_clk = devm_clk_get(&pdev->dev, NULL); | 1309 | tup->uart_clk = devm_clk_get(&pdev->dev, NULL); |
1311 | if (IS_ERR(tup->uart_clk)) { | 1310 | if (IS_ERR(tup->uart_clk)) { |
diff --git a/drivers/tty/serial/sh-sci.h b/drivers/tty/serial/sh-sci.h index 4c22a1529aac..5aca7364634c 100644 --- a/drivers/tty/serial/sh-sci.h +++ b/drivers/tty/serial/sh-sci.h | |||
@@ -15,8 +15,6 @@ | |||
15 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | 15 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
16 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ | 16 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
17 | defined(CONFIG_ARCH_SH73A0) || \ | 17 | defined(CONFIG_ARCH_SH73A0) || \ |
18 | defined(CONFIG_ARCH_SH7367) || \ | ||
19 | defined(CONFIG_ARCH_SH7377) || \ | ||
20 | defined(CONFIG_ARCH_SH7372) || \ | 18 | defined(CONFIG_ARCH_SH7372) || \ |
21 | defined(CONFIG_ARCH_R8A7740) | 19 | defined(CONFIG_ARCH_R8A7740) |
22 | 20 | ||
diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c index 8de2213664e0..a422c8b55a47 100644 --- a/drivers/tty/serial/sunsab.c +++ b/drivers/tty/serial/sunsab.c | |||
@@ -203,7 +203,7 @@ receive_chars(struct uart_sunsab_port *up, | |||
203 | flag = TTY_FRAME; | 203 | flag = TTY_FRAME; |
204 | } | 204 | } |
205 | 205 | ||
206 | if (uart_handle_sysrq_char(&up->port, ch)) | 206 | if (uart_handle_sysrq_char(&up->port, ch) || !port) |
207 | continue; | 207 | continue; |
208 | 208 | ||
209 | if ((stat->sreg.isr0 & (up->port.ignore_status_mask & 0xff)) == 0 && | 209 | if ((stat->sreg.isr0 & (up->port.ignore_status_mask & 0xff)) == 0 && |
diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c index 27669ff3d446..813ef8eb8eff 100644 --- a/drivers/tty/serial/sunzilog.c +++ b/drivers/tty/serial/sunzilog.c | |||
@@ -388,7 +388,7 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up, | |||
388 | else if (r1 & CRC_ERR) | 388 | else if (r1 & CRC_ERR) |
389 | flag = TTY_FRAME; | 389 | flag = TTY_FRAME; |
390 | } | 390 | } |
391 | if (uart_handle_sysrq_char(&up->port, ch)) | 391 | if (uart_handle_sysrq_char(&up->port, ch) || !port) |
392 | continue; | 392 | continue; |
393 | 393 | ||
394 | if (up->port.ignore_status_mask == 0xff || | 394 | if (up->port.ignore_status_mask == 0xff || |
diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c index 705240e6c4ec..1a8bc2275ea4 100644 --- a/drivers/tty/serial/vt8500_serial.c +++ b/drivers/tty/serial/vt8500_serial.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/clk.h> | 35 | #include <linux/clk.h> |
36 | #include <linux/platform_device.h> | 36 | #include <linux/platform_device.h> |
37 | #include <linux/of.h> | 37 | #include <linux/of.h> |
38 | #include <linux/err.h> | ||
38 | 39 | ||
39 | /* | 40 | /* |
40 | * UART Register offsets | 41 | * UART Register offsets |
@@ -585,9 +586,9 @@ static int vt8500_serial_probe(struct platform_device *pdev) | |||
585 | if (!vt8500_port) | 586 | if (!vt8500_port) |
586 | return -ENOMEM; | 587 | return -ENOMEM; |
587 | 588 | ||
588 | vt8500_port->uart.membase = devm_request_and_ioremap(&pdev->dev, mmres); | 589 | vt8500_port->uart.membase = devm_ioremap_resource(&pdev->dev, mmres); |
589 | if (!vt8500_port->uart.membase) | 590 | if (IS_ERR(vt8500_port->uart.membase)) |
590 | return -EADDRNOTAVAIL; | 591 | return PTR_ERR(vt8500_port->uart.membase); |
591 | 592 | ||
592 | vt8500_port->clk = of_clk_get(pdev->dev.of_node, 0); | 593 | vt8500_port->clk = of_clk_get(pdev->dev.of_node, 0); |
593 | if (IS_ERR(vt8500_port->clk)) { | 594 | if (IS_ERR(vt8500_port->clk)) { |
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index f36bbba1ac8b..4e5c77834c50 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c | |||
@@ -585,9 +585,6 @@ static int xuartps_startup(struct uart_port *port) | |||
585 | xuartps_writel(XUARTPS_IXR_TXEMPTY | XUARTPS_IXR_PARITY | | 585 | xuartps_writel(XUARTPS_IXR_TXEMPTY | XUARTPS_IXR_PARITY | |
586 | XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN | | 586 | XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN | |
587 | XUARTPS_IXR_RXTRIG | XUARTPS_IXR_TOUT, XUARTPS_IER_OFFSET); | 587 | XUARTPS_IXR_RXTRIG | XUARTPS_IXR_TOUT, XUARTPS_IER_OFFSET); |
588 | xuartps_writel(~(XUARTPS_IXR_TXEMPTY | XUARTPS_IXR_PARITY | | ||
589 | XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN | | ||
590 | XUARTPS_IXR_RXTRIG | XUARTPS_IXR_TOUT), XUARTPS_IDR_OFFSET); | ||
591 | 588 | ||
592 | return retval; | 589 | return retval; |
593 | } | 590 | } |
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c index 8983276aa35e..72d607101f90 100644 --- a/drivers/tty/synclink.c +++ b/drivers/tty/synclink.c | |||
@@ -1058,9 +1058,6 @@ static void mgsl_bh_handler(struct work_struct *work) | |||
1058 | container_of(work, struct mgsl_struct, task); | 1058 | container_of(work, struct mgsl_struct, task); |
1059 | int action; | 1059 | int action; |
1060 | 1060 | ||
1061 | if (!info) | ||
1062 | return; | ||
1063 | |||
1064 | if ( debug_level >= DEBUG_LEVEL_BH ) | 1061 | if ( debug_level >= DEBUG_LEVEL_BH ) |
1065 | printk( "%s(%d):mgsl_bh_handler(%s) entry\n", | 1062 | printk( "%s(%d):mgsl_bh_handler(%s) entry\n", |
1066 | __FILE__,__LINE__,info->device_name); | 1063 | __FILE__,__LINE__,info->device_name); |
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 3687f0cad642..0a0de333c765 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c | |||
@@ -101,7 +101,7 @@ static void sysrq_handle_SAK(int key) | |||
101 | } | 101 | } |
102 | static struct sysrq_key_op sysrq_SAK_op = { | 102 | static struct sysrq_key_op sysrq_SAK_op = { |
103 | .handler = sysrq_handle_SAK, | 103 | .handler = sysrq_handle_SAK, |
104 | .help_msg = "saK", | 104 | .help_msg = "sak(k)", |
105 | .action_msg = "SAK", | 105 | .action_msg = "SAK", |
106 | .enable_mask = SYSRQ_ENABLE_KEYBOARD, | 106 | .enable_mask = SYSRQ_ENABLE_KEYBOARD, |
107 | }; | 107 | }; |
@@ -117,7 +117,7 @@ static void sysrq_handle_unraw(int key) | |||
117 | 117 | ||
118 | static struct sysrq_key_op sysrq_unraw_op = { | 118 | static struct sysrq_key_op sysrq_unraw_op = { |
119 | .handler = sysrq_handle_unraw, | 119 | .handler = sysrq_handle_unraw, |
120 | .help_msg = "unRaw", | 120 | .help_msg = "unraw(r)", |
121 | .action_msg = "Keyboard mode set to system default", | 121 | .action_msg = "Keyboard mode set to system default", |
122 | .enable_mask = SYSRQ_ENABLE_KEYBOARD, | 122 | .enable_mask = SYSRQ_ENABLE_KEYBOARD, |
123 | }; | 123 | }; |
@@ -135,7 +135,7 @@ static void sysrq_handle_crash(int key) | |||
135 | } | 135 | } |
136 | static struct sysrq_key_op sysrq_crash_op = { | 136 | static struct sysrq_key_op sysrq_crash_op = { |
137 | .handler = sysrq_handle_crash, | 137 | .handler = sysrq_handle_crash, |
138 | .help_msg = "Crash", | 138 | .help_msg = "crash(c)", |
139 | .action_msg = "Trigger a crash", | 139 | .action_msg = "Trigger a crash", |
140 | .enable_mask = SYSRQ_ENABLE_DUMP, | 140 | .enable_mask = SYSRQ_ENABLE_DUMP, |
141 | }; | 141 | }; |
@@ -148,7 +148,7 @@ static void sysrq_handle_reboot(int key) | |||
148 | } | 148 | } |
149 | static struct sysrq_key_op sysrq_reboot_op = { | 149 | static struct sysrq_key_op sysrq_reboot_op = { |
150 | .handler = sysrq_handle_reboot, | 150 | .handler = sysrq_handle_reboot, |
151 | .help_msg = "reBoot", | 151 | .help_msg = "reboot(b)", |
152 | .action_msg = "Resetting", | 152 | .action_msg = "Resetting", |
153 | .enable_mask = SYSRQ_ENABLE_BOOT, | 153 | .enable_mask = SYSRQ_ENABLE_BOOT, |
154 | }; | 154 | }; |
@@ -159,7 +159,7 @@ static void sysrq_handle_sync(int key) | |||
159 | } | 159 | } |
160 | static struct sysrq_key_op sysrq_sync_op = { | 160 | static struct sysrq_key_op sysrq_sync_op = { |
161 | .handler = sysrq_handle_sync, | 161 | .handler = sysrq_handle_sync, |
162 | .help_msg = "Sync", | 162 | .help_msg = "sync(s)", |
163 | .action_msg = "Emergency Sync", | 163 | .action_msg = "Emergency Sync", |
164 | .enable_mask = SYSRQ_ENABLE_SYNC, | 164 | .enable_mask = SYSRQ_ENABLE_SYNC, |
165 | }; | 165 | }; |
@@ -171,7 +171,7 @@ static void sysrq_handle_show_timers(int key) | |||
171 | 171 | ||
172 | static struct sysrq_key_op sysrq_show_timers_op = { | 172 | static struct sysrq_key_op sysrq_show_timers_op = { |
173 | .handler = sysrq_handle_show_timers, | 173 | .handler = sysrq_handle_show_timers, |
174 | .help_msg = "show-all-timers(Q)", | 174 | .help_msg = "show-all-timers(q)", |
175 | .action_msg = "Show clockevent devices & pending hrtimers (no others)", | 175 | .action_msg = "Show clockevent devices & pending hrtimers (no others)", |
176 | }; | 176 | }; |
177 | 177 | ||
@@ -181,7 +181,7 @@ static void sysrq_handle_mountro(int key) | |||
181 | } | 181 | } |
182 | static struct sysrq_key_op sysrq_mountro_op = { | 182 | static struct sysrq_key_op sysrq_mountro_op = { |
183 | .handler = sysrq_handle_mountro, | 183 | .handler = sysrq_handle_mountro, |
184 | .help_msg = "Unmount", | 184 | .help_msg = "unmount(u)", |
185 | .action_msg = "Emergency Remount R/O", | 185 | .action_msg = "Emergency Remount R/O", |
186 | .enable_mask = SYSRQ_ENABLE_REMOUNT, | 186 | .enable_mask = SYSRQ_ENABLE_REMOUNT, |
187 | }; | 187 | }; |
@@ -194,7 +194,7 @@ static void sysrq_handle_showlocks(int key) | |||
194 | 194 | ||
195 | static struct sysrq_key_op sysrq_showlocks_op = { | 195 | static struct sysrq_key_op sysrq_showlocks_op = { |
196 | .handler = sysrq_handle_showlocks, | 196 | .handler = sysrq_handle_showlocks, |
197 | .help_msg = "show-all-locks(D)", | 197 | .help_msg = "show-all-locks(d)", |
198 | .action_msg = "Show Locks Held", | 198 | .action_msg = "Show Locks Held", |
199 | }; | 199 | }; |
200 | #else | 200 | #else |
@@ -245,7 +245,7 @@ static void sysrq_handle_showallcpus(int key) | |||
245 | 245 | ||
246 | static struct sysrq_key_op sysrq_showallcpus_op = { | 246 | static struct sysrq_key_op sysrq_showallcpus_op = { |
247 | .handler = sysrq_handle_showallcpus, | 247 | .handler = sysrq_handle_showallcpus, |
248 | .help_msg = "show-backtrace-all-active-cpus(L)", | 248 | .help_msg = "show-backtrace-all-active-cpus(l)", |
249 | .action_msg = "Show backtrace of all active CPUs", | 249 | .action_msg = "Show backtrace of all active CPUs", |
250 | .enable_mask = SYSRQ_ENABLE_DUMP, | 250 | .enable_mask = SYSRQ_ENABLE_DUMP, |
251 | }; | 251 | }; |
@@ -260,7 +260,7 @@ static void sysrq_handle_showregs(int key) | |||
260 | } | 260 | } |
261 | static struct sysrq_key_op sysrq_showregs_op = { | 261 | static struct sysrq_key_op sysrq_showregs_op = { |
262 | .handler = sysrq_handle_showregs, | 262 | .handler = sysrq_handle_showregs, |
263 | .help_msg = "show-registers(P)", | 263 | .help_msg = "show-registers(p)", |
264 | .action_msg = "Show Regs", | 264 | .action_msg = "Show Regs", |
265 | .enable_mask = SYSRQ_ENABLE_DUMP, | 265 | .enable_mask = SYSRQ_ENABLE_DUMP, |
266 | }; | 266 | }; |
@@ -271,7 +271,7 @@ static void sysrq_handle_showstate(int key) | |||
271 | } | 271 | } |
272 | static struct sysrq_key_op sysrq_showstate_op = { | 272 | static struct sysrq_key_op sysrq_showstate_op = { |
273 | .handler = sysrq_handle_showstate, | 273 | .handler = sysrq_handle_showstate, |
274 | .help_msg = "show-task-states(T)", | 274 | .help_msg = "show-task-states(t)", |
275 | .action_msg = "Show State", | 275 | .action_msg = "Show State", |
276 | .enable_mask = SYSRQ_ENABLE_DUMP, | 276 | .enable_mask = SYSRQ_ENABLE_DUMP, |
277 | }; | 277 | }; |
@@ -282,7 +282,7 @@ static void sysrq_handle_showstate_blocked(int key) | |||
282 | } | 282 | } |
283 | static struct sysrq_key_op sysrq_showstate_blocked_op = { | 283 | static struct sysrq_key_op sysrq_showstate_blocked_op = { |
284 | .handler = sysrq_handle_showstate_blocked, | 284 | .handler = sysrq_handle_showstate_blocked, |
285 | .help_msg = "show-blocked-tasks(W)", | 285 | .help_msg = "show-blocked-tasks(w)", |
286 | .action_msg = "Show Blocked State", | 286 | .action_msg = "Show Blocked State", |
287 | .enable_mask = SYSRQ_ENABLE_DUMP, | 287 | .enable_mask = SYSRQ_ENABLE_DUMP, |
288 | }; | 288 | }; |
@@ -296,7 +296,7 @@ static void sysrq_ftrace_dump(int key) | |||
296 | } | 296 | } |
297 | static struct sysrq_key_op sysrq_ftrace_dump_op = { | 297 | static struct sysrq_key_op sysrq_ftrace_dump_op = { |
298 | .handler = sysrq_ftrace_dump, | 298 | .handler = sysrq_ftrace_dump, |
299 | .help_msg = "dump-ftrace-buffer(Z)", | 299 | .help_msg = "dump-ftrace-buffer(z)", |
300 | .action_msg = "Dump ftrace buffer", | 300 | .action_msg = "Dump ftrace buffer", |
301 | .enable_mask = SYSRQ_ENABLE_DUMP, | 301 | .enable_mask = SYSRQ_ENABLE_DUMP, |
302 | }; | 302 | }; |
@@ -310,7 +310,7 @@ static void sysrq_handle_showmem(int key) | |||
310 | } | 310 | } |
311 | static struct sysrq_key_op sysrq_showmem_op = { | 311 | static struct sysrq_key_op sysrq_showmem_op = { |
312 | .handler = sysrq_handle_showmem, | 312 | .handler = sysrq_handle_showmem, |
313 | .help_msg = "show-memory-usage(M)", | 313 | .help_msg = "show-memory-usage(m)", |
314 | .action_msg = "Show Memory", | 314 | .action_msg = "Show Memory", |
315 | .enable_mask = SYSRQ_ENABLE_DUMP, | 315 | .enable_mask = SYSRQ_ENABLE_DUMP, |
316 | }; | 316 | }; |
@@ -341,7 +341,7 @@ static void sysrq_handle_term(int key) | |||
341 | } | 341 | } |
342 | static struct sysrq_key_op sysrq_term_op = { | 342 | static struct sysrq_key_op sysrq_term_op = { |
343 | .handler = sysrq_handle_term, | 343 | .handler = sysrq_handle_term, |
344 | .help_msg = "terminate-all-tasks(E)", | 344 | .help_msg = "terminate-all-tasks(e)", |
345 | .action_msg = "Terminate All Tasks", | 345 | .action_msg = "Terminate All Tasks", |
346 | .enable_mask = SYSRQ_ENABLE_SIGNAL, | 346 | .enable_mask = SYSRQ_ENABLE_SIGNAL, |
347 | }; | 347 | }; |
@@ -360,7 +360,7 @@ static void sysrq_handle_moom(int key) | |||
360 | } | 360 | } |
361 | static struct sysrq_key_op sysrq_moom_op = { | 361 | static struct sysrq_key_op sysrq_moom_op = { |
362 | .handler = sysrq_handle_moom, | 362 | .handler = sysrq_handle_moom, |
363 | .help_msg = "memory-full-oom-kill(F)", | 363 | .help_msg = "memory-full-oom-kill(f)", |
364 | .action_msg = "Manual OOM execution", | 364 | .action_msg = "Manual OOM execution", |
365 | .enable_mask = SYSRQ_ENABLE_SIGNAL, | 365 | .enable_mask = SYSRQ_ENABLE_SIGNAL, |
366 | }; | 366 | }; |
@@ -372,7 +372,7 @@ static void sysrq_handle_thaw(int key) | |||
372 | } | 372 | } |
373 | static struct sysrq_key_op sysrq_thaw_op = { | 373 | static struct sysrq_key_op sysrq_thaw_op = { |
374 | .handler = sysrq_handle_thaw, | 374 | .handler = sysrq_handle_thaw, |
375 | .help_msg = "thaw-filesystems(J)", | 375 | .help_msg = "thaw-filesystems(j)", |
376 | .action_msg = "Emergency Thaw of all frozen filesystems", | 376 | .action_msg = "Emergency Thaw of all frozen filesystems", |
377 | .enable_mask = SYSRQ_ENABLE_SIGNAL, | 377 | .enable_mask = SYSRQ_ENABLE_SIGNAL, |
378 | }; | 378 | }; |
@@ -385,7 +385,7 @@ static void sysrq_handle_kill(int key) | |||
385 | } | 385 | } |
386 | static struct sysrq_key_op sysrq_kill_op = { | 386 | static struct sysrq_key_op sysrq_kill_op = { |
387 | .handler = sysrq_handle_kill, | 387 | .handler = sysrq_handle_kill, |
388 | .help_msg = "kill-all-tasks(I)", | 388 | .help_msg = "kill-all-tasks(i)", |
389 | .action_msg = "Kill All Tasks", | 389 | .action_msg = "Kill All Tasks", |
390 | .enable_mask = SYSRQ_ENABLE_SIGNAL, | 390 | .enable_mask = SYSRQ_ENABLE_SIGNAL, |
391 | }; | 391 | }; |
@@ -396,7 +396,7 @@ static void sysrq_handle_unrt(int key) | |||
396 | } | 396 | } |
397 | static struct sysrq_key_op sysrq_unrt_op = { | 397 | static struct sysrq_key_op sysrq_unrt_op = { |
398 | .handler = sysrq_handle_unrt, | 398 | .handler = sysrq_handle_unrt, |
399 | .help_msg = "nice-all-RT-tasks(N)", | 399 | .help_msg = "nice-all-RT-tasks(n)", |
400 | .action_msg = "Nice All RT Tasks", | 400 | .action_msg = "Nice All RT Tasks", |
401 | .enable_mask = SYSRQ_ENABLE_RTNICE, | 401 | .enable_mask = SYSRQ_ENABLE_RTNICE, |
402 | }; | 402 | }; |
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 05400acbc456..cbf5a5040908 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
@@ -533,6 +533,60 @@ void tty_wakeup(struct tty_struct *tty) | |||
533 | EXPORT_SYMBOL_GPL(tty_wakeup); | 533 | EXPORT_SYMBOL_GPL(tty_wakeup); |
534 | 534 | ||
535 | /** | 535 | /** |
536 | * tty_signal_session_leader - sends SIGHUP to session leader | ||
537 | * @tty controlling tty | ||
538 | * @exit_session if non-zero, signal all foreground group processes | ||
539 | * | ||
540 | * Send SIGHUP and SIGCONT to the session leader and its process group. | ||
541 | * Optionally, signal all processes in the foreground process group. | ||
542 | * | ||
543 | * Returns the number of processes in the session with this tty | ||
544 | * as their controlling terminal. This value is used to drop | ||
545 | * tty references for those processes. | ||
546 | */ | ||
547 | static int tty_signal_session_leader(struct tty_struct *tty, int exit_session) | ||
548 | { | ||
549 | struct task_struct *p; | ||
550 | int refs = 0; | ||
551 | struct pid *tty_pgrp = NULL; | ||
552 | |||
553 | read_lock(&tasklist_lock); | ||
554 | if (tty->session) { | ||
555 | do_each_pid_task(tty->session, PIDTYPE_SID, p) { | ||
556 | spin_lock_irq(&p->sighand->siglock); | ||
557 | if (p->signal->tty == tty) { | ||
558 | p->signal->tty = NULL; | ||
559 | /* We defer the dereferences outside fo | ||
560 | the tasklist lock */ | ||
561 | refs++; | ||
562 | } | ||
563 | if (!p->signal->leader) { | ||
564 | spin_unlock_irq(&p->sighand->siglock); | ||
565 | continue; | ||
566 | } | ||
567 | __group_send_sig_info(SIGHUP, SEND_SIG_PRIV, p); | ||
568 | __group_send_sig_info(SIGCONT, SEND_SIG_PRIV, p); | ||
569 | put_pid(p->signal->tty_old_pgrp); /* A noop */ | ||
570 | spin_lock(&tty->ctrl_lock); | ||
571 | tty_pgrp = get_pid(tty->pgrp); | ||
572 | if (tty->pgrp) | ||
573 | p->signal->tty_old_pgrp = get_pid(tty->pgrp); | ||
574 | spin_unlock(&tty->ctrl_lock); | ||
575 | spin_unlock_irq(&p->sighand->siglock); | ||
576 | } while_each_pid_task(tty->session, PIDTYPE_SID, p); | ||
577 | } | ||
578 | read_unlock(&tasklist_lock); | ||
579 | |||
580 | if (tty_pgrp) { | ||
581 | if (exit_session) | ||
582 | kill_pgrp(tty_pgrp, SIGHUP, exit_session); | ||
583 | put_pid(tty_pgrp); | ||
584 | } | ||
585 | |||
586 | return refs; | ||
587 | } | ||
588 | |||
589 | /** | ||
536 | * __tty_hangup - actual handler for hangup events | 590 | * __tty_hangup - actual handler for hangup events |
537 | * @work: tty device | 591 | * @work: tty device |
538 | * | 592 | * |
@@ -554,15 +608,13 @@ EXPORT_SYMBOL_GPL(tty_wakeup); | |||
554 | * tasklist_lock to walk task list for hangup event | 608 | * tasklist_lock to walk task list for hangup event |
555 | * ->siglock to protect ->signal/->sighand | 609 | * ->siglock to protect ->signal/->sighand |
556 | */ | 610 | */ |
557 | static void __tty_hangup(struct tty_struct *tty) | 611 | static void __tty_hangup(struct tty_struct *tty, int exit_session) |
558 | { | 612 | { |
559 | struct file *cons_filp = NULL; | 613 | struct file *cons_filp = NULL; |
560 | struct file *filp, *f = NULL; | 614 | struct file *filp, *f = NULL; |
561 | struct task_struct *p; | ||
562 | struct tty_file_private *priv; | 615 | struct tty_file_private *priv; |
563 | int closecount = 0, n; | 616 | int closecount = 0, n; |
564 | unsigned long flags; | 617 | int refs; |
565 | int refs = 0; | ||
566 | 618 | ||
567 | if (!tty) | 619 | if (!tty) |
568 | return; | 620 | return; |
@@ -599,39 +651,18 @@ static void __tty_hangup(struct tty_struct *tty) | |||
599 | } | 651 | } |
600 | spin_unlock(&tty_files_lock); | 652 | spin_unlock(&tty_files_lock); |
601 | 653 | ||
654 | refs = tty_signal_session_leader(tty, exit_session); | ||
655 | /* Account for the p->signal references we killed */ | ||
656 | while (refs--) | ||
657 | tty_kref_put(tty); | ||
658 | |||
602 | /* | 659 | /* |
603 | * it drops BTM and thus races with reopen | 660 | * it drops BTM and thus races with reopen |
604 | * we protect the race by TTY_HUPPING | 661 | * we protect the race by TTY_HUPPING |
605 | */ | 662 | */ |
606 | tty_ldisc_hangup(tty); | 663 | tty_ldisc_hangup(tty); |
607 | 664 | ||
608 | read_lock(&tasklist_lock); | 665 | spin_lock_irq(&tty->ctrl_lock); |
609 | if (tty->session) { | ||
610 | do_each_pid_task(tty->session, PIDTYPE_SID, p) { | ||
611 | spin_lock_irq(&p->sighand->siglock); | ||
612 | if (p->signal->tty == tty) { | ||
613 | p->signal->tty = NULL; | ||
614 | /* We defer the dereferences outside fo | ||
615 | the tasklist lock */ | ||
616 | refs++; | ||
617 | } | ||
618 | if (!p->signal->leader) { | ||
619 | spin_unlock_irq(&p->sighand->siglock); | ||
620 | continue; | ||
621 | } | ||
622 | __group_send_sig_info(SIGHUP, SEND_SIG_PRIV, p); | ||
623 | __group_send_sig_info(SIGCONT, SEND_SIG_PRIV, p); | ||
624 | put_pid(p->signal->tty_old_pgrp); /* A noop */ | ||
625 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
626 | if (tty->pgrp) | ||
627 | p->signal->tty_old_pgrp = get_pid(tty->pgrp); | ||
628 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
629 | spin_unlock_irq(&p->sighand->siglock); | ||
630 | } while_each_pid_task(tty->session, PIDTYPE_SID, p); | ||
631 | } | ||
632 | read_unlock(&tasklist_lock); | ||
633 | |||
634 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
635 | clear_bit(TTY_THROTTLED, &tty->flags); | 666 | clear_bit(TTY_THROTTLED, &tty->flags); |
636 | clear_bit(TTY_PUSH, &tty->flags); | 667 | clear_bit(TTY_PUSH, &tty->flags); |
637 | clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); | 668 | clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); |
@@ -640,11 +671,7 @@ static void __tty_hangup(struct tty_struct *tty) | |||
640 | tty->session = NULL; | 671 | tty->session = NULL; |
641 | tty->pgrp = NULL; | 672 | tty->pgrp = NULL; |
642 | tty->ctrl_status = 0; | 673 | tty->ctrl_status = 0; |
643 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | 674 | spin_unlock_irq(&tty->ctrl_lock); |
644 | |||
645 | /* Account for the p->signal references we killed */ | ||
646 | while (refs--) | ||
647 | tty_kref_put(tty); | ||
648 | 675 | ||
649 | /* | 676 | /* |
650 | * If one of the devices matches a console pointer, we | 677 | * If one of the devices matches a console pointer, we |
@@ -666,7 +693,6 @@ static void __tty_hangup(struct tty_struct *tty) | |||
666 | */ | 693 | */ |
667 | set_bit(TTY_HUPPED, &tty->flags); | 694 | set_bit(TTY_HUPPED, &tty->flags); |
668 | clear_bit(TTY_HUPPING, &tty->flags); | 695 | clear_bit(TTY_HUPPING, &tty->flags); |
669 | tty_ldisc_enable(tty); | ||
670 | 696 | ||
671 | tty_unlock(tty); | 697 | tty_unlock(tty); |
672 | 698 | ||
@@ -679,7 +705,7 @@ static void do_tty_hangup(struct work_struct *work) | |||
679 | struct tty_struct *tty = | 705 | struct tty_struct *tty = |
680 | container_of(work, struct tty_struct, hangup_work); | 706 | container_of(work, struct tty_struct, hangup_work); |
681 | 707 | ||
682 | __tty_hangup(tty); | 708 | __tty_hangup(tty, 0); |
683 | } | 709 | } |
684 | 710 | ||
685 | /** | 711 | /** |
@@ -717,7 +743,7 @@ void tty_vhangup(struct tty_struct *tty) | |||
717 | 743 | ||
718 | printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf)); | 744 | printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf)); |
719 | #endif | 745 | #endif |
720 | __tty_hangup(tty); | 746 | __tty_hangup(tty, 0); |
721 | } | 747 | } |
722 | 748 | ||
723 | EXPORT_SYMBOL(tty_vhangup); | 749 | EXPORT_SYMBOL(tty_vhangup); |
@@ -741,6 +767,27 @@ void tty_vhangup_self(void) | |||
741 | } | 767 | } |
742 | 768 | ||
743 | /** | 769 | /** |
770 | * tty_vhangup_session - hangup session leader exit | ||
771 | * @tty: tty to hangup | ||
772 | * | ||
773 | * The session leader is exiting and hanging up its controlling terminal. | ||
774 | * Every process in the foreground process group is signalled SIGHUP. | ||
775 | * | ||
776 | * We do this synchronously so that when the syscall returns the process | ||
777 | * is complete. That guarantee is necessary for security reasons. | ||
778 | */ | ||
779 | |||
780 | static void tty_vhangup_session(struct tty_struct *tty) | ||
781 | { | ||
782 | #ifdef TTY_DEBUG_HANGUP | ||
783 | char buf[64]; | ||
784 | |||
785 | printk(KERN_DEBUG "%s vhangup session...\n", tty_name(tty, buf)); | ||
786 | #endif | ||
787 | __tty_hangup(tty, 1); | ||
788 | } | ||
789 | |||
790 | /** | ||
744 | * tty_hung_up_p - was tty hung up | 791 | * tty_hung_up_p - was tty hung up |
745 | * @filp: file pointer of tty | 792 | * @filp: file pointer of tty |
746 | * | 793 | * |
@@ -797,18 +844,18 @@ void disassociate_ctty(int on_exit) | |||
797 | 844 | ||
798 | tty = get_current_tty(); | 845 | tty = get_current_tty(); |
799 | if (tty) { | 846 | if (tty) { |
800 | struct pid *tty_pgrp = get_pid(tty->pgrp); | 847 | if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) { |
801 | if (on_exit) { | 848 | tty_vhangup_session(tty); |
802 | if (tty->driver->type != TTY_DRIVER_TYPE_PTY) | 849 | } else { |
803 | tty_vhangup(tty); | 850 | struct pid *tty_pgrp = tty_get_pgrp(tty); |
804 | } | 851 | if (tty_pgrp) { |
805 | tty_kref_put(tty); | 852 | kill_pgrp(tty_pgrp, SIGHUP, on_exit); |
806 | if (tty_pgrp) { | ||
807 | kill_pgrp(tty_pgrp, SIGHUP, on_exit); | ||
808 | if (!on_exit) | ||
809 | kill_pgrp(tty_pgrp, SIGCONT, on_exit); | 853 | kill_pgrp(tty_pgrp, SIGCONT, on_exit); |
810 | put_pid(tty_pgrp); | 854 | put_pid(tty_pgrp); |
855 | } | ||
811 | } | 856 | } |
857 | tty_kref_put(tty); | ||
858 | |||
812 | } else if (on_exit) { | 859 | } else if (on_exit) { |
813 | struct pid *old_pgrp; | 860 | struct pid *old_pgrp; |
814 | spin_lock_irq(¤t->sighand->siglock); | 861 | spin_lock_irq(¤t->sighand->siglock); |
@@ -1344,9 +1391,7 @@ static int tty_reopen(struct tty_struct *tty) | |||
1344 | } | 1391 | } |
1345 | tty->count++; | 1392 | tty->count++; |
1346 | 1393 | ||
1347 | mutex_lock(&tty->ldisc_mutex); | ||
1348 | WARN_ON(!test_bit(TTY_LDISC, &tty->flags)); | 1394 | WARN_ON(!test_bit(TTY_LDISC, &tty->flags)); |
1349 | mutex_unlock(&tty->ldisc_mutex); | ||
1350 | 1395 | ||
1351 | return 0; | 1396 | return 0; |
1352 | } | 1397 | } |
@@ -1463,6 +1508,17 @@ void tty_free_termios(struct tty_struct *tty) | |||
1463 | } | 1508 | } |
1464 | EXPORT_SYMBOL(tty_free_termios); | 1509 | EXPORT_SYMBOL(tty_free_termios); |
1465 | 1510 | ||
1511 | /** | ||
1512 | * tty_flush_works - flush all works of a tty | ||
1513 | * @tty: tty device to flush works for | ||
1514 | * | ||
1515 | * Sync flush all works belonging to @tty. | ||
1516 | */ | ||
1517 | static void tty_flush_works(struct tty_struct *tty) | ||
1518 | { | ||
1519 | flush_work(&tty->SAK_work); | ||
1520 | flush_work(&tty->hangup_work); | ||
1521 | } | ||
1466 | 1522 | ||
1467 | /** | 1523 | /** |
1468 | * release_one_tty - release tty structure memory | 1524 | * release_one_tty - release tty structure memory |
@@ -1548,6 +1604,7 @@ static void release_tty(struct tty_struct *tty, int idx) | |||
1548 | tty_free_termios(tty); | 1604 | tty_free_termios(tty); |
1549 | tty_driver_remove_tty(tty->driver, tty); | 1605 | tty_driver_remove_tty(tty->driver, tty); |
1550 | tty->port->itty = NULL; | 1606 | tty->port->itty = NULL; |
1607 | cancel_work_sync(&tty->port->buf.work); | ||
1551 | 1608 | ||
1552 | if (tty->link) | 1609 | if (tty->link) |
1553 | tty_kref_put(tty->link); | 1610 | tty_kref_put(tty->link); |
@@ -1777,12 +1834,21 @@ int tty_release(struct inode *inode, struct file *filp) | |||
1777 | return 0; | 1834 | return 0; |
1778 | 1835 | ||
1779 | #ifdef TTY_DEBUG_HANGUP | 1836 | #ifdef TTY_DEBUG_HANGUP |
1780 | printk(KERN_DEBUG "%s: freeing tty structure...\n", __func__); | 1837 | printk(KERN_DEBUG "%s: %s: final close\n", __func__, tty_name(tty, buf)); |
1781 | #endif | 1838 | #endif |
1782 | /* | 1839 | /* |
1783 | * Ask the line discipline code to release its structures | 1840 | * Ask the line discipline code to release its structures |
1784 | */ | 1841 | */ |
1785 | tty_ldisc_release(tty, o_tty); | 1842 | tty_ldisc_release(tty, o_tty); |
1843 | |||
1844 | /* Wait for pending work before tty destruction commmences */ | ||
1845 | tty_flush_works(tty); | ||
1846 | if (o_tty) | ||
1847 | tty_flush_works(o_tty); | ||
1848 | |||
1849 | #ifdef TTY_DEBUG_HANGUP | ||
1850 | printk(KERN_DEBUG "%s: %s: freeing structure...\n", __func__, tty_name(tty, buf)); | ||
1851 | #endif | ||
1786 | /* | 1852 | /* |
1787 | * The release_tty function takes care of the details of clearing | 1853 | * The release_tty function takes care of the details of clearing |
1788 | * the slots and preserving the termios structure. The tty_unlock_pair | 1854 | * the slots and preserving the termios structure. The tty_unlock_pair |
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index d58b92cc187c..d119034877de 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c | |||
@@ -106,6 +106,7 @@ void tty_throttle(struct tty_struct *tty) | |||
106 | if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) && | 106 | if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) && |
107 | tty->ops->throttle) | 107 | tty->ops->throttle) |
108 | tty->ops->throttle(tty); | 108 | tty->ops->throttle(tty); |
109 | tty->flow_change = 0; | ||
109 | mutex_unlock(&tty->termios_mutex); | 110 | mutex_unlock(&tty->termios_mutex); |
110 | } | 111 | } |
111 | EXPORT_SYMBOL(tty_throttle); | 112 | EXPORT_SYMBOL(tty_throttle); |
@@ -129,11 +130,74 @@ void tty_unthrottle(struct tty_struct *tty) | |||
129 | if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) && | 130 | if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) && |
130 | tty->ops->unthrottle) | 131 | tty->ops->unthrottle) |
131 | tty->ops->unthrottle(tty); | 132 | tty->ops->unthrottle(tty); |
133 | tty->flow_change = 0; | ||
132 | mutex_unlock(&tty->termios_mutex); | 134 | mutex_unlock(&tty->termios_mutex); |
133 | } | 135 | } |
134 | EXPORT_SYMBOL(tty_unthrottle); | 136 | EXPORT_SYMBOL(tty_unthrottle); |
135 | 137 | ||
136 | /** | 138 | /** |
139 | * tty_throttle_safe - flow control | ||
140 | * @tty: terminal | ||
141 | * | ||
142 | * Similar to tty_throttle() but will only attempt throttle | ||
143 | * if tty->flow_change is TTY_THROTTLE_SAFE. Prevents an accidental | ||
144 | * throttle due to race conditions when throttling is conditional | ||
145 | * on factors evaluated prior to throttling. | ||
146 | * | ||
147 | * Returns 0 if tty is throttled (or was already throttled) | ||
148 | */ | ||
149 | |||
150 | int tty_throttle_safe(struct tty_struct *tty) | ||
151 | { | ||
152 | int ret = 0; | ||
153 | |||
154 | mutex_lock(&tty->termios_mutex); | ||
155 | if (!test_bit(TTY_THROTTLED, &tty->flags)) { | ||
156 | if (tty->flow_change != TTY_THROTTLE_SAFE) | ||
157 | ret = 1; | ||
158 | else { | ||
159 | __set_bit(TTY_THROTTLED, &tty->flags); | ||
160 | if (tty->ops->throttle) | ||
161 | tty->ops->throttle(tty); | ||
162 | } | ||
163 | } | ||
164 | mutex_unlock(&tty->termios_mutex); | ||
165 | |||
166 | return ret; | ||
167 | } | ||
168 | |||
169 | /** | ||
170 | * tty_unthrottle_safe - flow control | ||
171 | * @tty: terminal | ||
172 | * | ||
173 | * Similar to tty_unthrottle() but will only attempt unthrottle | ||
174 | * if tty->flow_change is TTY_UNTHROTTLE_SAFE. Prevents an accidental | ||
175 | * unthrottle due to race conditions when unthrottling is conditional | ||
176 | * on factors evaluated prior to unthrottling. | ||
177 | * | ||
178 | * Returns 0 if tty is unthrottled (or was already unthrottled) | ||
179 | */ | ||
180 | |||
181 | int tty_unthrottle_safe(struct tty_struct *tty) | ||
182 | { | ||
183 | int ret = 0; | ||
184 | |||
185 | mutex_lock(&tty->termios_mutex); | ||
186 | if (test_bit(TTY_THROTTLED, &tty->flags)) { | ||
187 | if (tty->flow_change != TTY_UNTHROTTLE_SAFE) | ||
188 | ret = 1; | ||
189 | else { | ||
190 | __clear_bit(TTY_THROTTLED, &tty->flags); | ||
191 | if (tty->ops->unthrottle) | ||
192 | tty->ops->unthrottle(tty); | ||
193 | } | ||
194 | } | ||
195 | mutex_unlock(&tty->termios_mutex); | ||
196 | |||
197 | return ret; | ||
198 | } | ||
199 | |||
200 | /** | ||
137 | * tty_wait_until_sent - wait for I/O to finish | 201 | * tty_wait_until_sent - wait for I/O to finish |
138 | * @tty: tty we are waiting for | 202 | * @tty: tty we are waiting for |
139 | * @timeout: how long we will wait | 203 | * @timeout: how long we will wait |
@@ -415,34 +479,6 @@ void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud, speed_t obaud) | |||
415 | EXPORT_SYMBOL_GPL(tty_encode_baud_rate); | 479 | EXPORT_SYMBOL_GPL(tty_encode_baud_rate); |
416 | 480 | ||
417 | /** | 481 | /** |
418 | * tty_get_baud_rate - get tty bit rates | ||
419 | * @tty: tty to query | ||
420 | * | ||
421 | * Returns the baud rate as an integer for this terminal. The | ||
422 | * termios lock must be held by the caller and the terminal bit | ||
423 | * flags may be updated. | ||
424 | * | ||
425 | * Locking: none | ||
426 | */ | ||
427 | |||
428 | speed_t tty_get_baud_rate(struct tty_struct *tty) | ||
429 | { | ||
430 | speed_t baud = tty_termios_baud_rate(&tty->termios); | ||
431 | |||
432 | if (baud == 38400 && tty->alt_speed) { | ||
433 | if (!tty->warned) { | ||
434 | printk(KERN_WARNING "Use of setserial/setrocket to " | ||
435 | "set SPD_* flags is deprecated\n"); | ||
436 | tty->warned = 1; | ||
437 | } | ||
438 | baud = tty->alt_speed; | ||
439 | } | ||
440 | |||
441 | return baud; | ||
442 | } | ||
443 | EXPORT_SYMBOL(tty_get_baud_rate); | ||
444 | |||
445 | /** | ||
446 | * tty_termios_copy_hw - copy hardware settings | 482 | * tty_termios_copy_hw - copy hardware settings |
447 | * @new: New termios | 483 | * @new: New termios |
448 | * @old: Old termios | 484 | * @old: Old termios |
@@ -1086,14 +1122,12 @@ int tty_mode_ioctl(struct tty_struct *tty, struct file *file, | |||
1086 | } | 1122 | } |
1087 | EXPORT_SYMBOL_GPL(tty_mode_ioctl); | 1123 | EXPORT_SYMBOL_GPL(tty_mode_ioctl); |
1088 | 1124 | ||
1089 | int tty_perform_flush(struct tty_struct *tty, unsigned long arg) | 1125 | |
1126 | /* Caller guarantees ldisc reference is held */ | ||
1127 | static int __tty_perform_flush(struct tty_struct *tty, unsigned long arg) | ||
1090 | { | 1128 | { |
1091 | struct tty_ldisc *ld; | 1129 | struct tty_ldisc *ld = tty->ldisc; |
1092 | int retval = tty_check_change(tty); | ||
1093 | if (retval) | ||
1094 | return retval; | ||
1095 | 1130 | ||
1096 | ld = tty_ldisc_ref_wait(tty); | ||
1097 | switch (arg) { | 1131 | switch (arg) { |
1098 | case TCIFLUSH: | 1132 | case TCIFLUSH: |
1099 | if (ld && ld->ops->flush_buffer) { | 1133 | if (ld && ld->ops->flush_buffer) { |
@@ -1111,12 +1145,24 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg) | |||
1111 | tty_driver_flush_buffer(tty); | 1145 | tty_driver_flush_buffer(tty); |
1112 | break; | 1146 | break; |
1113 | default: | 1147 | default: |
1114 | tty_ldisc_deref(ld); | ||
1115 | return -EINVAL; | 1148 | return -EINVAL; |
1116 | } | 1149 | } |
1117 | tty_ldisc_deref(ld); | ||
1118 | return 0; | 1150 | return 0; |
1119 | } | 1151 | } |
1152 | |||
1153 | int tty_perform_flush(struct tty_struct *tty, unsigned long arg) | ||
1154 | { | ||
1155 | struct tty_ldisc *ld; | ||
1156 | int retval = tty_check_change(tty); | ||
1157 | if (retval) | ||
1158 | return retval; | ||
1159 | |||
1160 | ld = tty_ldisc_ref_wait(tty); | ||
1161 | retval = __tty_perform_flush(tty, arg); | ||
1162 | if (ld) | ||
1163 | tty_ldisc_deref(ld); | ||
1164 | return retval; | ||
1165 | } | ||
1120 | EXPORT_SYMBOL_GPL(tty_perform_flush); | 1166 | EXPORT_SYMBOL_GPL(tty_perform_flush); |
1121 | 1167 | ||
1122 | int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, | 1168 | int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, |
@@ -1155,7 +1201,7 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, | |||
1155 | } | 1201 | } |
1156 | return 0; | 1202 | return 0; |
1157 | case TCFLSH: | 1203 | case TCFLSH: |
1158 | return tty_perform_flush(tty, arg); | 1204 | return __tty_perform_flush(tty, arg); |
1159 | default: | 1205 | default: |
1160 | /* Try the mode commands */ | 1206 | /* Try the mode commands */ |
1161 | return tty_mode_ioctl(tty, file, cmd, arg); | 1207 | return tty_mode_ioctl(tty, file, cmd, arg); |
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index d794087c327e..1afe192bef6a 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c | |||
@@ -20,6 +20,17 @@ | |||
20 | #include <linux/uaccess.h> | 20 | #include <linux/uaccess.h> |
21 | #include <linux/ratelimit.h> | 21 | #include <linux/ratelimit.h> |
22 | 22 | ||
23 | #undef LDISC_DEBUG_HANGUP | ||
24 | |||
25 | #ifdef LDISC_DEBUG_HANGUP | ||
26 | #define tty_ldisc_debug(tty, f, args...) ({ \ | ||
27 | char __b[64]; \ | ||
28 | printk(KERN_DEBUG "%s: %s: " f, __func__, tty_name(tty, __b), ##args); \ | ||
29 | }) | ||
30 | #else | ||
31 | #define tty_ldisc_debug(tty, f, args...) | ||
32 | #endif | ||
33 | |||
23 | /* | 34 | /* |
24 | * This guards the refcounted line discipline lists. The lock | 35 | * This guards the refcounted line discipline lists. The lock |
25 | * must be taken with irqs off because there are hangup path | 36 | * must be taken with irqs off because there are hangup path |
@@ -31,44 +42,6 @@ static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait); | |||
31 | /* Line disc dispatch table */ | 42 | /* Line disc dispatch table */ |
32 | static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS]; | 43 | static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS]; |
33 | 44 | ||
34 | static inline struct tty_ldisc *get_ldisc(struct tty_ldisc *ld) | ||
35 | { | ||
36 | if (ld) | ||
37 | atomic_inc(&ld->users); | ||
38 | return ld; | ||
39 | } | ||
40 | |||
41 | static void put_ldisc(struct tty_ldisc *ld) | ||
42 | { | ||
43 | unsigned long flags; | ||
44 | |||
45 | if (WARN_ON_ONCE(!ld)) | ||
46 | return; | ||
47 | |||
48 | /* | ||
49 | * If this is the last user, free the ldisc, and | ||
50 | * release the ldisc ops. | ||
51 | * | ||
52 | * We really want an "atomic_dec_and_raw_lock_irqsave()", | ||
53 | * but we don't have it, so this does it by hand. | ||
54 | */ | ||
55 | raw_spin_lock_irqsave(&tty_ldisc_lock, flags); | ||
56 | if (atomic_dec_and_test(&ld->users)) { | ||
57 | struct tty_ldisc_ops *ldo = ld->ops; | ||
58 | |||
59 | ldo->refcount--; | ||
60 | module_put(ldo->owner); | ||
61 | raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); | ||
62 | |||
63 | kfree(ld); | ||
64 | return; | ||
65 | } | ||
66 | raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); | ||
67 | |||
68 | if (waitqueue_active(&ld->wq_idle)) | ||
69 | wake_up(&ld->wq_idle); | ||
70 | } | ||
71 | |||
72 | /** | 45 | /** |
73 | * tty_register_ldisc - install a line discipline | 46 | * tty_register_ldisc - install a line discipline |
74 | * @disc: ldisc number | 47 | * @disc: ldisc number |
@@ -206,6 +179,29 @@ static struct tty_ldisc *tty_ldisc_get(int disc) | |||
206 | return ld; | 179 | return ld; |
207 | } | 180 | } |
208 | 181 | ||
182 | /** | ||
183 | * tty_ldisc_put - release the ldisc | ||
184 | * | ||
185 | * Complement of tty_ldisc_get(). | ||
186 | */ | ||
187 | static inline void tty_ldisc_put(struct tty_ldisc *ld) | ||
188 | { | ||
189 | unsigned long flags; | ||
190 | |||
191 | if (WARN_ON_ONCE(!ld)) | ||
192 | return; | ||
193 | |||
194 | raw_spin_lock_irqsave(&tty_ldisc_lock, flags); | ||
195 | |||
196 | /* unreleased reader reference(s) will cause this WARN */ | ||
197 | WARN_ON(!atomic_dec_and_test(&ld->users)); | ||
198 | |||
199 | ld->ops->refcount--; | ||
200 | module_put(ld->ops->owner); | ||
201 | kfree(ld); | ||
202 | raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); | ||
203 | } | ||
204 | |||
209 | static void *tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos) | 205 | static void *tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos) |
210 | { | 206 | { |
211 | return (*pos < NR_LDISCS) ? pos : NULL; | 207 | return (*pos < NR_LDISCS) ? pos : NULL; |
@@ -255,24 +251,6 @@ const struct file_operations tty_ldiscs_proc_fops = { | |||
255 | }; | 251 | }; |
256 | 252 | ||
257 | /** | 253 | /** |
258 | * tty_ldisc_assign - set ldisc on a tty | ||
259 | * @tty: tty to assign | ||
260 | * @ld: line discipline | ||
261 | * | ||
262 | * Install an instance of a line discipline into a tty structure. The | ||
263 | * ldisc must have a reference count above zero to ensure it remains. | ||
264 | * The tty instance refcount starts at zero. | ||
265 | * | ||
266 | * Locking: | ||
267 | * Caller must hold references | ||
268 | */ | ||
269 | |||
270 | static void tty_ldisc_assign(struct tty_struct *tty, struct tty_ldisc *ld) | ||
271 | { | ||
272 | tty->ldisc = ld; | ||
273 | } | ||
274 | |||
275 | /** | ||
276 | * tty_ldisc_try - internal helper | 254 | * tty_ldisc_try - internal helper |
277 | * @tty: the tty | 255 | * @tty: the tty |
278 | * | 256 | * |
@@ -289,10 +267,13 @@ static struct tty_ldisc *tty_ldisc_try(struct tty_struct *tty) | |||
289 | unsigned long flags; | 267 | unsigned long flags; |
290 | struct tty_ldisc *ld; | 268 | struct tty_ldisc *ld; |
291 | 269 | ||
270 | /* FIXME: this allows reference acquire after TTY_LDISC is cleared */ | ||
292 | raw_spin_lock_irqsave(&tty_ldisc_lock, flags); | 271 | raw_spin_lock_irqsave(&tty_ldisc_lock, flags); |
293 | ld = NULL; | 272 | ld = NULL; |
294 | if (test_bit(TTY_LDISC, &tty->flags)) | 273 | if (test_bit(TTY_LDISC, &tty->flags) && tty->ldisc) { |
295 | ld = get_ldisc(tty->ldisc); | 274 | ld = tty->ldisc; |
275 | atomic_inc(&ld->users); | ||
276 | } | ||
296 | raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); | 277 | raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); |
297 | return ld; | 278 | return ld; |
298 | } | 279 | } |
@@ -352,14 +333,23 @@ EXPORT_SYMBOL_GPL(tty_ldisc_ref); | |||
352 | 333 | ||
353 | void tty_ldisc_deref(struct tty_ldisc *ld) | 334 | void tty_ldisc_deref(struct tty_ldisc *ld) |
354 | { | 335 | { |
355 | put_ldisc(ld); | 336 | unsigned long flags; |
356 | } | ||
357 | EXPORT_SYMBOL_GPL(tty_ldisc_deref); | ||
358 | 337 | ||
359 | static inline void tty_ldisc_put(struct tty_ldisc *ld) | 338 | if (WARN_ON_ONCE(!ld)) |
360 | { | 339 | return; |
361 | put_ldisc(ld); | 340 | |
341 | raw_spin_lock_irqsave(&tty_ldisc_lock, flags); | ||
342 | /* | ||
343 | * WARNs if one-too-many reader references were released | ||
344 | * - the last reference must be released with tty_ldisc_put | ||
345 | */ | ||
346 | WARN_ON(atomic_dec_and_test(&ld->users)); | ||
347 | raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); | ||
348 | |||
349 | if (waitqueue_active(&ld->wq_idle)) | ||
350 | wake_up(&ld->wq_idle); | ||
362 | } | 351 | } |
352 | EXPORT_SYMBOL_GPL(tty_ldisc_deref); | ||
363 | 353 | ||
364 | /** | 354 | /** |
365 | * tty_ldisc_enable - allow ldisc use | 355 | * tty_ldisc_enable - allow ldisc use |
@@ -373,8 +363,9 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld) | |||
373 | * Clearing directly is allowed. | 363 | * Clearing directly is allowed. |
374 | */ | 364 | */ |
375 | 365 | ||
376 | void tty_ldisc_enable(struct tty_struct *tty) | 366 | static void tty_ldisc_enable(struct tty_struct *tty) |
377 | { | 367 | { |
368 | clear_bit(TTY_LDISC_HALTED, &tty->flags); | ||
378 | set_bit(TTY_LDISC, &tty->flags); | 369 | set_bit(TTY_LDISC, &tty->flags); |
379 | clear_bit(TTY_LDISC_CHANGING, &tty->flags); | 370 | clear_bit(TTY_LDISC_CHANGING, &tty->flags); |
380 | wake_up(&tty_ldisc_wait); | 371 | wake_up(&tty_ldisc_wait); |
@@ -479,7 +470,7 @@ static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old) | |||
479 | /* There is an outstanding reference here so this is safe */ | 470 | /* There is an outstanding reference here so this is safe */ |
480 | old = tty_ldisc_get(old->ops->num); | 471 | old = tty_ldisc_get(old->ops->num); |
481 | WARN_ON(IS_ERR(old)); | 472 | WARN_ON(IS_ERR(old)); |
482 | tty_ldisc_assign(tty, old); | 473 | tty->ldisc = old; |
483 | tty_set_termios_ldisc(tty, old->ops->num); | 474 | tty_set_termios_ldisc(tty, old->ops->num); |
484 | if (tty_ldisc_open(tty, old) < 0) { | 475 | if (tty_ldisc_open(tty, old) < 0) { |
485 | tty_ldisc_put(old); | 476 | tty_ldisc_put(old); |
@@ -487,7 +478,7 @@ static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old) | |||
487 | new_ldisc = tty_ldisc_get(N_TTY); | 478 | new_ldisc = tty_ldisc_get(N_TTY); |
488 | if (IS_ERR(new_ldisc)) | 479 | if (IS_ERR(new_ldisc)) |
489 | panic("n_tty: get"); | 480 | panic("n_tty: get"); |
490 | tty_ldisc_assign(tty, new_ldisc); | 481 | tty->ldisc = new_ldisc; |
491 | tty_set_termios_ldisc(tty, N_TTY); | 482 | tty_set_termios_ldisc(tty, N_TTY); |
492 | r = tty_ldisc_open(tty, new_ldisc); | 483 | r = tty_ldisc_open(tty, new_ldisc); |
493 | if (r < 0) | 484 | if (r < 0) |
@@ -498,52 +489,98 @@ static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old) | |||
498 | } | 489 | } |
499 | 490 | ||
500 | /** | 491 | /** |
492 | * tty_ldisc_wait_idle - wait for the ldisc to become idle | ||
493 | * @tty: tty to wait for | ||
494 | * @timeout: for how long to wait at most | ||
495 | * | ||
496 | * Wait for the line discipline to become idle. The discipline must | ||
497 | * have been halted for this to guarantee it remains idle. | ||
498 | */ | ||
499 | static int tty_ldisc_wait_idle(struct tty_struct *tty, long timeout) | ||
500 | { | ||
501 | long ret; | ||
502 | ret = wait_event_timeout(tty->ldisc->wq_idle, | ||
503 | atomic_read(&tty->ldisc->users) == 1, timeout); | ||
504 | return ret > 0 ? 0 : -EBUSY; | ||
505 | } | ||
506 | |||
507 | /** | ||
501 | * tty_ldisc_halt - shut down the line discipline | 508 | * tty_ldisc_halt - shut down the line discipline |
502 | * @tty: tty device | 509 | * @tty: tty device |
510 | * @o_tty: paired pty device (can be NULL) | ||
511 | * @timeout: # of jiffies to wait for ldisc refs to be released | ||
503 | * | 512 | * |
504 | * Shut down the line discipline and work queue for this tty device. | 513 | * Shut down the line discipline and work queue for this tty device and |
505 | * The TTY_LDISC flag being cleared ensures no further references can | 514 | * its paired pty (if exists). Clearing the TTY_LDISC flag ensures |
506 | * be obtained while the delayed work queue halt ensures that no more | 515 | * no further references can be obtained, while waiting for existing |
507 | * data is fed to the ldisc. | 516 | * references to be released ensures no more data is fed to the ldisc. |
508 | * | 517 | * |
509 | * You need to do a 'flush_scheduled_work()' (outside the ldisc_mutex) | 518 | * You need to do a 'flush_scheduled_work()' (outside the ldisc_mutex) |
510 | * in order to make sure any currently executing ldisc work is also | 519 | * in order to make sure any currently executing ldisc work is also |
511 | * flushed. | 520 | * flushed. |
512 | */ | 521 | */ |
513 | 522 | ||
514 | static int tty_ldisc_halt(struct tty_struct *tty) | 523 | static int tty_ldisc_halt(struct tty_struct *tty, struct tty_struct *o_tty, |
524 | long timeout) | ||
515 | { | 525 | { |
526 | int retval; | ||
527 | |||
516 | clear_bit(TTY_LDISC, &tty->flags); | 528 | clear_bit(TTY_LDISC, &tty->flags); |
517 | return cancel_work_sync(&tty->port->buf.work); | 529 | if (o_tty) |
518 | } | 530 | clear_bit(TTY_LDISC, &o_tty->flags); |
519 | 531 | ||
520 | /** | 532 | retval = tty_ldisc_wait_idle(tty, timeout); |
521 | * tty_ldisc_flush_works - flush all works of a tty | 533 | if (!retval && o_tty) |
522 | * @tty: tty device to flush works for | 534 | retval = tty_ldisc_wait_idle(o_tty, timeout); |
523 | * | 535 | if (retval) |
524 | * Sync flush all works belonging to @tty. | 536 | return retval; |
525 | */ | 537 | |
526 | static void tty_ldisc_flush_works(struct tty_struct *tty) | 538 | set_bit(TTY_LDISC_HALTED, &tty->flags); |
527 | { | 539 | if (o_tty) |
528 | flush_work(&tty->hangup_work); | 540 | set_bit(TTY_LDISC_HALTED, &o_tty->flags); |
529 | flush_work(&tty->SAK_work); | 541 | |
530 | flush_work(&tty->port->buf.work); | 542 | return 0; |
531 | } | 543 | } |
532 | 544 | ||
533 | /** | 545 | /** |
534 | * tty_ldisc_wait_idle - wait for the ldisc to become idle | 546 | * tty_ldisc_hangup_halt - halt the line discipline for hangup |
535 | * @tty: tty to wait for | 547 | * @tty: tty being hung up |
536 | * @timeout: for how long to wait at most | ||
537 | * | 548 | * |
538 | * Wait for the line discipline to become idle. The discipline must | 549 | * Shut down the line discipline and work queue for the tty device |
539 | * have been halted for this to guarantee it remains idle. | 550 | * being hungup. Clear the TTY_LDISC flag to ensure no further |
551 | * references can be obtained and wait for remaining references to be | ||
552 | * released to ensure no more data is fed to this ldisc. | ||
553 | * Caller must hold legacy and ->ldisc_mutex. | ||
554 | * | ||
555 | * NB: tty_set_ldisc() is prevented from changing the ldisc concurrently | ||
556 | * with this function by checking the TTY_HUPPING flag. | ||
540 | */ | 557 | */ |
541 | static int tty_ldisc_wait_idle(struct tty_struct *tty, long timeout) | 558 | static bool tty_ldisc_hangup_halt(struct tty_struct *tty) |
542 | { | 559 | { |
543 | long ret; | 560 | char cur_n[TASK_COMM_LEN], tty_n[64]; |
544 | ret = wait_event_timeout(tty->ldisc->wq_idle, | 561 | long timeout = 3 * HZ; |
545 | atomic_read(&tty->ldisc->users) == 1, timeout); | 562 | |
546 | return ret > 0 ? 0 : -EBUSY; | 563 | clear_bit(TTY_LDISC, &tty->flags); |
564 | |||
565 | if (tty->ldisc) { /* Not yet closed */ | ||
566 | tty_unlock(tty); | ||
567 | |||
568 | while (tty_ldisc_wait_idle(tty, timeout) == -EBUSY) { | ||
569 | timeout = MAX_SCHEDULE_TIMEOUT; | ||
570 | printk_ratelimited(KERN_WARNING | ||
571 | "%s: waiting (%s) for %s took too long, but we keep waiting...\n", | ||
572 | __func__, get_task_comm(cur_n, current), | ||
573 | tty_name(tty, tty_n)); | ||
574 | } | ||
575 | |||
576 | set_bit(TTY_LDISC_HALTED, &tty->flags); | ||
577 | |||
578 | /* must reacquire both locks and preserve lock order */ | ||
579 | mutex_unlock(&tty->ldisc_mutex); | ||
580 | tty_lock(tty); | ||
581 | mutex_lock(&tty->ldisc_mutex); | ||
582 | } | ||
583 | return !!tty->ldisc; | ||
547 | } | 584 | } |
548 | 585 | ||
549 | /** | 586 | /** |
@@ -563,7 +600,6 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc) | |||
563 | { | 600 | { |
564 | int retval; | 601 | int retval; |
565 | struct tty_ldisc *o_ldisc, *new_ldisc; | 602 | struct tty_ldisc *o_ldisc, *new_ldisc; |
566 | int work, o_work = 0; | ||
567 | struct tty_struct *o_tty; | 603 | struct tty_struct *o_tty; |
568 | 604 | ||
569 | new_ldisc = tty_ldisc_get(ldisc); | 605 | new_ldisc = tty_ldisc_get(ldisc); |
@@ -589,15 +625,6 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc) | |||
589 | return 0; | 625 | return 0; |
590 | } | 626 | } |
591 | 627 | ||
592 | tty_unlock(tty); | ||
593 | /* | ||
594 | * Problem: What do we do if this blocks ? | ||
595 | * We could deadlock here | ||
596 | */ | ||
597 | |||
598 | tty_wait_until_sent(tty, 0); | ||
599 | |||
600 | tty_lock(tty); | ||
601 | mutex_lock(&tty->ldisc_mutex); | 628 | mutex_lock(&tty->ldisc_mutex); |
602 | 629 | ||
603 | /* | 630 | /* |
@@ -637,20 +664,16 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc) | |||
637 | * parallel to the change and re-referencing the tty. | 664 | * parallel to the change and re-referencing the tty. |
638 | */ | 665 | */ |
639 | 666 | ||
640 | work = tty_ldisc_halt(tty); | 667 | retval = tty_ldisc_halt(tty, o_tty, 5 * HZ); |
641 | if (o_tty) | ||
642 | o_work = tty_ldisc_halt(o_tty); | ||
643 | 668 | ||
644 | /* | 669 | /* |
645 | * Wait for ->hangup_work and ->buf.work handlers to terminate. | 670 | * Wait for hangup to complete, if pending. |
646 | * We must drop the mutex here in case a hangup is also in process. | 671 | * We must drop the mutex here in case a hangup is also in process. |
647 | */ | 672 | */ |
648 | 673 | ||
649 | mutex_unlock(&tty->ldisc_mutex); | 674 | mutex_unlock(&tty->ldisc_mutex); |
650 | 675 | ||
651 | tty_ldisc_flush_works(tty); | 676 | flush_work(&tty->hangup_work); |
652 | |||
653 | retval = tty_ldisc_wait_idle(tty, 5 * HZ); | ||
654 | 677 | ||
655 | tty_lock(tty); | 678 | tty_lock(tty); |
656 | mutex_lock(&tty->ldisc_mutex); | 679 | mutex_lock(&tty->ldisc_mutex); |
@@ -675,7 +698,7 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc) | |||
675 | tty_ldisc_close(tty, o_ldisc); | 698 | tty_ldisc_close(tty, o_ldisc); |
676 | 699 | ||
677 | /* Now set up the new line discipline. */ | 700 | /* Now set up the new line discipline. */ |
678 | tty_ldisc_assign(tty, new_ldisc); | 701 | tty->ldisc = new_ldisc; |
679 | tty_set_termios_ldisc(tty, ldisc); | 702 | tty_set_termios_ldisc(tty, ldisc); |
680 | 703 | ||
681 | retval = tty_ldisc_open(tty, new_ldisc); | 704 | retval = tty_ldisc_open(tty, new_ldisc); |
@@ -705,10 +728,10 @@ enable: | |||
705 | 728 | ||
706 | /* Restart the work queue in case no characters kick it off. Safe if | 729 | /* Restart the work queue in case no characters kick it off. Safe if |
707 | already running */ | 730 | already running */ |
708 | if (work) | 731 | schedule_work(&tty->port->buf.work); |
709 | schedule_work(&tty->port->buf.work); | 732 | if (o_tty) |
710 | if (o_work) | ||
711 | schedule_work(&o_tty->port->buf.work); | 733 | schedule_work(&o_tty->port->buf.work); |
734 | |||
712 | mutex_unlock(&tty->ldisc_mutex); | 735 | mutex_unlock(&tty->ldisc_mutex); |
713 | tty_unlock(tty); | 736 | tty_unlock(tty); |
714 | return retval; | 737 | return retval; |
@@ -749,11 +772,10 @@ static int tty_ldisc_reinit(struct tty_struct *tty, int ldisc) | |||
749 | 772 | ||
750 | tty_ldisc_close(tty, tty->ldisc); | 773 | tty_ldisc_close(tty, tty->ldisc); |
751 | tty_ldisc_put(tty->ldisc); | 774 | tty_ldisc_put(tty->ldisc); |
752 | tty->ldisc = NULL; | ||
753 | /* | 775 | /* |
754 | * Switch the line discipline back | 776 | * Switch the line discipline back |
755 | */ | 777 | */ |
756 | tty_ldisc_assign(tty, ld); | 778 | tty->ldisc = ld; |
757 | tty_set_termios_ldisc(tty, ldisc); | 779 | tty_set_termios_ldisc(tty, ldisc); |
758 | 780 | ||
759 | return 0; | 781 | return 0; |
@@ -780,6 +802,8 @@ void tty_ldisc_hangup(struct tty_struct *tty) | |||
780 | int reset = tty->driver->flags & TTY_DRIVER_RESET_TERMIOS; | 802 | int reset = tty->driver->flags & TTY_DRIVER_RESET_TERMIOS; |
781 | int err = 0; | 803 | int err = 0; |
782 | 804 | ||
805 | tty_ldisc_debug(tty, "closing ldisc: %p\n", tty->ldisc); | ||
806 | |||
783 | /* | 807 | /* |
784 | * FIXME! What are the locking issues here? This may me overdoing | 808 | * FIXME! What are the locking issues here? This may me overdoing |
785 | * things... This question is especially important now that we've | 809 | * things... This question is especially important now that we've |
@@ -812,40 +836,12 @@ void tty_ldisc_hangup(struct tty_struct *tty) | |||
812 | */ | 836 | */ |
813 | mutex_lock(&tty->ldisc_mutex); | 837 | mutex_lock(&tty->ldisc_mutex); |
814 | 838 | ||
815 | /* | 839 | if (tty_ldisc_hangup_halt(tty)) { |
816 | * this is like tty_ldisc_halt, but we need to give up | ||
817 | * the BTM before calling cancel_work_sync, which may | ||
818 | * need to wait for another function taking the BTM | ||
819 | */ | ||
820 | clear_bit(TTY_LDISC, &tty->flags); | ||
821 | tty_unlock(tty); | ||
822 | cancel_work_sync(&tty->port->buf.work); | ||
823 | mutex_unlock(&tty->ldisc_mutex); | ||
824 | retry: | ||
825 | tty_lock(tty); | ||
826 | mutex_lock(&tty->ldisc_mutex); | ||
827 | |||
828 | /* At this point we have a closed ldisc and we want to | ||
829 | reopen it. We could defer this to the next open but | ||
830 | it means auditing a lot of other paths so this is | ||
831 | a FIXME */ | ||
832 | if (tty->ldisc) { /* Not yet closed */ | ||
833 | if (atomic_read(&tty->ldisc->users) != 1) { | ||
834 | char cur_n[TASK_COMM_LEN], tty_n[64]; | ||
835 | long timeout = 3 * HZ; | ||
836 | tty_unlock(tty); | ||
837 | |||
838 | while (tty_ldisc_wait_idle(tty, timeout) == -EBUSY) { | ||
839 | timeout = MAX_SCHEDULE_TIMEOUT; | ||
840 | printk_ratelimited(KERN_WARNING | ||
841 | "%s: waiting (%s) for %s took too long, but we keep waiting...\n", | ||
842 | __func__, get_task_comm(cur_n, current), | ||
843 | tty_name(tty, tty_n)); | ||
844 | } | ||
845 | mutex_unlock(&tty->ldisc_mutex); | ||
846 | goto retry; | ||
847 | } | ||
848 | 840 | ||
841 | /* At this point we have a halted ldisc; we want to close it and | ||
842 | reopen a new ldisc. We could defer the reopen to the next | ||
843 | open but it means auditing a lot of other paths so this is | ||
844 | a FIXME */ | ||
849 | if (reset == 0) { | 845 | if (reset == 0) { |
850 | 846 | ||
851 | if (!tty_ldisc_reinit(tty, tty->termios.c_line)) | 847 | if (!tty_ldisc_reinit(tty, tty->termios.c_line)) |
@@ -864,6 +860,8 @@ retry: | |||
864 | mutex_unlock(&tty->ldisc_mutex); | 860 | mutex_unlock(&tty->ldisc_mutex); |
865 | if (reset) | 861 | if (reset) |
866 | tty_reset_termios(tty); | 862 | tty_reset_termios(tty); |
863 | |||
864 | tty_ldisc_debug(tty, "re-opened ldisc: %p\n", tty->ldisc); | ||
867 | } | 865 | } |
868 | 866 | ||
869 | /** | 867 | /** |
@@ -899,11 +897,6 @@ int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty) | |||
899 | 897 | ||
900 | static void tty_ldisc_kill(struct tty_struct *tty) | 898 | static void tty_ldisc_kill(struct tty_struct *tty) |
901 | { | 899 | { |
902 | /* There cannot be users from userspace now. But there still might be | ||
903 | * drivers holding a reference via tty_ldisc_ref. Do not steal them the | ||
904 | * ldisc until they are done. */ | ||
905 | tty_ldisc_wait_idle(tty, MAX_SCHEDULE_TIMEOUT); | ||
906 | |||
907 | mutex_lock(&tty->ldisc_mutex); | 900 | mutex_lock(&tty->ldisc_mutex); |
908 | /* | 901 | /* |
909 | * Now kill off the ldisc | 902 | * Now kill off the ldisc |
@@ -931,18 +924,13 @@ static void tty_ldisc_kill(struct tty_struct *tty) | |||
931 | void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty) | 924 | void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty) |
932 | { | 925 | { |
933 | /* | 926 | /* |
934 | * Prevent flush_to_ldisc() from rescheduling the work for later. Then | 927 | * Shutdown this line discipline. As this is the final close, |
935 | * kill any delayed work. As this is the final close it does not | 928 | * it does not race with the set_ldisc code path. |
936 | * race with the set_ldisc code path. | ||
937 | */ | 929 | */ |
938 | 930 | ||
939 | tty_ldisc_halt(tty); | 931 | tty_ldisc_debug(tty, "closing ldisc: %p\n", tty->ldisc); |
940 | if (o_tty) | ||
941 | tty_ldisc_halt(o_tty); | ||
942 | 932 | ||
943 | tty_ldisc_flush_works(tty); | 933 | tty_ldisc_halt(tty, o_tty, MAX_SCHEDULE_TIMEOUT); |
944 | if (o_tty) | ||
945 | tty_ldisc_flush_works(o_tty); | ||
946 | 934 | ||
947 | tty_lock_pair(tty, o_tty); | 935 | tty_lock_pair(tty, o_tty); |
948 | /* This will need doing differently if we need to lock */ | 936 | /* This will need doing differently if we need to lock */ |
@@ -953,6 +941,8 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty) | |||
953 | tty_unlock_pair(tty, o_tty); | 941 | tty_unlock_pair(tty, o_tty); |
954 | /* And the memory resources remaining (buffers, termios) will be | 942 | /* And the memory resources remaining (buffers, termios) will be |
955 | disposed of when the kref hits zero */ | 943 | disposed of when the kref hits zero */ |
944 | |||
945 | tty_ldisc_debug(tty, "ldisc closed\n"); | ||
956 | } | 946 | } |
957 | 947 | ||
958 | /** | 948 | /** |
@@ -968,7 +958,7 @@ void tty_ldisc_init(struct tty_struct *tty) | |||
968 | struct tty_ldisc *ld = tty_ldisc_get(N_TTY); | 958 | struct tty_ldisc *ld = tty_ldisc_get(N_TTY); |
969 | if (IS_ERR(ld)) | 959 | if (IS_ERR(ld)) |
970 | panic("n_tty: init_tty"); | 960 | panic("n_tty: init_tty"); |
971 | tty_ldisc_assign(tty, ld); | 961 | tty->ldisc = ld; |
972 | } | 962 | } |
973 | 963 | ||
974 | /** | 964 | /** |
@@ -980,8 +970,8 @@ void tty_ldisc_init(struct tty_struct *tty) | |||
980 | */ | 970 | */ |
981 | void tty_ldisc_deinit(struct tty_struct *tty) | 971 | void tty_ldisc_deinit(struct tty_struct *tty) |
982 | { | 972 | { |
983 | put_ldisc(tty->ldisc); | 973 | tty_ldisc_put(tty->ldisc); |
984 | tty_ldisc_assign(tty, NULL); | 974 | tty->ldisc = NULL; |
985 | } | 975 | } |
986 | 976 | ||
987 | void tty_ldisc_begin(void) | 977 | void tty_ldisc_begin(void) |
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index b7ff59d3db88..121aeb9393e1 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c | |||
@@ -132,6 +132,7 @@ EXPORT_SYMBOL(tty_port_free_xmit_buf); | |||
132 | */ | 132 | */ |
133 | void tty_port_destroy(struct tty_port *port) | 133 | void tty_port_destroy(struct tty_port *port) |
134 | { | 134 | { |
135 | cancel_work_sync(&port->buf.work); | ||
135 | tty_buffer_free_all(port); | 136 | tty_buffer_free_all(port); |
136 | } | 137 | } |
137 | EXPORT_SYMBOL(tty_port_destroy); | 138 | EXPORT_SYMBOL(tty_port_destroy); |
@@ -196,12 +197,24 @@ void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty) | |||
196 | } | 197 | } |
197 | EXPORT_SYMBOL(tty_port_tty_set); | 198 | EXPORT_SYMBOL(tty_port_tty_set); |
198 | 199 | ||
199 | static void tty_port_shutdown(struct tty_port *port) | 200 | static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty) |
200 | { | 201 | { |
201 | mutex_lock(&port->mutex); | 202 | mutex_lock(&port->mutex); |
202 | if (port->ops->shutdown && !port->console && | 203 | if (port->console) |
203 | test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags)) | 204 | goto out; |
205 | |||
206 | if (test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags)) { | ||
207 | /* | ||
208 | * Drop DTR/RTS if HUPCL is set. This causes any attached | ||
209 | * modem to hang up the line. | ||
210 | */ | ||
211 | if (tty && C_HUPCL(tty)) | ||
212 | tty_port_lower_dtr_rts(port); | ||
213 | |||
214 | if (port->ops->shutdown) | ||
204 | port->ops->shutdown(port); | 215 | port->ops->shutdown(port); |
216 | } | ||
217 | out: | ||
205 | mutex_unlock(&port->mutex); | 218 | mutex_unlock(&port->mutex); |
206 | } | 219 | } |
207 | 220 | ||
@@ -215,24 +228,58 @@ static void tty_port_shutdown(struct tty_port *port) | |||
215 | 228 | ||
216 | void tty_port_hangup(struct tty_port *port) | 229 | void tty_port_hangup(struct tty_port *port) |
217 | { | 230 | { |
231 | struct tty_struct *tty; | ||
218 | unsigned long flags; | 232 | unsigned long flags; |
219 | 233 | ||
220 | spin_lock_irqsave(&port->lock, flags); | 234 | spin_lock_irqsave(&port->lock, flags); |
221 | port->count = 0; | 235 | port->count = 0; |
222 | port->flags &= ~ASYNC_NORMAL_ACTIVE; | 236 | port->flags &= ~ASYNC_NORMAL_ACTIVE; |
223 | if (port->tty) { | 237 | tty = port->tty; |
224 | set_bit(TTY_IO_ERROR, &port->tty->flags); | 238 | if (tty) |
225 | tty_kref_put(port->tty); | 239 | set_bit(TTY_IO_ERROR, &tty->flags); |
226 | } | ||
227 | port->tty = NULL; | 240 | port->tty = NULL; |
228 | spin_unlock_irqrestore(&port->lock, flags); | 241 | spin_unlock_irqrestore(&port->lock, flags); |
242 | tty_port_shutdown(port, tty); | ||
243 | tty_kref_put(tty); | ||
229 | wake_up_interruptible(&port->open_wait); | 244 | wake_up_interruptible(&port->open_wait); |
230 | wake_up_interruptible(&port->delta_msr_wait); | 245 | wake_up_interruptible(&port->delta_msr_wait); |
231 | tty_port_shutdown(port); | ||
232 | } | 246 | } |
233 | EXPORT_SYMBOL(tty_port_hangup); | 247 | EXPORT_SYMBOL(tty_port_hangup); |
234 | 248 | ||
235 | /** | 249 | /** |
250 | * tty_port_tty_hangup - helper to hang up a tty | ||
251 | * | ||
252 | * @port: tty port | ||
253 | * @check_clocal: hang only ttys with CLOCAL unset? | ||
254 | */ | ||
255 | void tty_port_tty_hangup(struct tty_port *port, bool check_clocal) | ||
256 | { | ||
257 | struct tty_struct *tty = tty_port_tty_get(port); | ||
258 | |||
259 | if (tty && (!check_clocal || !C_CLOCAL(tty))) { | ||
260 | tty_hangup(tty); | ||
261 | tty_kref_put(tty); | ||
262 | } | ||
263 | } | ||
264 | EXPORT_SYMBOL_GPL(tty_port_tty_hangup); | ||
265 | |||
266 | /** | ||
267 | * tty_port_tty_wakeup - helper to wake up a tty | ||
268 | * | ||
269 | * @port: tty port | ||
270 | */ | ||
271 | void tty_port_tty_wakeup(struct tty_port *port) | ||
272 | { | ||
273 | struct tty_struct *tty = tty_port_tty_get(port); | ||
274 | |||
275 | if (tty) { | ||
276 | tty_wakeup(tty); | ||
277 | tty_kref_put(tty); | ||
278 | } | ||
279 | } | ||
280 | EXPORT_SYMBOL_GPL(tty_port_tty_wakeup); | ||
281 | |||
282 | /** | ||
236 | * tty_port_carrier_raised - carrier raised check | 283 | * tty_port_carrier_raised - carrier raised check |
237 | * @port: tty port | 284 | * @port: tty port |
238 | * | 285 | * |
@@ -350,7 +397,7 @@ int tty_port_block_til_ready(struct tty_port *port, | |||
350 | 397 | ||
351 | while (1) { | 398 | while (1) { |
352 | /* Indicate we are open */ | 399 | /* Indicate we are open */ |
353 | if (tty->termios.c_cflag & CBAUD) | 400 | if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) |
354 | tty_port_raise_dtr_rts(port); | 401 | tty_port_raise_dtr_rts(port); |
355 | 402 | ||
356 | prepare_to_wait(&port->open_wait, &wait, TASK_INTERRUPTIBLE); | 403 | prepare_to_wait(&port->open_wait, &wait, TASK_INTERRUPTIBLE); |
@@ -395,6 +442,20 @@ int tty_port_block_til_ready(struct tty_port *port, | |||
395 | } | 442 | } |
396 | EXPORT_SYMBOL(tty_port_block_til_ready); | 443 | EXPORT_SYMBOL(tty_port_block_til_ready); |
397 | 444 | ||
445 | static void tty_port_drain_delay(struct tty_port *port, struct tty_struct *tty) | ||
446 | { | ||
447 | unsigned int bps = tty_get_baud_rate(tty); | ||
448 | long timeout; | ||
449 | |||
450 | if (bps > 1200) { | ||
451 | timeout = (HZ * 10 * port->drain_delay) / bps; | ||
452 | timeout = max_t(long, timeout, HZ / 10); | ||
453 | } else { | ||
454 | timeout = 2 * HZ; | ||
455 | } | ||
456 | schedule_timeout_interruptible(timeout); | ||
457 | } | ||
458 | |||
398 | int tty_port_close_start(struct tty_port *port, | 459 | int tty_port_close_start(struct tty_port *port, |
399 | struct tty_struct *tty, struct file *filp) | 460 | struct tty_struct *tty, struct file *filp) |
400 | { | 461 | { |
@@ -427,31 +488,19 @@ int tty_port_close_start(struct tty_port *port, | |||
427 | set_bit(ASYNCB_CLOSING, &port->flags); | 488 | set_bit(ASYNCB_CLOSING, &port->flags); |
428 | tty->closing = 1; | 489 | tty->closing = 1; |
429 | spin_unlock_irqrestore(&port->lock, flags); | 490 | spin_unlock_irqrestore(&port->lock, flags); |
430 | /* Don't block on a stalled port, just pull the chain */ | 491 | |
431 | if (tty->flow_stopped) | 492 | if (test_bit(ASYNCB_INITIALIZED, &port->flags)) { |
432 | tty_driver_flush_buffer(tty); | 493 | /* Don't block on a stalled port, just pull the chain */ |
433 | if (test_bit(ASYNCB_INITIALIZED, &port->flags) && | 494 | if (tty->flow_stopped) |
434 | port->closing_wait != ASYNC_CLOSING_WAIT_NONE) | 495 | tty_driver_flush_buffer(tty); |
435 | tty_wait_until_sent_from_close(tty, port->closing_wait); | 496 | if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) |
436 | if (port->drain_delay) { | 497 | tty_wait_until_sent_from_close(tty, port->closing_wait); |
437 | unsigned int bps = tty_get_baud_rate(tty); | 498 | if (port->drain_delay) |
438 | long timeout; | 499 | tty_port_drain_delay(port, tty); |
439 | |||
440 | if (bps > 1200) | ||
441 | timeout = max_t(long, | ||
442 | (HZ * 10 * port->drain_delay) / bps, HZ / 10); | ||
443 | else | ||
444 | timeout = 2 * HZ; | ||
445 | schedule_timeout_interruptible(timeout); | ||
446 | } | 500 | } |
447 | /* Flush the ldisc buffering */ | 501 | /* Flush the ldisc buffering */ |
448 | tty_ldisc_flush(tty); | 502 | tty_ldisc_flush(tty); |
449 | 503 | ||
450 | /* Drop DTR/RTS if HUPCL is set. This causes any attached modem to | ||
451 | hang up the line */ | ||
452 | if (tty->termios.c_cflag & HUPCL) | ||
453 | tty_port_lower_dtr_rts(port); | ||
454 | |||
455 | /* Don't call port->drop for the last reference. Callers will want | 504 | /* Don't call port->drop for the last reference. Callers will want |
456 | to drop the last active reference in ->shutdown() or the tty | 505 | to drop the last active reference in ->shutdown() or the tty |
457 | shutdown path */ | 506 | shutdown path */ |
@@ -486,7 +535,7 @@ void tty_port_close(struct tty_port *port, struct tty_struct *tty, | |||
486 | { | 535 | { |
487 | if (tty_port_close_start(port, tty, filp) == 0) | 536 | if (tty_port_close_start(port, tty, filp) == 0) |
488 | return; | 537 | return; |
489 | tty_port_shutdown(port); | 538 | tty_port_shutdown(port, tty); |
490 | set_bit(TTY_IO_ERROR, &tty->flags); | 539 | set_bit(TTY_IO_ERROR, &tty->flags); |
491 | tty_port_close_end(port, tty); | 540 | tty_port_close_end(port, tty); |
492 | tty_port_tty_set(port, NULL); | 541 | tty_port_tty_set(port, NULL); |
diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c index 248381b30722..2978ca596a7f 100644 --- a/drivers/tty/vt/consolemap.c +++ b/drivers/tty/vt/consolemap.c | |||
@@ -194,8 +194,7 @@ static void set_inverse_transl(struct vc_data *conp, struct uni_pagedir *p, int | |||
194 | q = p->inverse_translations[i]; | 194 | q = p->inverse_translations[i]; |
195 | 195 | ||
196 | if (!q) { | 196 | if (!q) { |
197 | q = p->inverse_translations[i] = (unsigned char *) | 197 | q = p->inverse_translations[i] = kmalloc(MAX_GLYPH, GFP_KERNEL); |
198 | kmalloc(MAX_GLYPH, GFP_KERNEL); | ||
199 | if (!q) return; | 198 | if (!q) return; |
200 | } | 199 | } |
201 | memset(q, 0, MAX_GLYPH); | 200 | memset(q, 0, MAX_GLYPH); |
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 387dc6c8ad25..c77f7ae48f1c 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -292,7 +292,6 @@ static void acm_ctrl_irq(struct urb *urb) | |||
292 | { | 292 | { |
293 | struct acm *acm = urb->context; | 293 | struct acm *acm = urb->context; |
294 | struct usb_cdc_notification *dr = urb->transfer_buffer; | 294 | struct usb_cdc_notification *dr = urb->transfer_buffer; |
295 | struct tty_struct *tty; | ||
296 | unsigned char *data; | 295 | unsigned char *data; |
297 | int newctrl; | 296 | int newctrl; |
298 | int retval; | 297 | int retval; |
@@ -327,17 +326,12 @@ static void acm_ctrl_irq(struct urb *urb) | |||
327 | break; | 326 | break; |
328 | 327 | ||
329 | case USB_CDC_NOTIFY_SERIAL_STATE: | 328 | case USB_CDC_NOTIFY_SERIAL_STATE: |
330 | tty = tty_port_tty_get(&acm->port); | ||
331 | newctrl = get_unaligned_le16(data); | 329 | newctrl = get_unaligned_le16(data); |
332 | 330 | ||
333 | if (tty) { | 331 | if (!acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) { |
334 | if (!acm->clocal && | 332 | dev_dbg(&acm->control->dev, "%s - calling hangup\n", |
335 | (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) { | 333 | __func__); |
336 | dev_dbg(&acm->control->dev, | 334 | tty_port_tty_hangup(&acm->port, false); |
337 | "%s - calling hangup\n", __func__); | ||
338 | tty_hangup(tty); | ||
339 | } | ||
340 | tty_kref_put(tty); | ||
341 | } | 335 | } |
342 | 336 | ||
343 | acm->ctrlin = newctrl; | 337 | acm->ctrlin = newctrl; |
@@ -475,15 +469,10 @@ static void acm_write_bulk(struct urb *urb) | |||
475 | static void acm_softint(struct work_struct *work) | 469 | static void acm_softint(struct work_struct *work) |
476 | { | 470 | { |
477 | struct acm *acm = container_of(work, struct acm, work); | 471 | struct acm *acm = container_of(work, struct acm, work); |
478 | struct tty_struct *tty; | ||
479 | 472 | ||
480 | dev_vdbg(&acm->data->dev, "%s\n", __func__); | 473 | dev_vdbg(&acm->data->dev, "%s\n", __func__); |
481 | 474 | ||
482 | tty = tty_port_tty_get(&acm->port); | 475 | tty_port_tty_wakeup(&acm->port); |
483 | if (!tty) | ||
484 | return; | ||
485 | tty_wakeup(tty); | ||
486 | tty_kref_put(tty); | ||
487 | } | 476 | } |
488 | 477 | ||
489 | /* | 478 | /* |
@@ -1519,15 +1508,9 @@ err_out: | |||
1519 | static int acm_reset_resume(struct usb_interface *intf) | 1508 | static int acm_reset_resume(struct usb_interface *intf) |
1520 | { | 1509 | { |
1521 | struct acm *acm = usb_get_intfdata(intf); | 1510 | struct acm *acm = usb_get_intfdata(intf); |
1522 | struct tty_struct *tty; | ||
1523 | 1511 | ||
1524 | if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) { | 1512 | if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) |
1525 | tty = tty_port_tty_get(&acm->port); | 1513 | tty_port_tty_hangup(&acm->port, false); |
1526 | if (tty) { | ||
1527 | tty_hangup(tty); | ||
1528 | tty_kref_put(tty); | ||
1529 | } | ||
1530 | } | ||
1531 | 1514 | ||
1532 | return acm_resume(intf); | 1515 | return acm_resume(intf); |
1533 | } | 1516 | } |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index ebe45fa0ed50..31191581060c 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -210,7 +210,6 @@ struct digi_port { | |||
210 | 210 | ||
211 | /* Local Function Declarations */ | 211 | /* Local Function Declarations */ |
212 | 212 | ||
213 | static void digi_wakeup_write(struct usb_serial_port *port); | ||
214 | static void digi_wakeup_write_lock(struct work_struct *work); | 213 | static void digi_wakeup_write_lock(struct work_struct *work); |
215 | static int digi_write_oob_command(struct usb_serial_port *port, | 214 | static int digi_write_oob_command(struct usb_serial_port *port, |
216 | unsigned char *buf, int count, int interruptible); | 215 | unsigned char *buf, int count, int interruptible); |
@@ -374,20 +373,10 @@ static void digi_wakeup_write_lock(struct work_struct *work) | |||
374 | unsigned long flags; | 373 | unsigned long flags; |
375 | 374 | ||
376 | spin_lock_irqsave(&priv->dp_port_lock, flags); | 375 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
377 | digi_wakeup_write(port); | 376 | tty_port_tty_wakeup(&port->port); |
378 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | 377 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
379 | } | 378 | } |
380 | 379 | ||
381 | static void digi_wakeup_write(struct usb_serial_port *port) | ||
382 | { | ||
383 | struct tty_struct *tty = tty_port_tty_get(&port->port); | ||
384 | if (tty) { | ||
385 | tty_wakeup(tty); | ||
386 | tty_kref_put(tty); | ||
387 | } | ||
388 | } | ||
389 | |||
390 | |||
391 | /* | 380 | /* |
392 | * Digi Write OOB Command | 381 | * Digi Write OOB Command |
393 | * | 382 | * |
@@ -1044,7 +1033,7 @@ static void digi_write_bulk_callback(struct urb *urb) | |||
1044 | } | 1033 | } |
1045 | } | 1034 | } |
1046 | /* wake up processes sleeping on writes immediately */ | 1035 | /* wake up processes sleeping on writes immediately */ |
1047 | digi_wakeup_write(port); | 1036 | tty_port_tty_wakeup(&port->port); |
1048 | /* also queue up a wakeup at scheduler time, in case we */ | 1037 | /* also queue up a wakeup at scheduler time, in case we */ |
1049 | /* lost the race in write_chan(). */ | 1038 | /* lost the race in write_chan(). */ |
1050 | schedule_work(&priv->dp_wakeup_work); | 1039 | schedule_work(&priv->dp_wakeup_work); |
@@ -1522,7 +1511,7 @@ static int digi_read_oob_callback(struct urb *urb) | |||
1522 | /* port must be open to use tty struct */ | 1511 | /* port must be open to use tty struct */ |
1523 | if (rts) { | 1512 | if (rts) { |
1524 | tty->hw_stopped = 0; | 1513 | tty->hw_stopped = 0; |
1525 | digi_wakeup_write(port); | 1514 | tty_port_tty_wakeup(&port->port); |
1526 | } | 1515 | } |
1527 | } else { | 1516 | } else { |
1528 | priv->dp_modem_signals &= ~TIOCM_CTS; | 1517 | priv->dp_modem_signals &= ~TIOCM_CTS; |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index efd8b978128c..cf0b0a2f7b56 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -564,7 +564,6 @@ static void edge_interrupt_callback(struct urb *urb) | |||
564 | struct device *dev; | 564 | struct device *dev; |
565 | struct edgeport_port *edge_port; | 565 | struct edgeport_port *edge_port; |
566 | struct usb_serial_port *port; | 566 | struct usb_serial_port *port; |
567 | struct tty_struct *tty; | ||
568 | unsigned char *data = urb->transfer_buffer; | 567 | unsigned char *data = urb->transfer_buffer; |
569 | int length = urb->actual_length; | 568 | int length = urb->actual_length; |
570 | int bytes_avail; | 569 | int bytes_avail; |
@@ -643,12 +642,7 @@ static void edge_interrupt_callback(struct urb *urb) | |||
643 | 642 | ||
644 | /* tell the tty driver that something | 643 | /* tell the tty driver that something |
645 | has changed */ | 644 | has changed */ |
646 | tty = tty_port_tty_get( | 645 | tty_port_tty_wakeup(&edge_port->port->port); |
647 | &edge_port->port->port); | ||
648 | if (tty) { | ||
649 | tty_wakeup(tty); | ||
650 | tty_kref_put(tty); | ||
651 | } | ||
652 | /* Since we have more credit, check | 646 | /* Since we have more credit, check |
653 | if more data can be sent */ | 647 | if more data can be sent */ |
654 | send_more_port_data(edge_serial, | 648 | send_more_port_data(edge_serial, |
@@ -737,7 +731,6 @@ static void edge_bulk_in_callback(struct urb *urb) | |||
737 | static void edge_bulk_out_data_callback(struct urb *urb) | 731 | static void edge_bulk_out_data_callback(struct urb *urb) |
738 | { | 732 | { |
739 | struct edgeport_port *edge_port = urb->context; | 733 | struct edgeport_port *edge_port = urb->context; |
740 | struct tty_struct *tty; | ||
741 | int status = urb->status; | 734 | int status = urb->status; |
742 | 735 | ||
743 | if (status) { | 736 | if (status) { |
@@ -746,14 +739,8 @@ static void edge_bulk_out_data_callback(struct urb *urb) | |||
746 | __func__, status); | 739 | __func__, status); |
747 | } | 740 | } |
748 | 741 | ||
749 | tty = tty_port_tty_get(&edge_port->port->port); | 742 | if (edge_port->open) |
750 | 743 | tty_port_tty_wakeup(&edge_port->port->port); | |
751 | if (tty && edge_port->open) { | ||
752 | /* let the tty driver wakeup if it has a special | ||
753 | write_wakeup function */ | ||
754 | tty_wakeup(tty); | ||
755 | } | ||
756 | tty_kref_put(tty); | ||
757 | 744 | ||
758 | /* Release the Write URB */ | 745 | /* Release the Write URB */ |
759 | edge_port->write_in_progress = false; | 746 | edge_port->write_in_progress = false; |
@@ -772,7 +759,6 @@ static void edge_bulk_out_data_callback(struct urb *urb) | |||
772 | static void edge_bulk_out_cmd_callback(struct urb *urb) | 759 | static void edge_bulk_out_cmd_callback(struct urb *urb) |
773 | { | 760 | { |
774 | struct edgeport_port *edge_port = urb->context; | 761 | struct edgeport_port *edge_port = urb->context; |
775 | struct tty_struct *tty; | ||
776 | int status = urb->status; | 762 | int status = urb->status; |
777 | 763 | ||
778 | atomic_dec(&CmdUrbs); | 764 | atomic_dec(&CmdUrbs); |
@@ -793,13 +779,9 @@ static void edge_bulk_out_cmd_callback(struct urb *urb) | |||
793 | return; | 779 | return; |
794 | } | 780 | } |
795 | 781 | ||
796 | /* Get pointer to tty */ | ||
797 | tty = tty_port_tty_get(&edge_port->port->port); | ||
798 | |||
799 | /* tell the tty driver that something has changed */ | 782 | /* tell the tty driver that something has changed */ |
800 | if (tty && edge_port->open) | 783 | if (edge_port->open) |
801 | tty_wakeup(tty); | 784 | tty_port_tty_wakeup(&edge_port->port->port); |
802 | tty_kref_put(tty); | ||
803 | 785 | ||
804 | /* we have completed the command */ | 786 | /* we have completed the command */ |
805 | edge_port->commandPending = false; | 787 | edge_port->commandPending = false; |
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 1fd1935c8316..b011478d2e5f 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -378,7 +378,6 @@ static void usa26_instat_callback(struct urb *urb) | |||
378 | struct usb_serial *serial; | 378 | struct usb_serial *serial; |
379 | struct usb_serial_port *port; | 379 | struct usb_serial_port *port; |
380 | struct keyspan_port_private *p_priv; | 380 | struct keyspan_port_private *p_priv; |
381 | struct tty_struct *tty; | ||
382 | int old_dcd_state, err; | 381 | int old_dcd_state, err; |
383 | int status = urb->status; | 382 | int status = urb->status; |
384 | 383 | ||
@@ -421,12 +420,8 @@ static void usa26_instat_callback(struct urb *urb) | |||
421 | p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); | 420 | p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); |
422 | p_priv->ri_state = ((msg->ri) ? 1 : 0); | 421 | p_priv->ri_state = ((msg->ri) ? 1 : 0); |
423 | 422 | ||
424 | if (old_dcd_state != p_priv->dcd_state) { | 423 | if (old_dcd_state != p_priv->dcd_state) |
425 | tty = tty_port_tty_get(&port->port); | 424 | tty_port_tty_hangup(&port->port, true); |
426 | if (tty && !C_CLOCAL(tty)) | ||
427 | tty_hangup(tty); | ||
428 | tty_kref_put(tty); | ||
429 | } | ||
430 | 425 | ||
431 | /* Resubmit urb so we continue receiving */ | 426 | /* Resubmit urb so we continue receiving */ |
432 | err = usb_submit_urb(urb, GFP_ATOMIC); | 427 | err = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -510,7 +505,6 @@ static void usa28_instat_callback(struct urb *urb) | |||
510 | struct usb_serial *serial; | 505 | struct usb_serial *serial; |
511 | struct usb_serial_port *port; | 506 | struct usb_serial_port *port; |
512 | struct keyspan_port_private *p_priv; | 507 | struct keyspan_port_private *p_priv; |
513 | struct tty_struct *tty; | ||
514 | int old_dcd_state; | 508 | int old_dcd_state; |
515 | int status = urb->status; | 509 | int status = urb->status; |
516 | 510 | ||
@@ -551,12 +545,8 @@ static void usa28_instat_callback(struct urb *urb) | |||
551 | p_priv->dcd_state = ((msg->dcd) ? 1 : 0); | 545 | p_priv->dcd_state = ((msg->dcd) ? 1 : 0); |
552 | p_priv->ri_state = ((msg->ri) ? 1 : 0); | 546 | p_priv->ri_state = ((msg->ri) ? 1 : 0); |
553 | 547 | ||
554 | if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { | 548 | if (old_dcd_state != p_priv->dcd_state && old_dcd_state) |
555 | tty = tty_port_tty_get(&port->port); | 549 | tty_port_tty_hangup(&port->port, true); |
556 | if (tty && !C_CLOCAL(tty)) | ||
557 | tty_hangup(tty); | ||
558 | tty_kref_put(tty); | ||
559 | } | ||
560 | 550 | ||
561 | /* Resubmit urb so we continue receiving */ | 551 | /* Resubmit urb so we continue receiving */ |
562 | err = usb_submit_urb(urb, GFP_ATOMIC); | 552 | err = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -642,12 +632,8 @@ static void usa49_instat_callback(struct urb *urb) | |||
642 | p_priv->dcd_state = ((msg->dcd) ? 1 : 0); | 632 | p_priv->dcd_state = ((msg->dcd) ? 1 : 0); |
643 | p_priv->ri_state = ((msg->ri) ? 1 : 0); | 633 | p_priv->ri_state = ((msg->ri) ? 1 : 0); |
644 | 634 | ||
645 | if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { | 635 | if (old_dcd_state != p_priv->dcd_state && old_dcd_state) |
646 | struct tty_struct *tty = tty_port_tty_get(&port->port); | 636 | tty_port_tty_hangup(&port->port, true); |
647 | if (tty && !C_CLOCAL(tty)) | ||
648 | tty_hangup(tty); | ||
649 | tty_kref_put(tty); | ||
650 | } | ||
651 | 637 | ||
652 | /* Resubmit urb so we continue receiving */ | 638 | /* Resubmit urb so we continue receiving */ |
653 | err = usb_submit_urb(urb, GFP_ATOMIC); | 639 | err = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -851,7 +837,6 @@ static void usa90_instat_callback(struct urb *urb) | |||
851 | struct usb_serial *serial; | 837 | struct usb_serial *serial; |
852 | struct usb_serial_port *port; | 838 | struct usb_serial_port *port; |
853 | struct keyspan_port_private *p_priv; | 839 | struct keyspan_port_private *p_priv; |
854 | struct tty_struct *tty; | ||
855 | int old_dcd_state, err; | 840 | int old_dcd_state, err; |
856 | int status = urb->status; | 841 | int status = urb->status; |
857 | 842 | ||
@@ -880,12 +865,8 @@ static void usa90_instat_callback(struct urb *urb) | |||
880 | p_priv->dcd_state = ((msg->dcd) ? 1 : 0); | 865 | p_priv->dcd_state = ((msg->dcd) ? 1 : 0); |
881 | p_priv->ri_state = ((msg->ri) ? 1 : 0); | 866 | p_priv->ri_state = ((msg->ri) ? 1 : 0); |
882 | 867 | ||
883 | if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { | 868 | if (old_dcd_state != p_priv->dcd_state && old_dcd_state) |
884 | tty = tty_port_tty_get(&port->port); | 869 | tty_port_tty_hangup(&port->port, true); |
885 | if (tty && !C_CLOCAL(tty)) | ||
886 | tty_hangup(tty); | ||
887 | tty_kref_put(tty); | ||
888 | } | ||
889 | 870 | ||
890 | /* Resubmit urb so we continue receiving */ | 871 | /* Resubmit urb so we continue receiving */ |
891 | err = usb_submit_urb(urb, GFP_ATOMIC); | 872 | err = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -953,12 +934,8 @@ static void usa67_instat_callback(struct urb *urb) | |||
953 | p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); | 934 | p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); |
954 | p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); | 935 | p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); |
955 | 936 | ||
956 | if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { | 937 | if (old_dcd_state != p_priv->dcd_state && old_dcd_state) |
957 | struct tty_struct *tty = tty_port_tty_get(&port->port); | 938 | tty_port_tty_hangup(&port->port, true); |
958 | if (tty && !C_CLOCAL(tty)) | ||
959 | tty_hangup(tty); | ||
960 | tty_kref_put(tty); | ||
961 | } | ||
962 | 939 | ||
963 | /* Resubmit urb so we continue receiving */ | 940 | /* Resubmit urb so we continue receiving */ |
964 | err = usb_submit_urb(urb, GFP_ATOMIC); | 941 | err = usb_submit_urb(urb, GFP_ATOMIC); |
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 3b17d5d13dc8..2230223978ca 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -104,10 +104,8 @@ static void keyspan_pda_wakeup_write(struct work_struct *work) | |||
104 | struct keyspan_pda_private *priv = | 104 | struct keyspan_pda_private *priv = |
105 | container_of(work, struct keyspan_pda_private, wakeup_work); | 105 | container_of(work, struct keyspan_pda_private, wakeup_work); |
106 | struct usb_serial_port *port = priv->port; | 106 | struct usb_serial_port *port = priv->port; |
107 | struct tty_struct *tty = tty_port_tty_get(&port->port); | 107 | |
108 | if (tty) | 108 | tty_port_tty_wakeup(&port->port); |
109 | tty_wakeup(tty); | ||
110 | tty_kref_put(tty); | ||
111 | } | 109 | } |
112 | 110 | ||
113 | static void keyspan_pda_request_unthrottle(struct work_struct *work) | 111 | static void keyspan_pda_request_unthrottle(struct work_struct *work) |
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index e0ebec3b5d6a..e956eae198fd 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -932,7 +932,6 @@ static void mos7720_bulk_in_callback(struct urb *urb) | |||
932 | static void mos7720_bulk_out_data_callback(struct urb *urb) | 932 | static void mos7720_bulk_out_data_callback(struct urb *urb) |
933 | { | 933 | { |
934 | struct moschip_port *mos7720_port; | 934 | struct moschip_port *mos7720_port; |
935 | struct tty_struct *tty; | ||
936 | int status = urb->status; | 935 | int status = urb->status; |
937 | 936 | ||
938 | if (status) { | 937 | if (status) { |
@@ -946,11 +945,8 @@ static void mos7720_bulk_out_data_callback(struct urb *urb) | |||
946 | return ; | 945 | return ; |
947 | } | 946 | } |
948 | 947 | ||
949 | tty = tty_port_tty_get(&mos7720_port->port->port); | 948 | if (mos7720_port->open) |
950 | 949 | tty_port_tty_wakeup(&mos7720_port->port->port); | |
951 | if (tty && mos7720_port->open) | ||
952 | tty_wakeup(tty); | ||
953 | tty_kref_put(tty); | ||
954 | } | 950 | } |
955 | 951 | ||
956 | /* | 952 | /* |
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index b8051fa61911..2be376a2e0e3 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -816,7 +816,6 @@ static void mos7840_bulk_out_data_callback(struct urb *urb) | |||
816 | { | 816 | { |
817 | struct moschip_port *mos7840_port; | 817 | struct moschip_port *mos7840_port; |
818 | struct usb_serial_port *port; | 818 | struct usb_serial_port *port; |
819 | struct tty_struct *tty; | ||
820 | int status = urb->status; | 819 | int status = urb->status; |
821 | int i; | 820 | int i; |
822 | 821 | ||
@@ -839,10 +838,8 @@ static void mos7840_bulk_out_data_callback(struct urb *urb) | |||
839 | if (mos7840_port_paranoia_check(port, __func__)) | 838 | if (mos7840_port_paranoia_check(port, __func__)) |
840 | return; | 839 | return; |
841 | 840 | ||
842 | tty = tty_port_tty_get(&port->port); | 841 | if (mos7840_port->open) |
843 | if (tty && mos7840_port->open) | 842 | tty_port_tty_wakeup(&port->port); |
844 | tty_wakeup(tty); | ||
845 | tty_kref_put(tty); | ||
846 | 843 | ||
847 | } | 844 | } |
848 | 845 | ||
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 558adfc05007..09cd3967b8df 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -1537,13 +1537,8 @@ static void option_instat_callback(struct urb *urb) | |||
1537 | portdata->dsr_state = ((signals & 0x02) ? 1 : 0); | 1537 | portdata->dsr_state = ((signals & 0x02) ? 1 : 0); |
1538 | portdata->ri_state = ((signals & 0x08) ? 1 : 0); | 1538 | portdata->ri_state = ((signals & 0x08) ? 1 : 0); |
1539 | 1539 | ||
1540 | if (old_dcd_state && !portdata->dcd_state) { | 1540 | if (old_dcd_state && !portdata->dcd_state) |
1541 | struct tty_struct *tty = | 1541 | tty_port_tty_hangup(&port->port, true); |
1542 | tty_port_tty_get(&port->port); | ||
1543 | if (tty && !C_CLOCAL(tty)) | ||
1544 | tty_hangup(tty); | ||
1545 | tty_kref_put(tty); | ||
1546 | } | ||
1547 | } else { | 1542 | } else { |
1548 | dev_dbg(dev, "%s: type %x req %x\n", __func__, | 1543 | dev_dbg(dev, "%s: type %x req %x\n", __func__, |
1549 | req_pkt->bRequestType, req_pkt->bRequest); | 1544 | req_pkt->bRequestType, req_pkt->bRequest); |
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index 75f125ddb0c9..ef3a7d5eaab4 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c | |||
@@ -116,7 +116,6 @@ struct qt2_serial_private { | |||
116 | }; | 116 | }; |
117 | 117 | ||
118 | struct qt2_port_private { | 118 | struct qt2_port_private { |
119 | bool is_open; | ||
120 | u8 device_port; | 119 | u8 device_port; |
121 | 120 | ||
122 | spinlock_t urb_lock; | 121 | spinlock_t urb_lock; |
@@ -397,7 +396,6 @@ static int qt2_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
397 | return status; | 396 | return status; |
398 | } | 397 | } |
399 | 398 | ||
400 | port_priv->is_open = true; | ||
401 | port_priv->device_port = (u8) device_port; | 399 | port_priv->device_port = (u8) device_port; |
402 | 400 | ||
403 | if (tty) | 401 | if (tty) |
@@ -417,8 +415,6 @@ static void qt2_close(struct usb_serial_port *port) | |||
417 | serial = port->serial; | 415 | serial = port->serial; |
418 | port_priv = usb_get_serial_port_data(port); | 416 | port_priv = usb_get_serial_port_data(port); |
419 | 417 | ||
420 | port_priv->is_open = false; | ||
421 | |||
422 | spin_lock_irqsave(&port_priv->urb_lock, flags); | 418 | spin_lock_irqsave(&port_priv->urb_lock, flags); |
423 | usb_kill_urb(port_priv->write_urb); | 419 | usb_kill_urb(port_priv->write_urb); |
424 | port_priv->urb_in_use = false; | 420 | port_priv->urb_in_use = false; |
@@ -664,9 +660,7 @@ void qt2_process_read_urb(struct urb *urb) | |||
664 | __func__); | 660 | __func__); |
665 | break; | 661 | break; |
666 | } | 662 | } |
667 | 663 | tty_flip_buffer_push(&port->port); | |
668 | if (port_priv->is_open) | ||
669 | tty_flip_buffer_push(&port->port); | ||
670 | 664 | ||
671 | newport = *(ch + 3); | 665 | newport = *(ch + 3); |
672 | 666 | ||
@@ -709,8 +703,7 @@ void qt2_process_read_urb(struct urb *urb) | |||
709 | tty_insert_flip_string(&port->port, ch, 1); | 703 | tty_insert_flip_string(&port->port, ch, 1); |
710 | } | 704 | } |
711 | 705 | ||
712 | if (port_priv->is_open) | 706 | tty_flip_buffer_push(&port->port); |
713 | tty_flip_buffer_push(&port->port); | ||
714 | } | 707 | } |
715 | 708 | ||
716 | static void qt2_write_bulk_callback(struct urb *urb) | 709 | static void qt2_write_bulk_callback(struct urb *urb) |
@@ -910,12 +903,6 @@ static void qt2_break_ctl(struct tty_struct *tty, int break_state) | |||
910 | 903 | ||
911 | port_priv = usb_get_serial_port_data(port); | 904 | port_priv = usb_get_serial_port_data(port); |
912 | 905 | ||
913 | if (!port_priv->is_open) { | ||
914 | dev_err(&port->dev, | ||
915 | "%s - port is not open\n", __func__); | ||
916 | return; | ||
917 | } | ||
918 | |||
919 | val = (break_state == -1) ? 1 : 0; | 906 | val = (break_state == -1) ? 1 : 0; |
920 | 907 | ||
921 | status = qt2_control_msg(port->serial->dev, QT2_BREAK_CONTROL, | 908 | status = qt2_control_msg(port->serial->dev, QT2_BREAK_CONTROL, |
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index c13f6e747748..d66148a17fe3 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -628,7 +628,6 @@ static void sierra_instat_callback(struct urb *urb) | |||
628 | unsigned char signals = *((unsigned char *) | 628 | unsigned char signals = *((unsigned char *) |
629 | urb->transfer_buffer + | 629 | urb->transfer_buffer + |
630 | sizeof(struct usb_ctrlrequest)); | 630 | sizeof(struct usb_ctrlrequest)); |
631 | struct tty_struct *tty; | ||
632 | 631 | ||
633 | dev_dbg(&port->dev, "%s: signal x%x\n", __func__, | 632 | dev_dbg(&port->dev, "%s: signal x%x\n", __func__, |
634 | signals); | 633 | signals); |
@@ -639,11 +638,8 @@ static void sierra_instat_callback(struct urb *urb) | |||
639 | portdata->dsr_state = ((signals & 0x02) ? 1 : 0); | 638 | portdata->dsr_state = ((signals & 0x02) ? 1 : 0); |
640 | portdata->ri_state = ((signals & 0x08) ? 1 : 0); | 639 | portdata->ri_state = ((signals & 0x08) ? 1 : 0); |
641 | 640 | ||
642 | tty = tty_port_tty_get(&port->port); | 641 | if (old_dcd_state && !portdata->dcd_state) |
643 | if (tty && !C_CLOCAL(tty) && | 642 | tty_port_tty_hangup(&port->port, true); |
644 | old_dcd_state && !portdata->dcd_state) | ||
645 | tty_hangup(tty); | ||
646 | tty_kref_put(tty); | ||
647 | } else { | 643 | } else { |
648 | dev_dbg(&port->dev, "%s: type %x req %x\n", | 644 | dev_dbg(&port->dev, "%s: type %x req %x\n", |
649 | __func__, req_pkt->bRequestType, | 645 | __func__, req_pkt->bRequestType, |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 73deb029fc05..19a71a9eecf0 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -1229,7 +1229,6 @@ static void ti_send(struct ti_port *tport) | |||
1229 | { | 1229 | { |
1230 | int count, result; | 1230 | int count, result; |
1231 | struct usb_serial_port *port = tport->tp_port; | 1231 | struct usb_serial_port *port = tport->tp_port; |
1232 | struct tty_struct *tty = tty_port_tty_get(&port->port); /* FIXME */ | ||
1233 | unsigned long flags; | 1232 | unsigned long flags; |
1234 | 1233 | ||
1235 | spin_lock_irqsave(&tport->tp_lock, flags); | 1234 | spin_lock_irqsave(&tport->tp_lock, flags); |
@@ -1270,14 +1269,12 @@ static void ti_send(struct ti_port *tport) | |||
1270 | } | 1269 | } |
1271 | 1270 | ||
1272 | /* more room in the buffer for new writes, wakeup */ | 1271 | /* more room in the buffer for new writes, wakeup */ |
1273 | if (tty) | 1272 | tty_port_tty_wakeup(&port->port); |
1274 | tty_wakeup(tty); | 1273 | |
1275 | tty_kref_put(tty); | ||
1276 | wake_up_interruptible(&tport->tp_write_wait); | 1274 | wake_up_interruptible(&tport->tp_write_wait); |
1277 | return; | 1275 | return; |
1278 | unlock: | 1276 | unlock: |
1279 | spin_unlock_irqrestore(&tport->tp_lock, flags); | 1277 | spin_unlock_irqrestore(&tport->tp_lock, flags); |
1280 | tty_kref_put(tty); | ||
1281 | return; | 1278 | return; |
1282 | } | 1279 | } |
1283 | 1280 | ||
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 5d9b178484fd..650be17a68f2 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -542,16 +542,8 @@ static void usb_serial_port_work(struct work_struct *work) | |||
542 | { | 542 | { |
543 | struct usb_serial_port *port = | 543 | struct usb_serial_port *port = |
544 | container_of(work, struct usb_serial_port, work); | 544 | container_of(work, struct usb_serial_port, work); |
545 | struct tty_struct *tty; | ||
546 | 545 | ||
547 | tty = tty_port_tty_get(&port->port); | 546 | tty_port_tty_wakeup(&port->port); |
548 | if (!tty) | ||
549 | return; | ||
550 | |||
551 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); | ||
552 | |||
553 | tty_wakeup(tty); | ||
554 | tty_kref_put(tty); | ||
555 | } | 547 | } |
556 | 548 | ||
557 | static void kill_traffic(struct usb_serial_port *port) | 549 | static void kill_traffic(struct usb_serial_port *port) |
diff --git a/include/linux/amba/serial.h b/include/linux/amba/serial.h index f612c783170f..62d9303c2837 100644 --- a/include/linux/amba/serial.h +++ b/include/linux/amba/serial.h | |||
@@ -203,6 +203,9 @@ struct amba_pl011_data { | |||
203 | bool (*dma_filter)(struct dma_chan *chan, void *filter_param); | 203 | bool (*dma_filter)(struct dma_chan *chan, void *filter_param); |
204 | void *dma_rx_param; | 204 | void *dma_rx_param; |
205 | void *dma_tx_param; | 205 | void *dma_tx_param; |
206 | bool dma_rx_poll_enable; | ||
207 | unsigned int dma_rx_poll_rate; | ||
208 | unsigned int dma_rx_poll_timeout; | ||
206 | void (*init) (void); | 209 | void (*init) (void); |
207 | void (*exit) (void); | 210 | void (*exit) (void); |
208 | }; | 211 | }; |
diff --git a/include/linux/tty.h b/include/linux/tty.h index c75d886b0307..367a9dfc4ea2 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -255,9 +255,9 @@ struct tty_struct { | |||
255 | int count; | 255 | int count; |
256 | struct winsize winsize; /* termios mutex */ | 256 | struct winsize winsize; /* termios mutex */ |
257 | unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1; | 257 | unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1; |
258 | unsigned char warned:1; | ||
259 | unsigned char ctrl_status; /* ctrl_lock */ | 258 | unsigned char ctrl_status; /* ctrl_lock */ |
260 | unsigned int receive_room; /* Bytes free for queue */ | 259 | unsigned int receive_room; /* Bytes free for queue */ |
260 | int flow_change; | ||
261 | 261 | ||
262 | struct tty_struct *link; | 262 | struct tty_struct *link; |
263 | struct fasync_struct *fasync; | 263 | struct fasync_struct *fasync; |
@@ -315,9 +315,25 @@ struct tty_file_private { | |||
315 | #define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */ | 315 | #define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */ |
316 | #define TTY_HUPPED 18 /* Post driver->hangup() */ | 316 | #define TTY_HUPPED 18 /* Post driver->hangup() */ |
317 | #define TTY_HUPPING 21 /* ->hangup() in progress */ | 317 | #define TTY_HUPPING 21 /* ->hangup() in progress */ |
318 | #define TTY_LDISC_HALTED 22 /* Line discipline is halted */ | ||
318 | 319 | ||
319 | #define TTY_WRITE_FLUSH(tty) tty_write_flush((tty)) | 320 | #define TTY_WRITE_FLUSH(tty) tty_write_flush((tty)) |
320 | 321 | ||
322 | /* Values for tty->flow_change */ | ||
323 | #define TTY_THROTTLE_SAFE 1 | ||
324 | #define TTY_UNTHROTTLE_SAFE 2 | ||
325 | |||
326 | static inline void __tty_set_flow_change(struct tty_struct *tty, int val) | ||
327 | { | ||
328 | tty->flow_change = val; | ||
329 | } | ||
330 | |||
331 | static inline void tty_set_flow_change(struct tty_struct *tty, int val) | ||
332 | { | ||
333 | tty->flow_change = val; | ||
334 | smp_mb(); | ||
335 | } | ||
336 | |||
321 | #ifdef CONFIG_TTY | 337 | #ifdef CONFIG_TTY |
322 | extern void console_init(void); | 338 | extern void console_init(void); |
323 | extern void tty_kref_put(struct tty_struct *tty); | 339 | extern void tty_kref_put(struct tty_struct *tty); |
@@ -400,6 +416,8 @@ extern int tty_write_room(struct tty_struct *tty); | |||
400 | extern void tty_driver_flush_buffer(struct tty_struct *tty); | 416 | extern void tty_driver_flush_buffer(struct tty_struct *tty); |
401 | extern void tty_throttle(struct tty_struct *tty); | 417 | extern void tty_throttle(struct tty_struct *tty); |
402 | extern void tty_unthrottle(struct tty_struct *tty); | 418 | extern void tty_unthrottle(struct tty_struct *tty); |
419 | extern int tty_throttle_safe(struct tty_struct *tty); | ||
420 | extern int tty_unthrottle_safe(struct tty_struct *tty); | ||
403 | extern int tty_do_resize(struct tty_struct *tty, struct winsize *ws); | 421 | extern int tty_do_resize(struct tty_struct *tty, struct winsize *ws); |
404 | extern void tty_driver_remove_tty(struct tty_driver *driver, | 422 | extern void tty_driver_remove_tty(struct tty_driver *driver, |
405 | struct tty_struct *tty); | 423 | struct tty_struct *tty); |
@@ -419,13 +437,28 @@ extern void tty_flush_to_ldisc(struct tty_struct *tty); | |||
419 | extern void tty_buffer_free_all(struct tty_port *port); | 437 | extern void tty_buffer_free_all(struct tty_port *port); |
420 | extern void tty_buffer_flush(struct tty_struct *tty); | 438 | extern void tty_buffer_flush(struct tty_struct *tty); |
421 | extern void tty_buffer_init(struct tty_port *port); | 439 | extern void tty_buffer_init(struct tty_port *port); |
422 | extern speed_t tty_get_baud_rate(struct tty_struct *tty); | ||
423 | extern speed_t tty_termios_baud_rate(struct ktermios *termios); | 440 | extern speed_t tty_termios_baud_rate(struct ktermios *termios); |
424 | extern speed_t tty_termios_input_baud_rate(struct ktermios *termios); | 441 | extern speed_t tty_termios_input_baud_rate(struct ktermios *termios); |
425 | extern void tty_termios_encode_baud_rate(struct ktermios *termios, | 442 | extern void tty_termios_encode_baud_rate(struct ktermios *termios, |
426 | speed_t ibaud, speed_t obaud); | 443 | speed_t ibaud, speed_t obaud); |
427 | extern void tty_encode_baud_rate(struct tty_struct *tty, | 444 | extern void tty_encode_baud_rate(struct tty_struct *tty, |
428 | speed_t ibaud, speed_t obaud); | 445 | speed_t ibaud, speed_t obaud); |
446 | |||
447 | /** | ||
448 | * tty_get_baud_rate - get tty bit rates | ||
449 | * @tty: tty to query | ||
450 | * | ||
451 | * Returns the baud rate as an integer for this terminal. The | ||
452 | * termios lock must be held by the caller and the terminal bit | ||
453 | * flags may be updated. | ||
454 | * | ||
455 | * Locking: none | ||
456 | */ | ||
457 | static inline speed_t tty_get_baud_rate(struct tty_struct *tty) | ||
458 | { | ||
459 | return tty_termios_baud_rate(&tty->termios); | ||
460 | } | ||
461 | |||
429 | extern void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old); | 462 | extern void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old); |
430 | extern int tty_termios_hw_change(struct ktermios *a, struct ktermios *b); | 463 | extern int tty_termios_hw_change(struct ktermios *a, struct ktermios *b); |
431 | extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt); | 464 | extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt); |
@@ -502,6 +535,8 @@ extern int tty_port_carrier_raised(struct tty_port *port); | |||
502 | extern void tty_port_raise_dtr_rts(struct tty_port *port); | 535 | extern void tty_port_raise_dtr_rts(struct tty_port *port); |
503 | extern void tty_port_lower_dtr_rts(struct tty_port *port); | 536 | extern void tty_port_lower_dtr_rts(struct tty_port *port); |
504 | extern void tty_port_hangup(struct tty_port *port); | 537 | extern void tty_port_hangup(struct tty_port *port); |
538 | extern void tty_port_tty_hangup(struct tty_port *port, bool check_clocal); | ||
539 | extern void tty_port_tty_wakeup(struct tty_port *port); | ||
505 | extern int tty_port_block_til_ready(struct tty_port *port, | 540 | extern int tty_port_block_til_ready(struct tty_port *port, |
506 | struct tty_struct *tty, struct file *filp); | 541 | struct tty_struct *tty, struct file *filp); |
507 | extern int tty_port_close_start(struct tty_port *port, | 542 | extern int tty_port_close_start(struct tty_port *port, |
@@ -526,8 +561,6 @@ extern void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty); | |||
526 | extern void tty_ldisc_init(struct tty_struct *tty); | 561 | extern void tty_ldisc_init(struct tty_struct *tty); |
527 | extern void tty_ldisc_deinit(struct tty_struct *tty); | 562 | extern void tty_ldisc_deinit(struct tty_struct *tty); |
528 | extern void tty_ldisc_begin(void); | 563 | extern void tty_ldisc_begin(void); |
529 | /* This last one is just for the tty layer internals and shouldn't be used elsewhere */ | ||
530 | extern void tty_ldisc_enable(struct tty_struct *tty); | ||
531 | 564 | ||
532 | 565 | ||
533 | /* n_tty.c */ | 566 | /* n_tty.c */ |
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h index 455a0d7bf220..58390c73df8b 100644 --- a/include/linux/tty_ldisc.h +++ b/include/linux/tty_ldisc.h | |||
@@ -9,89 +9,89 @@ | |||
9 | * | 9 | * |
10 | * int (*open)(struct tty_struct *); | 10 | * int (*open)(struct tty_struct *); |
11 | * | 11 | * |
12 | * This function is called when the line discipline is associated | 12 | * This function is called when the line discipline is associated |
13 | * with the tty. The line discipline can use this as an | 13 | * with the tty. The line discipline can use this as an |
14 | * opportunity to initialize any state needed by the ldisc routines. | 14 | * opportunity to initialize any state needed by the ldisc routines. |
15 | * | 15 | * |
16 | * void (*close)(struct tty_struct *); | 16 | * void (*close)(struct tty_struct *); |
17 | * | 17 | * |
18 | * This function is called when the line discipline is being | 18 | * This function is called when the line discipline is being |
19 | * shutdown, either because the tty is being closed or because | 19 | * shutdown, either because the tty is being closed or because |
20 | * the tty is being changed to use a new line discipline | 20 | * the tty is being changed to use a new line discipline |
21 | * | 21 | * |
22 | * void (*flush_buffer)(struct tty_struct *tty); | 22 | * void (*flush_buffer)(struct tty_struct *tty); |
23 | * | 23 | * |
24 | * This function instructs the line discipline to clear its | 24 | * This function instructs the line discipline to clear its |
25 | * buffers of any input characters it may have queued to be | 25 | * buffers of any input characters it may have queued to be |
26 | * delivered to the user mode process. | 26 | * delivered to the user mode process. |
27 | * | 27 | * |
28 | * ssize_t (*chars_in_buffer)(struct tty_struct *tty); | 28 | * ssize_t (*chars_in_buffer)(struct tty_struct *tty); |
29 | * | 29 | * |
30 | * This function returns the number of input characters the line | 30 | * This function returns the number of input characters the line |
31 | * discipline may have queued up to be delivered to the user mode | 31 | * discipline may have queued up to be delivered to the user mode |
32 | * process. | 32 | * process. |
33 | * | 33 | * |
34 | * ssize_t (*read)(struct tty_struct * tty, struct file * file, | 34 | * ssize_t (*read)(struct tty_struct * tty, struct file * file, |
35 | * unsigned char * buf, size_t nr); | 35 | * unsigned char * buf, size_t nr); |
36 | * | 36 | * |
37 | * This function is called when the user requests to read from | 37 | * This function is called when the user requests to read from |
38 | * the tty. The line discipline will return whatever characters | 38 | * the tty. The line discipline will return whatever characters |
39 | * it has buffered up for the user. If this function is not | 39 | * it has buffered up for the user. If this function is not |
40 | * defined, the user will receive an EIO error. | 40 | * defined, the user will receive an EIO error. |
41 | * | 41 | * |
42 | * ssize_t (*write)(struct tty_struct * tty, struct file * file, | 42 | * ssize_t (*write)(struct tty_struct * tty, struct file * file, |
43 | * const unsigned char * buf, size_t nr); | 43 | * const unsigned char * buf, size_t nr); |
44 | * | 44 | * |
45 | * This function is called when the user requests to write to the | 45 | * This function is called when the user requests to write to the |
46 | * tty. The line discipline will deliver the characters to the | 46 | * tty. The line discipline will deliver the characters to the |
47 | * low-level tty device for transmission, optionally performing | 47 | * low-level tty device for transmission, optionally performing |
48 | * some processing on the characters first. If this function is | 48 | * some processing on the characters first. If this function is |
49 | * not defined, the user will receive an EIO error. | 49 | * not defined, the user will receive an EIO error. |
50 | * | 50 | * |
51 | * int (*ioctl)(struct tty_struct * tty, struct file * file, | 51 | * int (*ioctl)(struct tty_struct * tty, struct file * file, |
52 | * unsigned int cmd, unsigned long arg); | 52 | * unsigned int cmd, unsigned long arg); |
53 | * | 53 | * |
54 | * This function is called when the user requests an ioctl which | 54 | * This function is called when the user requests an ioctl which |
55 | * is not handled by the tty layer or the low-level tty driver. | 55 | * is not handled by the tty layer or the low-level tty driver. |
56 | * It is intended for ioctls which affect line discpline | 56 | * It is intended for ioctls which affect line discpline |
57 | * operation. Note that the search order for ioctls is (1) tty | 57 | * operation. Note that the search order for ioctls is (1) tty |
58 | * layer, (2) tty low-level driver, (3) line discpline. So a | 58 | * layer, (2) tty low-level driver, (3) line discpline. So a |
59 | * low-level driver can "grab" an ioctl request before the line | 59 | * low-level driver can "grab" an ioctl request before the line |
60 | * discpline has a chance to see it. | 60 | * discpline has a chance to see it. |
61 | * | 61 | * |
62 | * long (*compat_ioctl)(struct tty_struct * tty, struct file * file, | 62 | * long (*compat_ioctl)(struct tty_struct * tty, struct file * file, |
63 | * unsigned int cmd, unsigned long arg); | 63 | * unsigned int cmd, unsigned long arg); |
64 | * | 64 | * |
65 | * Process ioctl calls from 32-bit process on 64-bit system | 65 | * Process ioctl calls from 32-bit process on 64-bit system |
66 | * | 66 | * |
67 | * void (*set_termios)(struct tty_struct *tty, struct ktermios * old); | 67 | * void (*set_termios)(struct tty_struct *tty, struct ktermios * old); |
68 | * | 68 | * |
69 | * This function notifies the line discpline that a change has | 69 | * This function notifies the line discpline that a change has |
70 | * been made to the termios structure. | 70 | * been made to the termios structure. |
71 | * | 71 | * |
72 | * int (*poll)(struct tty_struct * tty, struct file * file, | 72 | * int (*poll)(struct tty_struct * tty, struct file * file, |
73 | * poll_table *wait); | 73 | * poll_table *wait); |
74 | * | 74 | * |
75 | * This function is called when a user attempts to select/poll on a | 75 | * This function is called when a user attempts to select/poll on a |
76 | * tty device. It is solely the responsibility of the line | 76 | * tty device. It is solely the responsibility of the line |
77 | * discipline to handle poll requests. | 77 | * discipline to handle poll requests. |
78 | * | 78 | * |
79 | * void (*receive_buf)(struct tty_struct *, const unsigned char *cp, | 79 | * void (*receive_buf)(struct tty_struct *, const unsigned char *cp, |
80 | * char *fp, int count); | 80 | * char *fp, int count); |
81 | * | 81 | * |
82 | * This function is called by the low-level tty driver to send | 82 | * This function is called by the low-level tty driver to send |
83 | * characters received by the hardware to the line discpline for | 83 | * characters received by the hardware to the line discpline for |
84 | * processing. <cp> is a pointer to the buffer of input | 84 | * processing. <cp> is a pointer to the buffer of input |
85 | * character received by the device. <fp> is a pointer to a | 85 | * character received by the device. <fp> is a pointer to a |
86 | * pointer of flag bytes which indicate whether a character was | 86 | * pointer of flag bytes which indicate whether a character was |
87 | * received with a parity error, etc. | 87 | * received with a parity error, etc. |
88 | * | 88 | * |
89 | * void (*write_wakeup)(struct tty_struct *); | 89 | * void (*write_wakeup)(struct tty_struct *); |
90 | * | 90 | * |
91 | * This function is called by the low-level tty driver to signal | 91 | * This function is called by the low-level tty driver to signal |
92 | * that line discpline should try to send more characters to the | 92 | * that line discpline should try to send more characters to the |
93 | * low-level driver for transmission. If the line discpline does | 93 | * low-level driver for transmission. If the line discpline does |
94 | * not have any more data to send, it can just return. | 94 | * not have any more data to send, it can just return. |
95 | * | 95 | * |
96 | * int (*hangup)(struct tty_struct *) | 96 | * int (*hangup)(struct tty_struct *) |
97 | * | 97 | * |
@@ -115,7 +115,7 @@ struct tty_ldisc_ops { | |||
115 | char *name; | 115 | char *name; |
116 | int num; | 116 | int num; |
117 | int flags; | 117 | int flags; |
118 | 118 | ||
119 | /* | 119 | /* |
120 | * The following routines are called from above. | 120 | * The following routines are called from above. |
121 | */ | 121 | */ |
@@ -123,19 +123,19 @@ struct tty_ldisc_ops { | |||
123 | void (*close)(struct tty_struct *); | 123 | void (*close)(struct tty_struct *); |
124 | void (*flush_buffer)(struct tty_struct *tty); | 124 | void (*flush_buffer)(struct tty_struct *tty); |
125 | ssize_t (*chars_in_buffer)(struct tty_struct *tty); | 125 | ssize_t (*chars_in_buffer)(struct tty_struct *tty); |
126 | ssize_t (*read)(struct tty_struct * tty, struct file * file, | 126 | ssize_t (*read)(struct tty_struct *tty, struct file *file, |
127 | unsigned char __user * buf, size_t nr); | 127 | unsigned char __user *buf, size_t nr); |
128 | ssize_t (*write)(struct tty_struct * tty, struct file * file, | 128 | ssize_t (*write)(struct tty_struct *tty, struct file *file, |
129 | const unsigned char * buf, size_t nr); | 129 | const unsigned char *buf, size_t nr); |
130 | int (*ioctl)(struct tty_struct * tty, struct file * file, | 130 | int (*ioctl)(struct tty_struct *tty, struct file *file, |
131 | unsigned int cmd, unsigned long arg); | 131 | unsigned int cmd, unsigned long arg); |
132 | long (*compat_ioctl)(struct tty_struct * tty, struct file * file, | 132 | long (*compat_ioctl)(struct tty_struct *tty, struct file *file, |
133 | unsigned int cmd, unsigned long arg); | 133 | unsigned int cmd, unsigned long arg); |
134 | void (*set_termios)(struct tty_struct *tty, struct ktermios * old); | 134 | void (*set_termios)(struct tty_struct *tty, struct ktermios *old); |
135 | unsigned int (*poll)(struct tty_struct *, struct file *, | 135 | unsigned int (*poll)(struct tty_struct *, struct file *, |
136 | struct poll_table_struct *); | 136 | struct poll_table_struct *); |
137 | int (*hangup)(struct tty_struct *tty); | 137 | int (*hangup)(struct tty_struct *tty); |
138 | 138 | ||
139 | /* | 139 | /* |
140 | * The following routines are called from below. | 140 | * The following routines are called from below. |
141 | */ | 141 | */ |
@@ -145,7 +145,7 @@ struct tty_ldisc_ops { | |||
145 | void (*dcd_change)(struct tty_struct *, unsigned int); | 145 | void (*dcd_change)(struct tty_struct *, unsigned int); |
146 | 146 | ||
147 | struct module *owner; | 147 | struct module *owner; |
148 | 148 | ||
149 | int refcount; | 149 | int refcount; |
150 | }; | 150 | }; |
151 | 151 | ||
diff --git a/net/irda/ircomm/ircomm_tty_attach.c b/net/irda/ircomm/ircomm_tty_attach.c index edab393e0c82..a2a508f5f268 100644 --- a/net/irda/ircomm/ircomm_tty_attach.c +++ b/net/irda/ircomm/ircomm_tty_attach.c | |||
@@ -997,12 +997,8 @@ static int ircomm_tty_state_ready(struct ircomm_tty_cb *self, | |||
997 | self->settings.dce = IRCOMM_DELTA_CD; | 997 | self->settings.dce = IRCOMM_DELTA_CD; |
998 | ircomm_tty_check_modem_status(self); | 998 | ircomm_tty_check_modem_status(self); |
999 | } else { | 999 | } else { |
1000 | struct tty_struct *tty = tty_port_tty_get(&self->port); | ||
1001 | IRDA_DEBUG(0, "%s(), hanging up!\n", __func__ ); | 1000 | IRDA_DEBUG(0, "%s(), hanging up!\n", __func__ ); |
1002 | if (tty) { | 1001 | tty_port_tty_hangup(&self->port, false); |
1003 | tty_hangup(tty); | ||
1004 | tty_kref_put(tty); | ||
1005 | } | ||
1006 | } | 1002 | } |
1007 | break; | 1003 | break; |
1008 | default: | 1004 | default: |