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.h92
1 files changed, 59 insertions, 33 deletions
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 9f47ab540f6..1509b86825d 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -43,6 +43,7 @@
43#include <linux/tty_driver.h> 43#include <linux/tty_driver.h>
44#include <linux/tty_ldisc.h> 44#include <linux/tty_ldisc.h>
45#include <linux/mutex.h> 45#include <linux/mutex.h>
46#include <linux/tty_flags.h>
46 47
47 48
48 49
@@ -103,28 +104,28 @@ struct tty_bufhead {
103#define TTY_PARITY 3 104#define TTY_PARITY 3
104#define TTY_OVERRUN 4 105#define TTY_OVERRUN 4
105 106
106#define INTR_CHAR(tty) ((tty)->termios->c_cc[VINTR]) 107#define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR])
107#define QUIT_CHAR(tty) ((tty)->termios->c_cc[VQUIT]) 108#define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT])
108#define ERASE_CHAR(tty) ((tty)->termios->c_cc[VERASE]) 109#define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE])
109#define KILL_CHAR(tty) ((tty)->termios->c_cc[VKILL]) 110#define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL])
110#define EOF_CHAR(tty) ((tty)->termios->c_cc[VEOF]) 111#define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF])
111#define TIME_CHAR(tty) ((tty)->termios->c_cc[VTIME]) 112#define TIME_CHAR(tty) ((tty)->termios.c_cc[VTIME])
112#define MIN_CHAR(tty) ((tty)->termios->c_cc[VMIN]) 113#define MIN_CHAR(tty) ((tty)->termios.c_cc[VMIN])
113#define SWTC_CHAR(tty) ((tty)->termios->c_cc[VSWTC]) 114#define SWTC_CHAR(tty) ((tty)->termios.c_cc[VSWTC])
114#define START_CHAR(tty) ((tty)->termios->c_cc[VSTART]) 115#define START_CHAR(tty) ((tty)->termios.c_cc[VSTART])
115#define STOP_CHAR(tty) ((tty)->termios->c_cc[VSTOP]) 116#define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP])
116#define SUSP_CHAR(tty) ((tty)->termios->c_cc[VSUSP]) 117#define SUSP_CHAR(tty) ((tty)->termios.c_cc[VSUSP])
117#define EOL_CHAR(tty) ((tty)->termios->c_cc[VEOL]) 118#define EOL_CHAR(tty) ((tty)->termios.c_cc[VEOL])
118#define REPRINT_CHAR(tty) ((tty)->termios->c_cc[VREPRINT]) 119#define REPRINT_CHAR(tty) ((tty)->termios.c_cc[VREPRINT])
119#define DISCARD_CHAR(tty) ((tty)->termios->c_cc[VDISCARD]) 120#define DISCARD_CHAR(tty) ((tty)->termios.c_cc[VDISCARD])
120#define WERASE_CHAR(tty) ((tty)->termios->c_cc[VWERASE]) 121#define WERASE_CHAR(tty) ((tty)->termios.c_cc[VWERASE])
121#define LNEXT_CHAR(tty) ((tty)->termios->c_cc[VLNEXT]) 122#define LNEXT_CHAR(tty) ((tty)->termios.c_cc[VLNEXT])
122#define EOL2_CHAR(tty) ((tty)->termios->c_cc[VEOL2]) 123#define EOL2_CHAR(tty) ((tty)->termios.c_cc[VEOL2])
123 124
124#define _I_FLAG(tty, f) ((tty)->termios->c_iflag & (f)) 125#define _I_FLAG(tty, f) ((tty)->termios.c_iflag & (f))
125#define _O_FLAG(tty, f) ((tty)->termios->c_oflag & (f)) 126#define _O_FLAG(tty, f) ((tty)->termios.c_oflag & (f))
126#define _C_FLAG(tty, f) ((tty)->termios->c_cflag & (f)) 127#define _C_FLAG(tty, f) ((tty)->termios.c_cflag & (f))
127#define _L_FLAG(tty, f) ((tty)->termios->c_lflag & (f)) 128#define _L_FLAG(tty, f) ((tty)->termios.c_lflag & (f))
128 129
129#define I_IGNBRK(tty) _I_FLAG((tty), IGNBRK) 130#define I_IGNBRK(tty) _I_FLAG((tty), IGNBRK)
130#define I_BRKINT(tty) _I_FLAG((tty), BRKINT) 131#define I_BRKINT(tty) _I_FLAG((tty), BRKINT)
@@ -268,10 +269,11 @@ struct tty_struct {
268 struct mutex ldisc_mutex; 269 struct mutex ldisc_mutex;
269 struct tty_ldisc *ldisc; 270 struct tty_ldisc *ldisc;
270 271
272 struct mutex legacy_mutex;
271 struct mutex termios_mutex; 273 struct mutex termios_mutex;
272 spinlock_t ctrl_lock; 274 spinlock_t ctrl_lock;
273 /* Termios values are protected by the termios mutex */ 275 /* Termios values are protected by the termios mutex */
274 struct ktermios *termios, *termios_locked; 276 struct ktermios termios, termios_locked;
275 struct termiox *termiox; /* May be NULL for unsupported */ 277 struct termiox *termiox; /* May be NULL for unsupported */
276 char name[64]; 278 char name[64];
277 struct pid *pgrp; /* Protected by ctrl lock */ 279 struct pid *pgrp; /* Protected by ctrl lock */
@@ -410,6 +412,10 @@ extern int tty_register_driver(struct tty_driver *driver);
410extern int tty_unregister_driver(struct tty_driver *driver); 412extern int tty_unregister_driver(struct tty_driver *driver);
411extern struct device *tty_register_device(struct tty_driver *driver, 413extern struct device *tty_register_device(struct tty_driver *driver,
412 unsigned index, struct device *dev); 414 unsigned index, struct device *dev);
415extern struct device *tty_register_device_attr(struct tty_driver *driver,
416 unsigned index, struct device *device,
417 void *drvdata,
418 const struct attribute_group **attr_grp);
413extern void tty_unregister_device(struct tty_driver *driver, unsigned index); 419extern void tty_unregister_device(struct tty_driver *driver, unsigned index);
414extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, 420extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
415 int buflen); 421 int buflen);
@@ -423,7 +429,6 @@ extern void tty_unthrottle(struct tty_struct *tty);
423extern int tty_do_resize(struct tty_struct *tty, struct winsize *ws); 429extern int tty_do_resize(struct tty_struct *tty, struct winsize *ws);
424extern void tty_driver_remove_tty(struct tty_driver *driver, 430extern void tty_driver_remove_tty(struct tty_driver *driver,
425 struct tty_struct *tty); 431 struct tty_struct *tty);
426extern void tty_shutdown(struct tty_struct *tty);
427extern void tty_free_termios(struct tty_struct *tty); 432extern void tty_free_termios(struct tty_struct *tty);
428extern int is_current_pgrp_orphaned(void); 433extern int is_current_pgrp_orphaned(void);
429extern struct pid *tty_get_pgrp(struct tty_struct *tty); 434extern struct pid *tty_get_pgrp(struct tty_struct *tty);
@@ -497,6 +502,15 @@ extern int tty_write_lock(struct tty_struct *tty, int ndelay);
497#define tty_is_writelocked(tty) (mutex_is_locked(&tty->atomic_write_lock)) 502#define tty_is_writelocked(tty) (mutex_is_locked(&tty->atomic_write_lock))
498 503
499extern void tty_port_init(struct tty_port *port); 504extern void tty_port_init(struct tty_port *port);
505extern void tty_port_link_device(struct tty_port *port,
506 struct tty_driver *driver, unsigned index);
507extern struct device *tty_port_register_device(struct tty_port *port,
508 struct tty_driver *driver, unsigned index,
509 struct device *device);
510extern struct device *tty_port_register_device_attr(struct tty_port *port,
511 struct tty_driver *driver, unsigned index,
512 struct device *device, void *drvdata,
513 const struct attribute_group **attr_grp);
500extern int tty_port_alloc_xmit_buf(struct tty_port *port); 514extern int tty_port_alloc_xmit_buf(struct tty_port *port);
501extern void tty_port_free_xmit_buf(struct tty_port *port); 515extern void tty_port_free_xmit_buf(struct tty_port *port);
502extern void tty_port_put(struct tty_port *port); 516extern void tty_port_put(struct tty_port *port);
@@ -508,6 +522,12 @@ static inline struct tty_port *tty_port_get(struct tty_port *port)
508 return port; 522 return port;
509} 523}
510 524
525/* If the cts flow control is enabled, return true. */
526static inline bool tty_port_cts_enabled(struct tty_port *port)
527{
528 return port->flags & ASYNC_CTS_FLOW;
529}
530
511extern struct tty_struct *tty_port_tty_get(struct tty_port *port); 531extern struct tty_struct *tty_port_tty_get(struct tty_port *port);
512extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); 532extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty);
513extern int tty_port_carrier_raised(struct tty_port *port); 533extern int tty_port_carrier_raised(struct tty_port *port);
@@ -521,6 +541,8 @@ extern int tty_port_close_start(struct tty_port *port,
521extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty); 541extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty);
522extern void tty_port_close(struct tty_port *port, 542extern void tty_port_close(struct tty_port *port,
523 struct tty_struct *tty, struct file *filp); 543 struct tty_struct *tty, struct file *filp);
544extern int tty_port_install(struct tty_port *port, struct tty_driver *driver,
545 struct tty_struct *tty);
524extern int tty_port_open(struct tty_port *port, 546extern int tty_port_open(struct tty_port *port,
525 struct tty_struct *tty, struct file *filp); 547 struct tty_struct *tty, struct file *filp);
526static inline int tty_port_users(struct tty_port *port) 548static inline int tty_port_users(struct tty_port *port)
@@ -605,8 +627,12 @@ extern long vt_compat_ioctl(struct tty_struct *tty,
605 627
606/* tty_mutex.c */ 628/* tty_mutex.c */
607/* functions for preparation of BKL removal */ 629/* functions for preparation of BKL removal */
608extern void __lockfunc tty_lock(void) __acquires(tty_lock); 630extern void __lockfunc tty_lock(struct tty_struct *tty);
609extern void __lockfunc tty_unlock(void) __releases(tty_lock); 631extern void __lockfunc tty_unlock(struct tty_struct *tty);
632extern void __lockfunc tty_lock_pair(struct tty_struct *tty,
633 struct tty_struct *tty2);
634extern void __lockfunc tty_unlock_pair(struct tty_struct *tty,
635 struct tty_struct *tty2);
610 636
611/* 637/*
612 * this shall be called only from where BTM is held (like close) 638 * this shall be called only from where BTM is held (like close)
@@ -621,9 +647,9 @@ extern void __lockfunc tty_unlock(void) __releases(tty_lock);
621static inline void tty_wait_until_sent_from_close(struct tty_struct *tty, 647static inline void tty_wait_until_sent_from_close(struct tty_struct *tty,
622 long timeout) 648 long timeout)
623{ 649{
624 tty_unlock(); /* tty->ops->close holds the BTM, drop it while waiting */ 650 tty_unlock(tty); /* tty->ops->close holds the BTM, drop it while waiting */
625 tty_wait_until_sent(tty, timeout); 651 tty_wait_until_sent(tty, timeout);
626 tty_lock(); 652 tty_lock(tty);
627} 653}
628 654
629/* 655/*
@@ -638,16 +664,16 @@ static inline void tty_wait_until_sent_from_close(struct tty_struct *tty,
638 * 664 *
639 * Do not use in new code. 665 * Do not use in new code.
640 */ 666 */
641#define wait_event_interruptible_tty(wq, condition) \ 667#define wait_event_interruptible_tty(tty, wq, condition) \
642({ \ 668({ \
643 int __ret = 0; \ 669 int __ret = 0; \
644 if (!(condition)) { \ 670 if (!(condition)) { \
645 __wait_event_interruptible_tty(wq, condition, __ret); \ 671 __wait_event_interruptible_tty(tty, wq, condition, __ret); \
646 } \ 672 } \
647 __ret; \ 673 __ret; \
648}) 674})
649 675
650#define __wait_event_interruptible_tty(wq, condition, ret) \ 676#define __wait_event_interruptible_tty(tty, wq, condition, ret) \
651do { \ 677do { \
652 DEFINE_WAIT(__wait); \ 678 DEFINE_WAIT(__wait); \
653 \ 679 \
@@ -656,9 +682,9 @@ do { \
656 if (condition) \ 682 if (condition) \
657 break; \ 683 break; \
658 if (!signal_pending(current)) { \ 684 if (!signal_pending(current)) { \
659 tty_unlock(); \ 685 tty_unlock(tty); \
660 schedule(); \ 686 schedule(); \
661 tty_lock(); \ 687 tty_lock(tty); \
662 continue; \ 688 continue; \
663 } \ 689 } \
664 ret = -ERESTARTSYS; \ 690 ret = -ERESTARTSYS; \