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 /drivers/tty/serial/sc26xx.c | |
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 'drivers/tty/serial/sc26xx.c')
-rw-r--r-- | drivers/tty/serial/sc26xx.c | 27 |
1 files changed, 12 insertions, 15 deletions
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 | } |