diff options
Diffstat (limited to 'include/linux/tty.h')
-rw-r--r-- | include/linux/tty.h | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/include/linux/tty.h b/include/linux/tty.h index f0f43d08d8b8..4409967db0c4 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -68,6 +68,17 @@ struct tty_buffer { | |||
68 | unsigned long data[0]; | 68 | unsigned long data[0]; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | /* | ||
72 | * We default to dicing tty buffer allocations to this many characters | ||
73 | * in order to avoid multiple page allocations. We know the size of | ||
74 | * tty_buffer itself but it must also be taken into account that the | ||
75 | * the buffer is 256 byte aligned. See tty_buffer_find for the allocation | ||
76 | * logic this must match | ||
77 | */ | ||
78 | |||
79 | #define TTY_BUFFER_PAGE (((PAGE_SIZE - sizeof(struct tty_buffer)) / 2) & ~0xFF) | ||
80 | |||
81 | |||
71 | struct tty_bufhead { | 82 | struct tty_bufhead { |
72 | struct delayed_work work; | 83 | struct delayed_work work; |
73 | spinlock_t lock; | 84 | spinlock_t lock; |
@@ -190,9 +201,17 @@ struct tty_port_operations { | |||
190 | /* Control the DTR line */ | 201 | /* Control the DTR line */ |
191 | void (*dtr_rts)(struct tty_port *port, int raise); | 202 | void (*dtr_rts)(struct tty_port *port, int raise); |
192 | /* Called when the last close completes or a hangup finishes | 203 | /* Called when the last close completes or a hangup finishes |
193 | IFF the port was initialized. Do not use to free resources */ | 204 | IFF the port was initialized. Do not use to free resources. Called |
205 | under the port mutex to serialize against activate/shutdowns */ | ||
194 | void (*shutdown)(struct tty_port *port); | 206 | void (*shutdown)(struct tty_port *port); |
195 | void (*drop)(struct tty_port *port); | 207 | void (*drop)(struct tty_port *port); |
208 | /* Called under the port mutex from tty_port_open, serialized using | ||
209 | the port mutex */ | ||
210 | /* FIXME: long term getting the tty argument *out* of this would be | ||
211 | good for consoles */ | ||
212 | int (*activate)(struct tty_port *port, struct tty_struct *tty); | ||
213 | /* Called on the final put of a port */ | ||
214 | void (*destruct)(struct tty_port *port); | ||
196 | }; | 215 | }; |
197 | 216 | ||
198 | struct tty_port { | 217 | struct tty_port { |
@@ -205,13 +224,16 @@ struct tty_port { | |||
205 | wait_queue_head_t close_wait; /* Close waiters */ | 224 | wait_queue_head_t close_wait; /* Close waiters */ |
206 | wait_queue_head_t delta_msr_wait; /* Modem status change */ | 225 | wait_queue_head_t delta_msr_wait; /* Modem status change */ |
207 | unsigned long flags; /* TTY flags ASY_*/ | 226 | unsigned long flags; /* TTY flags ASY_*/ |
227 | unsigned char console:1; /* port is a console */ | ||
208 | struct mutex mutex; /* Locking */ | 228 | struct mutex mutex; /* Locking */ |
229 | struct mutex buf_mutex; /* Buffer alloc lock */ | ||
209 | unsigned char *xmit_buf; /* Optional buffer */ | 230 | unsigned char *xmit_buf; /* Optional buffer */ |
210 | unsigned int close_delay; /* Close port delay */ | 231 | unsigned int close_delay; /* Close port delay */ |
211 | unsigned int closing_wait; /* Delay for output */ | 232 | unsigned int closing_wait; /* Delay for output */ |
212 | int drain_delay; /* Set to zero if no pure time | 233 | int drain_delay; /* Set to zero if no pure time |
213 | based drain is needed else | 234 | based drain is needed else |
214 | set to size of fifo */ | 235 | set to size of fifo */ |
236 | struct kref kref; /* Ref counter */ | ||
215 | }; | 237 | }; |
216 | 238 | ||
217 | /* | 239 | /* |
@@ -340,8 +362,6 @@ extern void tty_write_flush(struct tty_struct *); | |||
340 | 362 | ||
341 | extern struct ktermios tty_std_termios; | 363 | extern struct ktermios tty_std_termios; |
342 | 364 | ||
343 | extern int kmsg_redirect; | ||
344 | |||
345 | extern void console_init(void); | 365 | extern void console_init(void); |
346 | extern int vcs_init(void); | 366 | extern int vcs_init(void); |
347 | 367 | ||
@@ -439,7 +459,7 @@ extern void initialize_tty_struct(struct tty_struct *tty, | |||
439 | struct tty_driver *driver, int idx); | 459 | struct tty_driver *driver, int idx); |
440 | extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, | 460 | extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, |
441 | int first_ok); | 461 | int first_ok); |
442 | extern void tty_release_dev(struct file *filp); | 462 | extern int tty_release(struct inode *inode, struct file *filp); |
443 | extern int tty_init_termios(struct tty_struct *tty); | 463 | extern int tty_init_termios(struct tty_struct *tty); |
444 | 464 | ||
445 | extern struct tty_struct *tty_pair_get_tty(struct tty_struct *tty); | 465 | extern struct tty_struct *tty_pair_get_tty(struct tty_struct *tty); |
@@ -454,6 +474,15 @@ extern int tty_write_lock(struct tty_struct *tty, int ndelay); | |||
454 | extern void tty_port_init(struct tty_port *port); | 474 | extern void tty_port_init(struct tty_port *port); |
455 | extern int tty_port_alloc_xmit_buf(struct tty_port *port); | 475 | extern int tty_port_alloc_xmit_buf(struct tty_port *port); |
456 | extern void tty_port_free_xmit_buf(struct tty_port *port); | 476 | extern void tty_port_free_xmit_buf(struct tty_port *port); |
477 | extern void tty_port_put(struct tty_port *port); | ||
478 | |||
479 | static inline struct tty_port *tty_port_get(struct tty_port *port) | ||
480 | { | ||
481 | if (port) | ||
482 | kref_get(&port->kref); | ||
483 | return port; | ||
484 | } | ||
485 | |||
457 | extern struct tty_struct *tty_port_tty_get(struct tty_port *port); | 486 | extern struct tty_struct *tty_port_tty_get(struct tty_port *port); |
458 | extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); | 487 | extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); |
459 | extern int tty_port_carrier_raised(struct tty_port *port); | 488 | extern int tty_port_carrier_raised(struct tty_port *port); |
@@ -467,7 +496,9 @@ extern int tty_port_close_start(struct tty_port *port, | |||
467 | extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty); | 496 | extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty); |
468 | extern void tty_port_close(struct tty_port *port, | 497 | extern void tty_port_close(struct tty_port *port, |
469 | struct tty_struct *tty, struct file *filp); | 498 | struct tty_struct *tty, struct file *filp); |
470 | extern inline int tty_port_users(struct tty_port *port) | 499 | extern int tty_port_open(struct tty_port *port, |
500 | struct tty_struct *tty, struct file *filp); | ||
501 | static inline int tty_port_users(struct tty_port *port) | ||
471 | { | 502 | { |
472 | return port->count + port->blocked_open; | 503 | return port->count + port->blocked_open; |
473 | } | 504 | } |
@@ -485,6 +516,7 @@ extern void tty_ldisc_enable(struct tty_struct *tty); | |||
485 | 516 | ||
486 | /* n_tty.c */ | 517 | /* n_tty.c */ |
487 | extern struct tty_ldisc_ops tty_ldisc_N_TTY; | 518 | extern struct tty_ldisc_ops tty_ldisc_N_TTY; |
519 | extern void n_tty_inherit_ops(struct tty_ldisc_ops *ops); | ||
488 | 520 | ||
489 | /* tty_audit.c */ | 521 | /* tty_audit.c */ |
490 | #ifdef CONFIG_AUDIT | 522 | #ifdef CONFIG_AUDIT |