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 /arch | |
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/ia64/hp/sim/simserial.c | 18 | ||||
-rw-r--r-- | arch/mn10300/kernel/mn10300-serial.c | 7 | ||||
-rw-r--r-- | arch/parisc/kernel/pdc_cons.c | 8 | ||||
-rw-r--r-- | arch/um/drivers/chan.h | 3 | ||||
-rw-r--r-- | arch/um/drivers/chan_kern.c | 14 | ||||
-rw-r--r-- | arch/um/drivers/line.c | 7 | ||||
-rw-r--r-- | arch/xtensa/platforms/iss/console.c | 9 |
7 files changed, 23 insertions, 43 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); |