aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/tty.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/tty.h')
-rw-r--r--include/linux/tty.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/include/linux/tty.h b/include/linux/tty.h
index f0f43d08d8b8..405a9035fe40 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
198struct tty_port { 206struct 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/*
@@ -439,7 +449,7 @@ extern void initialize_tty_struct(struct tty_struct *tty,
439 struct tty_driver *driver, int idx); 449 struct tty_driver *driver, int idx);
440extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, 450extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx,
441 int first_ok); 451 int first_ok);
442extern void tty_release_dev(struct file *filp); 452extern int tty_release(struct inode *inode, struct file *filp);
443extern int tty_init_termios(struct tty_struct *tty); 453extern int tty_init_termios(struct tty_struct *tty);
444 454
445extern struct tty_struct *tty_pair_get_tty(struct tty_struct *tty); 455extern struct tty_struct *tty_pair_get_tty(struct tty_struct *tty);
@@ -454,6 +464,15 @@ extern int tty_write_lock(struct tty_struct *tty, int ndelay);
454extern void tty_port_init(struct tty_port *port); 464extern void tty_port_init(struct tty_port *port);
455extern int tty_port_alloc_xmit_buf(struct tty_port *port); 465extern int tty_port_alloc_xmit_buf(struct tty_port *port);
456extern void tty_port_free_xmit_buf(struct tty_port *port); 466extern void tty_port_free_xmit_buf(struct tty_port *port);
467extern void tty_port_put(struct tty_port *port);
468
469extern inline struct tty_port *tty_port_get(struct tty_port *port)
470{
471 if (port)
472 kref_get(&port->kref);
473 return port;
474}
475
457extern struct tty_struct *tty_port_tty_get(struct tty_port *port); 476extern struct tty_struct *tty_port_tty_get(struct tty_port *port);
458extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); 477extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty);
459extern int tty_port_carrier_raised(struct tty_port *port); 478extern int tty_port_carrier_raised(struct tty_port *port);
@@ -467,6 +486,8 @@ extern int tty_port_close_start(struct tty_port *port,
467extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty); 486extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty);
468extern void tty_port_close(struct tty_port *port, 487extern void tty_port_close(struct tty_port *port,
469 struct tty_struct *tty, struct file *filp); 488 struct tty_struct *tty, struct file *filp);
489extern int tty_port_open(struct tty_port *port,
490 struct tty_struct *tty, struct file *filp);
470extern inline int tty_port_users(struct tty_port *port) 491extern inline int tty_port_users(struct tty_port *port)
471{ 492{
472 return port->count + port->blocked_open; 493 return port->count + port->blocked_open;