diff options
author | Jiri Slaby <jslaby@suse.cz> | 2013-01-03 09:53:06 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-16 01:30:15 -0500 |
commit | 2e124b4a390ca85325fae75764bef92f0547fa25 (patch) | |
tree | 5519fbcdbe954e79b271ea6d31ac5a4dc754c4f5 | |
parent | d6c53c0e9bd0a83f9f9ddbc9fd80141a54d83896 (diff) |
TTY: switch tty_flip_buffer_push
Now, we start converting tty buffer functions to actually use
tty_port. This will allow us to get rid of the need of tty in many
call sites. Only tty_port will needed and hence no more
tty_port_tty_get in those paths.
Now, the one where most of tty_port_tty_get gets removed:
tty_flip_buffer_push.
IOW we also closed all the races in drivers not using tty_port_tty_get
at all yet.
Also we move tty_flip_buffer_push declaration from include/linux/tty.h
to include/linux/tty_flip.h to all others while we are changing it
anyway.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
146 files changed, 446 insertions, 988 deletions
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c index 942022a5bc86..da2f319fb71d 100644 --- a/arch/ia64/hp/sim/simserial.c +++ b/arch/ia64/hp/sim/simserial.c | |||
@@ -53,9 +53,8 @@ struct tty_driver *hp_simserial_driver; | |||
53 | 53 | ||
54 | static struct console *console; | 54 | static struct console *console; |
55 | 55 | ||
56 | static void receive_chars(struct tty_struct *tty) | 56 | static void receive_chars(struct tty_port *port) |
57 | { | 57 | { |
58 | struct tty_port *port = tty->port; | ||
59 | unsigned char ch; | 58 | unsigned char ch; |
60 | static unsigned char seen_esc = 0; | 59 | static unsigned char seen_esc = 0; |
61 | 60 | ||
@@ -85,7 +84,7 @@ static void receive_chars(struct tty_struct *tty) | |||
85 | if (tty_insert_flip_char(port, ch, TTY_NORMAL) == 0) | 84 | if (tty_insert_flip_char(port, ch, TTY_NORMAL) == 0) |
86 | break; | 85 | break; |
87 | } | 86 | } |
88 | tty_flip_buffer_push(tty); | 87 | tty_flip_buffer_push(port); |
89 | } | 88 | } |
90 | 89 | ||
91 | /* | 90 | /* |
@@ -94,18 +93,9 @@ static void receive_chars(struct tty_struct *tty) | |||
94 | static irqreturn_t rs_interrupt_single(int irq, void *dev_id) | 93 | static irqreturn_t rs_interrupt_single(int irq, void *dev_id) |
95 | { | 94 | { |
96 | struct serial_state *info = dev_id; | 95 | struct serial_state *info = dev_id; |
97 | struct tty_struct *tty = tty_port_tty_get(&info->port); | ||
98 | 96 | ||
99 | if (!tty) { | 97 | receive_chars(&info->port); |
100 | printk(KERN_INFO "%s: tty=0 problem\n", __func__); | 98 | |
101 | return IRQ_NONE; | ||
102 | } | ||
103 | /* | ||
104 | * pretty simple in our case, because we only get interrupts | ||
105 | * on inbound traffic | ||
106 | */ | ||
107 | receive_chars(tty); | ||
108 | tty_kref_put(tty); | ||
109 | return IRQ_HANDLED; | 99 | return IRQ_HANDLED; |
110 | } | 100 | } |
111 | 101 | ||
diff --git a/arch/mn10300/kernel/mn10300-serial.c b/arch/mn10300/kernel/mn10300-serial.c index ae61bd692b4b..1dd20dbfd098 100644 --- a/arch/mn10300/kernel/mn10300-serial.c +++ b/arch/mn10300/kernel/mn10300-serial.c | |||
@@ -525,7 +525,6 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port) | |||
525 | { | 525 | { |
526 | struct uart_icount *icount = &port->uart.icount; | 526 | struct uart_icount *icount = &port->uart.icount; |
527 | struct tty_port *port = &port->uart.state->port; | 527 | struct tty_port *port = &port->uart.state->port; |
528 | struct tty_struct *tty = port->tty; | ||
529 | unsigned ix; | 528 | unsigned ix; |
530 | int count; | 529 | int count; |
531 | u8 st, ch, push, status, overrun; | 530 | u8 st, ch, push, status, overrun; |
@@ -538,7 +537,7 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port) | |||
538 | count = tty_buffer_request_room(port, count); | 537 | count = tty_buffer_request_room(port, count); |
539 | if (count == 0) { | 538 | if (count == 0) { |
540 | if (!port->low_latency) | 539 | if (!port->low_latency) |
541 | tty_flip_buffer_push(tty); | 540 | tty_flip_buffer_push(port); |
542 | return; | 541 | return; |
543 | } | 542 | } |
544 | 543 | ||
@@ -547,7 +546,7 @@ try_again: | |||
547 | ix = ACCESS_ONCE(port->rx_outp); | 546 | ix = ACCESS_ONCE(port->rx_outp); |
548 | if (CIRC_CNT(port->rx_inp, ix, MNSC_BUFFER_SIZE) == 0) { | 547 | if (CIRC_CNT(port->rx_inp, ix, MNSC_BUFFER_SIZE) == 0) { |
549 | if (push && !port->low_latency) | 548 | if (push && !port->low_latency) |
550 | tty_flip_buffer_push(tty); | 549 | tty_flip_buffer_push(port); |
551 | return; | 550 | return; |
552 | } | 551 | } |
553 | 552 | ||
@@ -679,7 +678,7 @@ insert: | |||
679 | count--; | 678 | count--; |
680 | if (count <= 0) { | 679 | if (count <= 0) { |
681 | if (!port->low_latency) | 680 | if (!port->low_latency) |
682 | tty_flip_buffer_push(tty); | 681 | tty_flip_buffer_push(port); |
683 | return; | 682 | return; |
684 | } | 683 | } |
685 | 684 | ||
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c index 4d92a379eb21..d5cae55195ec 100644 --- a/arch/parisc/kernel/pdc_cons.c +++ b/arch/parisc/kernel/pdc_cons.c | |||
@@ -138,10 +138,6 @@ static const struct tty_operations pdc_console_tty_ops = { | |||
138 | static void pdc_console_poll(unsigned long unused) | 138 | static void pdc_console_poll(unsigned long unused) |
139 | { | 139 | { |
140 | int data, count = 0; | 140 | int data, count = 0; |
141 | struct tty_struct *tty = tty_port_tty_get(&tty_port); | ||
142 | |||
143 | if (!tty) | ||
144 | return; | ||
145 | 141 | ||
146 | while (1) { | 142 | while (1) { |
147 | data = pdc_console_poll_key(NULL); | 143 | data = pdc_console_poll_key(NULL); |
@@ -152,9 +148,7 @@ static void pdc_console_poll(unsigned long unused) | |||
152 | } | 148 | } |
153 | 149 | ||
154 | if (count) | 150 | if (count) |
155 | tty_flip_buffer_push(tty); | 151 | tty_flip_buffer_push(&tty_port); |
156 | |||
157 | tty_kref_put(tty); | ||
158 | 152 | ||
159 | if (pdc_cons.flags & CON_ENABLED) | 153 | if (pdc_cons.flags & CON_ENABLED) |
160 | mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY); | 154 | mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY); |
diff --git a/arch/um/drivers/chan.h b/arch/um/drivers/chan.h index 02b5a76e98d9..78f1b8999964 100644 --- a/arch/um/drivers/chan.h +++ b/arch/um/drivers/chan.h | |||
@@ -27,8 +27,7 @@ struct chan { | |||
27 | void *data; | 27 | void *data; |
28 | }; | 28 | }; |
29 | 29 | ||
30 | extern void chan_interrupt(struct line *line, | 30 | extern void chan_interrupt(struct line *line, int irq); |
31 | struct tty_struct *tty, int irq); | ||
32 | extern int parse_chan_pair(char *str, struct line *line, int device, | 31 | extern int parse_chan_pair(char *str, struct line *line, int device, |
33 | const struct chan_opts *opts, char **error_out); | 32 | const struct chan_opts *opts, char **error_out); |
34 | extern int write_chan(struct chan *chan, const char *buf, int len, | 33 | extern int write_chan(struct chan *chan, const char *buf, int len, |
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index 795bd8102205..15c553c239a1 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c | |||
@@ -131,11 +131,9 @@ void chan_enable_winch(struct chan *chan, struct tty_struct *tty) | |||
131 | static void line_timer_cb(struct work_struct *work) | 131 | static void line_timer_cb(struct work_struct *work) |
132 | { | 132 | { |
133 | struct line *line = container_of(work, struct line, task.work); | 133 | struct line *line = container_of(work, struct line, task.work); |
134 | struct tty_struct *tty = tty_port_tty_get(&line->port); | ||
135 | 134 | ||
136 | if (!line->throttled) | 135 | if (!line->throttled) |
137 | chan_interrupt(line, tty, line->driver->read_irq); | 136 | chan_interrupt(line, line->driver->read_irq); |
138 | tty_kref_put(tty); | ||
139 | } | 137 | } |
140 | 138 | ||
141 | int enable_chan(struct line *line) | 139 | int enable_chan(struct line *line) |
@@ -546,7 +544,7 @@ int parse_chan_pair(char *str, struct line *line, int device, | |||
546 | return 0; | 544 | return 0; |
547 | } | 545 | } |
548 | 546 | ||
549 | void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) | 547 | void chan_interrupt(struct line *line, int irq) |
550 | { | 548 | { |
551 | struct tty_port *port = &line->port; | 549 | struct tty_port *port = &line->port; |
552 | struct chan *chan = line->chan_in; | 550 | struct chan *chan = line->chan_in; |
@@ -570,8 +568,11 @@ void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) | |||
570 | reactivate_fd(chan->fd, irq); | 568 | reactivate_fd(chan->fd, irq); |
571 | if (err == -EIO) { | 569 | if (err == -EIO) { |
572 | if (chan->primary) { | 570 | if (chan->primary) { |
573 | if (tty != NULL) | 571 | struct tty_struct *tty = tty_port_tty_get(&line->port); |
572 | if (tty != NULL) { | ||
574 | tty_hangup(tty); | 573 | tty_hangup(tty); |
574 | tty_kref_put(tty); | ||
575 | } | ||
575 | if (line->chan_out != chan) | 576 | if (line->chan_out != chan) |
576 | close_one_chan(line->chan_out, 1); | 577 | close_one_chan(line->chan_out, 1); |
577 | } | 578 | } |
@@ -580,6 +581,5 @@ void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) | |||
580 | return; | 581 | return; |
581 | } | 582 | } |
582 | out: | 583 | out: |
583 | if (tty) | 584 | tty_flip_buffer_push(port); |
584 | tty_flip_buffer_push(tty); | ||
585 | } | 585 | } |
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index 9ffc28bd4b7a..f1b38571f94e 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c | |||
@@ -19,11 +19,10 @@ static irqreturn_t line_interrupt(int irq, void *data) | |||
19 | { | 19 | { |
20 | struct chan *chan = data; | 20 | struct chan *chan = data; |
21 | struct line *line = chan->line; | 21 | struct line *line = chan->line; |
22 | struct tty_struct *tty = tty_port_tty_get(&line->port); | ||
23 | 22 | ||
24 | if (line) | 23 | if (line) |
25 | chan_interrupt(line, tty, irq); | 24 | chan_interrupt(line, irq); |
26 | tty_kref_put(tty); | 25 | |
27 | return IRQ_HANDLED; | 26 | return IRQ_HANDLED; |
28 | } | 27 | } |
29 | 28 | ||
@@ -234,7 +233,7 @@ void line_unthrottle(struct tty_struct *tty) | |||
234 | struct line *line = tty->driver_data; | 233 | struct line *line = tty->driver_data; |
235 | 234 | ||
236 | line->throttled = 0; | 235 | line->throttled = 0; |
237 | chan_interrupt(line, tty, line->driver->read_irq); | 236 | chan_interrupt(line, line->driver->read_irq); |
238 | 237 | ||
239 | /* | 238 | /* |
240 | * Maybe there is enough stuff pending that calling the interrupt | 239 | * Maybe there is enough stuff pending that calling the interrupt |
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index 62447d63890c..da9866f7fecf 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c | |||
@@ -58,7 +58,8 @@ static int rs_open(struct tty_struct *tty, struct file * filp) | |||
58 | tty->port = &serial_port; | 58 | tty->port = &serial_port; |
59 | spin_lock(&timer_lock); | 59 | spin_lock(&timer_lock); |
60 | if (tty->count == 1) { | 60 | if (tty->count == 1) { |
61 | setup_timer(&serial_timer, rs_poll, (unsigned long)tty); | 61 | setup_timer(&serial_timer, rs_poll, |
62 | (unsigned long)&serial_port); | ||
62 | mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); | 63 | mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); |
63 | } | 64 | } |
64 | spin_unlock(&timer_lock); | 65 | spin_unlock(&timer_lock); |
@@ -97,9 +98,7 @@ static int rs_write(struct tty_struct * tty, | |||
97 | 98 | ||
98 | static void rs_poll(unsigned long priv) | 99 | static void rs_poll(unsigned long priv) |
99 | { | 100 | { |
100 | struct tty_struct* tty = (struct tty_struct*) priv; | 101 | struct tty_port *port = (struct tty_port *)priv; |
101 | struct tty_port *port = tty->port; | ||
102 | |||
103 | struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; | 102 | struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; |
104 | int i = 0; | 103 | int i = 0; |
105 | unsigned char c; | 104 | unsigned char c; |
@@ -113,7 +112,7 @@ static void rs_poll(unsigned long priv) | |||
113 | } | 112 | } |
114 | 113 | ||
115 | if (i) | 114 | if (i) |
116 | tty_flip_buffer_push(tty); | 115 | tty_flip_buffer_push(port); |
117 | 116 | ||
118 | 117 | ||
119 | mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); | 118 | mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); |
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 92dc7327c7aa..f334aec65fc7 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -886,7 +886,7 @@ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom) | |||
886 | issue_command(info, CHA, CMD_RXFIFO); | 886 | issue_command(info, CHA, CMD_RXFIFO); |
887 | } | 887 | } |
888 | 888 | ||
889 | static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) | 889 | static void rx_ready_async(MGSLPC_INFO *info, int tcd) |
890 | { | 890 | { |
891 | struct tty_port *port = &info->port; | 891 | struct tty_port *port = &info->port; |
892 | unsigned char data, status, flag; | 892 | unsigned char data, status, flag; |
@@ -894,14 +894,6 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) | |||
894 | int work = 0; | 894 | int work = 0; |
895 | struct mgsl_icount *icount = &info->icount; | 895 | struct mgsl_icount *icount = &info->icount; |
896 | 896 | ||
897 | if (!tty) { | ||
898 | /* tty is not available anymore */ | ||
899 | issue_command(info, CHA, CMD_RXRESET); | ||
900 | if (debug_level >= DEBUG_LEVEL_ISR) | ||
901 | printk("%s(%d):rx_ready_async(tty=NULL)\n",__FILE__,__LINE__); | ||
902 | return; | ||
903 | } | ||
904 | |||
905 | if (tcd) { | 897 | if (tcd) { |
906 | /* early termination, get FIFO count from RBCL register */ | 898 | /* early termination, get FIFO count from RBCL register */ |
907 | fifo_count = (unsigned char)(read_reg(info, CHA+RBCL) & 0x1f); | 899 | fifo_count = (unsigned char)(read_reg(info, CHA+RBCL) & 0x1f); |
@@ -958,7 +950,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) | |||
958 | } | 950 | } |
959 | 951 | ||
960 | if (work) | 952 | if (work) |
961 | tty_flip_buffer_push(tty); | 953 | tty_flip_buffer_push(port); |
962 | } | 954 | } |
963 | 955 | ||
964 | 956 | ||
@@ -1218,7 +1210,7 @@ static irqreturn_t mgslpc_isr(int dummy, void *dev_id) | |||
1218 | if (info->params.mode == MGSL_MODE_HDLC) | 1210 | if (info->params.mode == MGSL_MODE_HDLC) |
1219 | rx_ready_hdlc(info, isr & IRQ_RXEOM); | 1211 | rx_ready_hdlc(info, isr & IRQ_RXEOM); |
1220 | else | 1212 | else |
1221 | rx_ready_async(info, isr & IRQ_RXEOM, tty); | 1213 | rx_ready_async(info, isr & IRQ_RXEOM); |
1222 | } | 1214 | } |
1223 | 1215 | ||
1224 | /* transmit IRQs */ | 1216 | /* transmit IRQs */ |
diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c index 8e0ed663ba9b..ab20a0851dd2 100644 --- a/drivers/ipack/devices/ipoctal.c +++ b/drivers/ipack/devices/ipoctal.c | |||
@@ -133,8 +133,7 @@ static int ipoctal_get_icount(struct tty_struct *tty, | |||
133 | return 0; | 133 | return 0; |
134 | } | 134 | } |
135 | 135 | ||
136 | static void ipoctal_irq_rx(struct ipoctal_channel *channel, | 136 | static void ipoctal_irq_rx(struct ipoctal_channel *channel, u8 sr) |
137 | struct tty_struct *tty, u8 sr) | ||
138 | { | 137 | { |
139 | struct tty_port *port = &channel->tty_port; | 138 | struct tty_port *port = &channel->tty_port; |
140 | unsigned char value; | 139 | unsigned char value; |
@@ -176,7 +175,7 @@ static void ipoctal_irq_rx(struct ipoctal_channel *channel, | |||
176 | sr = ioread8(&channel->regs->r.sr); | 175 | sr = ioread8(&channel->regs->r.sr); |
177 | } while (isr & channel->isr_rx_rdy_mask); | 176 | } while (isr & channel->isr_rx_rdy_mask); |
178 | 177 | ||
179 | tty_flip_buffer_push(tty); | 178 | tty_flip_buffer_push(port); |
180 | } | 179 | } |
181 | 180 | ||
182 | static void ipoctal_irq_tx(struct ipoctal_channel *channel) | 181 | static void ipoctal_irq_tx(struct ipoctal_channel *channel) |
@@ -209,15 +208,11 @@ static void ipoctal_irq_tx(struct ipoctal_channel *channel) | |||
209 | static void ipoctal_irq_channel(struct ipoctal_channel *channel) | 208 | static void ipoctal_irq_channel(struct ipoctal_channel *channel) |
210 | { | 209 | { |
211 | u8 isr, sr; | 210 | u8 isr, sr; |
212 | struct tty_struct *tty; | ||
213 | 211 | ||
214 | /* If there is no client, skip the check */ | 212 | /* If there is no client, skip the check */ |
215 | if (!atomic_read(&channel->open)) | 213 | if (!atomic_read(&channel->open)) |
216 | return; | 214 | return; |
217 | 215 | ||
218 | tty = tty_port_tty_get(&channel->tty_port); | ||
219 | if (!tty) | ||
220 | return; | ||
221 | /* The HW is organized in pair of channels. See which register we need | 216 | /* The HW is organized in pair of channels. See which register we need |
222 | * to read from */ | 217 | * to read from */ |
223 | isr = ioread8(&channel->block_regs->r.isr); | 218 | isr = ioread8(&channel->block_regs->r.isr); |
@@ -236,14 +231,13 @@ static void ipoctal_irq_channel(struct ipoctal_channel *channel) | |||
236 | 231 | ||
237 | /* RX data */ | 232 | /* RX data */ |
238 | if ((isr & channel->isr_rx_rdy_mask) && (sr & SR_RX_READY)) | 233 | if ((isr & channel->isr_rx_rdy_mask) && (sr & SR_RX_READY)) |
239 | ipoctal_irq_rx(channel, tty, sr); | 234 | ipoctal_irq_rx(channel, sr); |
240 | 235 | ||
241 | /* TX of each character */ | 236 | /* TX of each character */ |
242 | if ((isr & channel->isr_tx_rdy_mask) && (sr & SR_TX_READY)) | 237 | if ((isr & channel->isr_tx_rdy_mask) && (sr & SR_TX_READY)) |
243 | ipoctal_irq_tx(channel); | 238 | ipoctal_irq_tx(channel); |
244 | 239 | ||
245 | tty_flip_buffer_push(tty); | 240 | tty_flip_buffer_push(&channel->tty_port); |
246 | tty_kref_put(tty); | ||
247 | } | 241 | } |
248 | 242 | ||
249 | static irqreturn_t ipoctal_irq_handler(void *arg) | 243 | static irqreturn_t ipoctal_irq_handler(void *arg) |
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index 6dcecd40a819..0fbf4f215d86 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c | |||
@@ -562,16 +562,8 @@ void gigaset_if_free(struct cardstate *cs) | |||
562 | void gigaset_if_receive(struct cardstate *cs, | 562 | void gigaset_if_receive(struct cardstate *cs, |
563 | unsigned char *buffer, size_t len) | 563 | unsigned char *buffer, size_t len) |
564 | { | 564 | { |
565 | struct tty_struct *tty = tty_port_tty_get(&cs->port); | ||
566 | |||
567 | if (tty == NULL) { | ||
568 | gig_dbg(DEBUG_IF, "receive on closed device"); | ||
569 | return; | ||
570 | } | ||
571 | |||
572 | tty_insert_flip_string(&cs->port, buffer, len); | 565 | tty_insert_flip_string(&cs->port, buffer, len); |
573 | tty_flip_buffer_push(tty); | 566 | tty_flip_buffer_push(&cs->port); |
574 | tty_kref_put(tty); | ||
575 | } | 567 | } |
576 | EXPORT_SYMBOL_GPL(gigaset_if_receive); | 568 | EXPORT_SYMBOL_GPL(gigaset_if_receive); |
577 | 569 | ||
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 9bb9986659e4..d8a7d8323414 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c | |||
@@ -63,16 +63,11 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb) | |||
63 | struct tty_port *port = &info->port; | 63 | struct tty_port *port = &info->port; |
64 | int c; | 64 | int c; |
65 | int len; | 65 | int len; |
66 | struct tty_struct *tty; | ||
67 | char last; | 66 | char last; |
68 | 67 | ||
69 | if (!info->online) | 68 | if (!info->online) |
70 | return 0; | 69 | return 0; |
71 | 70 | ||
72 | tty = port->tty; | ||
73 | if (!tty) | ||
74 | return 0; | ||
75 | |||
76 | if (!(info->mcr & UART_MCR_RTS)) | 71 | if (!(info->mcr & UART_MCR_RTS)) |
77 | return 0; | 72 | return 0; |
78 | 73 | ||
@@ -110,7 +105,7 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb) | |||
110 | tty_insert_flip_char(port, last, 0xFF); | 105 | tty_insert_flip_char(port, last, 0xFF); |
111 | else | 106 | else |
112 | tty_insert_flip_char(port, last, TTY_NORMAL); | 107 | tty_insert_flip_char(port, last, TTY_NORMAL); |
113 | tty_flip_buffer_push(tty); | 108 | tty_flip_buffer_push(port); |
114 | kfree_skb(skb); | 109 | kfree_skb(skb); |
115 | 110 | ||
116 | return 1; | 111 | return 1; |
@@ -127,7 +122,6 @@ isdn_tty_readmodem(void) | |||
127 | int midx; | 122 | int midx; |
128 | int i; | 123 | int i; |
129 | int r; | 124 | int r; |
130 | struct tty_struct *tty; | ||
131 | modem_info *info; | 125 | modem_info *info; |
132 | 126 | ||
133 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { | 127 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { |
@@ -145,20 +139,21 @@ isdn_tty_readmodem(void) | |||
145 | if ((info->vonline & 1) && (info->emu.vpar[1])) | 139 | if ((info->vonline & 1) && (info->emu.vpar[1])) |
146 | isdn_audio_eval_silence(info); | 140 | isdn_audio_eval_silence(info); |
147 | #endif | 141 | #endif |
148 | tty = info->port.tty; | 142 | if (info->mcr & UART_MCR_RTS) { |
149 | if (tty) { | 143 | /* CISCO AsyncPPP Hack */ |
150 | if (info->mcr & UART_MCR_RTS) { | 144 | if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) |
151 | /* CISCO AsyncPPP Hack */ | 145 | r = isdn_readbchan_tty(info->isdn_driver, |
152 | if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) | 146 | info->isdn_channel, |
153 | r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, &info->port, 0); | 147 | &info->port, 0); |
154 | else | 148 | else |
155 | r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, &info->port, 1); | 149 | r = isdn_readbchan_tty(info->isdn_driver, |
156 | if (r) | 150 | info->isdn_channel, |
157 | tty_flip_buffer_push(tty); | 151 | &info->port, 1); |
158 | } else | 152 | if (r) |
159 | r = 1; | 153 | tty_flip_buffer_push(&info->port); |
160 | } else | 154 | } else |
161 | r = 1; | 155 | r = 1; |
156 | |||
162 | if (r) { | 157 | if (r) { |
163 | info->rcvsched = 0; | 158 | info->rcvsched = 0; |
164 | resched = 1; | 159 | resched = 1; |
@@ -2230,7 +2225,6 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) | |||
2230 | void | 2225 | void |
2231 | isdn_tty_at_cout(char *msg, modem_info *info) | 2226 | isdn_tty_at_cout(char *msg, modem_info *info) |
2232 | { | 2227 | { |
2233 | struct tty_struct *tty; | ||
2234 | struct tty_port *port = &info->port; | 2228 | struct tty_port *port = &info->port; |
2235 | atemu *m = &info->emu; | 2229 | atemu *m = &info->emu; |
2236 | char *p; | 2230 | char *p; |
@@ -2248,8 +2242,7 @@ isdn_tty_at_cout(char *msg, modem_info *info) | |||
2248 | l = strlen(msg); | 2242 | l = strlen(msg); |
2249 | 2243 | ||
2250 | spin_lock_irqsave(&info->readlock, flags); | 2244 | spin_lock_irqsave(&info->readlock, flags); |
2251 | tty = port->tty; | 2245 | if (port->flags & ASYNC_CLOSING) { |
2252 | if ((port->flags & ASYNC_CLOSING) || (!tty)) { | ||
2253 | spin_unlock_irqrestore(&info->readlock, flags); | 2246 | spin_unlock_irqrestore(&info->readlock, flags); |
2254 | return; | 2247 | return; |
2255 | } | 2248 | } |
@@ -2301,7 +2294,7 @@ isdn_tty_at_cout(char *msg, modem_info *info) | |||
2301 | 2294 | ||
2302 | } else { | 2295 | } else { |
2303 | spin_unlock_irqrestore(&info->readlock, flags); | 2296 | spin_unlock_irqrestore(&info->readlock, flags); |
2304 | tty_flip_buffer_push(tty); | 2297 | tty_flip_buffer_push(port); |
2305 | } | 2298 | } |
2306 | } | 2299 | } |
2307 | 2300 | ||
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c index 894078be0b96..c931dfe6a59c 100644 --- a/drivers/mmc/card/sdio_uart.c +++ b/drivers/mmc/card/sdio_uart.c | |||
@@ -381,7 +381,6 @@ static void sdio_uart_stop_rx(struct sdio_uart_port *port) | |||
381 | static void sdio_uart_receive_chars(struct sdio_uart_port *port, | 381 | static void sdio_uart_receive_chars(struct sdio_uart_port *port, |
382 | unsigned int *status) | 382 | unsigned int *status) |
383 | { | 383 | { |
384 | struct tty_struct *tty = tty_port_tty_get(&port->port); | ||
385 | unsigned int ch, flag; | 384 | unsigned int ch, flag; |
386 | int max_count = 256; | 385 | int max_count = 256; |
387 | 386 | ||
@@ -418,24 +417,19 @@ static void sdio_uart_receive_chars(struct sdio_uart_port *port, | |||
418 | } | 417 | } |
419 | 418 | ||
420 | if ((*status & port->ignore_status_mask & ~UART_LSR_OE) == 0) | 419 | if ((*status & port->ignore_status_mask & ~UART_LSR_OE) == 0) |
421 | if (tty) | 420 | tty_insert_flip_char(&port->port, ch, flag); |
422 | tty_insert_flip_char(&port->port, ch, flag); | ||
423 | 421 | ||
424 | /* | 422 | /* |
425 | * Overrun is special. Since it's reported immediately, | 423 | * Overrun is special. Since it's reported immediately, |
426 | * it doesn't affect the current character. | 424 | * it doesn't affect the current character. |
427 | */ | 425 | */ |
428 | if (*status & ~port->ignore_status_mask & UART_LSR_OE) | 426 | if (*status & ~port->ignore_status_mask & UART_LSR_OE) |
429 | if (tty) | 427 | tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); |
430 | tty_insert_flip_char(&port->port, 0, | ||
431 | TTY_OVERRUN); | ||
432 | 428 | ||
433 | *status = sdio_in(port, UART_LSR); | 429 | *status = sdio_in(port, UART_LSR); |
434 | } while ((*status & UART_LSR_DR) && (max_count-- > 0)); | 430 | } while ((*status & UART_LSR_DR) && (max_count-- > 0)); |
435 | if (tty) { | 431 | |
436 | tty_flip_buffer_push(tty); | 432 | tty_flip_buffer_push(&port->port); |
437 | tty_kref_put(tty); | ||
438 | } | ||
439 | } | 433 | } |
440 | 434 | ||
441 | static void sdio_uart_transmit_chars(struct sdio_uart_port *port) | 435 | static void sdio_uart_transmit_chars(struct sdio_uart_port *port) |
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index d235ca07548f..f902a14da88c 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c | |||
@@ -2035,24 +2035,23 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) | |||
2035 | tty = tty_port_tty_get(&serial->port); | 2035 | tty = tty_port_tty_get(&serial->port); |
2036 | 2036 | ||
2037 | /* Push data to tty */ | 2037 | /* Push data to tty */ |
2038 | if (tty) { | 2038 | write_length_remaining = urb->actual_length - |
2039 | write_length_remaining = urb->actual_length - | 2039 | serial->curr_rx_urb_offset; |
2040 | serial->curr_rx_urb_offset; | 2040 | D1("data to push to tty"); |
2041 | D1("data to push to tty"); | 2041 | while (write_length_remaining) { |
2042 | while (write_length_remaining) { | 2042 | if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { |
2043 | if (test_bit(TTY_THROTTLED, &tty->flags)) { | 2043 | tty_kref_put(tty); |
2044 | tty_kref_put(tty); | 2044 | return -1; |
2045 | return -1; | ||
2046 | } | ||
2047 | curr_write_len = tty_insert_flip_string(&serial->port, | ||
2048 | urb->transfer_buffer + serial->curr_rx_urb_offset, | ||
2049 | write_length_remaining); | ||
2050 | serial->curr_rx_urb_offset += curr_write_len; | ||
2051 | write_length_remaining -= curr_write_len; | ||
2052 | tty_flip_buffer_push(tty); | ||
2053 | } | 2045 | } |
2054 | tty_kref_put(tty); | 2046 | curr_write_len = tty_insert_flip_string(&serial->port, |
2047 | urb->transfer_buffer + serial->curr_rx_urb_offset, | ||
2048 | write_length_remaining); | ||
2049 | serial->curr_rx_urb_offset += curr_write_len; | ||
2050 | write_length_remaining -= curr_write_len; | ||
2051 | tty_flip_buffer_push(&serial->port); | ||
2055 | } | 2052 | } |
2053 | tty_kref_put(tty); | ||
2054 | |||
2056 | if (write_length_remaining == 0) { | 2055 | if (write_length_remaining == 0) { |
2057 | serial->curr_rx_urb_offset = 0; | 2056 | serial->curr_rx_urb_offset = 0; |
2058 | serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; | 2057 | serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; |
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 41b75c5ae0d5..2f58e9fde156 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c | |||
@@ -413,7 +413,7 @@ static void raw3215_irq(struct ccw_device *cdev, unsigned long intparm, | |||
413 | case CTRLCHAR_CTRL: | 413 | case CTRLCHAR_CTRL: |
414 | tty_insert_flip_char(&raw->port, cchar, | 414 | tty_insert_flip_char(&raw->port, cchar, |
415 | TTY_NORMAL); | 415 | TTY_NORMAL); |
416 | tty_flip_buffer_push(tty); | 416 | tty_flip_buffer_push(&raw->port); |
417 | break; | 417 | break; |
418 | 418 | ||
419 | case CTRLCHAR_NONE: | 419 | case CTRLCHAR_NONE: |
@@ -427,7 +427,7 @@ static void raw3215_irq(struct ccw_device *cdev, unsigned long intparm, | |||
427 | count -= 2; | 427 | count -= 2; |
428 | tty_insert_flip_string(&raw->port, raw->inbuf, | 428 | tty_insert_flip_string(&raw->port, raw->inbuf, |
429 | count); | 429 | count); |
430 | tty_flip_buffer_push(tty); | 430 | tty_flip_buffer_push(&raw->port); |
431 | break; | 431 | break; |
432 | } | 432 | } |
433 | } else if (req->type == RAW3215_WRITE) { | 433 | } else if (req->type == RAW3215_WRITE) { |
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c index 19b7c516c07d..14b4cb8abcc8 100644 --- a/drivers/s390/char/sclp_tty.c +++ b/drivers/s390/char/sclp_tty.c | |||
@@ -343,7 +343,7 @@ sclp_tty_input(unsigned char* buf, unsigned int count) | |||
343 | break; | 343 | break; |
344 | case CTRLCHAR_CTRL: | 344 | case CTRLCHAR_CTRL: |
345 | tty_insert_flip_char(&sclp_port, cchar, TTY_NORMAL); | 345 | tty_insert_flip_char(&sclp_port, cchar, TTY_NORMAL); |
346 | tty_flip_buffer_push(tty); | 346 | tty_flip_buffer_push(&sclp_port); |
347 | break; | 347 | break; |
348 | case CTRLCHAR_NONE: | 348 | case CTRLCHAR_NONE: |
349 | /* send (normal) input to line discipline */ | 349 | /* send (normal) input to line discipline */ |
@@ -355,7 +355,7 @@ sclp_tty_input(unsigned char* buf, unsigned int count) | |||
355 | tty_insert_flip_char(&sclp_port, '\n', TTY_NORMAL); | 355 | tty_insert_flip_char(&sclp_port, '\n', TTY_NORMAL); |
356 | } else | 356 | } else |
357 | tty_insert_flip_string(&sclp_port, buf, count - 2); | 357 | tty_insert_flip_string(&sclp_port, buf, count - 2); |
358 | tty_flip_buffer_push(tty); | 358 | tty_flip_buffer_push(&sclp_port); |
359 | break; | 359 | break; |
360 | } | 360 | } |
361 | tty_kref_put(tty); | 361 | tty_kref_put(tty); |
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c index 0eca99b98712..6c92f62623be 100644 --- a/drivers/s390/char/sclp_vt220.c +++ b/drivers/s390/char/sclp_vt220.c | |||
@@ -461,14 +461,9 @@ sclp_vt220_write(struct tty_struct *tty, const unsigned char *buf, int count) | |||
461 | static void | 461 | static void |
462 | sclp_vt220_receiver_fn(struct evbuf_header *evbuf) | 462 | sclp_vt220_receiver_fn(struct evbuf_header *evbuf) |
463 | { | 463 | { |
464 | struct tty_struct *tty = tty_port_tty_get(&sclp_vt220_port); | ||
465 | char *buffer; | 464 | char *buffer; |
466 | unsigned int count; | 465 | unsigned int count; |
467 | 466 | ||
468 | /* Ignore input if device is not open */ | ||
469 | if (tty == NULL) | ||
470 | return; | ||
471 | |||
472 | buffer = (char *) ((addr_t) evbuf + sizeof(struct evbuf_header)); | 467 | buffer = (char *) ((addr_t) evbuf + sizeof(struct evbuf_header)); |
473 | count = evbuf->length - sizeof(struct evbuf_header); | 468 | count = evbuf->length - sizeof(struct evbuf_header); |
474 | 469 | ||
@@ -481,10 +476,9 @@ sclp_vt220_receiver_fn(struct evbuf_header *evbuf) | |||
481 | buffer++; | 476 | buffer++; |
482 | count--; | 477 | count--; |
483 | tty_insert_flip_string(&sclp_vt220_port, buffer, count); | 478 | tty_insert_flip_string(&sclp_vt220_port, buffer, count); |
484 | tty_flip_buffer_push(tty); | 479 | tty_flip_buffer_push(&sclp_vt220_port); |
485 | break; | 480 | break; |
486 | } | 481 | } |
487 | tty_kref_put(tty); | ||
488 | } | 482 | } |
489 | 483 | ||
490 | /* | 484 | /* |
diff --git a/drivers/staging/ccg/u_serial.c b/drivers/staging/ccg/u_serial.c index 7df2c02d1137..b10947ae0ac5 100644 --- a/drivers/staging/ccg/u_serial.c +++ b/drivers/staging/ccg/u_serial.c | |||
@@ -491,12 +491,8 @@ static void gs_rx_push(unsigned long _port) | |||
491 | 491 | ||
492 | req = list_first_entry(queue, struct usb_request, list); | 492 | req = list_first_entry(queue, struct usb_request, list); |
493 | 493 | ||
494 | /* discard data if tty was closed */ | ||
495 | if (!tty) | ||
496 | goto recycle; | ||
497 | |||
498 | /* leave data queued if tty was rx throttled */ | 494 | /* leave data queued if tty was rx throttled */ |
499 | if (test_bit(TTY_THROTTLED, &tty->flags)) | 495 | if (tty && test_bit(TTY_THROTTLED, &tty->flags)) |
500 | break; | 496 | break; |
501 | 497 | ||
502 | switch (req->status) { | 498 | switch (req->status) { |
@@ -542,7 +538,6 @@ static void gs_rx_push(unsigned long _port) | |||
542 | } | 538 | } |
543 | port->n_read = 0; | 539 | port->n_read = 0; |
544 | } | 540 | } |
545 | recycle: | ||
546 | list_move(&req->list, &port->read_pool); | 541 | list_move(&req->list, &port->read_pool); |
547 | port->read_started--; | 542 | port->read_started--; |
548 | } | 543 | } |
@@ -550,8 +545,8 @@ recycle: | |||
550 | /* Push from tty to ldisc; without low_latency set this is handled by | 545 | /* Push from tty to ldisc; without low_latency set this is handled by |
551 | * a workqueue, so we won't get callbacks and can hold port_lock | 546 | * a workqueue, so we won't get callbacks and can hold port_lock |
552 | */ | 547 | */ |
553 | if (tty && do_push) | 548 | if (do_push) |
554 | tty_flip_buffer_push(tty); | 549 | tty_flip_buffer_push(&port->port); |
555 | 550 | ||
556 | 551 | ||
557 | /* We want our data queue to become empty ASAP, keeping data | 552 | /* We want our data queue to become empty ASAP, keeping data |
diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c index e618a667d84c..4c7abfabf197 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c | |||
@@ -234,7 +234,7 @@ static void dgrp_input(struct ch_struct *ch) | |||
234 | 234 | ||
235 | tty_insert_flip_string_flags(&ch->port, myflipbuf, | 235 | tty_insert_flip_string_flags(&ch->port, myflipbuf, |
236 | myflipflagbuf, len); | 236 | myflipflagbuf, len); |
237 | tty_flip_buffer_push(tty); | 237 | tty_flip_buffer_push(&ch->port); |
238 | 238 | ||
239 | ch->ch_rxcount += len; | 239 | ch->ch_rxcount += len; |
240 | } | 240 | } |
@@ -2958,7 +2958,7 @@ check_query: | |||
2958 | 2958 | ||
2959 | tty_buffer_request_room(&ch->port, 1); | 2959 | tty_buffer_request_room(&ch->port, 1); |
2960 | tty_insert_flip_char(&ch->port, 0, TTY_BREAK); | 2960 | tty_insert_flip_char(&ch->port, 0, TTY_BREAK); |
2961 | tty_flip_buffer_push(ch->ch_tun.un_tty); | 2961 | tty_flip_buffer_push(&ch->port); |
2962 | 2962 | ||
2963 | } | 2963 | } |
2964 | 2964 | ||
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index a2a0c43dec1c..b403393c49c3 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c | |||
@@ -489,16 +489,11 @@ static void fwtty_do_hangup(struct work_struct *work) | |||
489 | static void fwtty_emit_breaks(struct work_struct *work) | 489 | static void fwtty_emit_breaks(struct work_struct *work) |
490 | { | 490 | { |
491 | struct fwtty_port *port = to_port(to_delayed_work(work), emit_breaks); | 491 | struct fwtty_port *port = to_port(to_delayed_work(work), emit_breaks); |
492 | struct tty_struct *tty; | ||
493 | static const char buf[16]; | 492 | static const char buf[16]; |
494 | unsigned long now = jiffies; | 493 | unsigned long now = jiffies; |
495 | unsigned long elapsed = now - port->break_last; | 494 | unsigned long elapsed = now - port->break_last; |
496 | int n, t, c, brk = 0; | 495 | int n, t, c, brk = 0; |
497 | 496 | ||
498 | tty = tty_port_tty_get(&port->port); | ||
499 | if (!tty) | ||
500 | return; | ||
501 | |||
502 | /* generate breaks at the line rate (but at least 1) */ | 497 | /* generate breaks at the line rate (but at least 1) */ |
503 | n = (elapsed * port->cps) / HZ + 1; | 498 | n = (elapsed * port->cps) / HZ + 1; |
504 | port->break_last = now; | 499 | port->break_last = now; |
@@ -514,9 +509,7 @@ static void fwtty_emit_breaks(struct work_struct *work) | |||
514 | if (c < t) | 509 | if (c < t) |
515 | break; | 510 | break; |
516 | } | 511 | } |
517 | tty_flip_buffer_push(tty); | 512 | tty_flip_buffer_push(&port->port); |
518 | |||
519 | tty_kref_put(tty); | ||
520 | 513 | ||
521 | if (port->mstatus & (UART_LSR_BI << 24)) | 514 | if (port->mstatus & (UART_LSR_BI << 24)) |
522 | schedule_delayed_work(&port->emit_breaks, FREQ_BREAKS); | 515 | schedule_delayed_work(&port->emit_breaks, FREQ_BREAKS); |
@@ -530,10 +523,6 @@ static void fwtty_pushrx(struct work_struct *work) | |||
530 | struct buffered_rx *buf, *next; | 523 | struct buffered_rx *buf, *next; |
531 | int n, c = 0; | 524 | int n, c = 0; |
532 | 525 | ||
533 | tty = tty_port_tty_get(&port->port); | ||
534 | if (!tty) | ||
535 | return; | ||
536 | |||
537 | spin_lock_bh(&port->lock); | 526 | spin_lock_bh(&port->lock); |
538 | list_for_each_entry_safe(buf, next, &port->buf_list, list) { | 527 | list_for_each_entry_safe(buf, next, &port->buf_list, list) { |
539 | n = tty_insert_flip_string_fixed_flag(&port->port, buf->data, | 528 | n = tty_insert_flip_string_fixed_flag(&port->port, buf->data, |
@@ -545,7 +534,11 @@ static void fwtty_pushrx(struct work_struct *work) | |||
545 | memmove(buf->data, buf->data + n, buf->n - n); | 534 | memmove(buf->data, buf->data + n, buf->n - n); |
546 | buf->n -= n; | 535 | buf->n -= n; |
547 | } | 536 | } |
548 | __fwtty_throttle(port, tty); | 537 | tty = tty_port_tty_get(&port->port); |
538 | if (tty) { | ||
539 | __fwtty_throttle(port, tty); | ||
540 | tty_kref_put(tty); | ||
541 | } | ||
549 | break; | 542 | break; |
550 | } else { | 543 | } else { |
551 | list_del(&buf->list); | 544 | list_del(&buf->list); |
@@ -553,13 +546,11 @@ static void fwtty_pushrx(struct work_struct *work) | |||
553 | } | 546 | } |
554 | } | 547 | } |
555 | if (c > 0) | 548 | if (c > 0) |
556 | tty_flip_buffer_push(tty); | 549 | tty_flip_buffer_push(&port->port); |
557 | 550 | ||
558 | if (list_empty(&port->buf_list)) | 551 | if (list_empty(&port->buf_list)) |
559 | clear_bit(BUFFERING_RX, &port->flags); | 552 | clear_bit(BUFFERING_RX, &port->flags); |
560 | spin_unlock_bh(&port->lock); | 553 | spin_unlock_bh(&port->lock); |
561 | |||
562 | tty_kref_put(tty); | ||
563 | } | 554 | } |
564 | 555 | ||
565 | static int fwtty_buffer_rx(struct fwtty_port *port, unsigned char *d, size_t n) | 556 | static int fwtty_buffer_rx(struct fwtty_port *port, unsigned char *d, size_t n) |
@@ -594,10 +585,6 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) | |||
594 | unsigned lsr; | 585 | unsigned lsr; |
595 | int err = 0; | 586 | int err = 0; |
596 | 587 | ||
597 | tty = tty_port_tty_get(&port->port); | ||
598 | if (!tty) | ||
599 | return -ENOENT; | ||
600 | |||
601 | fwtty_dbg(port, "%d", n); | 588 | fwtty_dbg(port, "%d", n); |
602 | profile_size_distrib(port->stats.reads, n); | 589 | profile_size_distrib(port->stats.reads, n); |
603 | 590 | ||
@@ -634,16 +621,20 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) | |||
634 | c = tty_insert_flip_string_fixed_flag(&port->port, data, | 621 | c = tty_insert_flip_string_fixed_flag(&port->port, data, |
635 | TTY_NORMAL, n); | 622 | TTY_NORMAL, n); |
636 | if (c > 0) | 623 | if (c > 0) |
637 | tty_flip_buffer_push(tty); | 624 | tty_flip_buffer_push(&port->port); |
638 | n -= c; | 625 | n -= c; |
639 | 626 | ||
640 | if (n) { | 627 | if (n) { |
641 | /* start buffering and throttling */ | 628 | /* start buffering and throttling */ |
642 | n -= fwtty_buffer_rx(port, &data[c], n); | 629 | n -= fwtty_buffer_rx(port, &data[c], n); |
643 | 630 | ||
644 | spin_lock_bh(&port->lock); | 631 | tty = tty_port_tty_get(&port->port); |
645 | __fwtty_throttle(port, tty); | 632 | if (tty) { |
646 | spin_unlock_bh(&port->lock); | 633 | spin_lock_bh(&port->lock); |
634 | __fwtty_throttle(port, tty); | ||
635 | spin_unlock_bh(&port->lock); | ||
636 | tty_kref_put(tty); | ||
637 | } | ||
647 | } | 638 | } |
648 | } else | 639 | } else |
649 | n -= fwtty_buffer_rx(port, data, n); | 640 | n -= fwtty_buffer_rx(port, data, n); |
@@ -654,8 +645,6 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) | |||
654 | } | 645 | } |
655 | 646 | ||
656 | out: | 647 | out: |
657 | tty_kref_put(tty); | ||
658 | |||
659 | port->icount.rx += len; | 648 | port->icount.rx += len; |
660 | port->stats.lost += n; | 649 | port->stats.lost += n; |
661 | return err; | 650 | return err; |
diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index 14965662d09c..df29a3de29f2 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c | |||
@@ -290,8 +290,7 @@ static void qt_interrupt_callback(struct urb *urb) | |||
290 | /* FIXME */ | 290 | /* FIXME */ |
291 | } | 291 | } |
292 | 292 | ||
293 | static void qt_status_change_check(struct tty_struct *tty, | 293 | static void qt_status_change_check(struct urb *urb, |
294 | struct urb *urb, | ||
295 | struct quatech_port *qt_port, | 294 | struct quatech_port *qt_port, |
296 | struct usb_serial_port *port) | 295 | struct usb_serial_port *port) |
297 | { | 296 | { |
@@ -348,7 +347,7 @@ static void qt_status_change_check(struct tty_struct *tty, | |||
348 | tty_insert_flip_char(&port->port, data[i], TTY_NORMAL); | 347 | tty_insert_flip_char(&port->port, data[i], TTY_NORMAL); |
349 | 348 | ||
350 | } | 349 | } |
351 | tty_flip_buffer_push(tty); | 350 | tty_flip_buffer_push(&port->port); |
352 | } | 351 | } |
353 | 352 | ||
354 | static void qt_read_bulk_callback(struct urb *urb) | 353 | static void qt_read_bulk_callback(struct urb *urb) |
@@ -411,7 +410,7 @@ static void qt_read_bulk_callback(struct urb *urb) | |||
411 | } | 410 | } |
412 | 411 | ||
413 | if (urb->actual_length) | 412 | if (urb->actual_length) |
414 | qt_status_change_check(tty, urb, qt_port, port); | 413 | qt_status_change_check(urb, qt_port, port); |
415 | 414 | ||
416 | /* Continue trying to always read */ | 415 | /* Continue trying to always read */ |
417 | usb_fill_bulk_urb(port->read_urb, serial->dev, | 416 | usb_fill_bulk_urb(port->read_urb, serial->dev, |
@@ -427,7 +426,7 @@ static void qt_read_bulk_callback(struct urb *urb) | |||
427 | __func__, result); | 426 | __func__, result); |
428 | else { | 427 | else { |
429 | if (urb->actual_length) { | 428 | if (urb->actual_length) { |
430 | tty_flip_buffer_push(tty); | 429 | tty_flip_buffer_push(&port->port); |
431 | tty_schedule_flip(tty); | 430 | tty_schedule_flip(tty); |
432 | } | 431 | } |
433 | } | 432 | } |
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index 2d1357acbc23..4c7d70172193 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c | |||
@@ -251,7 +251,6 @@ static void receive_chars(struct serial_state *info) | |||
251 | { | 251 | { |
252 | int status; | 252 | int status; |
253 | int serdatr; | 253 | int serdatr; |
254 | struct tty_struct *tty = info->tport.tty; | ||
255 | unsigned char ch, flag; | 254 | unsigned char ch, flag; |
256 | struct async_icount *icount; | 255 | struct async_icount *icount; |
257 | int oe = 0; | 256 | int oe = 0; |
@@ -314,7 +313,7 @@ static void receive_chars(struct serial_state *info) | |||
314 | #endif | 313 | #endif |
315 | flag = TTY_BREAK; | 314 | flag = TTY_BREAK; |
316 | if (info->tport.flags & ASYNC_SAK) | 315 | if (info->tport.flags & ASYNC_SAK) |
317 | do_SAK(tty); | 316 | do_SAK(info->tport.tty); |
318 | } else if (status & UART_LSR_PE) | 317 | } else if (status & UART_LSR_PE) |
319 | flag = TTY_PARITY; | 318 | flag = TTY_PARITY; |
320 | else if (status & UART_LSR_FE) | 319 | else if (status & UART_LSR_FE) |
@@ -331,7 +330,7 @@ static void receive_chars(struct serial_state *info) | |||
331 | tty_insert_flip_char(&info->tport, ch, flag); | 330 | tty_insert_flip_char(&info->tport, ch, flag); |
332 | if (oe == 1) | 331 | if (oe == 1) |
333 | tty_insert_flip_char(&info->tport, 0, TTY_OVERRUN); | 332 | tty_insert_flip_char(&info->tport, 0, TTY_OVERRUN); |
334 | tty_flip_buffer_push(tty); | 333 | tty_flip_buffer_push(&info->tport); |
335 | out: | 334 | out: |
336 | return; | 335 | return; |
337 | } | 336 | } |
diff --git a/drivers/tty/bfin_jtag_comm.c b/drivers/tty/bfin_jtag_comm.c index 143c38579cb5..a93a424873fa 100644 --- a/drivers/tty/bfin_jtag_comm.c +++ b/drivers/tty/bfin_jtag_comm.c | |||
@@ -95,18 +95,16 @@ bfin_jc_emudat_manager(void *arg) | |||
95 | 95 | ||
96 | /* if incoming data is ready, eat it */ | 96 | /* if incoming data is ready, eat it */ |
97 | if (bfin_read_DBGSTAT() & EMUDIF) { | 97 | if (bfin_read_DBGSTAT() & EMUDIF) { |
98 | if (tty != NULL) { | 98 | uint32_t emudat = bfin_read_emudat(); |
99 | uint32_t emudat = bfin_read_emudat(); | 99 | if (inbound_len == 0) { |
100 | if (inbound_len == 0) { | 100 | pr_debug("incoming length: 0x%08x\n", emudat); |
101 | pr_debug("incoming length: 0x%08x\n", emudat); | 101 | inbound_len = emudat; |
102 | inbound_len = emudat; | 102 | } else { |
103 | } else { | 103 | size_t num_chars = (4 <= inbound_len ? 4 : inbound_len); |
104 | size_t num_chars = (4 <= inbound_len ? 4 : inbound_len); | 104 | pr_debug(" incoming data: 0x%08x (pushing %zu)\n", emudat, num_chars); |
105 | pr_debug(" incoming data: 0x%08x (pushing %zu)\n", emudat, num_chars); | 105 | inbound_len -= num_chars; |
106 | inbound_len -= num_chars; | 106 | tty_insert_flip_string(&port, (unsigned char *)&emudat, num_chars); |
107 | tty_insert_flip_string(&port, (unsigned char *)&emudat, num_chars); | 107 | tty_flip_buffer_push(&port); |
108 | tty_flip_buffer_push(tty); | ||
109 | } | ||
110 | } | 108 | } |
111 | } | 109 | } |
112 | 110 | ||
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c index 5164f9a57017..ed92622b8949 100644 --- a/drivers/tty/ehv_bytechan.c +++ b/drivers/tty/ehv_bytechan.c | |||
@@ -371,16 +371,11 @@ console_initcall(ehv_bc_console_init); | |||
371 | static irqreturn_t ehv_bc_tty_rx_isr(int irq, void *data) | 371 | static irqreturn_t ehv_bc_tty_rx_isr(int irq, void *data) |
372 | { | 372 | { |
373 | struct ehv_bc_data *bc = data; | 373 | struct ehv_bc_data *bc = data; |
374 | struct tty_struct *ttys = tty_port_tty_get(&bc->port); | ||
375 | unsigned int rx_count, tx_count, len; | 374 | unsigned int rx_count, tx_count, len; |
376 | int count; | 375 | int count; |
377 | char buffer[EV_BYTE_CHANNEL_MAX_BYTES]; | 376 | char buffer[EV_BYTE_CHANNEL_MAX_BYTES]; |
378 | int ret; | 377 | int ret; |
379 | 378 | ||
380 | /* ttys could be NULL during a hangup */ | ||
381 | if (!ttys) | ||
382 | return IRQ_HANDLED; | ||
383 | |||
384 | /* Find out how much data needs to be read, and then ask the TTY layer | 379 | /* Find out how much data needs to be read, and then ask the TTY layer |
385 | * if it can handle that much. We want to ensure that every byte we | 380 | * if it can handle that much. We want to ensure that every byte we |
386 | * read from the byte channel will be accepted by the TTY layer. | 381 | * read from the byte channel will be accepted by the TTY layer. |
@@ -422,9 +417,7 @@ static irqreturn_t ehv_bc_tty_rx_isr(int irq, void *data) | |||
422 | } | 417 | } |
423 | 418 | ||
424 | /* Tell the tty layer that we're done. */ | 419 | /* Tell the tty layer that we're done. */ |
425 | tty_flip_buffer_push(ttys); | 420 | tty_flip_buffer_push(&bc->port); |
426 | |||
427 | tty_kref_put(ttys); | ||
428 | 421 | ||
429 | return IRQ_HANDLED; | 422 | return IRQ_HANDLED; |
430 | } | 423 | } |
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c index 8c2fe3a0e091..eb255e807c06 100644 --- a/drivers/tty/hvc/hvc_console.c +++ b/drivers/tty/hvc/hvc_console.c | |||
@@ -691,7 +691,7 @@ int hvc_poll(struct hvc_struct *hp) | |||
691 | a minimum for performance. */ | 691 | a minimum for performance. */ |
692 | timeout = MIN_TIMEOUT; | 692 | timeout = MIN_TIMEOUT; |
693 | 693 | ||
694 | tty_flip_buffer_push(tty); | 694 | tty_flip_buffer_push(&hp->port); |
695 | } | 695 | } |
696 | tty_kref_put(tty); | 696 | tty_kref_put(tty); |
697 | 697 | ||
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index 7bfc0a924b2f..1956593ee89d 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c | |||
@@ -623,7 +623,7 @@ static int hvcs_io(struct hvcs_struct *hvcsd) | |||
623 | spin_unlock_irqrestore(&hvcsd->lock, flags); | 623 | spin_unlock_irqrestore(&hvcsd->lock, flags); |
624 | /* This is synch because tty->low_latency == 1 */ | 624 | /* This is synch because tty->low_latency == 1 */ |
625 | if(got) | 625 | if(got) |
626 | tty_flip_buffer_push(tty); | 626 | tty_flip_buffer_push(&hvcsd->port); |
627 | 627 | ||
628 | if (!got) { | 628 | if (!got) { |
629 | /* Do this _after_ the flip_buffer_push */ | 629 | /* Do this _after_ the flip_buffer_push */ |
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c index 1f528b8ebf5f..dc591290120b 100644 --- a/drivers/tty/hvc/hvsi.c +++ b/drivers/tty/hvc/hvsi.c | |||
@@ -465,7 +465,7 @@ static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct *tty, | |||
465 | compact_inbuf(hp, packet); | 465 | compact_inbuf(hp, packet); |
466 | 466 | ||
467 | if (flip) | 467 | if (flip) |
468 | tty_flip_buffer_push(tty); | 468 | tty_flip_buffer_push(&hp->port); |
469 | 469 | ||
470 | return 1; | 470 | return 1; |
471 | } | 471 | } |
@@ -511,7 +511,7 @@ static irqreturn_t hvsi_interrupt(int irq, void *arg) | |||
511 | /* we weren't hung up and we weren't throttled, so we can | 511 | /* we weren't hung up and we weren't throttled, so we can |
512 | * deliver the rest now */ | 512 | * deliver the rest now */ |
513 | hvsi_send_overflow(hp); | 513 | hvsi_send_overflow(hp); |
514 | tty_flip_buffer_push(tty); | 514 | tty_flip_buffer_push(&hp->port); |
515 | } | 515 | } |
516 | spin_unlock_irqrestore(&hp->lock, flags); | 516 | spin_unlock_irqrestore(&hp->lock, flags); |
517 | 517 | ||
@@ -998,7 +998,7 @@ static void hvsi_unthrottle(struct tty_struct *tty) | |||
998 | spin_lock_irqsave(&hp->lock, flags); | 998 | spin_lock_irqsave(&hp->lock, flags); |
999 | if (hp->n_throttle) { | 999 | if (hp->n_throttle) { |
1000 | hvsi_send_overflow(hp); | 1000 | hvsi_send_overflow(hp); |
1001 | tty_flip_buffer_push(tty); | 1001 | tty_flip_buffer_push(&hp->port); |
1002 | } | 1002 | } |
1003 | spin_unlock_irqrestore(&hp->lock, flags); | 1003 | spin_unlock_irqrestore(&hp->lock, flags); |
1004 | 1004 | ||
diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c index c43da7445432..8fd72ff9436e 100644 --- a/drivers/tty/ipwireless/tty.c +++ b/drivers/tty/ipwireless/tty.c | |||
@@ -160,15 +160,9 @@ static void ipw_close(struct tty_struct *linux_tty, struct file *filp) | |||
160 | void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data, | 160 | void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data, |
161 | unsigned int length) | 161 | unsigned int length) |
162 | { | 162 | { |
163 | struct tty_struct *linux_tty; | ||
164 | int work = 0; | 163 | int work = 0; |
165 | 164 | ||
166 | mutex_lock(&tty->ipw_tty_mutex); | 165 | mutex_lock(&tty->ipw_tty_mutex); |
167 | linux_tty = tty->port.tty; | ||
168 | if (linux_tty == NULL) { | ||
169 | mutex_unlock(&tty->ipw_tty_mutex); | ||
170 | return; | ||
171 | } | ||
172 | 166 | ||
173 | if (!tty->port.count) { | 167 | if (!tty->port.count) { |
174 | mutex_unlock(&tty->ipw_tty_mutex); | 168 | mutex_unlock(&tty->ipw_tty_mutex); |
@@ -187,7 +181,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data, | |||
187 | * This may sleep if ->low_latency is set | 181 | * This may sleep if ->low_latency is set |
188 | */ | 182 | */ |
189 | if (work) | 183 | if (work) |
190 | tty_flip_buffer_push(linux_tty); | 184 | tty_flip_buffer_push(&tty->port); |
191 | } | 185 | } |
192 | 186 | ||
193 | static void ipw_write_packet_sent_callback(void *callback_data, | 187 | static void ipw_write_packet_sent_callback(void *callback_data, |
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c index c70144f55fc0..858291ca889c 100644 --- a/drivers/tty/isicom.c +++ b/drivers/tty/isicom.c | |||
@@ -637,7 +637,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) | |||
637 | tty_insert_flip_char(&port->port, 0, TTY_BREAK); | 637 | tty_insert_flip_char(&port->port, 0, TTY_BREAK); |
638 | if (port->port.flags & ASYNC_SAK) | 638 | if (port->port.flags & ASYNC_SAK) |
639 | do_SAK(tty); | 639 | do_SAK(tty); |
640 | tty_flip_buffer_push(tty); | 640 | tty_flip_buffer_push(&port->port); |
641 | break; | 641 | break; |
642 | 642 | ||
643 | case 2: /* Statistics */ | 643 | case 2: /* Statistics */ |
@@ -671,7 +671,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) | |||
671 | byte_count -= 2; | 671 | byte_count -= 2; |
672 | } | 672 | } |
673 | } | 673 | } |
674 | tty_flip_buffer_push(tty); | 674 | tty_flip_buffer_push(&port->port); |
675 | } | 675 | } |
676 | outw(0x0000, base+0x04); /* enable interrupts */ | 676 | outw(0x0000, base+0x04); /* enable interrupts */ |
677 | spin_unlock(&card->card_lock); | 677 | spin_unlock(&card->card_lock); |
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index e9cdfdfe06e9..ad34a202a34d 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c | |||
@@ -2145,7 +2145,7 @@ end_intr: | |||
2145 | * recursive locking. | 2145 | * recursive locking. |
2146 | */ | 2146 | */ |
2147 | spin_unlock(&port->slock); | 2147 | spin_unlock(&port->slock); |
2148 | tty_flip_buffer_push(tty); | 2148 | tty_flip_buffer_push(&port->port); |
2149 | spin_lock(&port->slock); | 2149 | spin_lock(&port->slock); |
2150 | } | 2150 | } |
2151 | 2151 | ||
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 4a3342d21c8f..d84dcfeadce3 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c | |||
@@ -1141,7 +1141,6 @@ static void gsm_control_modem(struct gsm_mux *gsm, u8 *data, int clen) | |||
1141 | static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen) | 1141 | static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen) |
1142 | { | 1142 | { |
1143 | struct tty_port *port; | 1143 | struct tty_port *port; |
1144 | struct tty_struct *tty; | ||
1145 | unsigned int addr = 0 ; | 1144 | unsigned int addr = 0 ; |
1146 | u8 bits; | 1145 | u8 bits; |
1147 | int len = clen; | 1146 | int len = clen; |
@@ -1174,12 +1173,8 @@ static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen) | |||
1174 | if (bits & 8) | 1173 | if (bits & 8) |
1175 | tty_insert_flip_char(port, 0, TTY_FRAME); | 1174 | tty_insert_flip_char(port, 0, TTY_FRAME); |
1176 | 1175 | ||
1177 | /* See if we have an uplink tty */ | 1176 | tty_flip_buffer_push(port); |
1178 | tty = tty_port_tty_get(port); | 1177 | |
1179 | if (tty) { | ||
1180 | tty_flip_buffer_push(tty); | ||
1181 | tty_kref_put(tty); | ||
1182 | } | ||
1183 | gsm_control_reply(gsm, CMD_RLS, data, clen); | 1178 | gsm_control_reply(gsm, CMD_RLS, data, clen); |
1184 | } | 1179 | } |
1185 | 1180 | ||
@@ -1552,36 +1547,37 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int clen) | |||
1552 | { | 1547 | { |
1553 | /* krefs .. */ | 1548 | /* krefs .. */ |
1554 | struct tty_port *port = &dlci->port; | 1549 | struct tty_port *port = &dlci->port; |
1555 | struct tty_struct *tty = tty_port_tty_get(port); | 1550 | struct tty_struct *tty; |
1556 | unsigned int modem = 0; | 1551 | unsigned int modem = 0; |
1557 | int len = clen; | 1552 | int len = clen; |
1558 | 1553 | ||
1559 | if (debug & 16) | 1554 | if (debug & 16) |
1560 | pr_debug("%d bytes for tty %p\n", len, tty); | 1555 | pr_debug("%d bytes for tty\n", len); |
1561 | if (tty) { | 1556 | switch (dlci->adaption) { |
1562 | switch (dlci->adaption) { | 1557 | /* Unsupported types */ |
1563 | /* Unsupported types */ | 1558 | /* Packetised interruptible data */ |
1564 | /* Packetised interruptible data */ | 1559 | case 4: |
1565 | case 4: | 1560 | break; |
1566 | break; | 1561 | /* Packetised uininterruptible voice/data */ |
1567 | /* Packetised uininterruptible voice/data */ | 1562 | case 3: |
1568 | case 3: | 1563 | break; |
1569 | break; | 1564 | /* Asynchronous serial with line state in each frame */ |
1570 | /* Asynchronous serial with line state in each frame */ | 1565 | case 2: |
1571 | case 2: | 1566 | while (gsm_read_ea(&modem, *data++) == 0) { |
1572 | while (gsm_read_ea(&modem, *data++) == 0) { | 1567 | len--; |
1573 | len--; | 1568 | if (len == 0) |
1574 | if (len == 0) | 1569 | return; |
1575 | return; | 1570 | } |
1576 | } | 1571 | tty = tty_port_tty_get(port); |
1572 | if (tty) { | ||
1577 | gsm_process_modem(tty, dlci, modem, clen); | 1573 | gsm_process_modem(tty, dlci, modem, clen); |
1578 | /* Line state will go via DLCI 0 controls only */ | 1574 | tty_kref_put(tty); |
1579 | case 1: | ||
1580 | default: | ||
1581 | tty_insert_flip_string(port, data, len); | ||
1582 | tty_flip_buffer_push(tty); | ||
1583 | } | 1575 | } |
1584 | tty_kref_put(tty); | 1576 | /* Line state will go via DLCI 0 controls only */ |
1577 | case 1: | ||
1578 | default: | ||
1579 | tty_insert_flip_string(port, data, len); | ||
1580 | tty_flip_buffer_push(port); | ||
1585 | } | 1581 | } |
1586 | } | 1582 | } |
1587 | 1583 | ||
diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index 941fe8060ea5..afdd7732d925 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c | |||
@@ -1272,15 +1272,11 @@ static irqreturn_t interrupt_handler(int irq, void *dev_id) | |||
1272 | 1272 | ||
1273 | exit_handler: | 1273 | exit_handler: |
1274 | spin_unlock(&dc->spin_mutex); | 1274 | spin_unlock(&dc->spin_mutex); |
1275 | for (a = 0; a < NOZOMI_MAX_PORTS; a++) { | 1275 | |
1276 | struct tty_struct *tty; | 1276 | for (a = 0; a < NOZOMI_MAX_PORTS; a++) |
1277 | if (test_and_clear_bit(a, &dc->flip)) { | 1277 | if (test_and_clear_bit(a, &dc->flip)) |
1278 | tty = tty_port_tty_get(&dc->port[a].port); | 1278 | tty_flip_buffer_push(&dc->port[a].port); |
1279 | if (tty) | 1279 | |
1280 | tty_flip_buffer_push(tty); | ||
1281 | tty_kref_put(tty); | ||
1282 | } | ||
1283 | } | ||
1284 | return IRQ_HANDLED; | 1280 | return IRQ_HANDLED; |
1285 | none: | 1281 | none: |
1286 | spin_unlock(&dc->spin_mutex); | 1282 | spin_unlock(&dc->spin_mutex); |
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 3c285d398f38..32d027c303aa 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
@@ -123,7 +123,7 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c) | |||
123 | c = tty_insert_flip_string(to->port, buf, c); | 123 | c = tty_insert_flip_string(to->port, buf, c); |
124 | /* And shovel */ | 124 | /* And shovel */ |
125 | if (c) { | 125 | if (c) { |
126 | tty_flip_buffer_push(to); | 126 | tty_flip_buffer_push(to->port); |
127 | tty_wakeup(tty); | 127 | tty_wakeup(tty); |
128 | } | 128 | } |
129 | } | 129 | } |
diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c index 5848a767001a..8073cc0dff59 100644 --- a/drivers/tty/rocket.c +++ b/drivers/tty/rocket.c | |||
@@ -315,9 +315,8 @@ static inline int rocket_paranoia_check(struct r_port *info, | |||
315 | * that receive data is present on a serial port. Pulls data from FIFO, moves it into the | 315 | * that receive data is present on a serial port. Pulls data from FIFO, moves it into the |
316 | * tty layer. | 316 | * tty layer. |
317 | */ | 317 | */ |
318 | static void rp_do_receive(struct r_port *info, | 318 | static void rp_do_receive(struct r_port *info, CHANNEL_t *cp, |
319 | struct tty_struct *tty, | 319 | unsigned int ChanStatus) |
320 | CHANNEL_t * cp, unsigned int ChanStatus) | ||
321 | { | 320 | { |
322 | unsigned int CharNStat; | 321 | unsigned int CharNStat; |
323 | int ToRecv, wRecv, space; | 322 | int ToRecv, wRecv, space; |
@@ -416,7 +415,7 @@ static void rp_do_receive(struct r_port *info, | |||
416 | cbuf[ToRecv - 1] = sInB(sGetTxRxDataIO(cp)); | 415 | cbuf[ToRecv - 1] = sInB(sGetTxRxDataIO(cp)); |
417 | } | 416 | } |
418 | /* Push the data up to the tty layer */ | 417 | /* Push the data up to the tty layer */ |
419 | tty_flip_buffer_push(tty); | 418 | tty_flip_buffer_push(&info->port); |
420 | } | 419 | } |
421 | 420 | ||
422 | /* | 421 | /* |
@@ -495,7 +494,6 @@ static void rp_do_transmit(struct r_port *info) | |||
495 | static void rp_handle_port(struct r_port *info) | 494 | static void rp_handle_port(struct r_port *info) |
496 | { | 495 | { |
497 | CHANNEL_t *cp; | 496 | CHANNEL_t *cp; |
498 | struct tty_struct *tty; | ||
499 | unsigned int IntMask, ChanStatus; | 497 | unsigned int IntMask, ChanStatus; |
500 | 498 | ||
501 | if (!info) | 499 | if (!info) |
@@ -506,12 +504,7 @@ static void rp_handle_port(struct r_port *info) | |||
506 | "info->flags & NOT_INIT\n"); | 504 | "info->flags & NOT_INIT\n"); |
507 | return; | 505 | return; |
508 | } | 506 | } |
509 | tty = tty_port_tty_get(&info->port); | 507 | |
510 | if (!tty) { | ||
511 | printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " | ||
512 | "tty==NULL\n"); | ||
513 | return; | ||
514 | } | ||
515 | cp = &info->channel; | 508 | cp = &info->channel; |
516 | 509 | ||
517 | IntMask = sGetChanIntID(cp) & info->intmask; | 510 | IntMask = sGetChanIntID(cp) & info->intmask; |
@@ -520,7 +513,7 @@ static void rp_handle_port(struct r_port *info) | |||
520 | #endif | 513 | #endif |
521 | ChanStatus = sGetChanStatus(cp); | 514 | ChanStatus = sGetChanStatus(cp); |
522 | if (IntMask & RXF_TRIG) { /* Rx FIFO trigger level */ | 515 | if (IntMask & RXF_TRIG) { /* Rx FIFO trigger level */ |
523 | rp_do_receive(info, tty, cp, ChanStatus); | 516 | rp_do_receive(info, cp, ChanStatus); |
524 | } | 517 | } |
525 | if (IntMask & DELTA_CD) { /* CD change */ | 518 | if (IntMask & DELTA_CD) { /* CD change */ |
526 | #if (defined(ROCKET_DEBUG_OPEN) || defined(ROCKET_DEBUG_INTR) || defined(ROCKET_DEBUG_HANGUP)) | 519 | #if (defined(ROCKET_DEBUG_OPEN) || defined(ROCKET_DEBUG_INTR) || defined(ROCKET_DEBUG_HANGUP)) |
@@ -528,10 +521,15 @@ static void rp_handle_port(struct r_port *info) | |||
528 | (ChanStatus & CD_ACT) ? "on" : "off"); | 521 | (ChanStatus & CD_ACT) ? "on" : "off"); |
529 | #endif | 522 | #endif |
530 | if (!(ChanStatus & CD_ACT) && info->cd_status) { | 523 | if (!(ChanStatus & CD_ACT) && info->cd_status) { |
524 | struct tty_struct *tty; | ||
531 | #ifdef ROCKET_DEBUG_HANGUP | 525 | #ifdef ROCKET_DEBUG_HANGUP |
532 | printk(KERN_INFO "CD drop, calling hangup.\n"); | 526 | printk(KERN_INFO "CD drop, calling hangup.\n"); |
533 | #endif | 527 | #endif |
534 | tty_hangup(tty); | 528 | tty = tty_port_tty_get(&info->port); |
529 | if (tty) { | ||
530 | tty_hangup(tty); | ||
531 | tty_kref_put(tty); | ||
532 | } | ||
535 | } | 533 | } |
536 | info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0; | 534 | info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0; |
537 | wake_up_interruptible(&info->port.open_wait); | 535 | wake_up_interruptible(&info->port.open_wait); |
@@ -544,7 +542,6 @@ static void rp_handle_port(struct r_port *info) | |||
544 | printk(KERN_INFO "DSR change...\n"); | 542 | printk(KERN_INFO "DSR change...\n"); |
545 | } | 543 | } |
546 | #endif | 544 | #endif |
547 | tty_kref_put(tty); | ||
548 | } | 545 | } |
549 | 546 | ||
550 | /* | 547 | /* |
diff --git a/drivers/tty/serial/21285.c b/drivers/tty/serial/21285.c index a44345a2dbb4..c7e8b60b6177 100644 --- a/drivers/tty/serial/21285.c +++ b/drivers/tty/serial/21285.c | |||
@@ -85,7 +85,6 @@ static void serial21285_enable_ms(struct uart_port *port) | |||
85 | static irqreturn_t serial21285_rx_chars(int irq, void *dev_id) | 85 | static irqreturn_t serial21285_rx_chars(int irq, void *dev_id) |
86 | { | 86 | { |
87 | struct uart_port *port = dev_id; | 87 | struct uart_port *port = dev_id; |
88 | struct tty_struct *tty = port->state->port.tty; | ||
89 | unsigned int status, ch, flag, rxs, max_count = 256; | 88 | unsigned int status, ch, flag, rxs, max_count = 256; |
90 | 89 | ||
91 | status = *CSR_UARTFLG; | 90 | status = *CSR_UARTFLG; |
@@ -115,7 +114,7 @@ static irqreturn_t serial21285_rx_chars(int irq, void *dev_id) | |||
115 | 114 | ||
116 | status = *CSR_UARTFLG; | 115 | status = *CSR_UARTFLG; |
117 | } | 116 | } |
118 | tty_flip_buffer_push(tty); | 117 | tty_flip_buffer_push(&port->state->port); |
119 | 118 | ||
120 | return IRQ_HANDLED; | 119 | return IRQ_HANDLED; |
121 | } | 120 | } |
diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c index 5fb6577b94dc..0d771ec16750 100644 --- a/drivers/tty/serial/8250/8250.c +++ b/drivers/tty/serial/8250/8250.c | |||
@@ -1323,7 +1323,6 @@ unsigned char | |||
1323 | serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) | 1323 | serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) |
1324 | { | 1324 | { |
1325 | struct uart_port *port = &up->port; | 1325 | struct uart_port *port = &up->port; |
1326 | struct tty_struct *tty = port->state->port.tty; | ||
1327 | unsigned char ch; | 1326 | unsigned char ch; |
1328 | int max_count = 256; | 1327 | int max_count = 256; |
1329 | char flag; | 1328 | char flag; |
@@ -1388,7 +1387,7 @@ ignore_char: | |||
1388 | lsr = serial_in(up, UART_LSR); | 1387 | lsr = serial_in(up, UART_LSR); |
1389 | } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0)); | 1388 | } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0)); |
1390 | spin_unlock(&port->lock); | 1389 | spin_unlock(&port->lock); |
1391 | tty_flip_buffer_push(tty); | 1390 | tty_flip_buffer_push(&port->state->port); |
1392 | spin_lock(&port->lock); | 1391 | spin_lock(&port->lock); |
1393 | return lsr; | 1392 | return lsr; |
1394 | } | 1393 | } |
diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c index 872f14ae43d2..84b90fd48063 100644 --- a/drivers/tty/serial/altera_jtaguart.c +++ b/drivers/tty/serial/altera_jtaguart.c | |||
@@ -139,7 +139,7 @@ static void altera_jtaguart_rx_chars(struct altera_jtaguart *pp) | |||
139 | uart_insert_char(port, 0, 0, ch, flag); | 139 | uart_insert_char(port, 0, 0, ch, flag); |
140 | } | 140 | } |
141 | 141 | ||
142 | tty_flip_buffer_push(port->state->port.tty); | 142 | tty_flip_buffer_push(&port->state->port); |
143 | } | 143 | } |
144 | 144 | ||
145 | static void altera_jtaguart_tx_chars(struct altera_jtaguart *pp) | 145 | static void altera_jtaguart_tx_chars(struct altera_jtaguart *pp) |
diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c index 684a0808e1c7..e133c8814bb5 100644 --- a/drivers/tty/serial/altera_uart.c +++ b/drivers/tty/serial/altera_uart.c | |||
@@ -231,7 +231,7 @@ static void altera_uart_rx_chars(struct altera_uart *pp) | |||
231 | flag); | 231 | flag); |
232 | } | 232 | } |
233 | 233 | ||
234 | tty_flip_buffer_push(port->state->port.tty); | 234 | tty_flip_buffer_push(&port->state->port); |
235 | } | 235 | } |
236 | 236 | ||
237 | static void altera_uart_tx_chars(struct altera_uart *pp) | 237 | static void altera_uart_tx_chars(struct altera_uart *pp) |
diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c index 22317dd16474..c36840519527 100644 --- a/drivers/tty/serial/amba-pl010.c +++ b/drivers/tty/serial/amba-pl010.c | |||
@@ -116,7 +116,6 @@ static void pl010_enable_ms(struct uart_port *port) | |||
116 | 116 | ||
117 | static void pl010_rx_chars(struct uart_amba_port *uap) | 117 | static void pl010_rx_chars(struct uart_amba_port *uap) |
118 | { | 118 | { |
119 | struct tty_struct *tty = uap->port.state->port.tty; | ||
120 | unsigned int status, ch, flag, rsr, max_count = 256; | 119 | unsigned int status, ch, flag, rsr, max_count = 256; |
121 | 120 | ||
122 | status = readb(uap->port.membase + UART01x_FR); | 121 | status = readb(uap->port.membase + UART01x_FR); |
@@ -165,7 +164,7 @@ static void pl010_rx_chars(struct uart_amba_port *uap) | |||
165 | status = readb(uap->port.membase + UART01x_FR); | 164 | status = readb(uap->port.membase + UART01x_FR); |
166 | } | 165 | } |
167 | spin_unlock(&uap->port.lock); | 166 | spin_unlock(&uap->port.lock); |
168 | tty_flip_buffer_push(tty); | 167 | tty_flip_buffer_push(&uap->port.state->port); |
169 | spin_lock(&uap->port.lock); | 168 | spin_lock(&uap->port.lock); |
170 | } | 169 | } |
171 | 170 | ||
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index e1257d17f5f0..3ea5408fcbeb 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c | |||
@@ -699,7 +699,6 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap, | |||
699 | bool readfifo) | 699 | bool readfifo) |
700 | { | 700 | { |
701 | struct tty_port *port = &uap->port.state->port; | 701 | struct tty_port *port = &uap->port.state->port; |
702 | struct tty_struct *tty = port->tty; | ||
703 | struct pl011_sgbuf *sgbuf = use_buf_b ? | 702 | struct pl011_sgbuf *sgbuf = use_buf_b ? |
704 | &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a; | 703 | &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a; |
705 | struct device *dev = uap->dmarx.chan->device->dev; | 704 | struct device *dev = uap->dmarx.chan->device->dev; |
@@ -754,7 +753,7 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap, | |||
754 | dev_vdbg(uap->port.dev, | 753 | dev_vdbg(uap->port.dev, |
755 | "Took %d chars from DMA buffer and %d chars from the FIFO\n", | 754 | "Took %d chars from DMA buffer and %d chars from the FIFO\n", |
756 | dma_count, fifotaken); | 755 | dma_count, fifotaken); |
757 | tty_flip_buffer_push(tty); | 756 | tty_flip_buffer_push(port); |
758 | spin_lock(&uap->port.lock); | 757 | spin_lock(&uap->port.lock); |
759 | } | 758 | } |
760 | 759 | ||
@@ -1076,12 +1075,10 @@ static void pl011_enable_ms(struct uart_port *port) | |||
1076 | 1075 | ||
1077 | static void pl011_rx_chars(struct uart_amba_port *uap) | 1076 | static void pl011_rx_chars(struct uart_amba_port *uap) |
1078 | { | 1077 | { |
1079 | struct tty_struct *tty = uap->port.state->port.tty; | ||
1080 | |||
1081 | pl011_fifo_to_tty(uap); | 1078 | pl011_fifo_to_tty(uap); |
1082 | 1079 | ||
1083 | spin_unlock(&uap->port.lock); | 1080 | spin_unlock(&uap->port.lock); |
1084 | tty_flip_buffer_push(tty); | 1081 | tty_flip_buffer_push(&uap->port.state->port); |
1085 | /* | 1082 | /* |
1086 | * If we were temporarily out of DMA mode for a while, | 1083 | * If we were temporarily out of DMA mode for a while, |
1087 | * attempt to switch back to DMA mode again. | 1084 | * attempt to switch back to DMA mode again. |
diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c index 59ae2b53e765..6331464d9101 100644 --- a/drivers/tty/serial/apbuart.c +++ b/drivers/tty/serial/apbuart.c | |||
@@ -78,7 +78,6 @@ static void apbuart_enable_ms(struct uart_port *port) | |||
78 | 78 | ||
79 | static void apbuart_rx_chars(struct uart_port *port) | 79 | static void apbuart_rx_chars(struct uart_port *port) |
80 | { | 80 | { |
81 | struct tty_struct *tty = port->state->port.tty; | ||
82 | unsigned int status, ch, rsr, flag; | 81 | unsigned int status, ch, rsr, flag; |
83 | unsigned int max_chars = port->fifosize; | 82 | unsigned int max_chars = port->fifosize; |
84 | 83 | ||
@@ -126,7 +125,7 @@ static void apbuart_rx_chars(struct uart_port *port) | |||
126 | status = UART_GET_STATUS(port); | 125 | status = UART_GET_STATUS(port); |
127 | } | 126 | } |
128 | 127 | ||
129 | tty_flip_buffer_push(tty); | 128 | tty_flip_buffer_push(&port->state->port); |
130 | } | 129 | } |
131 | 130 | ||
132 | static void apbuart_tx_chars(struct uart_port *port) | 131 | static void apbuart_tx_chars(struct uart_port *port) |
diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c index 6ca5dd615f9e..27f20c57abed 100644 --- a/drivers/tty/serial/ar933x_uart.c +++ b/drivers/tty/serial/ar933x_uart.c | |||
@@ -298,10 +298,8 @@ static void ar933x_uart_set_termios(struct uart_port *port, | |||
298 | static void ar933x_uart_rx_chars(struct ar933x_uart_port *up) | 298 | static void ar933x_uart_rx_chars(struct ar933x_uart_port *up) |
299 | { | 299 | { |
300 | struct tty_port *port = &up->port.state->port; | 300 | struct tty_port *port = &up->port.state->port; |
301 | struct tty_struct *tty; | ||
302 | int max_count = 256; | 301 | int max_count = 256; |
303 | 302 | ||
304 | tty = tty_port_tty_get(port); | ||
305 | do { | 303 | do { |
306 | unsigned int rdata; | 304 | unsigned int rdata; |
307 | unsigned char ch; | 305 | unsigned char ch; |
@@ -324,10 +322,7 @@ static void ar933x_uart_rx_chars(struct ar933x_uart_port *up) | |||
324 | tty_insert_flip_char(port, ch, TTY_NORMAL); | 322 | tty_insert_flip_char(port, ch, TTY_NORMAL); |
325 | } while (max_count-- > 0); | 323 | } while (max_count-- > 0); |
326 | 324 | ||
327 | if (tty) { | 325 | tty_flip_buffer_push(port); |
328 | tty_flip_buffer_push(tty); | ||
329 | tty_kref_put(tty); | ||
330 | } | ||
331 | } | 326 | } |
332 | 327 | ||
333 | static void ar933x_uart_tx_chars(struct ar933x_uart_port *up) | 328 | static void ar933x_uart_tx_chars(struct ar933x_uart_port *up) |
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index b46860104312..da734222e537 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c | |||
@@ -211,12 +211,8 @@ static void arc_serial_start_tx(struct uart_port *port) | |||
211 | 211 | ||
212 | static void arc_serial_rx_chars(struct arc_uart_port *uart) | 212 | static void arc_serial_rx_chars(struct arc_uart_port *uart) |
213 | { | 213 | { |
214 | struct tty_struct *tty = tty_port_tty_get(&uart->port.state->port); | ||
215 | unsigned int status, ch, flg = 0; | 214 | unsigned int status, ch, flg = 0; |
216 | 215 | ||
217 | if (!tty) | ||
218 | return; | ||
219 | |||
220 | /* | 216 | /* |
221 | * UART has 4 deep RX-FIFO. Driver's recongnition of this fact | 217 | * UART has 4 deep RX-FIFO. Driver's recongnition of this fact |
222 | * is very subtle. Here's how ... | 218 | * is very subtle. Here's how ... |
@@ -252,10 +248,8 @@ static void arc_serial_rx_chars(struct arc_uart_port *uart) | |||
252 | uart_insert_char(&uart->port, status, RXOERR, ch, flg); | 248 | uart_insert_char(&uart->port, status, RXOERR, ch, flg); |
253 | 249 | ||
254 | done: | 250 | done: |
255 | tty_flip_buffer_push(tty); | 251 | tty_flip_buffer_push(&uart->port.state->port); |
256 | } | 252 | } |
257 | |||
258 | tty_kref_put(tty); | ||
259 | } | 253 | } |
260 | 254 | ||
261 | /* | 255 | /* |
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 929567038c5a..d4a7c241b751 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c | |||
@@ -774,7 +774,7 @@ static void atmel_rx_from_ring(struct uart_port *port) | |||
774 | * uart_start(), which takes the lock. | 774 | * uart_start(), which takes the lock. |
775 | */ | 775 | */ |
776 | spin_unlock(&port->lock); | 776 | spin_unlock(&port->lock); |
777 | tty_flip_buffer_push(port->state->port.tty); | 777 | tty_flip_buffer_push(&port->state->port); |
778 | spin_lock(&port->lock); | 778 | spin_lock(&port->lock); |
779 | } | 779 | } |
780 | 780 | ||
@@ -782,7 +782,6 @@ static void atmel_rx_from_dma(struct uart_port *port) | |||
782 | { | 782 | { |
783 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | 783 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); |
784 | struct tty_port *tport = &port->state->port; | 784 | struct tty_port *tport = &port->state->port; |
785 | struct tty_struct *tty = tport->tty; | ||
786 | struct atmel_dma_buffer *pdc; | 785 | struct atmel_dma_buffer *pdc; |
787 | int rx_idx = atmel_port->pdc_rx_idx; | 786 | int rx_idx = atmel_port->pdc_rx_idx; |
788 | unsigned int head; | 787 | unsigned int head; |
@@ -850,7 +849,7 @@ static void atmel_rx_from_dma(struct uart_port *port) | |||
850 | * uart_start(), which takes the lock. | 849 | * uart_start(), which takes the lock. |
851 | */ | 850 | */ |
852 | spin_unlock(&port->lock); | 851 | spin_unlock(&port->lock); |
853 | tty_flip_buffer_push(tty); | 852 | tty_flip_buffer_push(tport); |
854 | spin_lock(&port->lock); | 853 | spin_lock(&port->lock); |
855 | 854 | ||
856 | UART_PUT_IER(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT); | 855 | UART_PUT_IER(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT); |
diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c index de30b1909728..719594e5fc21 100644 --- a/drivers/tty/serial/bcm63xx_uart.c +++ b/drivers/tty/serial/bcm63xx_uart.c | |||
@@ -236,14 +236,12 @@ static const char *bcm_uart_type(struct uart_port *port) | |||
236 | static void bcm_uart_do_rx(struct uart_port *port) | 236 | static void bcm_uart_do_rx(struct uart_port *port) |
237 | { | 237 | { |
238 | struct tty_port *port = &port->state->port; | 238 | struct tty_port *port = &port->state->port; |
239 | struct tty_struct *tty; | ||
240 | unsigned int max_count; | 239 | unsigned int max_count; |
241 | 240 | ||
242 | /* limit number of char read in interrupt, should not be | 241 | /* limit number of char read in interrupt, should not be |
243 | * higher than fifo size anyway since we're much faster than | 242 | * higher than fifo size anyway since we're much faster than |
244 | * serial port */ | 243 | * serial port */ |
245 | max_count = 32; | 244 | max_count = 32; |
246 | tty = port->tty; | ||
247 | do { | 245 | do { |
248 | unsigned int iestat, c, cstat; | 246 | unsigned int iestat, c, cstat; |
249 | char flag; | 247 | char flag; |
@@ -305,7 +303,7 @@ static void bcm_uart_do_rx(struct uart_port *port) | |||
305 | 303 | ||
306 | } while (--max_count); | 304 | } while (--max_count); |
307 | 305 | ||
308 | tty_flip_buffer_push(tty); | 306 | tty_flip_buffer_push(port); |
309 | } | 307 | } |
310 | 308 | ||
311 | /* | 309 | /* |
diff --git a/drivers/tty/serial/bfin_sport_uart.c b/drivers/tty/serial/bfin_sport_uart.c index e4d3ac2e8992..487c173b0f72 100644 --- a/drivers/tty/serial/bfin_sport_uart.c +++ b/drivers/tty/serial/bfin_sport_uart.c | |||
@@ -150,7 +150,6 @@ static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id) | |||
150 | { | 150 | { |
151 | struct sport_uart_port *up = dev_id; | 151 | struct sport_uart_port *up = dev_id; |
152 | struct tty_port *port = &up->port.state->port; | 152 | struct tty_port *port = &up->port.state->port; |
153 | struct tty_struct *tty = tport->tty; | ||
154 | unsigned int ch; | 153 | unsigned int ch; |
155 | 154 | ||
156 | spin_lock(&up->port.lock); | 155 | spin_lock(&up->port.lock); |
@@ -162,7 +161,8 @@ static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id) | |||
162 | if (!uart_handle_sysrq_char(&up->port, ch)) | 161 | if (!uart_handle_sysrq_char(&up->port, ch)) |
163 | tty_insert_flip_char(port, ch, TTY_NORMAL); | 162 | tty_insert_flip_char(port, ch, TTY_NORMAL); |
164 | } | 163 | } |
165 | tty_flip_buffer_push(tty); | 164 | /* XXX this won't deadlock with lowlat? */ |
165 | tty_flip_buffer_push(port); | ||
166 | 166 | ||
167 | spin_unlock(&up->port.lock); | 167 | spin_unlock(&up->port.lock); |
168 | 168 | ||
diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c index 2e2b2c1cb722..12dceda9db33 100644 --- a/drivers/tty/serial/bfin_uart.c +++ b/drivers/tty/serial/bfin_uart.c | |||
@@ -223,7 +223,6 @@ static void bfin_serial_enable_ms(struct uart_port *port) | |||
223 | #ifdef CONFIG_SERIAL_BFIN_PIO | 223 | #ifdef CONFIG_SERIAL_BFIN_PIO |
224 | static void bfin_serial_rx_chars(struct bfin_serial_port *uart) | 224 | static void bfin_serial_rx_chars(struct bfin_serial_port *uart) |
225 | { | 225 | { |
226 | struct tty_struct *tty = NULL; | ||
227 | unsigned int status, ch, flg; | 226 | unsigned int status, ch, flg; |
228 | static struct timeval anomaly_start = { .tv_sec = 0 }; | 227 | static struct timeval anomaly_start = { .tv_sec = 0 }; |
229 | 228 | ||
@@ -242,11 +241,9 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart) | |||
242 | return; | 241 | return; |
243 | } | 242 | } |
244 | 243 | ||
245 | if (!uart->port.state || !uart->port.state->port.tty) | 244 | if (!uart->port.state) |
246 | return; | 245 | return; |
247 | #endif | 246 | #endif |
248 | tty = uart->port.state->port.tty; | ||
249 | |||
250 | if (ANOMALY_05000363) { | 247 | if (ANOMALY_05000363) { |
251 | /* The BF533 (and BF561) family of processors have a nice anomaly | 248 | /* The BF533 (and BF561) family of processors have a nice anomaly |
252 | * where they continuously generate characters for a "single" break. | 249 | * where they continuously generate characters for a "single" break. |
@@ -325,7 +322,7 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart) | |||
325 | uart_insert_char(&uart->port, status, OE, ch, flg); | 322 | uart_insert_char(&uart->port, status, OE, ch, flg); |
326 | 323 | ||
327 | ignore_char: | 324 | ignore_char: |
328 | tty_flip_buffer_push(tty); | 325 | tty_flip_buffer_push(&uart->port.state->port); |
329 | } | 326 | } |
330 | 327 | ||
331 | static void bfin_serial_tx_chars(struct bfin_serial_port *uart) | 328 | static void bfin_serial_tx_chars(struct bfin_serial_port *uart) |
@@ -426,7 +423,6 @@ static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart) | |||
426 | 423 | ||
427 | static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart) | 424 | static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart) |
428 | { | 425 | { |
429 | struct tty_struct *tty = uart->port.state->port.tty; | ||
430 | int i, flg, status; | 426 | int i, flg, status; |
431 | 427 | ||
432 | status = UART_GET_LSR(uart); | 428 | status = UART_GET_LSR(uart); |
@@ -471,7 +467,7 @@ static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart) | |||
471 | } | 467 | } |
472 | 468 | ||
473 | dma_ignore_char: | 469 | dma_ignore_char: |
474 | tty_flip_buffer_push(tty); | 470 | tty_flip_buffer_push(&uart->port.state->port); |
475 | } | 471 | } |
476 | 472 | ||
477 | void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart) | 473 | void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart) |
diff --git a/drivers/tty/serial/clps711x.c b/drivers/tty/serial/clps711x.c index 3fd2526d121e..bfb17968c8db 100644 --- a/drivers/tty/serial/clps711x.c +++ b/drivers/tty/serial/clps711x.c | |||
@@ -85,12 +85,8 @@ static void uart_clps711x_enable_ms(struct uart_port *port) | |||
85 | static irqreturn_t uart_clps711x_int_rx(int irq, void *dev_id) | 85 | static irqreturn_t uart_clps711x_int_rx(int irq, void *dev_id) |
86 | { | 86 | { |
87 | struct uart_port *port = dev_id; | 87 | struct uart_port *port = dev_id; |
88 | struct tty_struct *tty = tty_port_tty_get(&port->state->port); | ||
89 | unsigned int status, ch, flg; | 88 | unsigned int status, ch, flg; |
90 | 89 | ||
91 | if (!tty) | ||
92 | return IRQ_HANDLED; | ||
93 | |||
94 | for (;;) { | 90 | for (;;) { |
95 | status = clps_readl(SYSFLG(port)); | 91 | status = clps_readl(SYSFLG(port)); |
96 | if (status & SYSFLG_URXFE) | 92 | if (status & SYSFLG_URXFE) |
@@ -130,9 +126,7 @@ static irqreturn_t uart_clps711x_int_rx(int irq, void *dev_id) | |||
130 | uart_insert_char(port, status, UARTDR_OVERR, ch, flg); | 126 | uart_insert_char(port, status, UARTDR_OVERR, ch, flg); |
131 | } | 127 | } |
132 | 128 | ||
133 | tty_flip_buffer_push(tty); | 129 | tty_flip_buffer_push(&port->state->port); |
134 | |||
135 | tty_kref_put(tty); | ||
136 | 130 | ||
137 | return IRQ_HANDLED; | 131 | return IRQ_HANDLED; |
138 | } | 132 | } |
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c index 0bb24378a3c0..97f4e1858649 100644 --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c | |||
@@ -246,7 +246,6 @@ static void cpm_uart_int_rx(struct uart_port *port) | |||
246 | unsigned char ch; | 246 | unsigned char ch; |
247 | u8 *cp; | 247 | u8 *cp; |
248 | struct tty_port *tport = &port->state->port; | 248 | struct tty_port *tport = &port->state->port; |
249 | struct tty_struct *tty = tport->tty; | ||
250 | struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; | 249 | struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; |
251 | cbd_t __iomem *bdp; | 250 | cbd_t __iomem *bdp; |
252 | u16 status; | 251 | u16 status; |
@@ -323,7 +322,7 @@ static void cpm_uart_int_rx(struct uart_port *port) | |||
323 | pinfo->rx_cur = bdp; | 322 | pinfo->rx_cur = bdp; |
324 | 323 | ||
325 | /* activate BH processing */ | 324 | /* activate BH processing */ |
326 | tty_flip_buffer_push(tty); | 325 | tty_flip_buffer_push(tport); |
327 | 326 | ||
328 | return; | 327 | return; |
329 | 328 | ||
diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index 52449adc09ac..45acf103433e 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c | |||
@@ -2104,17 +2104,10 @@ static int force_eop_if_needed(struct e100_serial *info) | |||
2104 | 2104 | ||
2105 | static void flush_to_flip_buffer(struct e100_serial *info) | 2105 | static void flush_to_flip_buffer(struct e100_serial *info) |
2106 | { | 2106 | { |
2107 | struct tty_struct *tty; | ||
2108 | struct etrax_recv_buffer *buffer; | 2107 | struct etrax_recv_buffer *buffer; |
2109 | unsigned long flags; | 2108 | unsigned long flags; |
2110 | 2109 | ||
2111 | local_irq_save(flags); | 2110 | local_irq_save(flags); |
2112 | tty = info->port.tty; | ||
2113 | |||
2114 | if (!tty) { | ||
2115 | local_irq_restore(flags); | ||
2116 | return; | ||
2117 | } | ||
2118 | 2111 | ||
2119 | while ((buffer = info->first_recv_buffer) != NULL) { | 2112 | while ((buffer = info->first_recv_buffer) != NULL) { |
2120 | unsigned int count = buffer->length; | 2113 | unsigned int count = buffer->length; |
@@ -2138,7 +2131,7 @@ static void flush_to_flip_buffer(struct e100_serial *info) | |||
2138 | local_irq_restore(flags); | 2131 | local_irq_restore(flags); |
2139 | 2132 | ||
2140 | /* This includes a check for low-latency */ | 2133 | /* This includes a check for low-latency */ |
2141 | tty_flip_buffer_push(tty); | 2134 | tty_flip_buffer_push(&info->port); |
2142 | } | 2135 | } |
2143 | 2136 | ||
2144 | static void check_flush_timeout(struct e100_serial *info) | 2137 | static void check_flush_timeout(struct e100_serial *info) |
@@ -2274,12 +2267,6 @@ static | |||
2274 | struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) | 2267 | struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) |
2275 | { | 2268 | { |
2276 | unsigned long data_read; | 2269 | unsigned long data_read; |
2277 | struct tty_struct *tty = info->port.tty; | ||
2278 | |||
2279 | if (!tty) { | ||
2280 | printk("!NO TTY!\n"); | ||
2281 | return info; | ||
2282 | } | ||
2283 | 2270 | ||
2284 | /* Read data and status at the same time */ | 2271 | /* Read data and status at the same time */ |
2285 | data_read = *((unsigned long *)&info->ioport[REG_DATA_STATUS32]); | 2272 | data_read = *((unsigned long *)&info->ioport[REG_DATA_STATUS32]); |
@@ -2382,7 +2369,7 @@ more_data: | |||
2382 | goto more_data; | 2369 | goto more_data; |
2383 | } | 2370 | } |
2384 | 2371 | ||
2385 | tty_flip_buffer_push(info->port.tty); | 2372 | tty_flip_buffer_push(&info->port); |
2386 | return info; | 2373 | return info; |
2387 | } | 2374 | } |
2388 | 2375 | ||
diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c index 6491b8644a7f..2f2b2e538a54 100644 --- a/drivers/tty/serial/dz.c +++ b/drivers/tty/serial/dz.c | |||
@@ -187,7 +187,6 @@ static inline void dz_receive_chars(struct dz_mux *mux) | |||
187 | { | 187 | { |
188 | struct uart_port *uport; | 188 | struct uart_port *uport; |
189 | struct dz_port *dport = &mux->dport[0]; | 189 | struct dz_port *dport = &mux->dport[0]; |
190 | struct tty_struct *tty = NULL; | ||
191 | struct uart_icount *icount; | 190 | struct uart_icount *icount; |
192 | int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 }; | 191 | int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 }; |
193 | unsigned char ch, flag; | 192 | unsigned char ch, flag; |
@@ -197,7 +196,6 @@ static inline void dz_receive_chars(struct dz_mux *mux) | |||
197 | while ((status = dz_in(dport, DZ_RBUF)) & DZ_DVAL) { | 196 | while ((status = dz_in(dport, DZ_RBUF)) & DZ_DVAL) { |
198 | dport = &mux->dport[LINE(status)]; | 197 | dport = &mux->dport[LINE(status)]; |
199 | uport = &dport->port; | 198 | uport = &dport->port; |
200 | tty = uport->state->port.tty; /* point to the proper dev */ | ||
201 | 199 | ||
202 | ch = UCHAR(status); /* grab the char */ | 200 | ch = UCHAR(status); /* grab the char */ |
203 | flag = TTY_NORMAL; | 201 | flag = TTY_NORMAL; |
@@ -249,7 +247,7 @@ static inline void dz_receive_chars(struct dz_mux *mux) | |||
249 | } | 247 | } |
250 | for (i = 0; i < DZ_NB_PORT; i++) | 248 | for (i = 0; i < DZ_NB_PORT; i++) |
251 | if (lines_rx[i]) | 249 | if (lines_rx[i]) |
252 | tty_flip_buffer_push(mux->dport[i].port.state->port.tty); | 250 | tty_flip_buffer_push(&mux->dport[i].port.state->port); |
253 | } | 251 | } |
254 | 252 | ||
255 | /* | 253 | /* |
diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c index bdf67b0cb8b6..de14bd7dce10 100644 --- a/drivers/tty/serial/efm32-uart.c +++ b/drivers/tty/serial/efm32-uart.c | |||
@@ -249,12 +249,9 @@ static irqreturn_t efm32_uart_rxirq(int irq, void *data) | |||
249 | int handled = IRQ_NONE; | 249 | int handled = IRQ_NONE; |
250 | struct uart_port *port = &efm_port->port; | 250 | struct uart_port *port = &efm_port->port; |
251 | struct tty_port *tport = &port->state->port; | 251 | struct tty_port *tport = &port->state->port; |
252 | struct tty_struct *tty; | ||
253 | 252 | ||
254 | spin_lock(&port->lock); | 253 | spin_lock(&port->lock); |
255 | 254 | ||
256 | tty = tty_kref_get(tport->tty); | ||
257 | |||
258 | if (irqflag & UARTn_IF_RXDATAV) { | 255 | if (irqflag & UARTn_IF_RXDATAV) { |
259 | efm32_uart_write32(efm_port, UARTn_IF_RXDATAV, UARTn_IFC); | 256 | efm32_uart_write32(efm_port, UARTn_IF_RXDATAV, UARTn_IFC); |
260 | efm32_uart_rx_chars(efm_port); | 257 | efm32_uart_rx_chars(efm_port); |
@@ -270,10 +267,7 @@ static irqreturn_t efm32_uart_rxirq(int irq, void *data) | |||
270 | handled = IRQ_HANDLED; | 267 | handled = IRQ_HANDLED; |
271 | } | 268 | } |
272 | 269 | ||
273 | if (tty) { | 270 | tty_flip_buffer_push(tport); |
274 | tty_flip_buffer_push(tty); | ||
275 | tty_kref_put(tty); | ||
276 | } | ||
277 | 271 | ||
278 | spin_unlock(&port->lock); | 272 | spin_unlock(&port->lock); |
279 | 273 | ||
diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c index 54903ee5e5ab..bc9e6b017b05 100644 --- a/drivers/tty/serial/icom.c +++ b/drivers/tty/serial/icom.c | |||
@@ -735,7 +735,6 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) | |||
735 | { | 735 | { |
736 | short int count, rcv_buff; | 736 | short int count, rcv_buff; |
737 | struct tty_port *port = &icom_port->uart_port.state->port; | 737 | struct tty_port *port = &icom_port->uart_port.state->port; |
738 | struct tty_struct *tty = port->tty; | ||
739 | unsigned short int status; | 738 | unsigned short int status; |
740 | struct uart_icount *icount; | 739 | struct uart_icount *icount; |
741 | unsigned long offset; | 740 | unsigned long offset; |
@@ -835,7 +834,7 @@ ignore_char: | |||
835 | status = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].flags); | 834 | status = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].flags); |
836 | } | 835 | } |
837 | icom_port->next_rcv = rcv_buff; | 836 | icom_port->next_rcv = rcv_buff; |
838 | tty_flip_buffer_push(tty); | 837 | tty_flip_buffer_push(port); |
839 | } | 838 | } |
840 | 839 | ||
841 | static void process_interrupt(u16 port_int_reg, | 840 | static void process_interrupt(u16 port_int_reg, |
diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c index 4bc6e47890b4..6a6668bbb330 100644 --- a/drivers/tty/serial/ifx6x60.c +++ b/drivers/tty/serial/ifx6x60.c | |||
@@ -669,12 +669,8 @@ static const struct tty_operations ifx_spi_serial_ops = { | |||
669 | static void ifx_spi_insert_flip_string(struct ifx_spi_device *ifx_dev, | 669 | static void ifx_spi_insert_flip_string(struct ifx_spi_device *ifx_dev, |
670 | unsigned char *chars, size_t size) | 670 | unsigned char *chars, size_t size) |
671 | { | 671 | { |
672 | struct tty_struct *tty = tty_port_tty_get(&ifx_dev->tty_port); | ||
673 | if (!tty) | ||
674 | return; | ||
675 | tty_insert_flip_string(&ifx_dev->tty_port, chars, size); | 672 | tty_insert_flip_string(&ifx_dev->tty_port, chars, size); |
676 | tty_flip_buffer_push(tty); | 673 | tty_flip_buffer_push(&ifx_dev->tty_port); |
677 | tty_kref_put(tty); | ||
678 | } | 674 | } |
679 | 675 | ||
680 | /** | 676 | /** |
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index f60c4028b6e1..be26345bf6a4 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c | |||
@@ -518,7 +518,6 @@ static irqreturn_t imx_rxint(int irq, void *dev_id) | |||
518 | unsigned int rx, flg, ignored = 0; | 518 | unsigned int rx, flg, ignored = 0; |
519 | struct tty_struct *tty = sport->port.state->port.tty; | 519 | struct tty_struct *tty = sport->port.state->port.tty; |
520 | struct tty_port *port = &sport->port.state->port; | 520 | struct tty_port *port = &sport->port.state->port; |
521 | struct tty_struct *tty = port->tty; | ||
522 | unsigned long flags, temp; | 521 | unsigned long flags, temp; |
523 | 522 | ||
524 | spin_lock_irqsave(&sport->port.lock, flags); | 523 | spin_lock_irqsave(&sport->port.lock, flags); |
@@ -576,7 +575,7 @@ static irqreturn_t imx_rxint(int irq, void *dev_id) | |||
576 | 575 | ||
577 | out: | 576 | out: |
578 | spin_unlock_irqrestore(&sport->port.lock, flags); | 577 | spin_unlock_irqrestore(&sport->port.lock, flags); |
579 | tty_flip_buffer_push(tty); | 578 | tty_flip_buffer_push(port); |
580 | return IRQ_HANDLED; | 579 | return IRQ_HANDLED; |
581 | } | 580 | } |
582 | 581 | ||
diff --git a/drivers/tty/serial/ioc3_serial.c b/drivers/tty/serial/ioc3_serial.c index edbdc4e45075..6e4c715c5d26 100644 --- a/drivers/tty/serial/ioc3_serial.c +++ b/drivers/tty/serial/ioc3_serial.c | |||
@@ -1393,7 +1393,6 @@ static inline int do_read(struct uart_port *the_port, char *buf, int len) | |||
1393 | */ | 1393 | */ |
1394 | static int receive_chars(struct uart_port *the_port) | 1394 | static int receive_chars(struct uart_port *the_port) |
1395 | { | 1395 | { |
1396 | struct tty_struct *tty; | ||
1397 | unsigned char ch[MAX_CHARS]; | 1396 | unsigned char ch[MAX_CHARS]; |
1398 | int read_count = 0, read_room, flip = 0; | 1397 | int read_count = 0, read_room, flip = 0; |
1399 | struct uart_state *state = the_port->state; | 1398 | struct uart_state *state = the_port->state; |
@@ -1403,14 +1402,11 @@ static int receive_chars(struct uart_port *the_port) | |||
1403 | /* Make sure all the pointers are "good" ones */ | 1402 | /* Make sure all the pointers are "good" ones */ |
1404 | if (!state) | 1403 | if (!state) |
1405 | return 0; | 1404 | return 0; |
1406 | if (!state->port.tty) | ||
1407 | return 0; | ||
1408 | 1405 | ||
1409 | if (!(port->ip_flags & INPUT_ENABLE)) | 1406 | if (!(port->ip_flags & INPUT_ENABLE)) |
1410 | return 0; | 1407 | return 0; |
1411 | 1408 | ||
1412 | spin_lock_irqsave(&the_port->lock, pflags); | 1409 | spin_lock_irqsave(&the_port->lock, pflags); |
1413 | tty = state->port.tty; | ||
1414 | 1410 | ||
1415 | read_count = do_read(the_port, ch, MAX_CHARS); | 1411 | read_count = do_read(the_port, ch, MAX_CHARS); |
1416 | if (read_count > 0) { | 1412 | if (read_count > 0) { |
@@ -1422,7 +1418,7 @@ static int receive_chars(struct uart_port *the_port) | |||
1422 | spin_unlock_irqrestore(&the_port->lock, pflags); | 1418 | spin_unlock_irqrestore(&the_port->lock, pflags); |
1423 | 1419 | ||
1424 | if (flip) | 1420 | if (flip) |
1425 | tty_flip_buffer_push(tty); | 1421 | tty_flip_buffer_push(&state->port); |
1426 | 1422 | ||
1427 | return read_count; | 1423 | return read_count; |
1428 | } | 1424 | } |
diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c index 86f64ed89b45..e2520abcb1c4 100644 --- a/drivers/tty/serial/ioc4_serial.c +++ b/drivers/tty/serial/ioc4_serial.c | |||
@@ -2340,7 +2340,6 @@ static inline int do_read(struct uart_port *the_port, unsigned char *buf, | |||
2340 | */ | 2340 | */ |
2341 | static void receive_chars(struct uart_port *the_port) | 2341 | static void receive_chars(struct uart_port *the_port) |
2342 | { | 2342 | { |
2343 | struct tty_struct *tty; | ||
2344 | unsigned char ch[IOC4_MAX_CHARS]; | 2343 | unsigned char ch[IOC4_MAX_CHARS]; |
2345 | int read_count, request_count = IOC4_MAX_CHARS; | 2344 | int read_count, request_count = IOC4_MAX_CHARS; |
2346 | struct uart_icount *icount; | 2345 | struct uart_icount *icount; |
@@ -2350,11 +2349,8 @@ static void receive_chars(struct uart_port *the_port) | |||
2350 | /* Make sure all the pointers are "good" ones */ | 2349 | /* Make sure all the pointers are "good" ones */ |
2351 | if (!state) | 2350 | if (!state) |
2352 | return; | 2351 | return; |
2353 | if (!state->port.tty) | ||
2354 | return; | ||
2355 | 2352 | ||
2356 | spin_lock_irqsave(&the_port->lock, pflags); | 2353 | spin_lock_irqsave(&the_port->lock, pflags); |
2357 | tty = state->port.tty; | ||
2358 | 2354 | ||
2359 | request_count = tty_buffer_request_room(&state->port, IOC4_MAX_CHARS); | 2355 | request_count = tty_buffer_request_room(&state->port, IOC4_MAX_CHARS); |
2360 | 2356 | ||
@@ -2369,7 +2365,7 @@ static void receive_chars(struct uart_port *the_port) | |||
2369 | 2365 | ||
2370 | spin_unlock_irqrestore(&the_port->lock, pflags); | 2366 | spin_unlock_irqrestore(&the_port->lock, pflags); |
2371 | 2367 | ||
2372 | tty_flip_buffer_push(tty); | 2368 | tty_flip_buffer_push(&state->port); |
2373 | } | 2369 | } |
2374 | 2370 | ||
2375 | /** | 2371 | /** |
diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c index c9ce00dd1f8a..00f250ae14c5 100644 --- a/drivers/tty/serial/jsm/jsm_tty.c +++ b/drivers/tty/serial/jsm/jsm_tty.c | |||
@@ -654,7 +654,7 @@ void jsm_input(struct jsm_channel *ch) | |||
654 | spin_unlock_irqrestore(&ch->ch_lock, lock_flags); | 654 | spin_unlock_irqrestore(&ch->ch_lock, lock_flags); |
655 | 655 | ||
656 | /* Tell the tty layer its okay to "eat" the data now */ | 656 | /* Tell the tty layer its okay to "eat" the data now */ |
657 | tty_flip_buffer_push(tp); | 657 | tty_flip_buffer_push(port); |
658 | 658 | ||
659 | jsm_dbg(IOCTL, &ch->ch_bd->pci_dev, "finish\n"); | 659 | jsm_dbg(IOCTL, &ch->ch_bd->pci_dev, "finish\n"); |
660 | } | 660 | } |
diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c index ba2ef627d9c6..26a50b0c868b 100644 --- a/drivers/tty/serial/kgdb_nmi.c +++ b/drivers/tty/serial/kgdb_nmi.c | |||
@@ -202,7 +202,6 @@ bool kgdb_nmi_poll_knock(void) | |||
202 | static void kgdb_nmi_tty_receiver(unsigned long data) | 202 | static void kgdb_nmi_tty_receiver(unsigned long data) |
203 | { | 203 | { |
204 | struct kgdb_nmi_tty_priv *priv = (void *)data; | 204 | struct kgdb_nmi_tty_priv *priv = (void *)data; |
205 | struct tty_struct *tty; | ||
206 | char ch; | 205 | char ch; |
207 | 206 | ||
208 | tasklet_schedule(&priv->tlet); | 207 | tasklet_schedule(&priv->tlet); |
@@ -210,16 +209,9 @@ static void kgdb_nmi_tty_receiver(unsigned long data) | |||
210 | if (likely(!kgdb_nmi_tty_enabled || !kfifo_len(&priv->fifo))) | 209 | if (likely(!kgdb_nmi_tty_enabled || !kfifo_len(&priv->fifo))) |
211 | return; | 210 | return; |
212 | 211 | ||
213 | /* Port is there, but tty might be hung up, check. */ | ||
214 | tty = tty_port_tty_get(kgdb_nmi_port); | ||
215 | if (!tty) | ||
216 | return; | ||
217 | |||
218 | while (kfifo_out(&priv->fifo, &ch, 1)) | 212 | while (kfifo_out(&priv->fifo, &ch, 1)) |
219 | tty_insert_flip_char(&priv->port, ch, TTY_NORMAL); | 213 | tty_insert_flip_char(&priv->port, ch, TTY_NORMAL); |
220 | tty_flip_buffer_push(priv->port.tty); | 214 | tty_flip_buffer_push(&priv->port); |
221 | |||
222 | tty_kref_put(tty); | ||
223 | } | 215 | } |
224 | 216 | ||
225 | static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty) | 217 | static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty) |
diff --git a/drivers/tty/serial/lantiq.c b/drivers/tty/serial/lantiq.c index 1933fe3c98dd..15733da757c6 100644 --- a/drivers/tty/serial/lantiq.c +++ b/drivers/tty/serial/lantiq.c | |||
@@ -163,21 +163,15 @@ static int | |||
163 | lqasc_rx_chars(struct uart_port *port) | 163 | lqasc_rx_chars(struct uart_port *port) |
164 | { | 164 | { |
165 | struct tty_port *tport = &port->state->port; | 165 | struct tty_port *tport = &port->state->port; |
166 | struct tty_struct *tty = tty_port_tty_get(tport); | ||
167 | unsigned int ch = 0, rsr = 0, fifocnt; | 166 | unsigned int ch = 0, rsr = 0, fifocnt; |
168 | 167 | ||
169 | if (!tty) { | 168 | fifocnt = ltq_r32(port->membase + LTQ_ASC_FSTAT) & ASCFSTAT_RXFFLMASK; |
170 | dev_dbg(port->dev, "%s:tty is busy now", __func__); | ||
171 | return -EBUSY; | ||
172 | } | ||
173 | fifocnt = | ||
174 | ltq_r32(port->membase + LTQ_ASC_FSTAT) & ASCFSTAT_RXFFLMASK; | ||
175 | while (fifocnt--) { | 169 | while (fifocnt--) { |
176 | u8 flag = TTY_NORMAL; | 170 | u8 flag = TTY_NORMAL; |
177 | ch = ltq_r8(port->membase + LTQ_ASC_RBUF); | 171 | ch = ltq_r8(port->membase + LTQ_ASC_RBUF); |
178 | rsr = (ltq_r32(port->membase + LTQ_ASC_STATE) | 172 | rsr = (ltq_r32(port->membase + LTQ_ASC_STATE) |
179 | & ASCSTATE_ANY) | UART_DUMMY_UER_RX; | 173 | & ASCSTATE_ANY) | UART_DUMMY_UER_RX; |
180 | tty_flip_buffer_push(tty); | 174 | tty_flip_buffer_push(tport); |
181 | port->icount.rx++; | 175 | port->icount.rx++; |
182 | 176 | ||
183 | /* | 177 | /* |
@@ -219,9 +213,10 @@ lqasc_rx_chars(struct uart_port *port) | |||
219 | */ | 213 | */ |
220 | tty_insert_flip_char(tport, 0, TTY_OVERRUN); | 214 | tty_insert_flip_char(tport, 0, TTY_OVERRUN); |
221 | } | 215 | } |
216 | |||
222 | if (ch != 0) | 217 | if (ch != 0) |
223 | tty_flip_buffer_push(tty); | 218 | tty_flip_buffer_push(tport); |
224 | tty_kref_put(tty); | 219 | |
225 | return 0; | 220 | return 0; |
226 | } | 221 | } |
227 | 222 | ||
diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c index 5cd180564c03..c8448e6f52e5 100644 --- a/drivers/tty/serial/lpc32xx_hs.c +++ b/drivers/tty/serial/lpc32xx_hs.c | |||
@@ -259,16 +259,6 @@ static void __serial_lpc32xx_rx(struct uart_port *port) | |||
259 | { | 259 | { |
260 | struct tty_port *tport = &port->state->port; | 260 | struct tty_port *tport = &port->state->port; |
261 | unsigned int tmp, flag; | 261 | unsigned int tmp, flag; |
262 | struct tty_struct *tty = tty_port_tty_get(tport); | ||
263 | |||
264 | if (!tty) { | ||
265 | /* Discard data: no tty available */ | ||
266 | while (!(readl(LPC32XX_HSUART_FIFO(port->membase)) & | ||
267 | LPC32XX_HSU_RX_EMPTY)) | ||
268 | ; | ||
269 | |||
270 | return; | ||
271 | } | ||
272 | 262 | ||
273 | /* Read data from FIFO and push into terminal */ | 263 | /* Read data from FIFO and push into terminal */ |
274 | tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); | 264 | tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); |
@@ -289,8 +279,7 @@ static void __serial_lpc32xx_rx(struct uart_port *port) | |||
289 | 279 | ||
290 | tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); | 280 | tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); |
291 | } | 281 | } |
292 | tty_flip_buffer_push(tty); | 282 | tty_flip_buffer_push(tport); |
293 | tty_kref_put(tty); | ||
294 | } | 283 | } |
295 | 284 | ||
296 | static void __serial_lpc32xx_tx(struct uart_port *port) | 285 | static void __serial_lpc32xx_tx(struct uart_port *port) |
@@ -367,8 +356,7 @@ static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id) | |||
367 | /* Data received? */ | 356 | /* Data received? */ |
368 | if (status & (LPC32XX_HSU_RX_TIMEOUT_INT | LPC32XX_HSU_RX_TRIG_INT)) { | 357 | if (status & (LPC32XX_HSU_RX_TIMEOUT_INT | LPC32XX_HSU_RX_TRIG_INT)) { |
369 | __serial_lpc32xx_rx(port); | 358 | __serial_lpc32xx_rx(port); |
370 | if (tty) | 359 | tty_flip_buffer_push(tport); |
371 | tty_flip_buffer_push(tty); | ||
372 | } | 360 | } |
373 | 361 | ||
374 | /* Transmit data request? */ | 362 | /* Transmit data request? */ |
diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c index 2e9a390f2ac4..bb1afa0922e1 100644 --- a/drivers/tty/serial/m32r_sio.c +++ b/drivers/tty/serial/m32r_sio.c | |||
@@ -301,7 +301,6 @@ static void m32r_sio_enable_ms(struct uart_port *port) | |||
301 | static void receive_chars(struct uart_sio_port *up, int *status) | 301 | static void receive_chars(struct uart_sio_port *up, int *status) |
302 | { | 302 | { |
303 | struct tty_port *port = &up->port.state->port; | 303 | struct tty_port *port = &up->port.state->port; |
304 | struct tty_struct *tty = tport->tty; | ||
305 | unsigned char ch; | 304 | unsigned char ch; |
306 | unsigned char flag; | 305 | unsigned char flag; |
307 | int max_count = 256; | 306 | int max_count = 256; |
@@ -369,7 +368,7 @@ static void receive_chars(struct uart_sio_port *up, int *status) | |||
369 | ignore_char: | 368 | ignore_char: |
370 | *status = serial_in(up, UART_LSR); | 369 | *status = serial_in(up, UART_LSR); |
371 | } while ((*status & UART_LSR_DR) && (max_count-- > 0)); | 370 | } while ((*status & UART_LSR_DR) && (max_count-- > 0)); |
372 | tty_flip_buffer_push(tty); | 371 | tty_flip_buffer_push(port); |
373 | } | 372 | } |
374 | 373 | ||
375 | static void transmit_chars(struct uart_sio_port *up) | 374 | static void transmit_chars(struct uart_sio_port *up) |
diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index e238e80cd981..791e1dfb8b11 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c | |||
@@ -311,8 +311,8 @@ static void max3100_work(struct work_struct *w) | |||
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | if (rxchars > 16 && s->port.state->port.tty != NULL) { | 314 | if (rxchars > 16) { |
315 | tty_flip_buffer_push(s->port.state->port.tty); | 315 | tty_flip_buffer_push(&s->port.state->port); |
316 | rxchars = 0; | 316 | rxchars = 0; |
317 | } | 317 | } |
318 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | 318 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |
@@ -324,8 +324,8 @@ static void max3100_work(struct work_struct *w) | |||
324 | (!uart_circ_empty(xmit) && | 324 | (!uart_circ_empty(xmit) && |
325 | !uart_tx_stopped(&s->port)))); | 325 | !uart_tx_stopped(&s->port)))); |
326 | 326 | ||
327 | if (rxchars > 0 && s->port.state->port.tty != NULL) | 327 | if (rxchars > 0) |
328 | tty_flip_buffer_push(s->port.state->port.tty); | 328 | tty_flip_buffer_push(&s->port.state->port); |
329 | } | 329 | } |
330 | 330 | ||
331 | static irqreturn_t max3100_irq(int irqno, void *dev_id) | 331 | static irqreturn_t max3100_irq(int irqno, void *dev_id) |
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index a801f6872cad..0c2422cb04ea 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c | |||
@@ -460,10 +460,6 @@ static int max310x_set_ref_clk(struct max310x_port *s) | |||
460 | static void max310x_handle_rx(struct max310x_port *s, unsigned int rxlen) | 460 | static void max310x_handle_rx(struct max310x_port *s, unsigned int rxlen) |
461 | { | 461 | { |
462 | unsigned int sts = 0, ch = 0, flag; | 462 | unsigned int sts = 0, ch = 0, flag; |
463 | struct tty_struct *tty = tty_port_tty_get(&s->port.state->port); | ||
464 | |||
465 | if (!tty) | ||
466 | return; | ||
467 | 463 | ||
468 | if (unlikely(rxlen >= MAX310X_FIFO_SIZE)) { | 464 | if (unlikely(rxlen >= MAX310X_FIFO_SIZE)) { |
469 | dev_warn(s->port.dev, "Possible RX FIFO overrun %d\n", rxlen); | 465 | dev_warn(s->port.dev, "Possible RX FIFO overrun %d\n", rxlen); |
@@ -516,9 +512,7 @@ static void max310x_handle_rx(struct max310x_port *s, unsigned int rxlen) | |||
516 | ch, flag); | 512 | ch, flag); |
517 | } | 513 | } |
518 | 514 | ||
519 | tty_flip_buffer_push(tty); | 515 | tty_flip_buffer_push(&s->port.state->port); |
520 | |||
521 | tty_kref_put(tty); | ||
522 | } | 516 | } |
523 | 517 | ||
524 | static void max310x_handle_tx(struct max310x_port *s) | 518 | static void max310x_handle_tx(struct max310x_port *s) |
diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c index fcd56ab6053f..7ed99274572f 100644 --- a/drivers/tty/serial/mcf.c +++ b/drivers/tty/serial/mcf.c | |||
@@ -310,7 +310,7 @@ static void mcf_rx_chars(struct mcf_uart *pp) | |||
310 | uart_insert_char(port, status, MCFUART_USR_RXOVERRUN, ch, flag); | 310 | uart_insert_char(port, status, MCFUART_USR_RXOVERRUN, ch, flag); |
311 | } | 311 | } |
312 | 312 | ||
313 | tty_flip_buffer_push(port->state->port.tty); | 313 | tty_flip_buffer_push(&port->state->port); |
314 | } | 314 | } |
315 | 315 | ||
316 | /****************************************************************************/ | 316 | /****************************************************************************/ |
diff --git a/drivers/tty/serial/mfd.c b/drivers/tty/serial/mfd.c index 60d585ab4870..5f4765a7a5c5 100644 --- a/drivers/tty/serial/mfd.c +++ b/drivers/tty/serial/mfd.c | |||
@@ -388,12 +388,8 @@ void hsu_dma_rx(struct uart_hsu_port *up, u32 int_sts) | |||
388 | struct hsu_dma_chan *chan = up->rxc; | 388 | struct hsu_dma_chan *chan = up->rxc; |
389 | struct uart_port *port = &up->port; | 389 | struct uart_port *port = &up->port; |
390 | struct tty_port *tport = &port->state->port; | 390 | struct tty_port *tport = &port->state->port; |
391 | struct tty_struct *tty = tport->tty; | ||
392 | int count; | 391 | int count; |
393 | 392 | ||
394 | if (!tty) | ||
395 | return; | ||
396 | |||
397 | /* | 393 | /* |
398 | * First need to know how many is already transferred, | 394 | * First need to know how many is already transferred, |
399 | * then check if its a timeout DMA irq, and return | 395 | * then check if its a timeout DMA irq, and return |
@@ -438,7 +434,7 @@ void hsu_dma_rx(struct uart_hsu_port *up, u32 int_sts) | |||
438 | | (0x1 << 16) | 434 | | (0x1 << 16) |
439 | | (0x1 << 24) /* timeout bit, see HSU Errata 1 */ | 435 | | (0x1 << 24) /* timeout bit, see HSU Errata 1 */ |
440 | ); | 436 | ); |
441 | tty_flip_buffer_push(tty); | 437 | tty_flip_buffer_push(tport); |
442 | 438 | ||
443 | chan_writel(chan, HSU_CH_CR, 0x3); | 439 | chan_writel(chan, HSU_CH_CR, 0x3); |
444 | 440 | ||
@@ -461,13 +457,9 @@ static void serial_hsu_stop_rx(struct uart_port *port) | |||
461 | 457 | ||
462 | static inline void receive_chars(struct uart_hsu_port *up, int *status) | 458 | static inline void receive_chars(struct uart_hsu_port *up, int *status) |
463 | { | 459 | { |
464 | struct tty_struct *tty = up->port.state->port.tty; | ||
465 | unsigned int ch, flag; | 460 | unsigned int ch, flag; |
466 | unsigned int max_count = 256; | 461 | unsigned int max_count = 256; |
467 | 462 | ||
468 | if (!tty) | ||
469 | return; | ||
470 | |||
471 | do { | 463 | do { |
472 | ch = serial_in(up, UART_RX); | 464 | ch = serial_in(up, UART_RX); |
473 | flag = TTY_NORMAL; | 465 | flag = TTY_NORMAL; |
@@ -523,7 +515,7 @@ static inline void receive_chars(struct uart_hsu_port *up, int *status) | |||
523 | ignore_char: | 515 | ignore_char: |
524 | *status = serial_in(up, UART_LSR); | 516 | *status = serial_in(up, UART_LSR); |
525 | } while ((*status & UART_LSR_DR) && max_count--); | 517 | } while ((*status & UART_LSR_DR) && max_count--); |
526 | tty_flip_buffer_push(tty); | 518 | tty_flip_buffer_push(&up->port.state->port); |
527 | } | 519 | } |
528 | 520 | ||
529 | static void transmit_chars(struct uart_hsu_port *up) | 521 | static void transmit_chars(struct uart_hsu_port *up) |
diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c index 0145aeb7721c..c0e1fad51be7 100644 --- a/drivers/tty/serial/mpc52xx_uart.c +++ b/drivers/tty/serial/mpc52xx_uart.c | |||
@@ -942,7 +942,6 @@ static inline int | |||
942 | mpc52xx_uart_int_rx_chars(struct uart_port *port) | 942 | mpc52xx_uart_int_rx_chars(struct uart_port *port) |
943 | { | 943 | { |
944 | struct tty_port *tport = &port->state->port; | 944 | struct tty_port *tport = &port->state->port; |
945 | struct tty_struct *tty = tport->tty; | ||
946 | unsigned char ch, flag; | 945 | unsigned char ch, flag; |
947 | unsigned short status; | 946 | unsigned short status; |
948 | 947 | ||
@@ -1000,7 +999,7 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port) | |||
1000 | } | 999 | } |
1001 | 1000 | ||
1002 | spin_unlock(&port->lock); | 1001 | spin_unlock(&port->lock); |
1003 | tty_flip_buffer_push(tty); | 1002 | tty_flip_buffer_push(tport); |
1004 | spin_lock(&port->lock); | 1003 | spin_lock(&port->lock); |
1005 | 1004 | ||
1006 | return psc_ops->raw_rx_rdy(port); | 1005 | return psc_ops->raw_rx_rdy(port); |
diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c index 6f2d2ceb326a..bc24f4931670 100644 --- a/drivers/tty/serial/mpsc.c +++ b/drivers/tty/serial/mpsc.c | |||
@@ -938,7 +938,6 @@ static int mpsc_rx_intr(struct mpsc_port_info *pi) | |||
938 | { | 938 | { |
939 | struct mpsc_rx_desc *rxre; | 939 | struct mpsc_rx_desc *rxre; |
940 | struct tty_port *port = &pi->port.state->port; | 940 | struct tty_port *port = &pi->port.state->port; |
941 | struct tty_struct *tty = port->tty; | ||
942 | u32 cmdstat, bytes_in, i; | 941 | u32 cmdstat, bytes_in, i; |
943 | int rc = 0; | 942 | int rc = 0; |
944 | u8 *bp; | 943 | u8 *bp; |
@@ -971,7 +970,7 @@ static int mpsc_rx_intr(struct mpsc_port_info *pi) | |||
971 | /* Following use of tty struct directly is deprecated */ | 970 | /* Following use of tty struct directly is deprecated */ |
972 | if (tty_buffer_request_room(port, bytes_in) < bytes_in) { | 971 | if (tty_buffer_request_room(port, bytes_in) < bytes_in) { |
973 | if (port->low_latency) | 972 | if (port->low_latency) |
974 | tty_flip_buffer_push(tty); | 973 | tty_flip_buffer_push(port); |
975 | /* | 974 | /* |
976 | * If this failed then we will throw away the bytes | 975 | * If this failed then we will throw away the bytes |
977 | * but must do so to clear interrupts. | 976 | * but must do so to clear interrupts. |
@@ -1081,7 +1080,7 @@ next_frame: | |||
1081 | if ((readl(pi->sdma_base + SDMA_SDCM) & SDMA_SDCM_ERD) == 0) | 1080 | if ((readl(pi->sdma_base + SDMA_SDCM) & SDMA_SDCM_ERD) == 0) |
1082 | mpsc_start_rx(pi); | 1081 | mpsc_start_rx(pi); |
1083 | 1082 | ||
1084 | tty_flip_buffer_push(tty); | 1083 | tty_flip_buffer_push(port); |
1085 | return rc; | 1084 | return rc; |
1086 | } | 1085 | } |
1087 | 1086 | ||
diff --git a/drivers/tty/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c index 4632db7a24b7..f641c232beca 100644 --- a/drivers/tty/serial/mrst_max3110.c +++ b/drivers/tty/serial/mrst_max3110.c | |||
@@ -340,7 +340,6 @@ receive_chars(struct uart_max3110 *max, unsigned short *str, int len) | |||
340 | { | 340 | { |
341 | struct uart_port *port = &max->port; | 341 | struct uart_port *port = &max->port; |
342 | struct tty_port *tport; | 342 | struct tty_port *tport; |
343 | struct tty_struct *tty; | ||
344 | char buf[M3110_RX_FIFO_DEPTH]; | 343 | char buf[M3110_RX_FIFO_DEPTH]; |
345 | int r, w, usable; | 344 | int r, w, usable; |
346 | 345 | ||
@@ -349,9 +348,6 @@ receive_chars(struct uart_max3110 *max, unsigned short *str, int len) | |||
349 | return 0; | 348 | return 0; |
350 | 349 | ||
351 | tport = &port->state->port; | 350 | tport = &port->state->port; |
352 | tty = tty_port_tty_get(tport); | ||
353 | if (!tty) | ||
354 | return 0; | ||
355 | 351 | ||
356 | for (r = 0, w = 0; r < len; r++) { | 352 | for (r = 0, w = 0; r < len; r++) { |
357 | if (str[r] & MAX3110_BREAK && | 353 | if (str[r] & MAX3110_BREAK && |
@@ -366,10 +362,8 @@ receive_chars(struct uart_max3110 *max, unsigned short *str, int len) | |||
366 | } | 362 | } |
367 | } | 363 | } |
368 | 364 | ||
369 | if (!w) { | 365 | if (!w) |
370 | tty_kref_put(tty); | ||
371 | return 0; | 366 | return 0; |
372 | } | ||
373 | 367 | ||
374 | for (r = 0; w; r += usable, w -= usable) { | 368 | for (r = 0; w; r += usable, w -= usable) { |
375 | usable = tty_buffer_request_room(tport, w); | 369 | usable = tty_buffer_request_room(tport, w); |
@@ -378,8 +372,7 @@ receive_chars(struct uart_max3110 *max, unsigned short *str, int len) | |||
378 | port->icount.rx += usable; | 372 | port->icount.rx += usable; |
379 | } | 373 | } |
380 | } | 374 | } |
381 | tty_flip_buffer_push(tty); | 375 | tty_flip_buffer_push(tport); |
382 | tty_kref_put(tty); | ||
383 | 376 | ||
384 | return r; | 377 | return r; |
385 | } | 378 | } |
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index cb787c0e279a..b11e99797fd8 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c | |||
@@ -92,7 +92,6 @@ static void msm_enable_ms(struct uart_port *port) | |||
92 | static void handle_rx_dm(struct uart_port *port, unsigned int misr) | 92 | static void handle_rx_dm(struct uart_port *port, unsigned int misr) |
93 | { | 93 | { |
94 | struct tty_port *tport = &port->state->port; | 94 | struct tty_port *tport = &port->state->port; |
95 | struct tty_struct *tty = tport->tty; | ||
96 | unsigned int sr; | 95 | unsigned int sr; |
97 | int count = 0; | 96 | int count = 0; |
98 | struct msm_port *msm_port = UART_TO_MSM(port); | 97 | struct msm_port *msm_port = UART_TO_MSM(port); |
@@ -138,7 +137,7 @@ static void handle_rx_dm(struct uart_port *port, unsigned int misr) | |||
138 | count -= 4; | 137 | count -= 4; |
139 | } | 138 | } |
140 | 139 | ||
141 | tty_flip_buffer_push(tty); | 140 | tty_flip_buffer_push(tport); |
142 | if (misr & (UART_IMR_RXSTALE)) | 141 | if (misr & (UART_IMR_RXSTALE)) |
143 | msm_write(port, UART_CR_CMD_RESET_STALE_INT, UART_CR); | 142 | msm_write(port, UART_CR_CMD_RESET_STALE_INT, UART_CR); |
144 | msm_write(port, 0xFFFFFF, UARTDM_DMRX); | 143 | msm_write(port, 0xFFFFFF, UARTDM_DMRX); |
@@ -148,7 +147,6 @@ static void handle_rx_dm(struct uart_port *port, unsigned int misr) | |||
148 | static void handle_rx(struct uart_port *port) | 147 | static void handle_rx(struct uart_port *port) |
149 | { | 148 | { |
150 | struct tty_port *tport = &port->state->port; | 149 | struct tty_port *tport = &port->state->port; |
151 | struct tty_struct *tty = tport->tty; | ||
152 | unsigned int sr; | 150 | unsigned int sr; |
153 | 151 | ||
154 | /* | 152 | /* |
@@ -191,7 +189,7 @@ static void handle_rx(struct uart_port *port) | |||
191 | tty_insert_flip_char(tport, c, flag); | 189 | tty_insert_flip_char(tport, c, flag); |
192 | } | 190 | } |
193 | 191 | ||
194 | tty_flip_buffer_push(tty); | 192 | tty_flip_buffer_push(tport); |
195 | } | 193 | } |
196 | 194 | ||
197 | static void reset_dm_count(struct uart_port *port) | 195 | static void reset_dm_count(struct uart_port *port) |
diff --git a/drivers/tty/serial/msm_serial_hs.c b/drivers/tty/serial/msm_serial_hs.c index c356ffff3c71..4a942c78347e 100644 --- a/drivers/tty/serial/msm_serial_hs.c +++ b/drivers/tty/serial/msm_serial_hs.c | |||
@@ -981,9 +981,8 @@ static void msm_hs_tty_flip_buffer_work(struct work_struct *work) | |||
981 | { | 981 | { |
982 | struct msm_hs_port *msm_uport = | 982 | struct msm_hs_port *msm_uport = |
983 | container_of(work, struct msm_hs_port, rx.tty_work); | 983 | container_of(work, struct msm_hs_port, rx.tty_work); |
984 | struct tty_struct *tty = msm_uport->uport.state->port.tty; | ||
985 | 984 | ||
986 | tty_flip_buffer_push(tty); | 985 | tty_flip_buffer_push(&msm_uport->uport.state->port); |
987 | } | 986 | } |
988 | 987 | ||
989 | /* | 988 | /* |
diff --git a/drivers/tty/serial/msm_smd_tty.c b/drivers/tty/serial/msm_smd_tty.c index b43b4ec39269..e722ff163d91 100644 --- a/drivers/tty/serial/msm_smd_tty.c +++ b/drivers/tty/serial/msm_smd_tty.c | |||
@@ -80,7 +80,7 @@ static void smd_tty_notify(void *priv, unsigned event) | |||
80 | pr_err("OOPS - smd_tty_buffer mismatch?!"); | 80 | pr_err("OOPS - smd_tty_buffer mismatch?!"); |
81 | } | 81 | } |
82 | 82 | ||
83 | tty_flip_buffer_push(tty); | 83 | tty_flip_buffer_push(&info->port); |
84 | } | 84 | } |
85 | 85 | ||
86 | /* XXX only when writable and necessary */ | 86 | /* XXX only when writable and necessary */ |
diff --git a/drivers/tty/serial/mux.c b/drivers/tty/serial/mux.c index 83b21686020e..7fd6aaaacd8e 100644 --- a/drivers/tty/serial/mux.c +++ b/drivers/tty/serial/mux.c | |||
@@ -244,7 +244,6 @@ static void mux_read(struct uart_port *port) | |||
244 | { | 244 | { |
245 | struct tty_port *tport = &port->state->port; | 245 | struct tty_port *tport = &port->state->port; |
246 | int data; | 246 | int data; |
247 | struct tty_struct *tty = tport->tty; | ||
248 | __u32 start_count = port->icount.rx; | 247 | __u32 start_count = port->icount.rx; |
249 | 248 | ||
250 | while(1) { | 249 | while(1) { |
@@ -270,9 +269,8 @@ static void mux_read(struct uart_port *port) | |||
270 | tty_insert_flip_char(tport, data & 0xFF, TTY_NORMAL); | 269 | tty_insert_flip_char(tport, data & 0xFF, TTY_NORMAL); |
271 | } | 270 | } |
272 | 271 | ||
273 | if (start_count != port->icount.rx) { | 272 | if (start_count != port->icount.rx) |
274 | tty_flip_buffer_push(tty); | 273 | tty_flip_buffer_push(tport); |
275 | } | ||
276 | } | 274 | } |
277 | 275 | ||
278 | /** | 276 | /** |
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c index 37a0046ef531..df0ba32f88ad 100644 --- a/drivers/tty/serial/mxs-auart.c +++ b/drivers/tty/serial/mxs-auart.c | |||
@@ -364,7 +364,6 @@ out: | |||
364 | 364 | ||
365 | static void mxs_auart_rx_chars(struct mxs_auart_port *s) | 365 | static void mxs_auart_rx_chars(struct mxs_auart_port *s) |
366 | { | 366 | { |
367 | struct tty_struct *tty = s->port.state->port.tty; | ||
368 | u32 stat = 0; | 367 | u32 stat = 0; |
369 | 368 | ||
370 | for (;;) { | 369 | for (;;) { |
@@ -375,7 +374,7 @@ static void mxs_auart_rx_chars(struct mxs_auart_port *s) | |||
375 | } | 374 | } |
376 | 375 | ||
377 | writel(stat, s->port.membase + AUART_STAT); | 376 | writel(stat, s->port.membase + AUART_STAT); |
378 | tty_flip_buffer_push(tty); | 377 | tty_flip_buffer_push(&s->port.state->port); |
379 | } | 378 | } |
380 | 379 | ||
381 | static int mxs_auart_request_port(struct uart_port *u) | 380 | static int mxs_auart_request_port(struct uart_port *u) |
@@ -458,7 +457,6 @@ static void dma_rx_callback(void *arg) | |||
458 | { | 457 | { |
459 | struct mxs_auart_port *s = (struct mxs_auart_port *) arg; | 458 | struct mxs_auart_port *s = (struct mxs_auart_port *) arg; |
460 | struct tty_port *port = &s->port.state->port; | 459 | struct tty_port *port = &s->port.state->port; |
461 | struct tty_struct *tty = port->tty; | ||
462 | int count; | 460 | int count; |
463 | u32 stat; | 461 | u32 stat; |
464 | 462 | ||
@@ -472,7 +470,7 @@ static void dma_rx_callback(void *arg) | |||
472 | tty_insert_flip_string(port, s->rx_dma_buf, count); | 470 | tty_insert_flip_string(port, s->rx_dma_buf, count); |
473 | 471 | ||
474 | writel(stat, s->port.membase + AUART_STAT); | 472 | writel(stat, s->port.membase + AUART_STAT); |
475 | tty_flip_buffer_push(tty); | 473 | tty_flip_buffer_push(port); |
476 | 474 | ||
477 | /* start the next DMA for RX. */ | 475 | /* start the next DMA for RX. */ |
478 | mxs_auart_dma_prep_rx(s); | 476 | mxs_auart_dma_prep_rx(s); |
diff --git a/drivers/tty/serial/netx-serial.c b/drivers/tty/serial/netx-serial.c index d40da78e7c85..b9a40ed70be2 100644 --- a/drivers/tty/serial/netx-serial.c +++ b/drivers/tty/serial/netx-serial.c | |||
@@ -199,7 +199,6 @@ static void netx_txint(struct uart_port *port) | |||
199 | static void netx_rxint(struct uart_port *port) | 199 | static void netx_rxint(struct uart_port *port) |
200 | { | 200 | { |
201 | unsigned char rx, flg, status; | 201 | unsigned char rx, flg, status; |
202 | struct tty_struct *tty = port->state->port.tty; | ||
203 | 202 | ||
204 | while (!(readl(port->membase + UART_FR) & FR_RXFE)) { | 203 | while (!(readl(port->membase + UART_FR) & FR_RXFE)) { |
205 | rx = readl(port->membase + UART_DR); | 204 | rx = readl(port->membase + UART_DR); |
@@ -237,8 +236,7 @@ static void netx_rxint(struct uart_port *port) | |||
237 | uart_insert_char(port, status, SR_OE, rx, flg); | 236 | uart_insert_char(port, status, SR_OE, rx, flg); |
238 | } | 237 | } |
239 | 238 | ||
240 | tty_flip_buffer_push(tty); | 239 | tty_flip_buffer_push(&port->state->port); |
241 | return; | ||
242 | } | 240 | } |
243 | 241 | ||
244 | static irqreturn_t netx_int(int irq, void *dev_id) | 242 | static irqreturn_t netx_int(int irq, void *dev_id) |
diff --git a/drivers/tty/serial/nwpserial.c b/drivers/tty/serial/nwpserial.c index 10d64a3697fb..77287c54f331 100644 --- a/drivers/tty/serial/nwpserial.c +++ b/drivers/tty/serial/nwpserial.c | |||
@@ -129,7 +129,6 @@ static irqreturn_t nwpserial_interrupt(int irq, void *dev_id) | |||
129 | { | 129 | { |
130 | struct nwpserial_port *up = dev_id; | 130 | struct nwpserial_port *up = dev_id; |
131 | struct tty_port *port = &up->port.state->port; | 131 | struct tty_port *port = &up->port.state->port; |
132 | struct tty_struct *tty = port->tty; | ||
133 | irqreturn_t ret; | 132 | irqreturn_t ret; |
134 | unsigned int iir; | 133 | unsigned int iir; |
135 | unsigned char ch; | 134 | unsigned char ch; |
@@ -150,7 +149,7 @@ static irqreturn_t nwpserial_interrupt(int irq, void *dev_id) | |||
150 | tty_insert_flip_char(port, ch, TTY_NORMAL); | 149 | tty_insert_flip_char(port, ch, TTY_NORMAL); |
151 | } while (dcr_read(up->dcr_host, UART_LSR) & UART_LSR_DR); | 150 | } while (dcr_read(up->dcr_host, UART_LSR) & UART_LSR_DR); |
152 | 151 | ||
153 | tty_flip_buffer_push(tty); | 152 | tty_flip_buffer_push(port); |
154 | ret = IRQ_HANDLED; | 153 | ret = IRQ_HANDLED; |
155 | 154 | ||
156 | /* clear interrupt */ | 155 | /* clear interrupt */ |
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index ec90651d661a..6f3dbf740f05 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c | |||
@@ -483,7 +483,6 @@ static void serial_omap_rdi(struct uart_omap_port *up, unsigned int lsr) | |||
483 | static irqreturn_t serial_omap_irq(int irq, void *dev_id) | 483 | static irqreturn_t serial_omap_irq(int irq, void *dev_id) |
484 | { | 484 | { |
485 | struct uart_omap_port *up = dev_id; | 485 | struct uart_omap_port *up = dev_id; |
486 | struct tty_struct *tty = up->port.state->port.tty; | ||
487 | unsigned int iir, lsr; | 486 | unsigned int iir, lsr; |
488 | unsigned int type; | 487 | unsigned int type; |
489 | irqreturn_t ret = IRQ_NONE; | 488 | irqreturn_t ret = IRQ_NONE; |
@@ -530,7 +529,7 @@ static irqreturn_t serial_omap_irq(int irq, void *dev_id) | |||
530 | 529 | ||
531 | spin_unlock(&up->port.lock); | 530 | spin_unlock(&up->port.lock); |
532 | 531 | ||
533 | tty_flip_buffer_push(tty); | 532 | tty_flip_buffer_push(&up->port.state->port); |
534 | 533 | ||
535 | pm_runtime_mark_last_busy(up->dev); | 534 | pm_runtime_mark_last_busy(up->dev); |
536 | pm_runtime_put_autosuspend(up->dev); | 535 | pm_runtime_put_autosuspend(up->dev); |
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index 967f1cb311f3..8b40a1fc9681 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c | |||
@@ -593,17 +593,9 @@ static int push_rx(struct eg20t_port *priv, const unsigned char *buf, | |||
593 | { | 593 | { |
594 | struct uart_port *port = &priv->port; | 594 | struct uart_port *port = &priv->port; |
595 | struct tty_port *tport = &port->state->port; | 595 | struct tty_port *tport = &port->state->port; |
596 | struct tty_struct *tty; | ||
597 | |||
598 | tty = tty_port_tty_get(tport); | ||
599 | if (!tty) { | ||
600 | dev_dbg(priv->port.dev, "%s:tty is busy now", __func__); | ||
601 | return -EBUSY; | ||
602 | } | ||
603 | 596 | ||
604 | tty_insert_flip_string(tport, buf, size); | 597 | tty_insert_flip_string(tport, buf, size); |
605 | tty_flip_buffer_push(tty); | 598 | tty_flip_buffer_push(tport); |
606 | tty_kref_put(tty); | ||
607 | 599 | ||
608 | return 0; | 600 | return 0; |
609 | } | 601 | } |
@@ -744,19 +736,12 @@ static void pch_dma_rx_complete(void *arg) | |||
744 | { | 736 | { |
745 | struct eg20t_port *priv = arg; | 737 | struct eg20t_port *priv = arg; |
746 | struct uart_port *port = &priv->port; | 738 | struct uart_port *port = &priv->port; |
747 | struct tty_struct *tty = tty_port_tty_get(&port->state->port); | ||
748 | int count; | 739 | int count; |
749 | 740 | ||
750 | if (!tty) { | ||
751 | dev_dbg(priv->port.dev, "%s:tty is busy now", __func__); | ||
752 | return; | ||
753 | } | ||
754 | |||
755 | dma_sync_sg_for_cpu(port->dev, &priv->sg_rx, 1, DMA_FROM_DEVICE); | 741 | dma_sync_sg_for_cpu(port->dev, &priv->sg_rx, 1, DMA_FROM_DEVICE); |
756 | count = dma_push_rx(priv, priv->trigger_level); | 742 | count = dma_push_rx(priv, priv->trigger_level); |
757 | if (count) | 743 | if (count) |
758 | tty_flip_buffer_push(tty); | 744 | tty_flip_buffer_push(&port->state->port); |
759 | tty_kref_put(tty); | ||
760 | async_tx_ack(priv->desc_rx); | 745 | async_tx_ack(priv->desc_rx); |
761 | pch_uart_hal_enable_interrupt(priv, PCH_UART_HAL_RX_INT | | 746 | pch_uart_hal_enable_interrupt(priv, PCH_UART_HAL_RX_INT | |
762 | PCH_UART_HAL_RX_ERR_INT); | 747 | PCH_UART_HAL_RX_ERR_INT); |
diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c index 73a3f295e7c4..b1785f58b6e3 100644 --- a/drivers/tty/serial/pmac_zilog.c +++ b/drivers/tty/serial/pmac_zilog.c | |||
@@ -227,21 +227,19 @@ static void pmz_interrupt_control(struct uart_pmac_port *uap, int enable) | |||
227 | write_zsreg(uap, R1, uap->curregs[1]); | 227 | write_zsreg(uap, R1, uap->curregs[1]); |
228 | } | 228 | } |
229 | 229 | ||
230 | static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap) | 230 | static bool pmz_receive_chars(struct uart_pmac_port *uap) |
231 | { | 231 | { |
232 | struct tty_port *port; | 232 | struct tty_port *port; |
233 | struct tty_struct *tty = NULL; | ||
234 | unsigned char ch, r1, drop, error, flag; | 233 | unsigned char ch, r1, drop, error, flag; |
235 | int loops = 0; | 234 | int loops = 0; |
236 | 235 | ||
237 | /* Sanity check, make sure the old bug is no longer happening */ | 236 | /* Sanity check, make sure the old bug is no longer happening */ |
238 | if (uap->port.state == NULL || uap->port.state->port.tty == NULL) { | 237 | if (uap->port.state == NULL) { |
239 | WARN_ON(1); | 238 | WARN_ON(1); |
240 | (void)read_zsdata(uap); | 239 | (void)read_zsdata(uap); |
241 | return NULL; | 240 | return false; |
242 | } | 241 | } |
243 | port = &uap->port.state->port; | 242 | port = &uap->port.state->port; |
244 | tty = port->tty; /* TOCTOU above */ | ||
245 | 243 | ||
246 | while (1) { | 244 | while (1) { |
247 | error = 0; | 245 | error = 0; |
@@ -330,11 +328,11 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap) | |||
330 | break; | 328 | break; |
331 | } | 329 | } |
332 | 330 | ||
333 | return tty; | 331 | return true; |
334 | flood: | 332 | flood: |
335 | pmz_interrupt_control(uap, 0); | 333 | pmz_interrupt_control(uap, 0); |
336 | pmz_error("pmz: rx irq flood !\n"); | 334 | pmz_error("pmz: rx irq flood !\n"); |
337 | return tty; | 335 | return true; |
338 | } | 336 | } |
339 | 337 | ||
340 | static void pmz_status_handle(struct uart_pmac_port *uap) | 338 | static void pmz_status_handle(struct uart_pmac_port *uap) |
@@ -455,7 +453,7 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id) | |||
455 | struct uart_pmac_port *uap_a; | 453 | struct uart_pmac_port *uap_a; |
456 | struct uart_pmac_port *uap_b; | 454 | struct uart_pmac_port *uap_b; |
457 | int rc = IRQ_NONE; | 455 | int rc = IRQ_NONE; |
458 | struct tty_struct *tty; | 456 | bool push; |
459 | u8 r3; | 457 | u8 r3; |
460 | 458 | ||
461 | uap_a = pmz_get_port_A(uap); | 459 | uap_a = pmz_get_port_A(uap); |
@@ -468,7 +466,7 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id) | |||
468 | pmz_debug("irq, r3: %x\n", r3); | 466 | pmz_debug("irq, r3: %x\n", r3); |
469 | #endif | 467 | #endif |
470 | /* Channel A */ | 468 | /* Channel A */ |
471 | tty = NULL; | 469 | push = false; |
472 | if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { | 470 | if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { |
473 | if (!ZS_IS_OPEN(uap_a)) { | 471 | if (!ZS_IS_OPEN(uap_a)) { |
474 | pmz_debug("ChanA interrupt while not open !\n"); | 472 | pmz_debug("ChanA interrupt while not open !\n"); |
@@ -479,21 +477,21 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id) | |||
479 | if (r3 & CHAEXT) | 477 | if (r3 & CHAEXT) |
480 | pmz_status_handle(uap_a); | 478 | pmz_status_handle(uap_a); |
481 | if (r3 & CHARxIP) | 479 | if (r3 & CHARxIP) |
482 | tty = pmz_receive_chars(uap_a); | 480 | push = pmz_receive_chars(uap_a); |
483 | if (r3 & CHATxIP) | 481 | if (r3 & CHATxIP) |
484 | pmz_transmit_chars(uap_a); | 482 | pmz_transmit_chars(uap_a); |
485 | rc = IRQ_HANDLED; | 483 | rc = IRQ_HANDLED; |
486 | } | 484 | } |
487 | skip_a: | 485 | skip_a: |
488 | spin_unlock(&uap_a->port.lock); | 486 | spin_unlock(&uap_a->port.lock); |
489 | if (tty != NULL) | 487 | if (push) |
490 | tty_flip_buffer_push(tty); | 488 | tty_flip_buffer_push(&uap->port.state->port); |
491 | 489 | ||
492 | if (!uap_b) | 490 | if (!uap_b) |
493 | goto out; | 491 | goto out; |
494 | 492 | ||
495 | spin_lock(&uap_b->port.lock); | 493 | spin_lock(&uap_b->port.lock); |
496 | tty = NULL; | 494 | push = false; |
497 | if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) { | 495 | if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) { |
498 | if (!ZS_IS_OPEN(uap_b)) { | 496 | if (!ZS_IS_OPEN(uap_b)) { |
499 | pmz_debug("ChanB interrupt while not open !\n"); | 497 | pmz_debug("ChanB interrupt while not open !\n"); |
@@ -504,15 +502,15 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id) | |||
504 | if (r3 & CHBEXT) | 502 | if (r3 & CHBEXT) |
505 | pmz_status_handle(uap_b); | 503 | pmz_status_handle(uap_b); |
506 | if (r3 & CHBRxIP) | 504 | if (r3 & CHBRxIP) |
507 | tty = pmz_receive_chars(uap_b); | 505 | push = pmz_receive_chars(uap_b); |
508 | if (r3 & CHBTxIP) | 506 | if (r3 & CHBTxIP) |
509 | pmz_transmit_chars(uap_b); | 507 | pmz_transmit_chars(uap_b); |
510 | rc = IRQ_HANDLED; | 508 | rc = IRQ_HANDLED; |
511 | } | 509 | } |
512 | skip_b: | 510 | skip_b: |
513 | spin_unlock(&uap_b->port.lock); | 511 | spin_unlock(&uap_b->port.lock); |
514 | if (tty != NULL) | 512 | if (push) |
515 | tty_flip_buffer_push(tty); | 513 | tty_flip_buffer_push(&uap->port.state->port); |
516 | 514 | ||
517 | out: | 515 | out: |
518 | return rc; | 516 | return rc; |
diff --git a/drivers/tty/serial/pnx8xxx_uart.c b/drivers/tty/serial/pnx8xxx_uart.c index 0aa75a97531c..7e277a5384a7 100644 --- a/drivers/tty/serial/pnx8xxx_uart.c +++ b/drivers/tty/serial/pnx8xxx_uart.c | |||
@@ -181,7 +181,6 @@ static void pnx8xxx_enable_ms(struct uart_port *port) | |||
181 | 181 | ||
182 | static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport) | 182 | static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport) |
183 | { | 183 | { |
184 | struct tty_struct *tty = sport->port.state->port.tty; | ||
185 | unsigned int status, ch, flg; | 184 | unsigned int status, ch, flg; |
186 | 185 | ||
187 | status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | | 186 | status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | |
@@ -238,7 +237,7 @@ static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport) | |||
238 | status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | | 237 | status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | |
239 | ISTAT_TO_SM(serial_in(sport, PNX8XXX_ISTAT)); | 238 | ISTAT_TO_SM(serial_in(sport, PNX8XXX_ISTAT)); |
240 | } | 239 | } |
241 | tty_flip_buffer_push(tty); | 240 | tty_flip_buffer_push(&sport->port.state->port); |
242 | } | 241 | } |
243 | 242 | ||
244 | static void pnx8xxx_tx_chars(struct pnx8xxx_port *sport) | 243 | static void pnx8xxx_tx_chars(struct pnx8xxx_port *sport) |
diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c index 2764828251f5..3b671bc3f966 100644 --- a/drivers/tty/serial/pxa.c +++ b/drivers/tty/serial/pxa.c | |||
@@ -98,7 +98,6 @@ static void serial_pxa_stop_rx(struct uart_port *port) | |||
98 | 98 | ||
99 | static inline void receive_chars(struct uart_pxa_port *up, int *status) | 99 | static inline void receive_chars(struct uart_pxa_port *up, int *status) |
100 | { | 100 | { |
101 | struct tty_struct *tty = up->port.state->port.tty; | ||
102 | unsigned int ch, flag; | 101 | unsigned int ch, flag; |
103 | int max_count = 256; | 102 | int max_count = 256; |
104 | 103 | ||
@@ -168,7 +167,7 @@ static inline void receive_chars(struct uart_pxa_port *up, int *status) | |||
168 | ignore_char: | 167 | ignore_char: |
169 | *status = serial_in(up, UART_LSR); | 168 | *status = serial_in(up, UART_LSR); |
170 | } while ((*status & UART_LSR_DR) && (max_count-- > 0)); | 169 | } while ((*status & UART_LSR_DR) && (max_count-- > 0)); |
171 | tty_flip_buffer_push(tty); | 170 | tty_flip_buffer_push(&up->port.state->port); |
172 | 171 | ||
173 | /* work around Errata #20 according to | 172 | /* work around Errata #20 according to |
174 | * Intel(R) PXA27x Processor Family | 173 | * Intel(R) PXA27x Processor Family |
diff --git a/drivers/tty/serial/sa1100.c b/drivers/tty/serial/sa1100.c index 5d4b9b449b4a..af6b3e3ad24d 100644 --- a/drivers/tty/serial/sa1100.c +++ b/drivers/tty/serial/sa1100.c | |||
@@ -188,7 +188,6 @@ static void sa1100_enable_ms(struct uart_port *port) | |||
188 | static void | 188 | static void |
189 | sa1100_rx_chars(struct sa1100_port *sport) | 189 | sa1100_rx_chars(struct sa1100_port *sport) |
190 | { | 190 | { |
191 | struct tty_struct *tty = sport->port.state->port.tty; | ||
192 | unsigned int status, ch, flg; | 191 | unsigned int status, ch, flg; |
193 | 192 | ||
194 | status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | | 193 | status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | |
@@ -233,7 +232,7 @@ sa1100_rx_chars(struct sa1100_port *sport) | |||
233 | status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | | 232 | status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | |
234 | UTSR0_TO_SM(UART_GET_UTSR0(sport)); | 233 | UTSR0_TO_SM(UART_GET_UTSR0(sport)); |
235 | } | 234 | } |
236 | tty_flip_buffer_push(tty); | 235 | tty_flip_buffer_push(&sport->port.state->port); |
237 | } | 236 | } |
238 | 237 | ||
239 | static void sa1100_tx_chars(struct sa1100_port *sport) | 238 | static void sa1100_tx_chars(struct sa1100_port *sport) |
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 0684529eb2ad..3aa3c4c83f8b 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c | |||
@@ -220,7 +220,6 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id) | |||
220 | { | 220 | { |
221 | struct s3c24xx_uart_port *ourport = dev_id; | 221 | struct s3c24xx_uart_port *ourport = dev_id; |
222 | struct uart_port *port = &ourport->port; | 222 | struct uart_port *port = &ourport->port; |
223 | struct tty_struct *tty = port->state->port.tty; | ||
224 | unsigned int ufcon, ch, flag, ufstat, uerstat; | 223 | unsigned int ufcon, ch, flag, ufstat, uerstat; |
225 | unsigned long flags; | 224 | unsigned long flags; |
226 | int max_count = 64; | 225 | int max_count = 64; |
@@ -298,7 +297,7 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id) | |||
298 | ignore_char: | 297 | ignore_char: |
299 | continue; | 298 | continue; |
300 | } | 299 | } |
301 | tty_flip_buffer_push(tty); | 300 | tty_flip_buffer_push(&port->state->port); |
302 | 301 | ||
303 | out: | 302 | out: |
304 | spin_unlock_irqrestore(&port->lock, flags); | 303 | spin_unlock_irqrestore(&port->lock, flags); |
diff --git a/drivers/tty/serial/sb1250-duart.c b/drivers/tty/serial/sb1250-duart.c index f76b1688c5c8..a7cdec2962dd 100644 --- a/drivers/tty/serial/sb1250-duart.c +++ b/drivers/tty/serial/sb1250-duart.c | |||
@@ -384,7 +384,7 @@ static void sbd_receive_chars(struct sbd_port *sport) | |||
384 | uart_insert_char(uport, status, M_DUART_OVRUN_ERR, ch, flag); | 384 | uart_insert_char(uport, status, M_DUART_OVRUN_ERR, ch, flag); |
385 | } | 385 | } |
386 | 386 | ||
387 | tty_flip_buffer_push(uport->state->port.tty); | 387 | tty_flip_buffer_push(&uport->state->port); |
388 | } | 388 | } |
389 | 389 | ||
390 | static void sbd_transmit_chars(struct sbd_port *sport) | 390 | static void sbd_transmit_chars(struct sbd_port *sport) |
diff --git a/drivers/tty/serial/sc26xx.c b/drivers/tty/serial/sc26xx.c index 0cd0e4ac12a6..c9735680762d 100644 --- a/drivers/tty/serial/sc26xx.c +++ b/drivers/tty/serial/sc26xx.c | |||
@@ -136,20 +136,17 @@ static void sc26xx_disable_irq(struct uart_port *port, int mask) | |||
136 | WRITE_SC(port, IMR, up->imr); | 136 | WRITE_SC(port, IMR, up->imr); |
137 | } | 137 | } |
138 | 138 | ||
139 | static struct tty_struct *receive_chars(struct uart_port *port) | 139 | static bool receive_chars(struct uart_port *port) |
140 | { | 140 | { |
141 | struct tty_port *tport = NULL; | 141 | struct tty_port *tport = NULL; |
142 | struct tty_struct *tty = NULL; | ||
143 | int limit = 10000; | 142 | int limit = 10000; |
144 | unsigned char ch; | 143 | unsigned char ch; |
145 | char flag; | 144 | char flag; |
146 | u8 status; | 145 | u8 status; |
147 | 146 | ||
148 | /* FIXME what is this trying to achieve? */ | 147 | /* FIXME what is this trying to achieve? */ |
149 | if (port->state != NULL) { /* Unopened serial console */ | 148 | if (port->state != NULL) /* Unopened serial console */ |
150 | tport = &port->state->port; | 149 | tport = &port->state->port; |
151 | tty = tport->tty; | ||
152 | } | ||
153 | 150 | ||
154 | while (limit-- > 0) { | 151 | while (limit-- > 0) { |
155 | status = READ_SC_PORT(port, SR); | 152 | status = READ_SC_PORT(port, SR); |
@@ -191,7 +188,7 @@ static struct tty_struct *receive_chars(struct uart_port *port) | |||
191 | 188 | ||
192 | tty_insert_flip_char(tport, ch, flag); | 189 | tty_insert_flip_char(tport, ch, flag); |
193 | } | 190 | } |
194 | return tty; | 191 | return !!tport; |
195 | } | 192 | } |
196 | 193 | ||
197 | static void transmit_chars(struct uart_port *port) | 194 | static void transmit_chars(struct uart_port *port) |
@@ -221,36 +218,36 @@ static void transmit_chars(struct uart_port *port) | |||
221 | static irqreturn_t sc26xx_interrupt(int irq, void *dev_id) | 218 | static irqreturn_t sc26xx_interrupt(int irq, void *dev_id) |
222 | { | 219 | { |
223 | struct uart_sc26xx_port *up = dev_id; | 220 | struct uart_sc26xx_port *up = dev_id; |
224 | struct tty_struct *tty; | ||
225 | unsigned long flags; | 221 | unsigned long flags; |
222 | bool push; | ||
226 | u8 isr; | 223 | u8 isr; |
227 | 224 | ||
228 | spin_lock_irqsave(&up->port[0].lock, flags); | 225 | spin_lock_irqsave(&up->port[0].lock, flags); |
229 | 226 | ||
230 | tty = NULL; | 227 | push = false; |
231 | isr = READ_SC(&up->port[0], ISR); | 228 | isr = READ_SC(&up->port[0], ISR); |
232 | if (isr & ISR_TXRDYA) | 229 | if (isr & ISR_TXRDYA) |
233 | transmit_chars(&up->port[0]); | 230 | transmit_chars(&up->port[0]); |
234 | if (isr & ISR_RXRDYA) | 231 | if (isr & ISR_RXRDYA) |
235 | tty = receive_chars(&up->port[0]); | 232 | push = receive_chars(&up->port[0]); |
236 | 233 | ||
237 | spin_unlock(&up->port[0].lock); | 234 | spin_unlock(&up->port[0].lock); |
238 | 235 | ||
239 | if (tty) | 236 | if (push) |
240 | tty_flip_buffer_push(tty); | 237 | tty_flip_buffer_push(&up->port[0].state->port); |
241 | 238 | ||
242 | spin_lock(&up->port[1].lock); | 239 | spin_lock(&up->port[1].lock); |
243 | 240 | ||
244 | tty = NULL; | 241 | push = false; |
245 | if (isr & ISR_TXRDYB) | 242 | if (isr & ISR_TXRDYB) |
246 | transmit_chars(&up->port[1]); | 243 | transmit_chars(&up->port[1]); |
247 | if (isr & ISR_RXRDYB) | 244 | if (isr & ISR_RXRDYB) |
248 | tty = receive_chars(&up->port[1]); | 245 | push = receive_chars(&up->port[1]); |
249 | 246 | ||
250 | spin_unlock_irqrestore(&up->port[1].lock, flags); | 247 | spin_unlock_irqrestore(&up->port[1].lock, flags); |
251 | 248 | ||
252 | if (tty) | 249 | if (push) |
253 | tty_flip_buffer_push(tty); | 250 | tty_flip_buffer_push(&up->port[1].state->port); |
254 | 251 | ||
255 | return IRQ_HANDLED; | 252 | return IRQ_HANDLED; |
256 | } | 253 | } |
diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c index 418b495e3233..2ced871becff 100644 --- a/drivers/tty/serial/sccnxp.c +++ b/drivers/tty/serial/sccnxp.c | |||
@@ -285,10 +285,6 @@ static void sccnxp_handle_rx(struct uart_port *port) | |||
285 | { | 285 | { |
286 | u8 sr; | 286 | u8 sr; |
287 | unsigned int ch, flag; | 287 | unsigned int ch, flag; |
288 | struct tty_struct *tty = tty_port_tty_get(&port->state->port); | ||
289 | |||
290 | if (!tty) | ||
291 | return; | ||
292 | 288 | ||
293 | for (;;) { | 289 | for (;;) { |
294 | sr = sccnxp_port_read(port, SCCNXP_SR_REG); | 290 | sr = sccnxp_port_read(port, SCCNXP_SR_REG); |
@@ -333,9 +329,7 @@ static void sccnxp_handle_rx(struct uart_port *port) | |||
333 | uart_insert_char(port, sr, SR_OVR, ch, flag); | 329 | uart_insert_char(port, sr, SR_OVR, ch, flag); |
334 | } | 330 | } |
335 | 331 | ||
336 | tty_flip_buffer_push(tty); | 332 | tty_flip_buffer_push(&port->state->port); |
337 | |||
338 | tty_kref_put(tty); | ||
339 | } | 333 | } |
340 | 334 | ||
341 | static void sccnxp_handle_tx(struct uart_port *port) | 335 | static void sccnxp_handle_tx(struct uart_port *port) |
diff --git a/drivers/tty/serial/serial_ks8695.c b/drivers/tty/serial/serial_ks8695.c index 9bd004f9da89..e1caa99e3d3b 100644 --- a/drivers/tty/serial/serial_ks8695.c +++ b/drivers/tty/serial/serial_ks8695.c | |||
@@ -153,7 +153,6 @@ static void ks8695uart_disable_ms(struct uart_port *port) | |||
153 | static irqreturn_t ks8695uart_rx_chars(int irq, void *dev_id) | 153 | static irqreturn_t ks8695uart_rx_chars(int irq, void *dev_id) |
154 | { | 154 | { |
155 | struct uart_port *port = dev_id; | 155 | struct uart_port *port = dev_id; |
156 | struct tty_struct *tty = port->state->port.tty; | ||
157 | unsigned int status, ch, lsr, flg, max_count = 256; | 156 | unsigned int status, ch, lsr, flg, max_count = 256; |
158 | 157 | ||
159 | status = UART_GET_LSR(port); /* clears pending LSR interrupts */ | 158 | status = UART_GET_LSR(port); /* clears pending LSR interrupts */ |
@@ -200,7 +199,7 @@ static irqreturn_t ks8695uart_rx_chars(int irq, void *dev_id) | |||
200 | ignore_char: | 199 | ignore_char: |
201 | status = UART_GET_LSR(port); | 200 | status = UART_GET_LSR(port); |
202 | } | 201 | } |
203 | tty_flip_buffer_push(tty); | 202 | tty_flip_buffer_push(&port->state->port); |
204 | 203 | ||
205 | return IRQ_HANDLED; | 204 | return IRQ_HANDLED; |
206 | } | 205 | } |
diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c index b52b21aeb250..fe48a0c2b4ca 100644 --- a/drivers/tty/serial/serial_txx9.c +++ b/drivers/tty/serial/serial_txx9.c | |||
@@ -277,7 +277,6 @@ static void serial_txx9_initialize(struct uart_port *port) | |||
277 | static inline void | 277 | static inline void |
278 | receive_chars(struct uart_txx9_port *up, unsigned int *status) | 278 | receive_chars(struct uart_txx9_port *up, unsigned int *status) |
279 | { | 279 | { |
280 | struct tty_struct *tty = up->port.state->port.tty; | ||
281 | unsigned char ch; | 280 | unsigned char ch; |
282 | unsigned int disr = *status; | 281 | unsigned int disr = *status; |
283 | int max_count = 256; | 282 | int max_count = 256; |
@@ -346,7 +345,7 @@ receive_chars(struct uart_txx9_port *up, unsigned int *status) | |||
346 | disr = sio_in(up, TXX9_SIDISR); | 345 | disr = sio_in(up, TXX9_SIDISR); |
347 | } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0)); | 346 | } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0)); |
348 | spin_unlock(&up->port.lock); | 347 | spin_unlock(&up->port.lock); |
349 | tty_flip_buffer_push(tty); | 348 | tty_flip_buffer_push(&up->port.state->port); |
350 | spin_lock(&up->port.lock); | 349 | spin_lock(&up->port.lock); |
351 | *status = disr; | 350 | *status = disr; |
352 | } | 351 | } |
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index ecef748f5385..156418619949 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c | |||
@@ -597,7 +597,6 @@ static void sci_receive_chars(struct uart_port *port) | |||
597 | { | 597 | { |
598 | struct sci_port *sci_port = to_sci_port(port); | 598 | struct sci_port *sci_port = to_sci_port(port); |
599 | struct tty_port *tport = &port->state->port; | 599 | struct tty_port *tport = &port->state->port; |
600 | struct tty_struct *tty = tport->tty; | ||
601 | int i, count, copied = 0; | 600 | int i, count, copied = 0; |
602 | unsigned short status; | 601 | unsigned short status; |
603 | unsigned char flag; | 602 | unsigned char flag; |
@@ -675,7 +674,7 @@ static void sci_receive_chars(struct uart_port *port) | |||
675 | 674 | ||
676 | if (copied) { | 675 | if (copied) { |
677 | /* Tell the rest of the system the news. New characters! */ | 676 | /* Tell the rest of the system the news. New characters! */ |
678 | tty_flip_buffer_push(tty); | 677 | tty_flip_buffer_push(tport); |
679 | } else { | 678 | } else { |
680 | serial_port_in(port, SCxSR); /* dummy read */ | 679 | serial_port_in(port, SCxSR); /* dummy read */ |
681 | serial_port_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); | 680 | serial_port_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); |
@@ -722,7 +721,6 @@ static int sci_handle_errors(struct uart_port *port) | |||
722 | int copied = 0; | 721 | int copied = 0; |
723 | unsigned short status = serial_port_in(port, SCxSR); | 722 | unsigned short status = serial_port_in(port, SCxSR); |
724 | struct tty_port *tport = &port->state->port; | 723 | struct tty_port *tport = &port->state->port; |
725 | struct tty_struct *tty = tport->tty; | ||
726 | struct sci_port *s = to_sci_port(port); | 724 | struct sci_port *s = to_sci_port(port); |
727 | 725 | ||
728 | /* | 726 | /* |
@@ -783,7 +781,7 @@ static int sci_handle_errors(struct uart_port *port) | |||
783 | } | 781 | } |
784 | 782 | ||
785 | if (copied) | 783 | if (copied) |
786 | tty_flip_buffer_push(tty); | 784 | tty_flip_buffer_push(tport); |
787 | 785 | ||
788 | return copied; | 786 | return copied; |
789 | } | 787 | } |
@@ -791,7 +789,6 @@ static int sci_handle_errors(struct uart_port *port) | |||
791 | static int sci_handle_fifo_overrun(struct uart_port *port) | 789 | static int sci_handle_fifo_overrun(struct uart_port *port) |
792 | { | 790 | { |
793 | struct tty_port *tport = &port->state->port; | 791 | struct tty_port *tport = &port->state->port; |
794 | struct tty_struct *tty = tport->tty; | ||
795 | struct sci_port *s = to_sci_port(port); | 792 | struct sci_port *s = to_sci_port(port); |
796 | struct plat_sci_reg *reg; | 793 | struct plat_sci_reg *reg; |
797 | int copied = 0; | 794 | int copied = 0; |
@@ -806,7 +803,7 @@ static int sci_handle_fifo_overrun(struct uart_port *port) | |||
806 | port->icount.overrun++; | 803 | port->icount.overrun++; |
807 | 804 | ||
808 | tty_insert_flip_char(tport, 0, TTY_OVERRUN); | 805 | tty_insert_flip_char(tport, 0, TTY_OVERRUN); |
809 | tty_flip_buffer_push(tty); | 806 | tty_flip_buffer_push(tport); |
810 | 807 | ||
811 | dev_notice(port->dev, "overrun error\n"); | 808 | dev_notice(port->dev, "overrun error\n"); |
812 | copied++; | 809 | copied++; |
@@ -820,7 +817,6 @@ static int sci_handle_breaks(struct uart_port *port) | |||
820 | int copied = 0; | 817 | int copied = 0; |
821 | unsigned short status = serial_port_in(port, SCxSR); | 818 | unsigned short status = serial_port_in(port, SCxSR); |
822 | struct tty_port *tport = &port->state->port; | 819 | struct tty_port *tport = &port->state->port; |
823 | struct tty_struct *tty = tport->tty; | ||
824 | struct sci_port *s = to_sci_port(port); | 820 | struct sci_port *s = to_sci_port(port); |
825 | 821 | ||
826 | if (uart_handle_break(port)) | 822 | if (uart_handle_break(port)) |
@@ -842,7 +838,7 @@ static int sci_handle_breaks(struct uart_port *port) | |||
842 | } | 838 | } |
843 | 839 | ||
844 | if (copied) | 840 | if (copied) |
845 | tty_flip_buffer_push(tty); | 841 | tty_flip_buffer_push(tport); |
846 | 842 | ||
847 | copied += sci_handle_fifo_overrun(port); | 843 | copied += sci_handle_fifo_overrun(port); |
848 | 844 | ||
@@ -1299,7 +1295,6 @@ static void sci_dma_rx_complete(void *arg) | |||
1299 | { | 1295 | { |
1300 | struct sci_port *s = arg; | 1296 | struct sci_port *s = arg; |
1301 | struct uart_port *port = &s->port; | 1297 | struct uart_port *port = &s->port; |
1302 | struct tty_struct *tty = port->state->port.tty; | ||
1303 | unsigned long flags; | 1298 | unsigned long flags; |
1304 | int count; | 1299 | int count; |
1305 | 1300 | ||
@@ -1314,7 +1309,7 @@ static void sci_dma_rx_complete(void *arg) | |||
1314 | spin_unlock_irqrestore(&port->lock, flags); | 1309 | spin_unlock_irqrestore(&port->lock, flags); |
1315 | 1310 | ||
1316 | if (count) | 1311 | if (count) |
1317 | tty_flip_buffer_push(tty); | 1312 | tty_flip_buffer_push(&port->state->port); |
1318 | 1313 | ||
1319 | schedule_work(&s->work_rx); | 1314 | schedule_work(&s->work_rx); |
1320 | } | 1315 | } |
@@ -1408,7 +1403,6 @@ static void work_fn_rx(struct work_struct *work) | |||
1408 | if (dma_async_is_tx_complete(s->chan_rx, s->active_rx, NULL, NULL) != | 1403 | if (dma_async_is_tx_complete(s->chan_rx, s->active_rx, NULL, NULL) != |
1409 | DMA_SUCCESS) { | 1404 | DMA_SUCCESS) { |
1410 | /* Handle incomplete DMA receive */ | 1405 | /* Handle incomplete DMA receive */ |
1411 | struct tty_struct *tty = port->state->port.tty; | ||
1412 | struct dma_chan *chan = s->chan_rx; | 1406 | struct dma_chan *chan = s->chan_rx; |
1413 | struct shdma_desc *sh_desc = container_of(desc, | 1407 | struct shdma_desc *sh_desc = container_of(desc, |
1414 | struct shdma_desc, async_tx); | 1408 | struct shdma_desc, async_tx); |
@@ -1424,7 +1418,7 @@ static void work_fn_rx(struct work_struct *work) | |||
1424 | spin_unlock_irqrestore(&port->lock, flags); | 1418 | spin_unlock_irqrestore(&port->lock, flags); |
1425 | 1419 | ||
1426 | if (count) | 1420 | if (count) |
1427 | tty_flip_buffer_push(tty); | 1421 | tty_flip_buffer_push(&port->state->port); |
1428 | 1422 | ||
1429 | sci_submit_rx(s); | 1423 | sci_submit_rx(s); |
1430 | 1424 | ||
diff --git a/drivers/tty/serial/sirfsoc_uart.c b/drivers/tty/serial/sirfsoc_uart.c index 142217cd01f4..8f3d6c091acc 100644 --- a/drivers/tty/serial/sirfsoc_uart.c +++ b/drivers/tty/serial/sirfsoc_uart.c | |||
@@ -206,11 +206,6 @@ static unsigned int | |||
206 | sirfsoc_uart_pio_rx_chars(struct uart_port *port, unsigned int max_rx_count) | 206 | sirfsoc_uart_pio_rx_chars(struct uart_port *port, unsigned int max_rx_count) |
207 | { | 207 | { |
208 | unsigned int ch, rx_count = 0; | 208 | unsigned int ch, rx_count = 0; |
209 | struct tty_struct *tty; | ||
210 | |||
211 | tty = tty_port_tty_get(&port->state->port); | ||
212 | if (!tty) | ||
213 | return -ENODEV; | ||
214 | 209 | ||
215 | while (!(rd_regl(port, SIRFUART_RX_FIFO_STATUS) & | 210 | while (!(rd_regl(port, SIRFUART_RX_FIFO_STATUS) & |
216 | SIRFUART_FIFOEMPTY_MASK(port))) { | 211 | SIRFUART_FIFOEMPTY_MASK(port))) { |
@@ -224,8 +219,7 @@ sirfsoc_uart_pio_rx_chars(struct uart_port *port, unsigned int max_rx_count) | |||
224 | } | 219 | } |
225 | 220 | ||
226 | port->icount.rx += rx_count; | 221 | port->icount.rx += rx_count; |
227 | tty_flip_buffer_push(tty); | 222 | tty_flip_buffer_push(&port->state->port); |
228 | tty_kref_put(tty); | ||
229 | 223 | ||
230 | return rx_count; | 224 | return rx_count; |
231 | } | 225 | } |
diff --git a/drivers/tty/serial/sn_console.c b/drivers/tty/serial/sn_console.c index 283232c64656..f51ffdc696fd 100644 --- a/drivers/tty/serial/sn_console.c +++ b/drivers/tty/serial/sn_console.c | |||
@@ -459,7 +459,6 @@ sn_receive_chars(struct sn_cons_port *port, unsigned long flags) | |||
459 | { | 459 | { |
460 | struct tty_port *tport = NULL; | 460 | struct tty_port *tport = NULL; |
461 | int ch; | 461 | int ch; |
462 | struct tty_struct *tty; | ||
463 | 462 | ||
464 | if (!port) { | 463 | if (!port) { |
465 | printk(KERN_ERR "sn_receive_chars - port NULL so can't receive\n"); | 464 | printk(KERN_ERR "sn_receive_chars - port NULL so can't receive\n"); |
@@ -474,11 +473,6 @@ sn_receive_chars(struct sn_cons_port *port, unsigned long flags) | |||
474 | if (port->sc_port.state) { | 473 | if (port->sc_port.state) { |
475 | /* The serial_core stuffs are initialized, use them */ | 474 | /* The serial_core stuffs are initialized, use them */ |
476 | tport = &port->sc_port.state->port; | 475 | tport = &port->sc_port.state->port; |
477 | tty = tport->tty; | ||
478 | } | ||
479 | else { | ||
480 | /* Not registered yet - can't pass to tty layer. */ | ||
481 | tty = NULL; | ||
482 | } | 476 | } |
483 | 477 | ||
484 | while (port->sc_ops->sal_input_pending()) { | 478 | while (port->sc_ops->sal_input_pending()) { |
@@ -518,15 +512,15 @@ sn_receive_chars(struct sn_cons_port *port, unsigned long flags) | |||
518 | #endif /* CONFIG_MAGIC_SYSRQ */ | 512 | #endif /* CONFIG_MAGIC_SYSRQ */ |
519 | 513 | ||
520 | /* record the character to pass up to the tty layer */ | 514 | /* record the character to pass up to the tty layer */ |
521 | if (tty) { | 515 | if (tport) { |
522 | if (tty_insert_flip_char(tport, ch, TTY_NORMAL) == 0) | 516 | if (tty_insert_flip_char(tport, ch, TTY_NORMAL) == 0) |
523 | break; | 517 | break; |
524 | } | 518 | } |
525 | port->sc_port.icount.rx++; | 519 | port->sc_port.icount.rx++; |
526 | } | 520 | } |
527 | 521 | ||
528 | if (tty) | 522 | if (tport) |
529 | tty_flip_buffer_push(tty); | 523 | tty_flip_buffer_push(tport); |
530 | } | 524 | } |
531 | 525 | ||
532 | /** | 526 | /** |
diff --git a/drivers/tty/serial/sunhv.c b/drivers/tty/serial/sunhv.c index defe92b19e16..ba60708053e0 100644 --- a/drivers/tty/serial/sunhv.c +++ b/drivers/tty/serial/sunhv.c | |||
@@ -181,17 +181,17 @@ static struct sunhv_ops bywrite_ops = { | |||
181 | 181 | ||
182 | static struct sunhv_ops *sunhv_ops = &bychar_ops; | 182 | static struct sunhv_ops *sunhv_ops = &bychar_ops; |
183 | 183 | ||
184 | static struct tty_struct *receive_chars(struct uart_port *port) | 184 | static struct tty_port *receive_chars(struct uart_port *port) |
185 | { | 185 | { |
186 | struct tty_struct *tty = NULL; | 186 | struct tty_port *tport = NULL; |
187 | 187 | ||
188 | if (port->state != NULL) /* Unopened serial console */ | 188 | if (port->state != NULL) /* Unopened serial console */ |
189 | tty = port->state->port.tty; | 189 | tport = &port->state->port; |
190 | 190 | ||
191 | if (sunhv_ops->receive_chars(port)) | 191 | if (sunhv_ops->receive_chars(port)) |
192 | sun_do_break(); | 192 | sun_do_break(); |
193 | 193 | ||
194 | return tty; | 194 | return tport; |
195 | } | 195 | } |
196 | 196 | ||
197 | static void transmit_chars(struct uart_port *port) | 197 | static void transmit_chars(struct uart_port *port) |
@@ -214,16 +214,16 @@ static void transmit_chars(struct uart_port *port) | |||
214 | static irqreturn_t sunhv_interrupt(int irq, void *dev_id) | 214 | static irqreturn_t sunhv_interrupt(int irq, void *dev_id) |
215 | { | 215 | { |
216 | struct uart_port *port = dev_id; | 216 | struct uart_port *port = dev_id; |
217 | struct tty_struct *tty; | 217 | struct tty_port *tport; |
218 | unsigned long flags; | 218 | unsigned long flags; |
219 | 219 | ||
220 | spin_lock_irqsave(&port->lock, flags); | 220 | spin_lock_irqsave(&port->lock, flags); |
221 | tty = receive_chars(port); | 221 | tport = receive_chars(port); |
222 | transmit_chars(port); | 222 | transmit_chars(port); |
223 | spin_unlock_irqrestore(&port->lock, flags); | 223 | spin_unlock_irqrestore(&port->lock, flags); |
224 | 224 | ||
225 | if (tty) | 225 | if (tport) |
226 | tty_flip_buffer_push(tty); | 226 | tty_flip_buffer_push(tport); |
227 | 227 | ||
228 | return IRQ_HANDLED; | 228 | return IRQ_HANDLED; |
229 | } | 229 | } |
diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c index 4abc4d43a8e8..8de2213664e0 100644 --- a/drivers/tty/serial/sunsab.c +++ b/drivers/tty/serial/sunsab.c | |||
@@ -107,22 +107,19 @@ static __inline__ void sunsab_cec_wait(struct uart_sunsab_port *up) | |||
107 | udelay(1); | 107 | udelay(1); |
108 | } | 108 | } |
109 | 109 | ||
110 | static struct tty_struct * | 110 | static struct tty_port * |
111 | receive_chars(struct uart_sunsab_port *up, | 111 | receive_chars(struct uart_sunsab_port *up, |
112 | union sab82532_irq_status *stat) | 112 | union sab82532_irq_status *stat) |
113 | { | 113 | { |
114 | struct tty_port *port = NULL; | 114 | struct tty_port *port = NULL; |
115 | struct tty_struct *tty = NULL; | ||
116 | unsigned char buf[32]; | 115 | unsigned char buf[32]; |
117 | int saw_console_brk = 0; | 116 | int saw_console_brk = 0; |
118 | int free_fifo = 0; | 117 | int free_fifo = 0; |
119 | int count = 0; | 118 | int count = 0; |
120 | int i; | 119 | int i; |
121 | 120 | ||
122 | if (up->port.state != NULL) { /* Unopened serial console */ | 121 | if (up->port.state != NULL) /* Unopened serial console */ |
123 | port = &up->port.state->port; | 122 | port = &up->port.state->port; |
124 | tty = port->tty; | ||
125 | } | ||
126 | 123 | ||
127 | /* Read number of BYTES (Character + Status) available. */ | 124 | /* Read number of BYTES (Character + Status) available. */ |
128 | if (stat->sreg.isr0 & SAB82532_ISR0_RPF) { | 125 | if (stat->sreg.isr0 & SAB82532_ISR0_RPF) { |
@@ -139,7 +136,7 @@ receive_chars(struct uart_sunsab_port *up, | |||
139 | if (stat->sreg.isr0 & SAB82532_ISR0_TIME) { | 136 | if (stat->sreg.isr0 & SAB82532_ISR0_TIME) { |
140 | sunsab_cec_wait(up); | 137 | sunsab_cec_wait(up); |
141 | writeb(SAB82532_CMDR_RFRD, &up->regs->w.cmdr); | 138 | writeb(SAB82532_CMDR_RFRD, &up->regs->w.cmdr); |
142 | return tty; | 139 | return port; |
143 | } | 140 | } |
144 | 141 | ||
145 | if (stat->sreg.isr0 & SAB82532_ISR0_RFO) | 142 | if (stat->sreg.isr0 & SAB82532_ISR0_RFO) |
@@ -219,7 +216,7 @@ receive_chars(struct uart_sunsab_port *up, | |||
219 | if (saw_console_brk) | 216 | if (saw_console_brk) |
220 | sun_do_break(); | 217 | sun_do_break(); |
221 | 218 | ||
222 | return tty; | 219 | return port; |
223 | } | 220 | } |
224 | 221 | ||
225 | static void sunsab_stop_tx(struct uart_port *); | 222 | static void sunsab_stop_tx(struct uart_port *); |
@@ -302,7 +299,7 @@ static void check_status(struct uart_sunsab_port *up, | |||
302 | static irqreturn_t sunsab_interrupt(int irq, void *dev_id) | 299 | static irqreturn_t sunsab_interrupt(int irq, void *dev_id) |
303 | { | 300 | { |
304 | struct uart_sunsab_port *up = dev_id; | 301 | struct uart_sunsab_port *up = dev_id; |
305 | struct tty_struct *tty; | 302 | struct tty_port *port = NULL; |
306 | union sab82532_irq_status status; | 303 | union sab82532_irq_status status; |
307 | unsigned long flags; | 304 | unsigned long flags; |
308 | unsigned char gis; | 305 | unsigned char gis; |
@@ -316,12 +313,11 @@ static irqreturn_t sunsab_interrupt(int irq, void *dev_id) | |||
316 | if (gis & 2) | 313 | if (gis & 2) |
317 | status.sreg.isr1 = readb(&up->regs->r.isr1); | 314 | status.sreg.isr1 = readb(&up->regs->r.isr1); |
318 | 315 | ||
319 | tty = NULL; | ||
320 | if (status.stat) { | 316 | if (status.stat) { |
321 | if ((status.sreg.isr0 & (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME | | 317 | if ((status.sreg.isr0 & (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME | |
322 | SAB82532_ISR0_RFO | SAB82532_ISR0_RPF)) || | 318 | SAB82532_ISR0_RFO | SAB82532_ISR0_RPF)) || |
323 | (status.sreg.isr1 & SAB82532_ISR1_BRK)) | 319 | (status.sreg.isr1 & SAB82532_ISR1_BRK)) |
324 | tty = receive_chars(up, &status); | 320 | port = receive_chars(up, &status); |
325 | if ((status.sreg.isr0 & SAB82532_ISR0_CDSC) || | 321 | if ((status.sreg.isr0 & SAB82532_ISR0_CDSC) || |
326 | (status.sreg.isr1 & SAB82532_ISR1_CSC)) | 322 | (status.sreg.isr1 & SAB82532_ISR1_CSC)) |
327 | check_status(up, &status); | 323 | check_status(up, &status); |
@@ -331,8 +327,8 @@ static irqreturn_t sunsab_interrupt(int irq, void *dev_id) | |||
331 | 327 | ||
332 | spin_unlock_irqrestore(&up->port.lock, flags); | 328 | spin_unlock_irqrestore(&up->port.lock, flags); |
333 | 329 | ||
334 | if (tty) | 330 | if (port) |
335 | tty_flip_buffer_push(tty); | 331 | tty_flip_buffer_push(port); |
336 | 332 | ||
337 | return IRQ_HANDLED; | 333 | return IRQ_HANDLED; |
338 | } | 334 | } |
diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c index 52325968b06c..e343d6670854 100644 --- a/drivers/tty/serial/sunsu.c +++ b/drivers/tty/serial/sunsu.c | |||
@@ -315,11 +315,10 @@ static void sunsu_enable_ms(struct uart_port *port) | |||
315 | spin_unlock_irqrestore(&up->port.lock, flags); | 315 | spin_unlock_irqrestore(&up->port.lock, flags); |
316 | } | 316 | } |
317 | 317 | ||
318 | static struct tty_struct * | 318 | static void |
319 | receive_chars(struct uart_sunsu_port *up, unsigned char *status) | 319 | receive_chars(struct uart_sunsu_port *up, unsigned char *status) |
320 | { | 320 | { |
321 | struct tty_port *port = &up->port.state->port; | 321 | struct tty_port *port = &up->port.state->port; |
322 | struct tty_struct *tty = port->tty; | ||
323 | unsigned char ch, flag; | 322 | unsigned char ch, flag; |
324 | int max_count = 256; | 323 | int max_count = 256; |
325 | int saw_console_brk = 0; | 324 | int saw_console_brk = 0; |
@@ -391,8 +390,6 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status) | |||
391 | 390 | ||
392 | if (saw_console_brk) | 391 | if (saw_console_brk) |
393 | sun_do_break(); | 392 | sun_do_break(); |
394 | |||
395 | return tty; | ||
396 | } | 393 | } |
397 | 394 | ||
398 | static void transmit_chars(struct uart_sunsu_port *up) | 395 | static void transmit_chars(struct uart_sunsu_port *up) |
@@ -461,20 +458,16 @@ static irqreturn_t sunsu_serial_interrupt(int irq, void *dev_id) | |||
461 | spin_lock_irqsave(&up->port.lock, flags); | 458 | spin_lock_irqsave(&up->port.lock, flags); |
462 | 459 | ||
463 | do { | 460 | do { |
464 | struct tty_struct *tty; | ||
465 | |||
466 | status = serial_inp(up, UART_LSR); | 461 | status = serial_inp(up, UART_LSR); |
467 | tty = NULL; | ||
468 | if (status & UART_LSR_DR) | 462 | if (status & UART_LSR_DR) |
469 | tty = receive_chars(up, &status); | 463 | receive_chars(up, &status); |
470 | check_modem_status(up); | 464 | check_modem_status(up); |
471 | if (status & UART_LSR_THRE) | 465 | if (status & UART_LSR_THRE) |
472 | transmit_chars(up); | 466 | transmit_chars(up); |
473 | 467 | ||
474 | spin_unlock_irqrestore(&up->port.lock, flags); | 468 | spin_unlock_irqrestore(&up->port.lock, flags); |
475 | 469 | ||
476 | if (tty) | 470 | tty_flip_buffer_push(&up->port.state->port); |
477 | tty_flip_buffer_push(tty); | ||
478 | 471 | ||
479 | spin_lock_irqsave(&up->port.lock, flags); | 472 | spin_lock_irqsave(&up->port.lock, flags); |
480 | 473 | ||
diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c index 4a11be3849f6..27669ff3d446 100644 --- a/drivers/tty/serial/sunzilog.c +++ b/drivers/tty/serial/sunzilog.c | |||
@@ -323,19 +323,15 @@ static void sunzilog_kbdms_receive_chars(struct uart_sunzilog_port *up, | |||
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
326 | static struct tty_struct * | 326 | static struct tty_port * |
327 | sunzilog_receive_chars(struct uart_sunzilog_port *up, | 327 | sunzilog_receive_chars(struct uart_sunzilog_port *up, |
328 | struct zilog_channel __iomem *channel) | 328 | struct zilog_channel __iomem *channel) |
329 | { | 329 | { |
330 | struct tty_port *port = NULL; | 330 | struct tty_port *port = NULL; |
331 | struct tty_struct *tty; | ||
332 | unsigned char ch, r1, flag; | 331 | unsigned char ch, r1, flag; |
333 | 332 | ||
334 | tty = NULL; | 333 | if (up->port.state != NULL) /* Unopened serial console */ |
335 | if (up->port.state != NULL) { /* Unopened serial console */ | ||
336 | port = &up->port.state->port; | 334 | port = &up->port.state->port; |
337 | tty = port->tty; /* mouse => tty is NULL */ | ||
338 | } | ||
339 | 335 | ||
340 | for (;;) { | 336 | for (;;) { |
341 | 337 | ||
@@ -403,7 +399,7 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up, | |||
403 | tty_insert_flip_char(port, 0, TTY_OVERRUN); | 399 | tty_insert_flip_char(port, 0, TTY_OVERRUN); |
404 | } | 400 | } |
405 | 401 | ||
406 | return tty; | 402 | return port; |
407 | } | 403 | } |
408 | 404 | ||
409 | static void sunzilog_status_handle(struct uart_sunzilog_port *up, | 405 | static void sunzilog_status_handle(struct uart_sunzilog_port *up, |
@@ -536,21 +532,21 @@ static irqreturn_t sunzilog_interrupt(int irq, void *dev_id) | |||
536 | while (up) { | 532 | while (up) { |
537 | struct zilog_channel __iomem *channel | 533 | struct zilog_channel __iomem *channel |
538 | = ZILOG_CHANNEL_FROM_PORT(&up->port); | 534 | = ZILOG_CHANNEL_FROM_PORT(&up->port); |
539 | struct tty_struct *tty; | 535 | struct tty_port *port; |
540 | unsigned char r3; | 536 | unsigned char r3; |
541 | 537 | ||
542 | spin_lock(&up->port.lock); | 538 | spin_lock(&up->port.lock); |
543 | r3 = read_zsreg(channel, R3); | 539 | r3 = read_zsreg(channel, R3); |
544 | 540 | ||
545 | /* Channel A */ | 541 | /* Channel A */ |
546 | tty = NULL; | 542 | port = NULL; |
547 | if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { | 543 | if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { |
548 | writeb(RES_H_IUS, &channel->control); | 544 | writeb(RES_H_IUS, &channel->control); |
549 | ZSDELAY(); | 545 | ZSDELAY(); |
550 | ZS_WSYNC(channel); | 546 | ZS_WSYNC(channel); |
551 | 547 | ||
552 | if (r3 & CHARxIP) | 548 | if (r3 & CHARxIP) |
553 | tty = sunzilog_receive_chars(up, channel); | 549 | port = sunzilog_receive_chars(up, channel); |
554 | if (r3 & CHAEXT) | 550 | if (r3 & CHAEXT) |
555 | sunzilog_status_handle(up, channel); | 551 | sunzilog_status_handle(up, channel); |
556 | if (r3 & CHATxIP) | 552 | if (r3 & CHATxIP) |
@@ -558,22 +554,22 @@ static irqreturn_t sunzilog_interrupt(int irq, void *dev_id) | |||
558 | } | 554 | } |
559 | spin_unlock(&up->port.lock); | 555 | spin_unlock(&up->port.lock); |
560 | 556 | ||
561 | if (tty) | 557 | if (port) |
562 | tty_flip_buffer_push(tty); | 558 | tty_flip_buffer_push(port); |
563 | 559 | ||
564 | /* Channel B */ | 560 | /* Channel B */ |
565 | up = up->next; | 561 | up = up->next; |
566 | channel = ZILOG_CHANNEL_FROM_PORT(&up->port); | 562 | channel = ZILOG_CHANNEL_FROM_PORT(&up->port); |
567 | 563 | ||
568 | spin_lock(&up->port.lock); | 564 | spin_lock(&up->port.lock); |
569 | tty = NULL; | 565 | port = NULL; |
570 | if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) { | 566 | if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) { |
571 | writeb(RES_H_IUS, &channel->control); | 567 | writeb(RES_H_IUS, &channel->control); |
572 | ZSDELAY(); | 568 | ZSDELAY(); |
573 | ZS_WSYNC(channel); | 569 | ZS_WSYNC(channel); |
574 | 570 | ||
575 | if (r3 & CHBRxIP) | 571 | if (r3 & CHBRxIP) |
576 | tty = sunzilog_receive_chars(up, channel); | 572 | port = sunzilog_receive_chars(up, channel); |
577 | if (r3 & CHBEXT) | 573 | if (r3 & CHBEXT) |
578 | sunzilog_status_handle(up, channel); | 574 | sunzilog_status_handle(up, channel); |
579 | if (r3 & CHBTxIP) | 575 | if (r3 & CHBTxIP) |
@@ -581,8 +577,8 @@ static irqreturn_t sunzilog_interrupt(int irq, void *dev_id) | |||
581 | } | 577 | } |
582 | spin_unlock(&up->port.lock); | 578 | spin_unlock(&up->port.lock); |
583 | 579 | ||
584 | if (tty) | 580 | if (port) |
585 | tty_flip_buffer_push(tty); | 581 | tty_flip_buffer_push(port); |
586 | 582 | ||
587 | up = up->next; | 583 | up = up->next; |
588 | } | 584 | } |
diff --git a/drivers/tty/serial/timbuart.c b/drivers/tty/serial/timbuart.c index f40c634f7528..6818410a2bea 100644 --- a/drivers/tty/serial/timbuart.c +++ b/drivers/tty/serial/timbuart.c | |||
@@ -100,7 +100,7 @@ static void timbuart_rx_chars(struct uart_port *port) | |||
100 | } | 100 | } |
101 | 101 | ||
102 | spin_unlock(&port->lock); | 102 | spin_unlock(&port->lock); |
103 | tty_flip_buffer_push(port->state->port.tty); | 103 | tty_flip_buffer_push(tport); |
104 | spin_lock(&port->lock); | 104 | spin_lock(&port->lock); |
105 | 105 | ||
106 | dev_dbg(port->dev, "%s - total read %d bytes\n", | 106 | dev_dbg(port->dev, "%s - total read %d bytes\n", |
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c index 5caf1f0ebc82..5486505e87c7 100644 --- a/drivers/tty/serial/uartlite.c +++ b/drivers/tty/serial/uartlite.c | |||
@@ -156,7 +156,7 @@ static irqreturn_t ulite_isr(int irq, void *dev_id) | |||
156 | 156 | ||
157 | /* work done? */ | 157 | /* work done? */ |
158 | if (n > 1) { | 158 | if (n > 1) { |
159 | tty_flip_buffer_push(port->state->port.tty); | 159 | tty_flip_buffer_push(&port->state->port); |
160 | return IRQ_HANDLED; | 160 | return IRQ_HANDLED; |
161 | } else { | 161 | } else { |
162 | return IRQ_NONE; | 162 | return IRQ_NONE; |
diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c index 7a2378627fa5..7355303dad99 100644 --- a/drivers/tty/serial/ucc_uart.c +++ b/drivers/tty/serial/ucc_uart.c | |||
@@ -470,7 +470,6 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port) | |||
470 | unsigned char ch, *cp; | 470 | unsigned char ch, *cp; |
471 | struct uart_port *port = &qe_port->port; | 471 | struct uart_port *port = &qe_port->port; |
472 | struct tty_port *tport = &port->state->port; | 472 | struct tty_port *tport = &port->state->port; |
473 | struct tty_struct *tty = tport->tty; | ||
474 | struct qe_bd *bdp; | 473 | struct qe_bd *bdp; |
475 | u16 status; | 474 | u16 status; |
476 | unsigned int flg; | 475 | unsigned int flg; |
@@ -531,7 +530,7 @@ error_return: | |||
531 | qe_port->rx_cur = bdp; | 530 | qe_port->rx_cur = bdp; |
532 | 531 | ||
533 | /* Activate BH processing */ | 532 | /* Activate BH processing */ |
534 | tty_flip_buffer_push(tty); | 533 | tty_flip_buffer_push(tport); |
535 | 534 | ||
536 | return; | 535 | return; |
537 | 536 | ||
diff --git a/drivers/tty/serial/vr41xx_siu.c b/drivers/tty/serial/vr41xx_siu.c index 62ee0166bc65..f655997f44af 100644 --- a/drivers/tty/serial/vr41xx_siu.c +++ b/drivers/tty/serial/vr41xx_siu.c | |||
@@ -313,12 +313,10 @@ static void siu_break_ctl(struct uart_port *port, int ctl) | |||
313 | 313 | ||
314 | static inline void receive_chars(struct uart_port *port, uint8_t *status) | 314 | static inline void receive_chars(struct uart_port *port, uint8_t *status) |
315 | { | 315 | { |
316 | struct tty_struct *tty; | ||
317 | uint8_t lsr, ch; | 316 | uint8_t lsr, ch; |
318 | char flag; | 317 | char flag; |
319 | int max_count = RX_MAX_COUNT; | 318 | int max_count = RX_MAX_COUNT; |
320 | 319 | ||
321 | tty = port->state->port.tty; | ||
322 | lsr = *status; | 320 | lsr = *status; |
323 | 321 | ||
324 | do { | 322 | do { |
@@ -365,7 +363,7 @@ static inline void receive_chars(struct uart_port *port, uint8_t *status) | |||
365 | lsr = siu_read(port, UART_LSR); | 363 | lsr = siu_read(port, UART_LSR); |
366 | } while ((lsr & UART_LSR_DR) && (max_count-- > 0)); | 364 | } while ((lsr & UART_LSR_DR) && (max_count-- > 0)); |
367 | 365 | ||
368 | tty_flip_buffer_push(tty); | 366 | tty_flip_buffer_push(&port->state->port); |
369 | 367 | ||
370 | *status = lsr; | 368 | *status = lsr; |
371 | } | 369 | } |
diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c index 7f4112423f3d..f1a398c672fa 100644 --- a/drivers/tty/serial/vt8500_serial.c +++ b/drivers/tty/serial/vt8500_serial.c | |||
@@ -137,15 +137,6 @@ static void vt8500_enable_ms(struct uart_port *port) | |||
137 | static void handle_rx(struct uart_port *port) | 137 | static void handle_rx(struct uart_port *port) |
138 | { | 138 | { |
139 | struct tty_port *tport = &port->state->port; | 139 | struct tty_port *tport = &port->state->port; |
140 | struct tty_struct *tty = tty_port_tty_get(tport); | ||
141 | if (!tty) { | ||
142 | /* Discard data: no tty available */ | ||
143 | int count = (vt8500_read(port, VT8500_URFIDX) & 0x1f00) >> 8; | ||
144 | u16 ch; | ||
145 | while (count--) | ||
146 | ch = readw(port->membase + VT8500_RXFIFO); | ||
147 | return; | ||
148 | } | ||
149 | 140 | ||
150 | /* | 141 | /* |
151 | * Handle overrun | 142 | * Handle overrun |
@@ -178,8 +169,7 @@ static void handle_rx(struct uart_port *port) | |||
178 | tty_insert_flip_char(tport, c, flag); | 169 | tty_insert_flip_char(tport, c, flag); |
179 | } | 170 | } |
180 | 171 | ||
181 | tty_flip_buffer_push(tty); | 172 | tty_flip_buffer_push(tport); |
182 | tty_kref_put(tty); | ||
183 | } | 173 | } |
184 | 174 | ||
185 | static void handle_tx(struct uart_port *port) | 175 | static void handle_tx(struct uart_port *port) |
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 9ab910370c56..82a3151e393c 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c | |||
@@ -147,15 +147,11 @@ | |||
147 | static irqreturn_t xuartps_isr(int irq, void *dev_id) | 147 | static irqreturn_t xuartps_isr(int irq, void *dev_id) |
148 | { | 148 | { |
149 | struct uart_port *port = (struct uart_port *)dev_id; | 149 | struct uart_port *port = (struct uart_port *)dev_id; |
150 | struct tty_struct *tty; | ||
151 | unsigned long flags; | 150 | unsigned long flags; |
152 | unsigned int isrstatus, numbytes; | 151 | unsigned int isrstatus, numbytes; |
153 | unsigned int data; | 152 | unsigned int data; |
154 | char status = TTY_NORMAL; | 153 | char status = TTY_NORMAL; |
155 | 154 | ||
156 | /* Get the tty which could be NULL so don't assume it's valid */ | ||
157 | tty = tty_port_tty_get(&port->state->port); | ||
158 | |||
159 | spin_lock_irqsave(&port->lock, flags); | 155 | spin_lock_irqsave(&port->lock, flags); |
160 | 156 | ||
161 | /* Read the interrupt status register to determine which | 157 | /* Read the interrupt status register to determine which |
@@ -187,14 +183,11 @@ static irqreturn_t xuartps_isr(int irq, void *dev_id) | |||
187 | } else if (isrstatus & XUARTPS_IXR_OVERRUN) | 183 | } else if (isrstatus & XUARTPS_IXR_OVERRUN) |
188 | port->icount.overrun++; | 184 | port->icount.overrun++; |
189 | 185 | ||
190 | if (tty) | 186 | uart_insert_char(port, isrstatus, XUARTPS_IXR_OVERRUN, |
191 | uart_insert_char(port, isrstatus, | 187 | data, status); |
192 | XUARTPS_IXR_OVERRUN, data, | ||
193 | status); | ||
194 | } | 188 | } |
195 | spin_unlock(&port->lock); | 189 | spin_unlock(&port->lock); |
196 | if (tty) | 190 | tty_flip_buffer_push(&port->state->port); |
197 | tty_flip_buffer_push(tty); | ||
198 | spin_lock(&port->lock); | 191 | spin_lock(&port->lock); |
199 | } | 192 | } |
200 | 193 | ||
@@ -237,7 +230,6 @@ static irqreturn_t xuartps_isr(int irq, void *dev_id) | |||
237 | 230 | ||
238 | /* be sure to release the lock and tty before leaving */ | 231 | /* be sure to release the lock and tty before leaving */ |
239 | spin_unlock_irqrestore(&port->lock, flags); | 232 | spin_unlock_irqrestore(&port->lock, flags); |
240 | tty_kref_put(tty); | ||
241 | 233 | ||
242 | return IRQ_HANDLED; | 234 | return IRQ_HANDLED; |
243 | } | 235 | } |
diff --git a/drivers/tty/serial/zs.c b/drivers/tty/serial/zs.c index 92c00b24d0df..6a169877109b 100644 --- a/drivers/tty/serial/zs.c +++ b/drivers/tty/serial/zs.c | |||
@@ -603,7 +603,7 @@ static void zs_receive_chars(struct zs_port *zport) | |||
603 | uart_insert_char(uport, status, Rx_OVR, ch, flag); | 603 | uart_insert_char(uport, status, Rx_OVR, ch, flag); |
604 | } | 604 | } |
605 | 605 | ||
606 | tty_flip_buffer_push(uport->state->port.tty); | 606 | tty_flip_buffer_push(&uport->state->port); |
607 | } | 607 | } |
608 | 608 | ||
609 | static void zs_raw_transmit_chars(struct zs_port *zport) | 609 | static void zs_raw_transmit_chars(struct zs_port *zport) |
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c index 2f6967d61a80..555fdc0ed0f1 100644 --- a/drivers/tty/synclink.c +++ b/drivers/tty/synclink.c | |||
@@ -1439,7 +1439,6 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info ) | |||
1439 | u16 status; | 1439 | u16 status; |
1440 | int work = 0; | 1440 | int work = 0; |
1441 | unsigned char DataByte; | 1441 | unsigned char DataByte; |
1442 | struct tty_struct *tty = info->port.tty; | ||
1443 | struct mgsl_icount *icount = &info->icount; | 1442 | struct mgsl_icount *icount = &info->icount; |
1444 | 1443 | ||
1445 | if ( debug_level >= DEBUG_LEVEL_ISR ) | 1444 | if ( debug_level >= DEBUG_LEVEL_ISR ) |
@@ -1501,7 +1500,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info ) | |||
1501 | if (status & RXSTATUS_BREAK_RECEIVED) { | 1500 | if (status & RXSTATUS_BREAK_RECEIVED) { |
1502 | flag = TTY_BREAK; | 1501 | flag = TTY_BREAK; |
1503 | if (info->port.flags & ASYNC_SAK) | 1502 | if (info->port.flags & ASYNC_SAK) |
1504 | do_SAK(tty); | 1503 | do_SAK(info->port.tty); |
1505 | } else if (status & RXSTATUS_PARITY_ERROR) | 1504 | } else if (status & RXSTATUS_PARITY_ERROR) |
1506 | flag = TTY_PARITY; | 1505 | flag = TTY_PARITY; |
1507 | else if (status & RXSTATUS_FRAMING_ERROR) | 1506 | else if (status & RXSTATUS_FRAMING_ERROR) |
@@ -1524,7 +1523,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info ) | |||
1524 | } | 1523 | } |
1525 | 1524 | ||
1526 | if(work) | 1525 | if(work) |
1527 | tty_flip_buffer_push(tty); | 1526 | tty_flip_buffer_push(&info->port); |
1528 | } | 1527 | } |
1529 | 1528 | ||
1530 | /* mgsl_isr_misc() | 1529 | /* mgsl_isr_misc() |
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index 9a0358a1e0dd..fced6acc74ee 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c | |||
@@ -1854,7 +1854,6 @@ static void hdlcdev_exit(struct slgt_info *info) | |||
1854 | */ | 1854 | */ |
1855 | static void rx_async(struct slgt_info *info) | 1855 | static void rx_async(struct slgt_info *info) |
1856 | { | 1856 | { |
1857 | struct tty_struct *tty = info->port.tty; | ||
1858 | struct mgsl_icount *icount = &info->icount; | 1857 | struct mgsl_icount *icount = &info->icount; |
1859 | unsigned int start, end; | 1858 | unsigned int start, end; |
1860 | unsigned char *p; | 1859 | unsigned char *p; |
@@ -1915,8 +1914,8 @@ static void rx_async(struct slgt_info *info) | |||
1915 | break; | 1914 | break; |
1916 | } | 1915 | } |
1917 | 1916 | ||
1918 | if (tty && chars) | 1917 | if (chars) |
1919 | tty_flip_buffer_push(tty); | 1918 | tty_flip_buffer_push(&info->port); |
1920 | } | 1919 | } |
1921 | 1920 | ||
1922 | /* | 1921 | /* |
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index 419f58ff4a13..e4a2904af565 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c | |||
@@ -2167,7 +2167,6 @@ static void isr_rxrdy(SLMP_INFO * info) | |||
2167 | { | 2167 | { |
2168 | u16 status; | 2168 | u16 status; |
2169 | unsigned char DataByte; | 2169 | unsigned char DataByte; |
2170 | struct tty_struct *tty = info->port.tty; | ||
2171 | struct mgsl_icount *icount = &info->icount; | 2170 | struct mgsl_icount *icount = &info->icount; |
2172 | 2171 | ||
2173 | if ( debug_level >= DEBUG_LEVEL_ISR ) | 2172 | if ( debug_level >= DEBUG_LEVEL_ISR ) |
@@ -2225,8 +2224,7 @@ static void isr_rxrdy(SLMP_INFO * info) | |||
2225 | icount->frame,icount->overrun); | 2224 | icount->frame,icount->overrun); |
2226 | } | 2225 | } |
2227 | 2226 | ||
2228 | if ( tty ) | 2227 | tty_flip_buffer_push(&info->port); |
2229 | tty_flip_buffer_push(tty); | ||
2230 | } | 2228 | } |
2231 | 2229 | ||
2232 | static void isr_txeom(SLMP_INFO * info, unsigned char status) | 2230 | static void isr_txeom(SLMP_INFO * info, unsigned char status) |
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 1bfe97a8e2eb..b6efacadf23b 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c | |||
@@ -544,7 +544,7 @@ void tty_flush_to_ldisc(struct tty_struct *tty) | |||
544 | 544 | ||
545 | /** | 545 | /** |
546 | * tty_flip_buffer_push - terminal | 546 | * tty_flip_buffer_push - terminal |
547 | * @tty: tty to push | 547 | * @port: tty port to push |
548 | * | 548 | * |
549 | * Queue a push of the terminal flip buffers to the line discipline. This | 549 | * Queue a push of the terminal flip buffers to the line discipline. This |
550 | * function must not be called from IRQ context if port->low_latency is | 550 | * function must not be called from IRQ context if port->low_latency is |
@@ -556,9 +556,9 @@ void tty_flush_to_ldisc(struct tty_struct *tty) | |||
556 | * Locking: tty buffer lock. Driver locks in low latency mode. | 556 | * Locking: tty buffer lock. Driver locks in low latency mode. |
557 | */ | 557 | */ |
558 | 558 | ||
559 | void tty_flip_buffer_push(struct tty_struct *tty) | 559 | void tty_flip_buffer_push(struct tty_port *port) |
560 | { | 560 | { |
561 | struct tty_bufhead *buf = &tty->port->buf; | 561 | struct tty_bufhead *buf = &port->buf; |
562 | unsigned long flags; | 562 | unsigned long flags; |
563 | 563 | ||
564 | spin_lock_irqsave(&buf->lock, flags); | 564 | spin_lock_irqsave(&buf->lock, flags); |
@@ -566,7 +566,7 @@ void tty_flip_buffer_push(struct tty_struct *tty) | |||
566 | buf->tail->commit = buf->tail->used; | 566 | buf->tail->commit = buf->tail->used; |
567 | spin_unlock_irqrestore(&buf->lock, flags); | 567 | spin_unlock_irqrestore(&buf->lock, flags); |
568 | 568 | ||
569 | if (tty->port->low_latency) | 569 | if (port->low_latency) |
570 | flush_to_ldisc(&buf->work); | 570 | flush_to_ldisc(&buf->work); |
571 | else | 571 | else |
572 | schedule_work(&buf->work); | 572 | schedule_work(&buf->work); |
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 20dc2add27ba..15b36e2efa85 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -410,20 +410,12 @@ static int acm_submit_read_urbs(struct acm *acm, gfp_t mem_flags) | |||
410 | 410 | ||
411 | static void acm_process_read_urb(struct acm *acm, struct urb *urb) | 411 | static void acm_process_read_urb(struct acm *acm, struct urb *urb) |
412 | { | 412 | { |
413 | struct tty_struct *tty; | ||
414 | |||
415 | if (!urb->actual_length) | 413 | if (!urb->actual_length) |
416 | return; | 414 | return; |
417 | 415 | ||
418 | tty = tty_port_tty_get(&acm->port); | ||
419 | if (!tty) | ||
420 | return; | ||
421 | |||
422 | tty_insert_flip_string(&acm->port, urb->transfer_buffer, | 416 | tty_insert_flip_string(&acm->port, urb->transfer_buffer, |
423 | urb->actual_length); | 417 | urb->actual_length); |
424 | tty_flip_buffer_push(tty); | 418 | tty_flip_buffer_push(&acm->port); |
425 | |||
426 | tty_kref_put(tty); | ||
427 | } | 419 | } |
428 | 420 | ||
429 | static void acm_read_bulk_callback(struct urb *urb) | 421 | static void acm_read_bulk_callback(struct urb *urb) |
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c index 3560799d530a..ca4fc3d3e7ff 100644 --- a/drivers/usb/gadget/u_serial.c +++ b/drivers/usb/gadget/u_serial.c | |||
@@ -551,8 +551,8 @@ static void gs_rx_push(unsigned long _port) | |||
551 | /* Push from tty to ldisc; without low_latency set this is handled by | 551 | /* Push from tty to ldisc; without low_latency set this is handled by |
552 | * a workqueue, so we won't get callbacks and can hold port_lock | 552 | * a workqueue, so we won't get callbacks and can hold port_lock |
553 | */ | 553 | */ |
554 | if (tty && do_push) | 554 | if (do_push) |
555 | tty_flip_buffer_push(tty); | 555 | tty_flip_buffer_push(&port->port); |
556 | 556 | ||
557 | 557 | ||
558 | /* We want our data queue to become empty ASAP, keeping data | 558 | /* We want our data queue to become empty ASAP, keeping data |
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index 3bb1f8f11fc8..6e320cec397d 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c | |||
@@ -140,16 +140,11 @@ static void aircable_process_read_urb(struct urb *urb) | |||
140 | { | 140 | { |
141 | struct usb_serial_port *port = urb->context; | 141 | struct usb_serial_port *port = urb->context; |
142 | char *data = (char *)urb->transfer_buffer; | 142 | char *data = (char *)urb->transfer_buffer; |
143 | struct tty_struct *tty; | ||
144 | int has_headers; | 143 | int has_headers; |
145 | int count; | 144 | int count; |
146 | int len; | 145 | int len; |
147 | int i; | 146 | int i; |
148 | 147 | ||
149 | tty = tty_port_tty_get(&port->port); | ||
150 | if (!tty) | ||
151 | return; | ||
152 | |||
153 | has_headers = (urb->actual_length > 2 && data[0] == RX_HEADER_0); | 148 | has_headers = (urb->actual_length > 2 && data[0] == RX_HEADER_0); |
154 | 149 | ||
155 | count = 0; | 150 | count = 0; |
@@ -160,8 +155,7 @@ static void aircable_process_read_urb(struct urb *urb) | |||
160 | } | 155 | } |
161 | 156 | ||
162 | if (count) | 157 | if (count) |
163 | tty_flip_buffer_push(tty); | 158 | tty_flip_buffer_push(&port->port); |
164 | tty_kref_put(tty); | ||
165 | } | 159 | } |
166 | 160 | ||
167 | static struct usb_serial_driver aircable_device = { | 161 | static struct usb_serial_driver aircable_device = { |
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 1614feb6a76e..cbd904b8fba5 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -674,7 +674,6 @@ static void ark3116_process_read_urb(struct urb *urb) | |||
674 | { | 674 | { |
675 | struct usb_serial_port *port = urb->context; | 675 | struct usb_serial_port *port = urb->context; |
676 | struct ark3116_private *priv = usb_get_serial_port_data(port); | 676 | struct ark3116_private *priv = usb_get_serial_port_data(port); |
677 | struct tty_struct *tty; | ||
678 | unsigned char *data = urb->transfer_buffer; | 677 | unsigned char *data = urb->transfer_buffer; |
679 | char tty_flag = TTY_NORMAL; | 678 | char tty_flag = TTY_NORMAL; |
680 | unsigned long flags; | 679 | unsigned long flags; |
@@ -689,10 +688,6 @@ static void ark3116_process_read_urb(struct urb *urb) | |||
689 | if (!urb->actual_length) | 688 | if (!urb->actual_length) |
690 | return; | 689 | return; |
691 | 690 | ||
692 | tty = tty_port_tty_get(&port->port); | ||
693 | if (!tty) | ||
694 | return; | ||
695 | |||
696 | if (lsr & UART_LSR_BRK_ERROR_BITS) { | 691 | if (lsr & UART_LSR_BRK_ERROR_BITS) { |
697 | if (lsr & UART_LSR_BI) | 692 | if (lsr & UART_LSR_BI) |
698 | tty_flag = TTY_BREAK; | 693 | tty_flag = TTY_BREAK; |
@@ -707,8 +702,7 @@ static void ark3116_process_read_urb(struct urb *urb) | |||
707 | } | 702 | } |
708 | tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, | 703 | tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, |
709 | urb->actual_length); | 704 | urb->actual_length); |
710 | tty_flip_buffer_push(tty); | 705 | tty_flip_buffer_push(&port->port); |
711 | tty_kref_put(tty); | ||
712 | } | 706 | } |
713 | 707 | ||
714 | static struct usb_serial_driver ark3116_device = { | 708 | static struct usb_serial_driver ark3116_device = { |
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 7ba2c0bdcec9..84217e78ded4 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
@@ -242,7 +242,6 @@ static void belkin_sa_process_read_urb(struct urb *urb) | |||
242 | { | 242 | { |
243 | struct usb_serial_port *port = urb->context; | 243 | struct usb_serial_port *port = urb->context; |
244 | struct belkin_sa_private *priv = usb_get_serial_port_data(port); | 244 | struct belkin_sa_private *priv = usb_get_serial_port_data(port); |
245 | struct tty_struct *tty; | ||
246 | unsigned char *data = urb->transfer_buffer; | 245 | unsigned char *data = urb->transfer_buffer; |
247 | unsigned long flags; | 246 | unsigned long flags; |
248 | unsigned char status; | 247 | unsigned char status; |
@@ -259,10 +258,6 @@ static void belkin_sa_process_read_urb(struct urb *urb) | |||
259 | if (!urb->actual_length) | 258 | if (!urb->actual_length) |
260 | return; | 259 | return; |
261 | 260 | ||
262 | tty = tty_port_tty_get(&port->port); | ||
263 | if (!tty) | ||
264 | return; | ||
265 | |||
266 | if (status & BELKIN_SA_LSR_ERR) { | 261 | if (status & BELKIN_SA_LSR_ERR) { |
267 | /* Break takes precedence over parity, which takes precedence | 262 | /* Break takes precedence over parity, which takes precedence |
268 | * over framing errors. */ | 263 | * over framing errors. */ |
@@ -281,8 +276,7 @@ static void belkin_sa_process_read_urb(struct urb *urb) | |||
281 | 276 | ||
282 | tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, | 277 | tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, |
283 | urb->actual_length); | 278 | urb->actual_length); |
284 | tty_flip_buffer_push(tty); | 279 | tty_flip_buffer_push(&port->port); |
285 | tty_kref_put(tty); | ||
286 | } | 280 | } |
287 | 281 | ||
288 | static void belkin_sa_set_termios(struct tty_struct *tty, | 282 | static void belkin_sa_set_termios(struct tty_struct *tty, |
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index e6976a974472..629bd2894506 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
@@ -324,7 +324,6 @@ static void cyberjack_read_bulk_callback(struct urb *urb) | |||
324 | struct usb_serial_port *port = urb->context; | 324 | struct usb_serial_port *port = urb->context; |
325 | struct cyberjack_private *priv = usb_get_serial_port_data(port); | 325 | struct cyberjack_private *priv = usb_get_serial_port_data(port); |
326 | struct device *dev = &port->dev; | 326 | struct device *dev = &port->dev; |
327 | struct tty_struct *tty; | ||
328 | unsigned char *data = urb->transfer_buffer; | 327 | unsigned char *data = urb->transfer_buffer; |
329 | short todo; | 328 | short todo; |
330 | int result; | 329 | int result; |
@@ -337,16 +336,10 @@ static void cyberjack_read_bulk_callback(struct urb *urb) | |||
337 | return; | 336 | return; |
338 | } | 337 | } |
339 | 338 | ||
340 | tty = tty_port_tty_get(&port->port); | ||
341 | if (!tty) { | ||
342 | dev_dbg(dev, "%s - ignoring since device not open\n", __func__); | ||
343 | return; | ||
344 | } | ||
345 | if (urb->actual_length) { | 339 | if (urb->actual_length) { |
346 | tty_insert_flip_string(&port->port, data, urb->actual_length); | 340 | tty_insert_flip_string(&port->port, data, urb->actual_length); |
347 | tty_flip_buffer_push(tty); | 341 | tty_flip_buffer_push(&port->port); |
348 | } | 342 | } |
349 | tty_kref_put(tty); | ||
350 | 343 | ||
351 | spin_lock(&priv->lock); | 344 | spin_lock(&priv->lock); |
352 | 345 | ||
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index ac14e3eb95ea..8efa19d0e9fb 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
@@ -1214,10 +1214,10 @@ static void cypress_read_int_callback(struct urb *urb) | |||
1214 | spin_unlock_irqrestore(&priv->lock, flags); | 1214 | spin_unlock_irqrestore(&priv->lock, flags); |
1215 | 1215 | ||
1216 | /* process read if there is data other than line status */ | 1216 | /* process read if there is data other than line status */ |
1217 | if (tty && bytes > i) { | 1217 | if (bytes > i) { |
1218 | tty_insert_flip_string_fixed_flag(&port->port, data + i, | 1218 | tty_insert_flip_string_fixed_flag(&port->port, data + i, |
1219 | tty_flag, bytes - i); | 1219 | tty_flag, bytes - i); |
1220 | tty_flip_buffer_push(tty); | 1220 | tty_flip_buffer_push(&port->port); |
1221 | } | 1221 | } |
1222 | 1222 | ||
1223 | spin_lock_irqsave(&priv->lock, flags); | 1223 | spin_lock_irqsave(&priv->lock, flags); |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index b5fa738512ca..ebe45fa0ed50 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -1399,9 +1399,7 @@ static void digi_read_bulk_callback(struct urb *urb) | |||
1399 | 1399 | ||
1400 | static int digi_read_inb_callback(struct urb *urb) | 1400 | static int digi_read_inb_callback(struct urb *urb) |
1401 | { | 1401 | { |
1402 | |||
1403 | struct usb_serial_port *port = urb->context; | 1402 | struct usb_serial_port *port = urb->context; |
1404 | struct tty_struct *tty; | ||
1405 | struct digi_port *priv = usb_get_serial_port_data(port); | 1403 | struct digi_port *priv = usb_get_serial_port_data(port); |
1406 | int opcode = ((unsigned char *)urb->transfer_buffer)[0]; | 1404 | int opcode = ((unsigned char *)urb->transfer_buffer)[0]; |
1407 | int len = ((unsigned char *)urb->transfer_buffer)[1]; | 1405 | int len = ((unsigned char *)urb->transfer_buffer)[1]; |
@@ -1425,7 +1423,6 @@ static int digi_read_inb_callback(struct urb *urb) | |||
1425 | return -1; | 1423 | return -1; |
1426 | } | 1424 | } |
1427 | 1425 | ||
1428 | tty = tty_port_tty_get(&port->port); | ||
1429 | spin_lock(&priv->dp_port_lock); | 1426 | spin_lock(&priv->dp_port_lock); |
1430 | 1427 | ||
1431 | /* check for throttle; if set, do not resubmit read urb */ | 1428 | /* check for throttle; if set, do not resubmit read urb */ |
@@ -1435,7 +1432,7 @@ static int digi_read_inb_callback(struct urb *urb) | |||
1435 | priv->dp_throttle_restart = 1; | 1432 | priv->dp_throttle_restart = 1; |
1436 | 1433 | ||
1437 | /* receive data */ | 1434 | /* receive data */ |
1438 | if (tty && opcode == DIGI_CMD_RECEIVE_DATA) { | 1435 | if (opcode == DIGI_CMD_RECEIVE_DATA) { |
1439 | /* get flag from port_status */ | 1436 | /* get flag from port_status */ |
1440 | flag = 0; | 1437 | flag = 0; |
1441 | 1438 | ||
@@ -1457,11 +1454,10 @@ static int digi_read_inb_callback(struct urb *urb) | |||
1457 | if (len > 0) { | 1454 | if (len > 0) { |
1458 | tty_insert_flip_string_fixed_flag(&port->port, data, | 1455 | tty_insert_flip_string_fixed_flag(&port->port, data, |
1459 | flag, len); | 1456 | flag, len); |
1460 | tty_flip_buffer_push(tty); | 1457 | tty_flip_buffer_push(&port->port); |
1461 | } | 1458 | } |
1462 | } | 1459 | } |
1463 | spin_unlock(&priv->dp_port_lock); | 1460 | spin_unlock(&priv->dp_port_lock); |
1464 | tty_kref_put(tty); | ||
1465 | 1461 | ||
1466 | if (opcode == DIGI_CMD_RECEIVE_DISABLE) | 1462 | if (opcode == DIGI_CMD_RECEIVE_DISABLE) |
1467 | dev_dbg(&port->dev, "%s: got RECEIVE_DISABLE\n", __func__); | 1463 | dev_dbg(&port->dev, "%s: got RECEIVE_DISABLE\n", __func__); |
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 6b880c33d258..b1b2dc64b50b 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c | |||
@@ -100,7 +100,6 @@ static void f81232_process_read_urb(struct urb *urb) | |||
100 | { | 100 | { |
101 | struct usb_serial_port *port = urb->context; | 101 | struct usb_serial_port *port = urb->context; |
102 | struct f81232_private *priv = usb_get_serial_port_data(port); | 102 | struct f81232_private *priv = usb_get_serial_port_data(port); |
103 | struct tty_struct *tty; | ||
104 | unsigned char *data = urb->transfer_buffer; | 103 | unsigned char *data = urb->transfer_buffer; |
105 | char tty_flag = TTY_NORMAL; | 104 | char tty_flag = TTY_NORMAL; |
106 | unsigned long flags; | 105 | unsigned long flags; |
@@ -117,10 +116,6 @@ static void f81232_process_read_urb(struct urb *urb) | |||
117 | if (!urb->actual_length) | 116 | if (!urb->actual_length) |
118 | return; | 117 | return; |
119 | 118 | ||
120 | tty = tty_port_tty_get(&port->port); | ||
121 | if (!tty) | ||
122 | return; | ||
123 | |||
124 | /* break takes precedence over parity, */ | 119 | /* break takes precedence over parity, */ |
125 | /* which takes precedence over framing errors */ | 120 | /* which takes precedence over framing errors */ |
126 | if (line_status & UART_BREAK_ERROR) | 121 | if (line_status & UART_BREAK_ERROR) |
@@ -145,8 +140,7 @@ static void f81232_process_read_urb(struct urb *urb) | |||
145 | urb->actual_length); | 140 | urb->actual_length); |
146 | } | 141 | } |
147 | 142 | ||
148 | tty_flip_buffer_push(tty); | 143 | tty_flip_buffer_push(&port->port); |
149 | tty_kref_put(tty); | ||
150 | } | 144 | } |
151 | 145 | ||
152 | static int set_control_lines(struct usb_device *dev, u8 value) | 146 | static int set_control_lines(struct usb_device *dev, u8 value) |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index eb59ba3789ad..a96083b7fabc 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -2040,25 +2040,19 @@ static int ftdi_process_packet(struct usb_serial_port *port, | |||
2040 | static void ftdi_process_read_urb(struct urb *urb) | 2040 | static void ftdi_process_read_urb(struct urb *urb) |
2041 | { | 2041 | { |
2042 | struct usb_serial_port *port = urb->context; | 2042 | struct usb_serial_port *port = urb->context; |
2043 | struct tty_struct *tty; | ||
2044 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 2043 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
2045 | char *data = (char *)urb->transfer_buffer; | 2044 | char *data = (char *)urb->transfer_buffer; |
2046 | int i; | 2045 | int i; |
2047 | int len; | 2046 | int len; |
2048 | int count = 0; | 2047 | int count = 0; |
2049 | 2048 | ||
2050 | tty = tty_port_tty_get(&port->port); | ||
2051 | if (!tty) | ||
2052 | return; | ||
2053 | |||
2054 | for (i = 0; i < urb->actual_length; i += priv->max_packet_size) { | 2049 | for (i = 0; i < urb->actual_length; i += priv->max_packet_size) { |
2055 | len = min_t(int, urb->actual_length - i, priv->max_packet_size); | 2050 | len = min_t(int, urb->actual_length - i, priv->max_packet_size); |
2056 | count += ftdi_process_packet(port, priv, &data[i], len); | 2051 | count += ftdi_process_packet(port, priv, &data[i], len); |
2057 | } | 2052 | } |
2058 | 2053 | ||
2059 | if (count) | 2054 | if (count) |
2060 | tty_flip_buffer_push(tty); | 2055 | tty_flip_buffer_push(&port->port); |
2061 | tty_kref_put(tty); | ||
2062 | } | 2056 | } |
2063 | 2057 | ||
2064 | static void ftdi_break_ctl(struct tty_struct *tty, int break_state) | 2058 | static void ftdi_break_ctl(struct tty_struct *tty, int break_state) |
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 498b5f0da639..1a07b12ef341 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
@@ -252,14 +252,11 @@ static inline int isAbortTrfCmnd(const unsigned char *buf) | |||
252 | static void send_to_tty(struct usb_serial_port *port, | 252 | static void send_to_tty(struct usb_serial_port *port, |
253 | char *data, unsigned int actual_length) | 253 | char *data, unsigned int actual_length) |
254 | { | 254 | { |
255 | struct tty_struct *tty = tty_port_tty_get(&port->port); | 255 | if (actual_length) { |
256 | |||
257 | if (tty && actual_length) { | ||
258 | usb_serial_debug_data(&port->dev, __func__, actual_length, data); | 256 | usb_serial_debug_data(&port->dev, __func__, actual_length, data); |
259 | tty_insert_flip_string(&port->port, data, actual_length); | 257 | tty_insert_flip_string(&port->port, data, actual_length); |
260 | tty_flip_buffer_push(tty); | 258 | tty_flip_buffer_push(&port->port); |
261 | } | 259 | } |
262 | tty_kref_put(tty); | ||
263 | } | 260 | } |
264 | 261 | ||
265 | 262 | ||
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 3780f6a501b3..4c5c23f1cae5 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -313,17 +313,12 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_submit_read_urbs); | |||
313 | void usb_serial_generic_process_read_urb(struct urb *urb) | 313 | void usb_serial_generic_process_read_urb(struct urb *urb) |
314 | { | 314 | { |
315 | struct usb_serial_port *port = urb->context; | 315 | struct usb_serial_port *port = urb->context; |
316 | struct tty_struct *tty; | ||
317 | char *ch = (char *)urb->transfer_buffer; | 316 | char *ch = (char *)urb->transfer_buffer; |
318 | int i; | 317 | int i; |
319 | 318 | ||
320 | if (!urb->actual_length) | 319 | if (!urb->actual_length) |
321 | return; | 320 | return; |
322 | 321 | ||
323 | tty = tty_port_tty_get(&port->port); | ||
324 | if (!tty) | ||
325 | return; | ||
326 | |||
327 | /* The per character mucking around with sysrq path it too slow for | 322 | /* The per character mucking around with sysrq path it too slow for |
328 | stuff like 3G modems, so shortcircuit it in the 99.9999999% of cases | 323 | stuff like 3G modems, so shortcircuit it in the 99.9999999% of cases |
329 | where the USB serial is not a console anyway */ | 324 | where the USB serial is not a console anyway */ |
@@ -335,8 +330,7 @@ void usb_serial_generic_process_read_urb(struct urb *urb) | |||
335 | tty_insert_flip_char(&port->port, *ch, TTY_NORMAL); | 330 | tty_insert_flip_char(&port->port, *ch, TTY_NORMAL); |
336 | } | 331 | } |
337 | } | 332 | } |
338 | tty_flip_buffer_push(tty); | 333 | tty_flip_buffer_push(&port->port); |
339 | tty_kref_put(tty); | ||
340 | } | 334 | } |
341 | EXPORT_SYMBOL_GPL(usb_serial_generic_process_read_urb); | 335 | EXPORT_SYMBOL_GPL(usb_serial_generic_process_read_urb); |
342 | 336 | ||
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index f96b91da964f..b00e5cbf741f 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -232,8 +232,8 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, | |||
232 | unsigned char *buffer, __u16 bufferLength); | 232 | unsigned char *buffer, __u16 bufferLength); |
233 | static void process_rcvd_status(struct edgeport_serial *edge_serial, | 233 | static void process_rcvd_status(struct edgeport_serial *edge_serial, |
234 | __u8 byte2, __u8 byte3); | 234 | __u8 byte2, __u8 byte3); |
235 | static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, | 235 | static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, |
236 | unsigned char *data, int length); | 236 | int length); |
237 | static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr); | 237 | static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr); |
238 | static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, | 238 | static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, |
239 | __u8 lsr, __u8 data); | 239 | __u8 lsr, __u8 data); |
@@ -1752,7 +1752,6 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, | |||
1752 | struct device *dev = &edge_serial->serial->dev->dev; | 1752 | struct device *dev = &edge_serial->serial->dev->dev; |
1753 | struct usb_serial_port *port; | 1753 | struct usb_serial_port *port; |
1754 | struct edgeport_port *edge_port; | 1754 | struct edgeport_port *edge_port; |
1755 | struct tty_struct *tty; | ||
1756 | __u16 lastBufferLength; | 1755 | __u16 lastBufferLength; |
1757 | __u16 rxLen; | 1756 | __u16 rxLen; |
1758 | 1757 | ||
@@ -1860,14 +1859,11 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, | |||
1860 | edge_serial->rxPort]; | 1859 | edge_serial->rxPort]; |
1861 | edge_port = usb_get_serial_port_data(port); | 1860 | edge_port = usb_get_serial_port_data(port); |
1862 | if (edge_port->open) { | 1861 | if (edge_port->open) { |
1863 | tty = tty_port_tty_get( | 1862 | dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n", |
1864 | &edge_port->port->port); | 1863 | __func__, rxLen, |
1865 | if (tty) { | 1864 | edge_serial->rxPort); |
1866 | dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n", | 1865 | edge_tty_recv(edge_port->port, buffer, |
1867 | __func__, rxLen, edge_serial->rxPort); | 1866 | rxLen); |
1868 | edge_tty_recv(edge_port->port, tty, buffer, rxLen); | ||
1869 | tty_kref_put(tty); | ||
1870 | } | ||
1871 | edge_port->icount.rx += rxLen; | 1867 | edge_port->icount.rx += rxLen; |
1872 | } | 1868 | } |
1873 | buffer += rxLen; | 1869 | buffer += rxLen; |
@@ -2017,8 +2013,8 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial, | |||
2017 | * edge_tty_recv | 2013 | * edge_tty_recv |
2018 | * this function passes data on to the tty flip buffer | 2014 | * this function passes data on to the tty flip buffer |
2019 | *****************************************************************************/ | 2015 | *****************************************************************************/ |
2020 | static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, | 2016 | static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, |
2021 | unsigned char *data, int length) | 2017 | int length) |
2022 | { | 2018 | { |
2023 | int cnt; | 2019 | int cnt; |
2024 | 2020 | ||
@@ -2030,7 +2026,7 @@ static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, | |||
2030 | data += cnt; | 2026 | data += cnt; |
2031 | length -= cnt; | 2027 | length -= cnt; |
2032 | 2028 | ||
2033 | tty_flip_buffer_push(tty); | 2029 | tty_flip_buffer_push(&port->port); |
2034 | } | 2030 | } |
2035 | 2031 | ||
2036 | 2032 | ||
@@ -2086,14 +2082,9 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, | |||
2086 | } | 2082 | } |
2087 | 2083 | ||
2088 | /* Place LSR data byte into Rx buffer */ | 2084 | /* Place LSR data byte into Rx buffer */ |
2089 | if (lsrData) { | 2085 | if (lsrData) |
2090 | struct tty_struct *tty = | 2086 | edge_tty_recv(edge_port->port, &data, 1); |
2091 | tty_port_tty_get(&edge_port->port->port); | 2087 | |
2092 | if (tty) { | ||
2093 | edge_tty_recv(edge_port->port, tty, &data, 1); | ||
2094 | tty_kref_put(tty); | ||
2095 | } | ||
2096 | } | ||
2097 | /* update input line counters */ | 2088 | /* update input line counters */ |
2098 | icount = &edge_port->icount; | 2089 | icount = &edge_port->icount; |
2099 | if (newLsr & LSR_BREAK) | 2090 | if (newLsr & LSR_BREAK) |
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 1286a0b2e2b7..d6485be49ebf 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -201,8 +201,8 @@ static int closing_wait = EDGE_CLOSING_WAIT; | |||
201 | static bool ignore_cpu_rev; | 201 | static bool ignore_cpu_rev; |
202 | static int default_uart_mode; /* RS232 */ | 202 | static int default_uart_mode; /* RS232 */ |
203 | 203 | ||
204 | static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, | 204 | static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, |
205 | unsigned char *data, int length); | 205 | int length); |
206 | 206 | ||
207 | static void stop_read(struct edgeport_port *edge_port); | 207 | static void stop_read(struct edgeport_port *edge_port); |
208 | static int restart_read(struct edgeport_port *edge_port); | 208 | static int restart_read(struct edgeport_port *edge_port); |
@@ -1540,7 +1540,6 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data, | |||
1540 | struct async_icount *icount; | 1540 | struct async_icount *icount; |
1541 | __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | | 1541 | __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | |
1542 | LSR_FRM_ERR | LSR_BREAK)); | 1542 | LSR_FRM_ERR | LSR_BREAK)); |
1543 | struct tty_struct *tty; | ||
1544 | 1543 | ||
1545 | dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, new_lsr); | 1544 | dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, new_lsr); |
1546 | 1545 | ||
@@ -1554,13 +1553,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data, | |||
1554 | new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); | 1553 | new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); |
1555 | 1554 | ||
1556 | /* Place LSR data byte into Rx buffer */ | 1555 | /* Place LSR data byte into Rx buffer */ |
1557 | if (lsr_data) { | 1556 | if (lsr_data) |
1558 | tty = tty_port_tty_get(&edge_port->port->port); | 1557 | edge_tty_recv(edge_port->port, &data, 1); |
1559 | if (tty) { | ||
1560 | edge_tty_recv(edge_port->port, tty, &data, 1); | ||
1561 | tty_kref_put(tty); | ||
1562 | } | ||
1563 | } | ||
1564 | 1558 | ||
1565 | /* update input line counters */ | 1559 | /* update input line counters */ |
1566 | icount = &edge_port->icount; | 1560 | icount = &edge_port->icount; |
@@ -1676,7 +1670,6 @@ static void edge_bulk_in_callback(struct urb *urb) | |||
1676 | struct edgeport_port *edge_port = urb->context; | 1670 | struct edgeport_port *edge_port = urb->context; |
1677 | struct device *dev = &edge_port->port->dev; | 1671 | struct device *dev = &edge_port->port->dev; |
1678 | unsigned char *data = urb->transfer_buffer; | 1672 | unsigned char *data = urb->transfer_buffer; |
1679 | struct tty_struct *tty; | ||
1680 | int retval = 0; | 1673 | int retval = 0; |
1681 | int port_number; | 1674 | int port_number; |
1682 | int status = urb->status; | 1675 | int status = urb->status; |
@@ -1715,18 +1708,16 @@ static void edge_bulk_in_callback(struct urb *urb) | |||
1715 | ++data; | 1708 | ++data; |
1716 | } | 1709 | } |
1717 | 1710 | ||
1718 | tty = tty_port_tty_get(&edge_port->port->port); | 1711 | if (urb->actual_length) { |
1719 | if (tty && urb->actual_length) { | ||
1720 | usb_serial_debug_data(dev, __func__, urb->actual_length, data); | 1712 | usb_serial_debug_data(dev, __func__, urb->actual_length, data); |
1721 | if (edge_port->close_pending) | 1713 | if (edge_port->close_pending) |
1722 | dev_dbg(dev, "%s - close pending, dropping data on the floor\n", | 1714 | dev_dbg(dev, "%s - close pending, dropping data on the floor\n", |
1723 | __func__); | 1715 | __func__); |
1724 | else | 1716 | else |
1725 | edge_tty_recv(edge_port->port, tty, data, | 1717 | edge_tty_recv(edge_port->port, data, |
1726 | urb->actual_length); | 1718 | urb->actual_length); |
1727 | edge_port->icount.rx += urb->actual_length; | 1719 | edge_port->icount.rx += urb->actual_length; |
1728 | } | 1720 | } |
1729 | tty_kref_put(tty); | ||
1730 | 1721 | ||
1731 | exit: | 1722 | exit: |
1732 | /* continue read unless stopped */ | 1723 | /* continue read unless stopped */ |
@@ -1741,8 +1732,8 @@ exit: | |||
1741 | dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval); | 1732 | dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval); |
1742 | } | 1733 | } |
1743 | 1734 | ||
1744 | static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, | 1735 | static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, |
1745 | unsigned char *data, int length) | 1736 | int length) |
1746 | { | 1737 | { |
1747 | int queued; | 1738 | int queued; |
1748 | 1739 | ||
@@ -1750,7 +1741,7 @@ static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, | |||
1750 | if (queued < length) | 1741 | if (queued < length) |
1751 | dev_err(&port->dev, "%s - dropping data, %d bytes lost\n", | 1742 | dev_err(&port->dev, "%s - dropping data, %d bytes lost\n", |
1752 | __func__, length - queued); | 1743 | __func__, length - queued); |
1753 | tty_flip_buffer_push(tty); | 1744 | tty_flip_buffer_push(&port->port); |
1754 | } | 1745 | } |
1755 | 1746 | ||
1756 | static void edge_bulk_out_callback(struct urb *urb) | 1747 | static void edge_bulk_out_callback(struct urb *urb) |
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 171dae1f4a62..716930ab1bb1 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c | |||
@@ -287,7 +287,6 @@ static void ir_process_read_urb(struct urb *urb) | |||
287 | { | 287 | { |
288 | struct usb_serial_port *port = urb->context; | 288 | struct usb_serial_port *port = urb->context; |
289 | unsigned char *data = urb->transfer_buffer; | 289 | unsigned char *data = urb->transfer_buffer; |
290 | struct tty_struct *tty; | ||
291 | 290 | ||
292 | if (!urb->actual_length) | 291 | if (!urb->actual_length) |
293 | return; | 292 | return; |
@@ -302,12 +301,8 @@ static void ir_process_read_urb(struct urb *urb) | |||
302 | if (urb->actual_length == 1) | 301 | if (urb->actual_length == 1) |
303 | return; | 302 | return; |
304 | 303 | ||
305 | tty = tty_port_tty_get(&port->port); | ||
306 | if (!tty) | ||
307 | return; | ||
308 | tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1); | 304 | tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1); |
309 | tty_flip_buffer_push(tty); | 305 | tty_flip_buffer_push(&port->port); |
310 | tty_kref_put(tty); | ||
311 | } | 306 | } |
312 | 307 | ||
313 | static void ir_set_termios_callback(struct urb *urb) | 308 | static void ir_set_termios_callback(struct urb *urb) |
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index dd0d910730c7..ff77027160aa 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c | |||
@@ -581,7 +581,6 @@ static void read_buf_callback(struct urb *urb) | |||
581 | { | 581 | { |
582 | struct usb_serial_port *port = urb->context; | 582 | struct usb_serial_port *port = urb->context; |
583 | unsigned char *data = urb->transfer_buffer; | 583 | unsigned char *data = urb->transfer_buffer; |
584 | struct tty_struct *tty; | ||
585 | int status = urb->status; | 584 | int status = urb->status; |
586 | 585 | ||
587 | if (status) { | 586 | if (status) { |
@@ -592,14 +591,12 @@ static void read_buf_callback(struct urb *urb) | |||
592 | } | 591 | } |
593 | 592 | ||
594 | dev_dbg(&port->dev, "%s - %i chars to write\n", __func__, urb->actual_length); | 593 | dev_dbg(&port->dev, "%s - %i chars to write\n", __func__, urb->actual_length); |
595 | tty = tty_port_tty_get(&port->port); | ||
596 | if (data == NULL) | 594 | if (data == NULL) |
597 | dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__); | 595 | dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__); |
598 | if (tty && urb->actual_length && data) { | 596 | if (urb->actual_length && data) { |
599 | tty_insert_flip_string(&port->port, data, urb->actual_length); | 597 | tty_insert_flip_string(&port->port, data, urb->actual_length); |
600 | tty_flip_buffer_push(tty); | 598 | tty_flip_buffer_push(&port->port); |
601 | } | 599 | } |
602 | tty_kref_put(tty); | ||
603 | iuu_led_activity_on(urb); | 600 | iuu_led_activity_on(urb); |
604 | } | 601 | } |
605 | 602 | ||
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 14a219ba4ee6..f6d7f68fa43c 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -291,7 +291,6 @@ static void usa26_indat_callback(struct urb *urb) | |||
291 | int i, err; | 291 | int i, err; |
292 | int endpoint; | 292 | int endpoint; |
293 | struct usb_serial_port *port; | 293 | struct usb_serial_port *port; |
294 | struct tty_struct *tty; | ||
295 | unsigned char *data = urb->transfer_buffer; | 294 | unsigned char *data = urb->transfer_buffer; |
296 | int status = urb->status; | 295 | int status = urb->status; |
297 | 296 | ||
@@ -304,8 +303,7 @@ static void usa26_indat_callback(struct urb *urb) | |||
304 | } | 303 | } |
305 | 304 | ||
306 | port = urb->context; | 305 | port = urb->context; |
307 | tty = tty_port_tty_get(&port->port); | 306 | if (urb->actual_length) { |
308 | if (tty && urb->actual_length) { | ||
309 | /* 0x80 bit is error flag */ | 307 | /* 0x80 bit is error flag */ |
310 | if ((data[0] & 0x80) == 0) { | 308 | if ((data[0] & 0x80) == 0) { |
311 | /* no errors on individual bytes, only | 309 | /* no errors on individual bytes, only |
@@ -332,9 +330,8 @@ static void usa26_indat_callback(struct urb *urb) | |||
332 | flag); | 330 | flag); |
333 | } | 331 | } |
334 | } | 332 | } |
335 | tty_flip_buffer_push(tty); | 333 | tty_flip_buffer_push(&port->port); |
336 | } | 334 | } |
337 | tty_kref_put(tty); | ||
338 | 335 | ||
339 | /* Resubmit urb so we continue receiving */ | 336 | /* Resubmit urb so we continue receiving */ |
340 | err = usb_submit_urb(urb, GFP_ATOMIC); | 337 | err = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -447,7 +444,6 @@ static void usa28_indat_callback(struct urb *urb) | |||
447 | { | 444 | { |
448 | int err; | 445 | int err; |
449 | struct usb_serial_port *port; | 446 | struct usb_serial_port *port; |
450 | struct tty_struct *tty; | ||
451 | unsigned char *data; | 447 | unsigned char *data; |
452 | struct keyspan_port_private *p_priv; | 448 | struct keyspan_port_private *p_priv; |
453 | int status = urb->status; | 449 | int status = urb->status; |
@@ -470,13 +466,11 @@ static void usa28_indat_callback(struct urb *urb) | |||
470 | p_priv = usb_get_serial_port_data(port); | 466 | p_priv = usb_get_serial_port_data(port); |
471 | data = urb->transfer_buffer; | 467 | data = urb->transfer_buffer; |
472 | 468 | ||
473 | tty = tty_port_tty_get(&port->port); | 469 | if (urb->actual_length) { |
474 | if (tty && urb->actual_length) { | ||
475 | tty_insert_flip_string(&port->port, data, | 470 | tty_insert_flip_string(&port->port, data, |
476 | urb->actual_length); | 471 | urb->actual_length); |
477 | tty_flip_buffer_push(tty); | 472 | tty_flip_buffer_push(&port->port); |
478 | } | 473 | } |
479 | tty_kref_put(tty); | ||
480 | 474 | ||
481 | /* Resubmit urb so we continue receiving */ | 475 | /* Resubmit urb so we continue receiving */ |
482 | err = usb_submit_urb(urb, GFP_ATOMIC); | 476 | err = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -671,7 +665,6 @@ static void usa49_indat_callback(struct urb *urb) | |||
671 | int i, err; | 665 | int i, err; |
672 | int endpoint; | 666 | int endpoint; |
673 | struct usb_serial_port *port; | 667 | struct usb_serial_port *port; |
674 | struct tty_struct *tty; | ||
675 | unsigned char *data = urb->transfer_buffer; | 668 | unsigned char *data = urb->transfer_buffer; |
676 | int status = urb->status; | 669 | int status = urb->status; |
677 | 670 | ||
@@ -684,8 +677,7 @@ static void usa49_indat_callback(struct urb *urb) | |||
684 | } | 677 | } |
685 | 678 | ||
686 | port = urb->context; | 679 | port = urb->context; |
687 | tty = tty_port_tty_get(&port->port); | 680 | if (urb->actual_length) { |
688 | if (tty && urb->actual_length) { | ||
689 | /* 0x80 bit is error flag */ | 681 | /* 0x80 bit is error flag */ |
690 | if ((data[0] & 0x80) == 0) { | 682 | if ((data[0] & 0x80) == 0) { |
691 | /* no error on any byte */ | 683 | /* no error on any byte */ |
@@ -706,9 +698,8 @@ static void usa49_indat_callback(struct urb *urb) | |||
706 | flag); | 698 | flag); |
707 | } | 699 | } |
708 | } | 700 | } |
709 | tty_flip_buffer_push(tty); | 701 | tty_flip_buffer_push(&port->port); |
710 | } | 702 | } |
711 | tty_kref_put(tty); | ||
712 | 703 | ||
713 | /* Resubmit urb so we continue receiving */ | 704 | /* Resubmit urb so we continue receiving */ |
714 | err = usb_submit_urb(urb, GFP_ATOMIC); | 705 | err = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -721,7 +712,6 @@ static void usa49wg_indat_callback(struct urb *urb) | |||
721 | int i, len, x, err; | 712 | int i, len, x, err; |
722 | struct usb_serial *serial; | 713 | struct usb_serial *serial; |
723 | struct usb_serial_port *port; | 714 | struct usb_serial_port *port; |
724 | struct tty_struct *tty; | ||
725 | unsigned char *data = urb->transfer_buffer; | 715 | unsigned char *data = urb->transfer_buffer; |
726 | int status = urb->status; | 716 | int status = urb->status; |
727 | 717 | ||
@@ -746,7 +736,6 @@ static void usa49wg_indat_callback(struct urb *urb) | |||
746 | return; | 736 | return; |
747 | } | 737 | } |
748 | port = serial->port[data[i++]]; | 738 | port = serial->port[data[i++]]; |
749 | tty = tty_port_tty_get(&port->port); | ||
750 | len = data[i++]; | 739 | len = data[i++]; |
751 | 740 | ||
752 | /* 0x80 bit is error flag */ | 741 | /* 0x80 bit is error flag */ |
@@ -774,8 +763,7 @@ static void usa49wg_indat_callback(struct urb *urb) | |||
774 | i += 2; | 763 | i += 2; |
775 | } | 764 | } |
776 | } | 765 | } |
777 | tty_flip_buffer_push(tty); | 766 | tty_flip_buffer_push(&port->port); |
778 | tty_kref_put(tty); | ||
779 | } | 767 | } |
780 | } | 768 | } |
781 | 769 | ||
@@ -796,7 +784,6 @@ static void usa90_indat_callback(struct urb *urb) | |||
796 | int endpoint; | 784 | int endpoint; |
797 | struct usb_serial_port *port; | 785 | struct usb_serial_port *port; |
798 | struct keyspan_port_private *p_priv; | 786 | struct keyspan_port_private *p_priv; |
799 | struct tty_struct *tty; | ||
800 | unsigned char *data = urb->transfer_buffer; | 787 | unsigned char *data = urb->transfer_buffer; |
801 | int status = urb->status; | 788 | int status = urb->status; |
802 | 789 | ||
@@ -812,7 +799,6 @@ static void usa90_indat_callback(struct urb *urb) | |||
812 | p_priv = usb_get_serial_port_data(port); | 799 | p_priv = usb_get_serial_port_data(port); |
813 | 800 | ||
814 | if (urb->actual_length) { | 801 | if (urb->actual_length) { |
815 | tty = tty_port_tty_get(&port->port); | ||
816 | /* if current mode is DMA, looks like usa28 format | 802 | /* if current mode is DMA, looks like usa28 format |
817 | otherwise looks like usa26 data format */ | 803 | otherwise looks like usa26 data format */ |
818 | 804 | ||
@@ -848,8 +834,7 @@ static void usa90_indat_callback(struct urb *urb) | |||
848 | } | 834 | } |
849 | } | 835 | } |
850 | } | 836 | } |
851 | tty_flip_buffer_push(tty); | 837 | tty_flip_buffer_push(&port->port); |
852 | tty_kref_put(tty); | ||
853 | } | 838 | } |
854 | 839 | ||
855 | /* Resubmit urb so we continue receiving */ | 840 | /* Resubmit urb so we continue receiving */ |
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 334b1a295c6b..3b17d5d13dc8 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -138,7 +138,6 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work) | |||
138 | static void keyspan_pda_rx_interrupt(struct urb *urb) | 138 | static void keyspan_pda_rx_interrupt(struct urb *urb) |
139 | { | 139 | { |
140 | struct usb_serial_port *port = urb->context; | 140 | struct usb_serial_port *port = urb->context; |
141 | struct tty_struct *tty; | ||
142 | unsigned char *data = urb->transfer_buffer; | 141 | unsigned char *data = urb->transfer_buffer; |
143 | int retval; | 142 | int retval; |
144 | int status = urb->status; | 143 | int status = urb->status; |
@@ -163,14 +162,12 @@ static void keyspan_pda_rx_interrupt(struct urb *urb) | |||
163 | /* see if the message is data or a status interrupt */ | 162 | /* see if the message is data or a status interrupt */ |
164 | switch (data[0]) { | 163 | switch (data[0]) { |
165 | case 0: | 164 | case 0: |
166 | tty = tty_port_tty_get(&port->port); | ||
167 | /* rest of message is rx data */ | 165 | /* rest of message is rx data */ |
168 | if (tty && urb->actual_length) { | 166 | if (urb->actual_length) { |
169 | tty_insert_flip_string(&port->port, data + 1, | 167 | tty_insert_flip_string(&port->port, data + 1, |
170 | urb->actual_length - 1); | 168 | urb->actual_length - 1); |
171 | tty_flip_buffer_push(tty); | 169 | tty_flip_buffer_push(&port->port); |
172 | } | 170 | } |
173 | tty_kref_put(tty); | ||
174 | break; | 171 | break; |
175 | case 1: | 172 | case 1: |
176 | /* status interrupt */ | 173 | /* status interrupt */ |
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 8ee0825ad700..769d910ae0a5 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -389,7 +389,6 @@ static void klsi_105_process_read_urb(struct urb *urb) | |||
389 | { | 389 | { |
390 | struct usb_serial_port *port = urb->context; | 390 | struct usb_serial_port *port = urb->context; |
391 | unsigned char *data = urb->transfer_buffer; | 391 | unsigned char *data = urb->transfer_buffer; |
392 | struct tty_struct *tty; | ||
393 | unsigned len; | 392 | unsigned len; |
394 | 393 | ||
395 | /* empty urbs seem to happen, we ignore them */ | 394 | /* empty urbs seem to happen, we ignore them */ |
@@ -401,10 +400,6 @@ static void klsi_105_process_read_urb(struct urb *urb) | |||
401 | return; | 400 | return; |
402 | } | 401 | } |
403 | 402 | ||
404 | tty = tty_port_tty_get(&port->port); | ||
405 | if (!tty) | ||
406 | return; | ||
407 | |||
408 | len = get_unaligned_le16(data); | 403 | len = get_unaligned_le16(data); |
409 | if (len > urb->actual_length - KLSI_HDR_LEN) { | 404 | if (len > urb->actual_length - KLSI_HDR_LEN) { |
410 | dev_dbg(&port->dev, "%s - packet length mismatch\n", __func__); | 405 | dev_dbg(&port->dev, "%s - packet length mismatch\n", __func__); |
@@ -412,8 +407,7 @@ static void klsi_105_process_read_urb(struct urb *urb) | |||
412 | } | 407 | } |
413 | 408 | ||
414 | tty_insert_flip_string(&port->port, data + KLSI_HDR_LEN, len); | 409 | tty_insert_flip_string(&port->port, data + KLSI_HDR_LEN, len); |
415 | tty_flip_buffer_push(tty); | 410 | tty_flip_buffer_push(&port->port); |
416 | tty_kref_put(tty); | ||
417 | } | 411 | } |
418 | 412 | ||
419 | static void klsi_105_set_termios(struct tty_struct *tty, | 413 | static void klsi_105_set_termios(struct tty_struct *tty, |
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 135c8b4b26f7..903d938e174b 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -324,7 +324,6 @@ static void kobil_read_int_callback(struct urb *urb) | |||
324 | { | 324 | { |
325 | int result; | 325 | int result; |
326 | struct usb_serial_port *port = urb->context; | 326 | struct usb_serial_port *port = urb->context; |
327 | struct tty_struct *tty; | ||
328 | unsigned char *data = urb->transfer_buffer; | 327 | unsigned char *data = urb->transfer_buffer; |
329 | int status = urb->status; | 328 | int status = urb->status; |
330 | 329 | ||
@@ -333,8 +332,7 @@ static void kobil_read_int_callback(struct urb *urb) | |||
333 | return; | 332 | return; |
334 | } | 333 | } |
335 | 334 | ||
336 | tty = tty_port_tty_get(&port->port); | 335 | if (urb->actual_length) { |
337 | if (tty && urb->actual_length) { | ||
338 | 336 | ||
339 | /* BEGIN DEBUG */ | 337 | /* BEGIN DEBUG */ |
340 | /* | 338 | /* |
@@ -354,9 +352,8 @@ static void kobil_read_int_callback(struct urb *urb) | |||
354 | /* END DEBUG */ | 352 | /* END DEBUG */ |
355 | 353 | ||
356 | tty_insert_flip_string(&port->port, data, urb->actual_length); | 354 | tty_insert_flip_string(&port->port, data, urb->actual_length); |
357 | tty_flip_buffer_push(tty); | 355 | tty_flip_buffer_push(&port->port); |
358 | } | 356 | } |
359 | tty_kref_put(tty); | ||
360 | 357 | ||
361 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 358 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
362 | dev_dbg(&port->dev, "%s - Send read URB returns: %i\n", __func__, result); | 359 | dev_dbg(&port->dev, "%s - Send read URB returns: %i\n", __func__, result); |
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index ba20bb037b28..f42528e05d7b 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
@@ -531,7 +531,6 @@ static void mct_u232_read_int_callback(struct urb *urb) | |||
531 | { | 531 | { |
532 | struct usb_serial_port *port = urb->context; | 532 | struct usb_serial_port *port = urb->context; |
533 | struct mct_u232_private *priv = usb_get_serial_port_data(port); | 533 | struct mct_u232_private *priv = usb_get_serial_port_data(port); |
534 | struct tty_struct *tty; | ||
535 | unsigned char *data = urb->transfer_buffer; | 534 | unsigned char *data = urb->transfer_buffer; |
536 | int retval; | 535 | int retval; |
537 | int status = urb->status; | 536 | int status = urb->status; |
@@ -561,13 +560,9 @@ static void mct_u232_read_int_callback(struct urb *urb) | |||
561 | */ | 560 | */ |
562 | if (urb->transfer_buffer_length > 2) { | 561 | if (urb->transfer_buffer_length > 2) { |
563 | if (urb->actual_length) { | 562 | if (urb->actual_length) { |
564 | tty = tty_port_tty_get(&port->port); | 563 | tty_insert_flip_string(&port->port, data, |
565 | if (tty) { | 564 | urb->actual_length); |
566 | tty_insert_flip_string(&port->port, data, | 565 | tty_flip_buffer_push(&port->port); |
567 | urb->actual_length); | ||
568 | tty_flip_buffer_push(tty); | ||
569 | } | ||
570 | tty_kref_put(tty); | ||
571 | } | 566 | } |
572 | goto exit; | 567 | goto exit; |
573 | } | 568 | } |
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c index 6264f3974ea7..bf3c7a23553e 100644 --- a/drivers/usb/serial/metro-usb.c +++ b/drivers/usb/serial/metro-usb.c | |||
@@ -95,7 +95,6 @@ static void metrousb_read_int_callback(struct urb *urb) | |||
95 | { | 95 | { |
96 | struct usb_serial_port *port = urb->context; | 96 | struct usb_serial_port *port = urb->context; |
97 | struct metrousb_private *metro_priv = usb_get_serial_port_data(port); | 97 | struct metrousb_private *metro_priv = usb_get_serial_port_data(port); |
98 | struct tty_struct *tty; | ||
99 | unsigned char *data = urb->transfer_buffer; | 98 | unsigned char *data = urb->transfer_buffer; |
100 | int throttled = 0; | 99 | int throttled = 0; |
101 | int result = 0; | 100 | int result = 0; |
@@ -124,15 +123,13 @@ static void metrousb_read_int_callback(struct urb *urb) | |||
124 | 123 | ||
125 | 124 | ||
126 | /* Set the data read from the usb port into the serial port buffer. */ | 125 | /* Set the data read from the usb port into the serial port buffer. */ |
127 | tty = tty_port_tty_get(&port->port); | 126 | if (urb->actual_length) { |
128 | if (tty && urb->actual_length) { | ||
129 | /* Loop through the data copying each byte to the tty layer. */ | 127 | /* Loop through the data copying each byte to the tty layer. */ |
130 | tty_insert_flip_string(&port->port, data, urb->actual_length); | 128 | tty_insert_flip_string(&port->port, data, urb->actual_length); |
131 | 129 | ||
132 | /* Force the data to the tty layer. */ | 130 | /* Force the data to the tty layer. */ |
133 | tty_flip_buffer_push(tty); | 131 | tty_flip_buffer_push(&port->port); |
134 | } | 132 | } |
135 | tty_kref_put(tty); | ||
136 | 133 | ||
137 | /* Set any port variables. */ | 134 | /* Set any port variables. */ |
138 | spin_lock_irqsave(&metro_priv->lock, flags); | 135 | spin_lock_irqsave(&metro_priv->lock, flags); |
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 22818fb765e0..e0ebec3b5d6a 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -899,7 +899,6 @@ static void mos7720_bulk_in_callback(struct urb *urb) | |||
899 | int retval; | 899 | int retval; |
900 | unsigned char *data ; | 900 | unsigned char *data ; |
901 | struct usb_serial_port *port; | 901 | struct usb_serial_port *port; |
902 | struct tty_struct *tty; | ||
903 | int status = urb->status; | 902 | int status = urb->status; |
904 | 903 | ||
905 | if (status) { | 904 | if (status) { |
@@ -913,12 +912,10 @@ static void mos7720_bulk_in_callback(struct urb *urb) | |||
913 | 912 | ||
914 | data = urb->transfer_buffer; | 913 | data = urb->transfer_buffer; |
915 | 914 | ||
916 | tty = tty_port_tty_get(&port->port); | 915 | if (urb->actual_length) { |
917 | if (tty && urb->actual_length) { | ||
918 | tty_insert_flip_string(&port->port, data, urb->actual_length); | 916 | tty_insert_flip_string(&port->port, data, urb->actual_length); |
919 | tty_flip_buffer_push(tty); | 917 | tty_flip_buffer_push(&port->port); |
920 | } | 918 | } |
921 | tty_kref_put(tty); | ||
922 | 919 | ||
923 | if (port->read_urb->status != -EINPROGRESS) { | 920 | if (port->read_urb->status != -EINPROGRESS) { |
924 | retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 921 | retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 3ddd7a1f7ff3..809fb329eca5 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -744,7 +744,6 @@ static void mos7840_bulk_in_callback(struct urb *urb) | |||
744 | struct usb_serial *serial; | 744 | struct usb_serial *serial; |
745 | struct usb_serial_port *port; | 745 | struct usb_serial_port *port; |
746 | struct moschip_port *mos7840_port; | 746 | struct moschip_port *mos7840_port; |
747 | struct tty_struct *tty; | ||
748 | int status = urb->status; | 747 | int status = urb->status; |
749 | 748 | ||
750 | mos7840_port = urb->context; | 749 | mos7840_port = urb->context; |
@@ -774,12 +773,8 @@ static void mos7840_bulk_in_callback(struct urb *urb) | |||
774 | 773 | ||
775 | if (urb->actual_length) { | 774 | if (urb->actual_length) { |
776 | struct tty_port *tport = &mos7840_port->port->port; | 775 | struct tty_port *tport = &mos7840_port->port->port; |
777 | tty = tty_port_tty_get(tport); | 776 | tty_insert_flip_string(tport, data, urb->actual_length); |
778 | if (tty) { | 777 | tty_flip_buffer_push(tport); |
779 | tty_insert_flip_string(tport, data, urb->actual_length); | ||
780 | tty_flip_buffer_push(tty); | ||
781 | tty_kref_put(tty); | ||
782 | } | ||
783 | mos7840_port->icount.rx += urb->actual_length; | 778 | mos7840_port->icount.rx += urb->actual_length; |
784 | smp_wmb(); | 779 | smp_wmb(); |
785 | dev_dbg(&port->dev, "mos7840_port->icount.rx is %d:\n", mos7840_port->icount.rx); | 780 | dev_dbg(&port->dev, "mos7840_port->icount.rx is %d:\n", mos7840_port->icount.rx); |
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c index 0d96a1a7b9e5..38725fc8c2c8 100644 --- a/drivers/usb/serial/navman.c +++ b/drivers/usb/serial/navman.c | |||
@@ -32,7 +32,6 @@ static void navman_read_int_callback(struct urb *urb) | |||
32 | { | 32 | { |
33 | struct usb_serial_port *port = urb->context; | 33 | struct usb_serial_port *port = urb->context; |
34 | unsigned char *data = urb->transfer_buffer; | 34 | unsigned char *data = urb->transfer_buffer; |
35 | struct tty_struct *tty; | ||
36 | int status = urb->status; | 35 | int status = urb->status; |
37 | int result; | 36 | int result; |
38 | 37 | ||
@@ -55,12 +54,10 @@ static void navman_read_int_callback(struct urb *urb) | |||
55 | 54 | ||
56 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); | 55 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); |
57 | 56 | ||
58 | tty = tty_port_tty_get(&port->port); | 57 | if (urb->actual_length) { |
59 | if (tty && urb->actual_length) { | ||
60 | tty_insert_flip_string(&port->port, data, urb->actual_length); | 58 | tty_insert_flip_string(&port->port, data, urb->actual_length); |
61 | tty_flip_buffer_push(tty); | 59 | tty_flip_buffer_push(&port->port); |
62 | } | 60 | } |
63 | tty_kref_put(tty); | ||
64 | 61 | ||
65 | exit: | 62 | exit: |
66 | result = usb_submit_urb(urb, GFP_ATOMIC); | 63 | result = usb_submit_urb(urb, GFP_ATOMIC); |
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 338191bae5a3..1e1cafe287e4 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -174,14 +174,9 @@ static void omninet_read_bulk_callback(struct urb *urb) | |||
174 | } | 174 | } |
175 | 175 | ||
176 | if (urb->actual_length && header->oh_len) { | 176 | if (urb->actual_length && header->oh_len) { |
177 | struct tty_struct *tty = tty_port_tty_get(&port->port); | 177 | tty_insert_flip_string(&port->port, data + OMNINET_DATAOFFSET, |
178 | if (tty) { | 178 | header->oh_len); |
179 | tty_insert_flip_string(&port->port, | 179 | tty_flip_buffer_push(&port->port); |
180 | data + OMNINET_DATAOFFSET, | ||
181 | header->oh_len); | ||
182 | tty_flip_buffer_push(tty); | ||
183 | tty_kref_put(tty); | ||
184 | } | ||
185 | } | 180 | } |
186 | 181 | ||
187 | /* Continue trying to always read */ | 182 | /* Continue trying to always read */ |
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index d3b74e50aff1..e13e1a4d3e1e 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c | |||
@@ -51,15 +51,8 @@ struct opticon_private { | |||
51 | static void opticon_process_data_packet(struct usb_serial_port *port, | 51 | static void opticon_process_data_packet(struct usb_serial_port *port, |
52 | const unsigned char *buf, size_t len) | 52 | const unsigned char *buf, size_t len) |
53 | { | 53 | { |
54 | struct tty_struct *tty; | ||
55 | |||
56 | tty = tty_port_tty_get(&port->port); | ||
57 | if (!tty) | ||
58 | return; | ||
59 | |||
60 | tty_insert_flip_string(&port->port, buf, len); | 54 | tty_insert_flip_string(&port->port, buf, len); |
61 | tty_flip_buffer_push(tty); | 55 | tty_flip_buffer_push(&port->port); |
62 | tty_kref_put(tty); | ||
63 | } | 56 | } |
64 | 57 | ||
65 | static void opticon_process_status_packet(struct usb_serial_port *port, | 58 | static void opticon_process_status_packet(struct usb_serial_port *port, |
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index 7a53fe9f3af3..a958fd41b5b3 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c | |||
@@ -820,7 +820,6 @@ static void oti6858_read_bulk_callback(struct urb *urb) | |||
820 | { | 820 | { |
821 | struct usb_serial_port *port = urb->context; | 821 | struct usb_serial_port *port = urb->context; |
822 | struct oti6858_private *priv = usb_get_serial_port_data(port); | 822 | struct oti6858_private *priv = usb_get_serial_port_data(port); |
823 | struct tty_struct *tty; | ||
824 | unsigned char *data = urb->transfer_buffer; | 823 | unsigned char *data = urb->transfer_buffer; |
825 | unsigned long flags; | 824 | unsigned long flags; |
826 | int status = urb->status; | 825 | int status = urb->status; |
@@ -835,12 +834,10 @@ static void oti6858_read_bulk_callback(struct urb *urb) | |||
835 | return; | 834 | return; |
836 | } | 835 | } |
837 | 836 | ||
838 | tty = tty_port_tty_get(&port->port); | 837 | if (urb->actual_length > 0) { |
839 | if (tty != NULL && urb->actual_length > 0) { | ||
840 | tty_insert_flip_string(&port->port, data, urb->actual_length); | 838 | tty_insert_flip_string(&port->port, data, urb->actual_length); |
841 | tty_flip_buffer_push(tty); | 839 | tty_flip_buffer_push(&port->port); |
842 | } | 840 | } |
843 | tty_kref_put(tty); | ||
844 | 841 | ||
845 | /* schedule the interrupt urb */ | 842 | /* schedule the interrupt urb */ |
846 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 843 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 00047f3c7293..54adc9125e5c 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -772,7 +772,6 @@ static void pl2303_process_read_urb(struct urb *urb) | |||
772 | { | 772 | { |
773 | struct usb_serial_port *port = urb->context; | 773 | struct usb_serial_port *port = urb->context; |
774 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 774 | struct pl2303_private *priv = usb_get_serial_port_data(port); |
775 | struct tty_struct *tty; | ||
776 | unsigned char *data = urb->transfer_buffer; | 775 | unsigned char *data = urb->transfer_buffer; |
777 | char tty_flag = TTY_NORMAL; | 776 | char tty_flag = TTY_NORMAL; |
778 | unsigned long flags; | 777 | unsigned long flags; |
@@ -789,10 +788,6 @@ static void pl2303_process_read_urb(struct urb *urb) | |||
789 | if (!urb->actual_length) | 788 | if (!urb->actual_length) |
790 | return; | 789 | return; |
791 | 790 | ||
792 | tty = tty_port_tty_get(&port->port); | ||
793 | if (!tty) | ||
794 | return; | ||
795 | |||
796 | /* break takes precedence over parity, */ | 791 | /* break takes precedence over parity, */ |
797 | /* which takes precedence over framing errors */ | 792 | /* which takes precedence over framing errors */ |
798 | if (line_status & UART_BREAK_ERROR) | 793 | if (line_status & UART_BREAK_ERROR) |
@@ -817,8 +812,7 @@ static void pl2303_process_read_urb(struct urb *urb) | |||
817 | urb->actual_length); | 812 | urb->actual_length); |
818 | } | 813 | } |
819 | 814 | ||
820 | tty_flip_buffer_push(tty); | 815 | tty_flip_buffer_push(&port->port); |
821 | tty_kref_put(tty); | ||
822 | } | 816 | } |
823 | 817 | ||
824 | /* All of the device info needed for the PL2303 SIO serial converter */ | 818 | /* All of the device info needed for the PL2303 SIO serial converter */ |
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index 5dccc4f957df..6850745808c3 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c | |||
@@ -609,7 +609,6 @@ void qt2_process_read_urb(struct urb *urb) | |||
609 | struct qt2_serial_private *serial_priv; | 609 | struct qt2_serial_private *serial_priv; |
610 | struct usb_serial_port *port; | 610 | struct usb_serial_port *port; |
611 | struct qt2_port_private *port_priv; | 611 | struct qt2_port_private *port_priv; |
612 | struct tty_struct *tty; | ||
613 | bool escapeflag; | 612 | bool escapeflag; |
614 | unsigned char *ch; | 613 | unsigned char *ch; |
615 | int i; | 614 | int i; |
@@ -620,15 +619,11 @@ void qt2_process_read_urb(struct urb *urb) | |||
620 | return; | 619 | return; |
621 | 620 | ||
622 | ch = urb->transfer_buffer; | 621 | ch = urb->transfer_buffer; |
623 | tty = NULL; | ||
624 | serial = urb->context; | 622 | serial = urb->context; |
625 | serial_priv = usb_get_serial_data(serial); | 623 | serial_priv = usb_get_serial_data(serial); |
626 | port = serial->port[serial_priv->current_port]; | 624 | port = serial->port[serial_priv->current_port]; |
627 | port_priv = usb_get_serial_port_data(port); | 625 | port_priv = usb_get_serial_port_data(port); |
628 | 626 | ||
629 | if (port_priv->is_open) | ||
630 | tty = tty_port_tty_get(&port->port); | ||
631 | |||
632 | for (i = 0; i < urb->actual_length; i++) { | 627 | for (i = 0; i < urb->actual_length; i++) { |
633 | ch = (unsigned char *)urb->transfer_buffer + i; | 628 | ch = (unsigned char *)urb->transfer_buffer + i; |
634 | if ((i <= (len - 3)) && | 629 | if ((i <= (len - 3)) && |
@@ -666,10 +661,7 @@ void qt2_process_read_urb(struct urb *urb) | |||
666 | __func__); | 661 | __func__); |
667 | break; | 662 | break; |
668 | } | 663 | } |
669 | if (tty) { | 664 | tty_flip_buffer_push(&port->port); |
670 | tty_flip_buffer_push(tty); | ||
671 | tty_kref_put(tty); | ||
672 | } | ||
673 | 665 | ||
674 | newport = *(ch + 3); | 666 | newport = *(ch + 3); |
675 | 667 | ||
@@ -683,10 +675,6 @@ void qt2_process_read_urb(struct urb *urb) | |||
683 | serial_priv->current_port = newport; | 675 | serial_priv->current_port = newport; |
684 | port = serial->port[serial_priv->current_port]; | 676 | port = serial->port[serial_priv->current_port]; |
685 | port_priv = usb_get_serial_port_data(port); | 677 | port_priv = usb_get_serial_port_data(port); |
686 | if (port_priv->is_open) | ||
687 | tty = tty_port_tty_get(&port->port); | ||
688 | else | ||
689 | tty = NULL; | ||
690 | i += 3; | 678 | i += 3; |
691 | escapeflag = true; | 679 | escapeflag = true; |
692 | break; | 680 | break; |
@@ -716,10 +704,7 @@ void qt2_process_read_urb(struct urb *urb) | |||
716 | tty_insert_flip_string(&port->port, ch, 1); | 704 | tty_insert_flip_string(&port->port, ch, 1); |
717 | } | 705 | } |
718 | 706 | ||
719 | if (tty) { | 707 | tty_flip_buffer_push(&port->port); |
720 | tty_flip_buffer_push(tty); | ||
721 | tty_kref_put(tty); | ||
722 | } | ||
723 | } | 708 | } |
724 | 709 | ||
725 | static void qt2_write_bulk_callback(struct urb *urb) | 710 | static void qt2_write_bulk_callback(struct urb *urb) |
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index ad12e9e2c7ee..21cd7bf2a8cc 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c | |||
@@ -207,38 +207,31 @@ static void safe_process_read_urb(struct urb *urb) | |||
207 | unsigned char *data = urb->transfer_buffer; | 207 | unsigned char *data = urb->transfer_buffer; |
208 | unsigned char length = urb->actual_length; | 208 | unsigned char length = urb->actual_length; |
209 | int actual_length; | 209 | int actual_length; |
210 | struct tty_struct *tty; | ||
211 | __u16 fcs; | 210 | __u16 fcs; |
212 | 211 | ||
213 | if (!length) | 212 | if (!length) |
214 | return; | 213 | return; |
215 | 214 | ||
216 | tty = tty_port_tty_get(&port->port); | ||
217 | if (!tty) | ||
218 | return; | ||
219 | |||
220 | if (!safe) | 215 | if (!safe) |
221 | goto out; | 216 | goto out; |
222 | 217 | ||
223 | fcs = fcs_compute10(data, length, CRC10_INITFCS); | 218 | fcs = fcs_compute10(data, length, CRC10_INITFCS); |
224 | if (fcs) { | 219 | if (fcs) { |
225 | dev_err(&port->dev, "%s - bad CRC %x\n", __func__, fcs); | 220 | dev_err(&port->dev, "%s - bad CRC %x\n", __func__, fcs); |
226 | goto err; | 221 | return; |
227 | } | 222 | } |
228 | 223 | ||
229 | actual_length = data[length - 2] >> 2; | 224 | actual_length = data[length - 2] >> 2; |
230 | if (actual_length > (length - 2)) { | 225 | if (actual_length > (length - 2)) { |
231 | dev_err(&port->dev, "%s - inconsistent lengths %d:%d\n", | 226 | dev_err(&port->dev, "%s - inconsistent lengths %d:%d\n", |
232 | __func__, actual_length, length); | 227 | __func__, actual_length, length); |
233 | goto err; | 228 | return; |
234 | } | 229 | } |
235 | dev_info(&urb->dev->dev, "%s - actual: %d\n", __func__, actual_length); | 230 | dev_info(&urb->dev->dev, "%s - actual: %d\n", __func__, actual_length); |
236 | length = actual_length; | 231 | length = actual_length; |
237 | out: | 232 | out: |
238 | tty_insert_flip_string(&port->port, data, length); | 233 | tty_insert_flip_string(&port->port, data, length); |
239 | tty_flip_buffer_push(tty); | 234 | tty_flip_buffer_push(&port->port); |
240 | err: | ||
241 | tty_kref_put(tty); | ||
242 | } | 235 | } |
243 | 236 | ||
244 | static int safe_prepare_write_buffer(struct usb_serial_port *port, | 237 | static int safe_prepare_write_buffer(struct usb_serial_port *port, |
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 64e53fda149b..70aee8d59f23 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -569,7 +569,6 @@ static void sierra_indat_callback(struct urb *urb) | |||
569 | int err; | 569 | int err; |
570 | int endpoint; | 570 | int endpoint; |
571 | struct usb_serial_port *port; | 571 | struct usb_serial_port *port; |
572 | struct tty_struct *tty; | ||
573 | unsigned char *data = urb->transfer_buffer; | 572 | unsigned char *data = urb->transfer_buffer; |
574 | int status = urb->status; | 573 | int status = urb->status; |
575 | 574 | ||
@@ -581,16 +580,12 @@ static void sierra_indat_callback(struct urb *urb) | |||
581 | " endpoint %02x\n", __func__, status, endpoint); | 580 | " endpoint %02x\n", __func__, status, endpoint); |
582 | } else { | 581 | } else { |
583 | if (urb->actual_length) { | 582 | if (urb->actual_length) { |
584 | tty = tty_port_tty_get(&port->port); | 583 | tty_insert_flip_string(&port->port, data, |
585 | if (tty) { | 584 | urb->actual_length); |
586 | tty_insert_flip_string(&port->port, data, | 585 | tty_flip_buffer_push(&port->port); |
587 | urb->actual_length); | 586 | |
588 | tty_flip_buffer_push(tty); | 587 | usb_serial_debug_data(&port->dev, __func__, |
589 | 588 | urb->actual_length, data); | |
590 | tty_kref_put(tty); | ||
591 | usb_serial_debug_data(&port->dev, __func__, | ||
592 | urb->actual_length, data); | ||
593 | } | ||
594 | } else { | 589 | } else { |
595 | dev_dbg(&port->dev, "%s: empty read urb" | 590 | dev_dbg(&port->dev, "%s: empty read urb" |
596 | " received\n", __func__); | 591 | " received\n", __func__); |
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index 04e373152724..91ff8e3bddbd 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c | |||
@@ -462,7 +462,6 @@ static void spcp8x5_process_read_urb(struct urb *urb) | |||
462 | { | 462 | { |
463 | struct usb_serial_port *port = urb->context; | 463 | struct usb_serial_port *port = urb->context; |
464 | struct spcp8x5_private *priv = usb_get_serial_port_data(port); | 464 | struct spcp8x5_private *priv = usb_get_serial_port_data(port); |
465 | struct tty_struct *tty; | ||
466 | unsigned char *data = urb->transfer_buffer; | 465 | unsigned char *data = urb->transfer_buffer; |
467 | unsigned long flags; | 466 | unsigned long flags; |
468 | u8 status; | 467 | u8 status; |
@@ -481,9 +480,6 @@ static void spcp8x5_process_read_urb(struct urb *urb) | |||
481 | if (!urb->actual_length) | 480 | if (!urb->actual_length) |
482 | return; | 481 | return; |
483 | 482 | ||
484 | tty = tty_port_tty_get(&port->port); | ||
485 | if (!tty) | ||
486 | return; | ||
487 | 483 | ||
488 | if (status & UART_STATE_TRANSIENT_MASK) { | 484 | if (status & UART_STATE_TRANSIENT_MASK) { |
489 | /* break takes precedence over parity, which takes precedence | 485 | /* break takes precedence over parity, which takes precedence |
@@ -500,15 +496,19 @@ static void spcp8x5_process_read_urb(struct urb *urb) | |||
500 | if (status & UART_OVERRUN_ERROR) | 496 | if (status & UART_OVERRUN_ERROR) |
501 | tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); | 497 | tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); |
502 | 498 | ||
503 | if (status & UART_DCD) | 499 | if (status & UART_DCD) { |
504 | usb_serial_handle_dcd_change(port, tty, | 500 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
505 | priv->line_status & MSR_STATUS_LINE_DCD); | 501 | if (tty) { |
502 | usb_serial_handle_dcd_change(port, tty, | ||
503 | priv->line_status & MSR_STATUS_LINE_DCD); | ||
504 | tty_kref_put(tty); | ||
505 | } | ||
506 | } | ||
506 | } | 507 | } |
507 | 508 | ||
508 | tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, | 509 | tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, |
509 | urb->actual_length); | 510 | urb->actual_length); |
510 | tty_flip_buffer_push(tty); | 511 | tty_flip_buffer_push(&port->port); |
511 | tty_kref_put(tty); | ||
512 | } | 512 | } |
513 | 513 | ||
514 | static int spcp8x5_wait_modem_info(struct usb_serial_port *port, | 514 | static int spcp8x5_wait_modem_info(struct usb_serial_port *port, |
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index 38713156e957..58bc7e793524 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c | |||
@@ -582,7 +582,7 @@ static void ssu100_update_lsr(struct usb_serial_port *port, u8 lsr, | |||
582 | 582 | ||
583 | } | 583 | } |
584 | 584 | ||
585 | static int ssu100_process_packet(struct urb *urb) | 585 | static void ssu100_process_read_urb(struct urb *urb) |
586 | { | 586 | { |
587 | struct usb_serial_port *port = urb->context; | 587 | struct usb_serial_port *port = urb->context; |
588 | char *packet = (char *)urb->transfer_buffer; | 588 | char *packet = (char *)urb->transfer_buffer; |
@@ -609,7 +609,7 @@ static int ssu100_process_packet(struct urb *urb) | |||
609 | ch = packet; | 609 | ch = packet; |
610 | 610 | ||
611 | if (!len) | 611 | if (!len) |
612 | return 0; /* status only */ | 612 | return; /* status only */ |
613 | 613 | ||
614 | if (port->port.console && port->sysrq) { | 614 | if (port->port.console && port->sysrq) { |
615 | for (i = 0; i < len; i++, ch++) { | 615 | for (i = 0; i < len; i++, ch++) { |
@@ -619,24 +619,7 @@ static int ssu100_process_packet(struct urb *urb) | |||
619 | } else | 619 | } else |
620 | tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); | 620 | tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); |
621 | 621 | ||
622 | return len; | 622 | tty_flip_buffer_push(&port->port); |
623 | } | ||
624 | |||
625 | static void ssu100_process_read_urb(struct urb *urb) | ||
626 | { | ||
627 | struct usb_serial_port *port = urb->context; | ||
628 | struct tty_struct *tty; | ||
629 | int count; | ||
630 | |||
631 | tty = tty_port_tty_get(&port->port); | ||
632 | if (!tty) | ||
633 | return; | ||
634 | |||
635 | count = ssu100_process_packet(urb); | ||
636 | |||
637 | if (count) | ||
638 | tty_flip_buffer_push(tty); | ||
639 | tty_kref_put(tty); | ||
640 | } | 623 | } |
641 | 624 | ||
642 | static struct usb_serial_driver ssu100_device = { | 625 | static struct usb_serial_driver ssu100_device = { |
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c index 2ffa6ae3b5ed..be05e6caf9a3 100644 --- a/drivers/usb/serial/symbolserial.c +++ b/drivers/usb/serial/symbolserial.c | |||
@@ -48,7 +48,6 @@ static void symbol_int_callback(struct urb *urb) | |||
48 | unsigned char *data = urb->transfer_buffer; | 48 | unsigned char *data = urb->transfer_buffer; |
49 | struct usb_serial_port *port = priv->port; | 49 | struct usb_serial_port *port = priv->port; |
50 | int status = urb->status; | 50 | int status = urb->status; |
51 | struct tty_struct *tty; | ||
52 | int result; | 51 | int result; |
53 | int data_length; | 52 | int data_length; |
54 | 53 | ||
@@ -82,13 +81,8 @@ static void symbol_int_callback(struct urb *urb) | |||
82 | * we pretty much just ignore the size and send everything | 81 | * we pretty much just ignore the size and send everything |
83 | * else to the tty layer. | 82 | * else to the tty layer. |
84 | */ | 83 | */ |
85 | tty = tty_port_tty_get(&port->port); | 84 | tty_insert_flip_string(&port->port, &data[1], data_length); |
86 | if (tty) { | 85 | tty_flip_buffer_push(&port->port); |
87 | tty_insert_flip_string(&port->port, &data[1], | ||
88 | data_length); | ||
89 | tty_flip_buffer_push(tty); | ||
90 | tty_kref_put(tty); | ||
91 | } | ||
92 | } else { | 86 | } else { |
93 | dev_dbg(&priv->udev->dev, | 87 | dev_dbg(&priv->udev->dev, |
94 | "Improper amount of data received from the device, " | 88 | "Improper amount of data received from the device, " |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 05077e3c7631..39cb9b807c3c 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -121,8 +121,8 @@ static void ti_interrupt_callback(struct urb *urb); | |||
121 | static void ti_bulk_in_callback(struct urb *urb); | 121 | static void ti_bulk_in_callback(struct urb *urb); |
122 | static void ti_bulk_out_callback(struct urb *urb); | 122 | static void ti_bulk_out_callback(struct urb *urb); |
123 | 123 | ||
124 | static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty, | 124 | static void ti_recv(struct usb_serial_port *port, unsigned char *data, |
125 | unsigned char *data, int length); | 125 | int length); |
126 | static void ti_send(struct ti_port *tport); | 126 | static void ti_send(struct ti_port *tport); |
127 | static int ti_set_mcr(struct ti_port *tport, unsigned int mcr); | 127 | static int ti_set_mcr(struct ti_port *tport, unsigned int mcr); |
128 | static int ti_get_lsr(struct ti_port *tport); | 128 | static int ti_get_lsr(struct ti_port *tport); |
@@ -1118,7 +1118,6 @@ static void ti_bulk_in_callback(struct urb *urb) | |||
1118 | struct device *dev = &urb->dev->dev; | 1118 | struct device *dev = &urb->dev->dev; |
1119 | int status = urb->status; | 1119 | int status = urb->status; |
1120 | int retval = 0; | 1120 | int retval = 0; |
1121 | struct tty_struct *tty; | ||
1122 | 1121 | ||
1123 | switch (status) { | 1122 | switch (status) { |
1124 | case 0: | 1123 | case 0: |
@@ -1145,23 +1144,18 @@ static void ti_bulk_in_callback(struct urb *urb) | |||
1145 | return; | 1144 | return; |
1146 | } | 1145 | } |
1147 | 1146 | ||
1148 | tty = tty_port_tty_get(&port->port); | 1147 | if (urb->actual_length) { |
1149 | if (tty) { | 1148 | usb_serial_debug_data(dev, __func__, urb->actual_length, |
1150 | if (urb->actual_length) { | 1149 | urb->transfer_buffer); |
1151 | usb_serial_debug_data(dev, __func__, urb->actual_length, | ||
1152 | urb->transfer_buffer); | ||
1153 | 1150 | ||
1154 | if (!tport->tp_is_open) | 1151 | if (!tport->tp_is_open) |
1155 | dev_dbg(dev, "%s - port closed, dropping data\n", | 1152 | dev_dbg(dev, "%s - port closed, dropping data\n", |
1156 | __func__); | 1153 | __func__); |
1157 | else | 1154 | else |
1158 | ti_recv(port, tty, urb->transfer_buffer, | 1155 | ti_recv(port, urb->transfer_buffer, urb->actual_length); |
1159 | urb->actual_length); | 1156 | spin_lock(&tport->tp_lock); |
1160 | spin_lock(&tport->tp_lock); | 1157 | tport->tp_icount.rx += urb->actual_length; |
1161 | tport->tp_icount.rx += urb->actual_length; | 1158 | spin_unlock(&tport->tp_lock); |
1162 | spin_unlock(&tport->tp_lock); | ||
1163 | } | ||
1164 | tty_kref_put(tty); | ||
1165 | } | 1159 | } |
1166 | 1160 | ||
1167 | exit: | 1161 | exit: |
@@ -1209,8 +1203,8 @@ static void ti_bulk_out_callback(struct urb *urb) | |||
1209 | } | 1203 | } |
1210 | 1204 | ||
1211 | 1205 | ||
1212 | static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty, | 1206 | static void ti_recv(struct usb_serial_port *port, unsigned char *data, |
1213 | unsigned char *data, int length) | 1207 | int length) |
1214 | { | 1208 | { |
1215 | int cnt; | 1209 | int cnt; |
1216 | 1210 | ||
@@ -1222,11 +1216,10 @@ static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty, | |||
1222 | if (cnt == 0) | 1216 | if (cnt == 0) |
1223 | break; | 1217 | break; |
1224 | } | 1218 | } |
1225 | tty_flip_buffer_push(tty); | 1219 | tty_flip_buffer_push(&port->port); |
1226 | data += cnt; | 1220 | data += cnt; |
1227 | length -= cnt; | 1221 | length -= cnt; |
1228 | } while (length > 0); | 1222 | } while (length > 0); |
1229 | |||
1230 | } | 1223 | } |
1231 | 1224 | ||
1232 | 1225 | ||
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index 293b460030cb..a547c91e3c05 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c | |||
@@ -275,7 +275,6 @@ static void usb_wwan_indat_callback(struct urb *urb) | |||
275 | int err; | 275 | int err; |
276 | int endpoint; | 276 | int endpoint; |
277 | struct usb_serial_port *port; | 277 | struct usb_serial_port *port; |
278 | struct tty_struct *tty; | ||
279 | struct device *dev; | 278 | struct device *dev; |
280 | unsigned char *data = urb->transfer_buffer; | 279 | unsigned char *data = urb->transfer_buffer; |
281 | int status = urb->status; | 280 | int status = urb->status; |
@@ -288,16 +287,12 @@ static void usb_wwan_indat_callback(struct urb *urb) | |||
288 | dev_dbg(dev, "%s: nonzero status: %d on endpoint %02x.\n", | 287 | dev_dbg(dev, "%s: nonzero status: %d on endpoint %02x.\n", |
289 | __func__, status, endpoint); | 288 | __func__, status, endpoint); |
290 | } else { | 289 | } else { |
291 | tty = tty_port_tty_get(&port->port); | 290 | if (urb->actual_length) { |
292 | if (tty) { | 291 | tty_insert_flip_string(&port->port, data, |
293 | if (urb->actual_length) { | 292 | urb->actual_length); |
294 | tty_insert_flip_string(&port->port, data, | 293 | tty_flip_buffer_push(&port->port); |
295 | urb->actual_length); | 294 | } else |
296 | tty_flip_buffer_push(tty); | 295 | dev_dbg(dev, "%s: empty read urb received\n", __func__); |
297 | } else | ||
298 | dev_dbg(dev, "%s: empty read urb received\n", __func__); | ||
299 | tty_kref_put(tty); | ||
300 | } | ||
301 | 296 | ||
302 | /* Resubmit urb so we continue receiving */ | 297 | /* Resubmit urb so we continue receiving */ |
303 | err = usb_submit_urb(urb, GFP_ATOMIC); | 298 | err = usb_submit_urb(urb, GFP_ATOMIC); |
diff --git a/include/linux/tty.h b/include/linux/tty.h index f16a47a13a09..f89acd1ed6d3 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -387,7 +387,6 @@ extern void do_SAK(struct tty_struct *tty); | |||
387 | extern void __do_SAK(struct tty_struct *tty); | 387 | extern void __do_SAK(struct tty_struct *tty); |
388 | extern void disassociate_ctty(int priv); | 388 | extern void disassociate_ctty(int priv); |
389 | extern void no_tty(void); | 389 | extern void no_tty(void); |
390 | extern void tty_flip_buffer_push(struct tty_struct *tty); | ||
391 | extern void tty_flush_to_ldisc(struct tty_struct *tty); | 390 | extern void tty_flush_to_ldisc(struct tty_struct *tty); |
392 | extern void tty_buffer_free_all(struct tty_port *port); | 391 | extern void tty_buffer_free_all(struct tty_port *port); |
393 | extern void tty_buffer_flush(struct tty_struct *tty); | 392 | extern void tty_buffer_flush(struct tty_struct *tty); |
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h index 5cb694aba322..c5572807633a 100644 --- a/include/linux/tty_flip.h +++ b/include/linux/tty_flip.h | |||
@@ -10,6 +10,7 @@ extern int tty_prepare_flip_string(struct tty_port *port, | |||
10 | unsigned char **chars, size_t size); | 10 | unsigned char **chars, size_t size); |
11 | extern int tty_prepare_flip_string_flags(struct tty_port *port, | 11 | extern int tty_prepare_flip_string_flags(struct tty_port *port, |
12 | unsigned char **chars, char **flags, size_t size); | 12 | unsigned char **chars, char **flags, size_t size); |
13 | extern void tty_flip_buffer_push(struct tty_port *port); | ||
13 | void tty_schedule_flip(struct tty_struct *tty); | 14 | void tty_schedule_flip(struct tty_struct *tty); |
14 | 15 | ||
15 | static inline int tty_insert_flip_char(struct tty_port *port, | 16 | static inline int tty_insert_flip_char(struct tty_port *port, |
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index cbec3b642871..b6e44ad6cca6 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c | |||
@@ -541,23 +541,21 @@ int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg) | |||
541 | static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb) | 541 | static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb) |
542 | { | 542 | { |
543 | struct rfcomm_dev *dev = dlc->owner; | 543 | struct rfcomm_dev *dev = dlc->owner; |
544 | struct tty_struct *tty; | ||
545 | 544 | ||
546 | if (!dev) { | 545 | if (!dev) { |
547 | kfree_skb(skb); | 546 | kfree_skb(skb); |
548 | return; | 547 | return; |
549 | } | 548 | } |
550 | 549 | ||
551 | tty = dev->port.tty; | 550 | if (!skb_queue_empty(&dev->pending)) { |
552 | if (!tty || !skb_queue_empty(&dev->pending)) { | ||
553 | skb_queue_tail(&dev->pending, skb); | 551 | skb_queue_tail(&dev->pending, skb); |
554 | return; | 552 | return; |
555 | } | 553 | } |
556 | 554 | ||
557 | BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len); | 555 | BT_DBG("dlc %p len %d", dlc, skb->len); |
558 | 556 | ||
559 | tty_insert_flip_string(&dev->port, skb->data, skb->len); | 557 | tty_insert_flip_string(&dev->port, skb->data, skb->len); |
560 | tty_flip_buffer_push(tty); | 558 | tty_flip_buffer_push(&dev->port); |
561 | 559 | ||
562 | kfree_skb(skb); | 560 | kfree_skb(skb); |
563 | } | 561 | } |
@@ -621,14 +619,10 @@ static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig) | |||
621 | /* ---- TTY functions ---- */ | 619 | /* ---- TTY functions ---- */ |
622 | static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev) | 620 | static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev) |
623 | { | 621 | { |
624 | struct tty_struct *tty = dev->port.tty; | ||
625 | struct sk_buff *skb; | 622 | struct sk_buff *skb; |
626 | int inserted = 0; | 623 | int inserted = 0; |
627 | 624 | ||
628 | if (!tty) | 625 | BT_DBG("dev %p", dev); |
629 | return; | ||
630 | |||
631 | BT_DBG("dev %p tty %p", dev, tty); | ||
632 | 626 | ||
633 | rfcomm_dlc_lock(dev->dlc); | 627 | rfcomm_dlc_lock(dev->dlc); |
634 | 628 | ||
@@ -641,7 +635,7 @@ static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev) | |||
641 | rfcomm_dlc_unlock(dev->dlc); | 635 | rfcomm_dlc_unlock(dev->dlc); |
642 | 636 | ||
643 | if (inserted > 0) | 637 | if (inserted > 0) |
644 | tty_flip_buffer_push(tty); | 638 | tty_flip_buffer_push(&dev->port); |
645 | } | 639 | } |
646 | 640 | ||
647 | static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) | 641 | static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) |
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index 2491f6f53871..9a5fd3c3e530 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c | |||
@@ -1136,14 +1136,14 @@ static int ircomm_tty_data_indication(void *instance, void *sap, | |||
1136 | ircomm_tty_send_initial_parameters(self); | 1136 | ircomm_tty_send_initial_parameters(self); |
1137 | ircomm_tty_link_established(self); | 1137 | ircomm_tty_link_established(self); |
1138 | } | 1138 | } |
1139 | tty_kref_put(tty); | ||
1139 | 1140 | ||
1140 | /* | 1141 | /* |
1141 | * Use flip buffer functions since the code may be called from interrupt | 1142 | * Use flip buffer functions since the code may be called from interrupt |
1142 | * context | 1143 | * context |
1143 | */ | 1144 | */ |
1144 | tty_insert_flip_string(&self->port, skb->data, skb->len); | 1145 | tty_insert_flip_string(&self->port, skb->data, skb->len); |
1145 | tty_flip_buffer_push(tty); | 1146 | tty_flip_buffer_push(&self->port); |
1146 | tty_kref_put(tty); | ||
1147 | 1147 | ||
1148 | /* No need to kfree_skb - see ircomm_ttp_data_indication() */ | 1148 | /* No need to kfree_skb - see ircomm_ttp_data_indication() */ |
1149 | 1149 | ||