diff options
author | Alan Cox <alan@redhat.com> | 2009-01-02 08:49:21 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-02 13:19:42 -0500 |
commit | f751928e0ddf54ea4fe5546f35e99efc5b5d9938 (patch) | |
tree | a8198e420a70408dc58cabb54e10f67e0c1c0ebf /include/linux/serial_core.h | |
parent | 6ef53066ff7991d5f9670340e92d42ee1776bbe4 (diff) |
tty: We want the port object to be persistent
Move the tty_port and uart_info bits around a little. By embedding the uart_info
into the uart_port we get rid of lots of corner case testing and also get the
ability to go port<->state<->info which is a bit more elegant than the current
data structures.
Downsides - we allocate a tiny bit more memory for unused ports, upside we've
removed as much code as it saved for most users..
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/serial_core.h')
-rw-r--r-- | include/linux/serial_core.h | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index feb3b939ec4b..2395969faa04 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h | |||
@@ -316,35 +316,13 @@ struct uart_port { | |||
316 | }; | 316 | }; |
317 | 317 | ||
318 | /* | 318 | /* |
319 | * This is the state information which is persistent across opens. | ||
320 | * The low level driver must not to touch any elements contained | ||
321 | * within. | ||
322 | */ | ||
323 | struct uart_state { | ||
324 | unsigned int close_delay; /* msec */ | ||
325 | unsigned int closing_wait; /* msec */ | ||
326 | |||
327 | #define USF_CLOSING_WAIT_INF (0) | ||
328 | #define USF_CLOSING_WAIT_NONE (~0U) | ||
329 | |||
330 | int count; | ||
331 | int pm_state; | ||
332 | struct uart_info *info; | ||
333 | struct uart_port *port; | ||
334 | |||
335 | struct mutex mutex; | ||
336 | }; | ||
337 | |||
338 | #define UART_XMIT_SIZE PAGE_SIZE | ||
339 | |||
340 | typedef unsigned int __bitwise__ uif_t; | ||
341 | |||
342 | /* | ||
343 | * This is the state information which is only valid when the port | 319 | * This is the state information which is only valid when the port |
344 | * is open; it may be freed by the core driver once the device has | 320 | * is open; it may be cleared the core driver once the device has |
345 | * been closed. Either the low level driver or the core can modify | 321 | * been closed. Either the low level driver or the core can modify |
346 | * stuff here. | 322 | * stuff here. |
347 | */ | 323 | */ |
324 | typedef unsigned int __bitwise__ uif_t; | ||
325 | |||
348 | struct uart_info { | 326 | struct uart_info { |
349 | struct tty_port port; | 327 | struct tty_port port; |
350 | struct circ_buf xmit; | 328 | struct circ_buf xmit; |
@@ -366,6 +344,29 @@ struct uart_info { | |||
366 | wait_queue_head_t delta_msr_wait; | 344 | wait_queue_head_t delta_msr_wait; |
367 | }; | 345 | }; |
368 | 346 | ||
347 | /* | ||
348 | * This is the state information which is persistent across opens. | ||
349 | * The low level driver must not to touch any elements contained | ||
350 | * within. | ||
351 | */ | ||
352 | struct uart_state { | ||
353 | unsigned int close_delay; /* msec */ | ||
354 | unsigned int closing_wait; /* msec */ | ||
355 | |||
356 | #define USF_CLOSING_WAIT_INF (0) | ||
357 | #define USF_CLOSING_WAIT_NONE (~0U) | ||
358 | |||
359 | int count; | ||
360 | int pm_state; | ||
361 | struct uart_info info; | ||
362 | struct uart_port *port; | ||
363 | |||
364 | struct mutex mutex; | ||
365 | }; | ||
366 | |||
367 | #define UART_XMIT_SIZE PAGE_SIZE | ||
368 | |||
369 | |||
369 | /* number of characters left in xmit buffer before we ask for more */ | 370 | /* number of characters left in xmit buffer before we ask for more */ |
370 | #define WAKEUP_CHARS 256 | 371 | #define WAKEUP_CHARS 256 |
371 | 372 | ||
@@ -439,8 +440,13 @@ int uart_resume_port(struct uart_driver *reg, struct uart_port *port); | |||
439 | #define uart_circ_chars_free(circ) \ | 440 | #define uart_circ_chars_free(circ) \ |
440 | (CIRC_SPACE((circ)->head, (circ)->tail, UART_XMIT_SIZE)) | 441 | (CIRC_SPACE((circ)->head, (circ)->tail, UART_XMIT_SIZE)) |
441 | 442 | ||
442 | #define uart_tx_stopped(portp) \ | 443 | static inline int uart_tx_stopped(struct uart_port *port) |
443 | ((portp)->info->port.tty->stopped || (portp)->info->port.tty->hw_stopped) | 444 | { |
445 | struct tty_struct *tty = port->info->port.tty; | ||
446 | if(tty->stopped || tty->hw_stopped) | ||
447 | return 1; | ||
448 | return 0; | ||
449 | } | ||
444 | 450 | ||
445 | /* | 451 | /* |
446 | * The following are helper functions for the low level drivers. | 452 | * The following are helper functions for the low level drivers. |
@@ -451,7 +457,7 @@ uart_handle_sysrq_char(struct uart_port *port, unsigned int ch) | |||
451 | #ifdef SUPPORT_SYSRQ | 457 | #ifdef SUPPORT_SYSRQ |
452 | if (port->sysrq) { | 458 | if (port->sysrq) { |
453 | if (ch && time_before(jiffies, port->sysrq)) { | 459 | if (ch && time_before(jiffies, port->sysrq)) { |
454 | handle_sysrq(ch, port->info ? port->info->port.tty : NULL); | 460 | handle_sysrq(ch, port->info->port.tty); |
455 | port->sysrq = 0; | 461 | port->sysrq = 0; |
456 | return 1; | 462 | return 1; |
457 | } | 463 | } |