diff options
Diffstat (limited to 'include/linux/tty.h')
-rw-r--r-- | include/linux/tty.h | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/include/linux/tty.h b/include/linux/tty.h index f0f43d08d8b8..6abfcf5b5887 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -190,9 +190,17 @@ struct tty_port_operations { | |||
190 | /* Control the DTR line */ | 190 | /* Control the DTR line */ |
191 | void (*dtr_rts)(struct tty_port *port, int raise); | 191 | void (*dtr_rts)(struct tty_port *port, int raise); |
192 | /* Called when the last close completes or a hangup finishes | 192 | /* Called when the last close completes or a hangup finishes |
193 | IFF the port was initialized. Do not use to free resources */ | 193 | IFF the port was initialized. Do not use to free resources. Called |
194 | under the port mutex to serialize against activate/shutdowns */ | ||
194 | void (*shutdown)(struct tty_port *port); | 195 | void (*shutdown)(struct tty_port *port); |
195 | void (*drop)(struct tty_port *port); | 196 | void (*drop)(struct tty_port *port); |
197 | /* Called under the port mutex from tty_port_open, serialized using | ||
198 | the port mutex */ | ||
199 | /* FIXME: long term getting the tty argument *out* of this would be | ||
200 | good for consoles */ | ||
201 | int (*activate)(struct tty_port *port, struct tty_struct *tty); | ||
202 | /* Called on the final put of a port */ | ||
203 | void (*destruct)(struct tty_port *port); | ||
196 | }; | 204 | }; |
197 | 205 | ||
198 | struct tty_port { | 206 | struct tty_port { |
@@ -206,12 +214,14 @@ struct tty_port { | |||
206 | wait_queue_head_t delta_msr_wait; /* Modem status change */ | 214 | wait_queue_head_t delta_msr_wait; /* Modem status change */ |
207 | unsigned long flags; /* TTY flags ASY_*/ | 215 | unsigned long flags; /* TTY flags ASY_*/ |
208 | struct mutex mutex; /* Locking */ | 216 | struct mutex mutex; /* Locking */ |
217 | struct mutex buf_mutex; /* Buffer alloc lock */ | ||
209 | unsigned char *xmit_buf; /* Optional buffer */ | 218 | unsigned char *xmit_buf; /* Optional buffer */ |
210 | unsigned int close_delay; /* Close port delay */ | 219 | unsigned int close_delay; /* Close port delay */ |
211 | unsigned int closing_wait; /* Delay for output */ | 220 | unsigned int closing_wait; /* Delay for output */ |
212 | int drain_delay; /* Set to zero if no pure time | 221 | int drain_delay; /* Set to zero if no pure time |
213 | based drain is needed else | 222 | based drain is needed else |
214 | set to size of fifo */ | 223 | set to size of fifo */ |
224 | struct kref kref; /* Ref counter */ | ||
215 | }; | 225 | }; |
216 | 226 | ||
217 | /* | 227 | /* |
@@ -340,8 +350,6 @@ extern void tty_write_flush(struct tty_struct *); | |||
340 | 350 | ||
341 | extern struct ktermios tty_std_termios; | 351 | extern struct ktermios tty_std_termios; |
342 | 352 | ||
343 | extern int kmsg_redirect; | ||
344 | |||
345 | extern void console_init(void); | 353 | extern void console_init(void); |
346 | extern int vcs_init(void); | 354 | extern int vcs_init(void); |
347 | 355 | ||
@@ -439,7 +447,7 @@ extern void initialize_tty_struct(struct tty_struct *tty, | |||
439 | struct tty_driver *driver, int idx); | 447 | struct tty_driver *driver, int idx); |
440 | extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, | 448 | extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, |
441 | int first_ok); | 449 | int first_ok); |
442 | extern void tty_release_dev(struct file *filp); | 450 | extern int tty_release(struct inode *inode, struct file *filp); |
443 | extern int tty_init_termios(struct tty_struct *tty); | 451 | extern int tty_init_termios(struct tty_struct *tty); |
444 | 452 | ||
445 | extern struct tty_struct *tty_pair_get_tty(struct tty_struct *tty); | 453 | extern struct tty_struct *tty_pair_get_tty(struct tty_struct *tty); |
@@ -454,6 +462,15 @@ extern int tty_write_lock(struct tty_struct *tty, int ndelay); | |||
454 | extern void tty_port_init(struct tty_port *port); | 462 | extern void tty_port_init(struct tty_port *port); |
455 | extern int tty_port_alloc_xmit_buf(struct tty_port *port); | 463 | extern int tty_port_alloc_xmit_buf(struct tty_port *port); |
456 | extern void tty_port_free_xmit_buf(struct tty_port *port); | 464 | extern void tty_port_free_xmit_buf(struct tty_port *port); |
465 | extern void tty_port_put(struct tty_port *port); | ||
466 | |||
467 | static inline struct tty_port *tty_port_get(struct tty_port *port) | ||
468 | { | ||
469 | if (port) | ||
470 | kref_get(&port->kref); | ||
471 | return port; | ||
472 | } | ||
473 | |||
457 | extern struct tty_struct *tty_port_tty_get(struct tty_port *port); | 474 | 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); | 475 | 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); | 476 | extern int tty_port_carrier_raised(struct tty_port *port); |
@@ -467,7 +484,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); | 484 | extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty); |
468 | extern void tty_port_close(struct tty_port *port, | 485 | extern void tty_port_close(struct tty_port *port, |
469 | struct tty_struct *tty, struct file *filp); | 486 | struct tty_struct *tty, struct file *filp); |
470 | extern inline int tty_port_users(struct tty_port *port) | 487 | extern int tty_port_open(struct tty_port *port, |
488 | struct tty_struct *tty, struct file *filp); | ||
489 | static inline int tty_port_users(struct tty_port *port) | ||
471 | { | 490 | { |
472 | return port->count + port->blocked_open; | 491 | return port->count + port->blocked_open; |
473 | } | 492 | } |