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.h42
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
71struct tty_bufhead { 82struct 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
198struct tty_port { 217struct 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
341extern struct ktermios tty_std_termios; 363extern struct ktermios tty_std_termios;
342 364
343extern int kmsg_redirect;
344
345extern void console_init(void); 365extern void console_init(void);
346extern int vcs_init(void); 366extern 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);
440extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, 460extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx,
441 int first_ok); 461 int first_ok);
442extern void tty_release_dev(struct file *filp); 462extern int tty_release(struct inode *inode, struct file *filp);
443extern int tty_init_termios(struct tty_struct *tty); 463extern int tty_init_termios(struct tty_struct *tty);
444 464
445extern struct tty_struct *tty_pair_get_tty(struct tty_struct *tty); 465extern 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);
454extern void tty_port_init(struct tty_port *port); 474extern void tty_port_init(struct tty_port *port);
455extern int tty_port_alloc_xmit_buf(struct tty_port *port); 475extern int tty_port_alloc_xmit_buf(struct tty_port *port);
456extern void tty_port_free_xmit_buf(struct tty_port *port); 476extern void tty_port_free_xmit_buf(struct tty_port *port);
477extern void tty_port_put(struct tty_port *port);
478
479static 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
457extern struct tty_struct *tty_port_tty_get(struct tty_port *port); 486extern 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); 487extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty);
459extern int tty_port_carrier_raised(struct tty_port *port); 488extern int tty_port_carrier_raised(struct tty_port *port);
@@ -467,7 +496,9 @@ extern int tty_port_close_start(struct tty_port *port,
467extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty); 496extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty);
468extern void tty_port_close(struct tty_port *port, 497extern void tty_port_close(struct tty_port *port,
469 struct tty_struct *tty, struct file *filp); 498 struct tty_struct *tty, struct file *filp);
470extern inline int tty_port_users(struct tty_port *port) 499extern int tty_port_open(struct tty_port *port,
500 struct tty_struct *tty, struct file *filp);
501static 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 */
487extern struct tty_ldisc_ops tty_ldisc_N_TTY; 518extern struct tty_ldisc_ops tty_ldisc_N_TTY;
519extern 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