diff options
Diffstat (limited to 'include/linux/tty_driver.h')
| -rw-r--r-- | include/linux/tty_driver.h | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 16d27944c321..78416b901589 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h | |||
| @@ -7,6 +7,28 @@ | |||
| 7 | * defined; unless noted otherwise, they are optional, and can be | 7 | * defined; unless noted otherwise, they are optional, and can be |
| 8 | * filled in with a null pointer. | 8 | * filled in with a null pointer. |
| 9 | * | 9 | * |
| 10 | * struct tty_struct * (*lookup)(struct tty_driver *self, int idx) | ||
| 11 | * | ||
| 12 | * Return the tty device corresponding to idx, NULL if there is not | ||
| 13 | * one currently in use and an ERR_PTR value on error. Called under | ||
| 14 | * tty_mutex (for now!) | ||
| 15 | * | ||
| 16 | * Optional method. Default behaviour is to use the ttys array | ||
| 17 | * | ||
| 18 | * int (*install)(struct tty_driver *self, struct tty_struct *tty) | ||
| 19 | * | ||
| 20 | * Install a new tty into the tty driver internal tables. Used in | ||
| 21 | * conjunction with lookup and remove methods. | ||
| 22 | * | ||
| 23 | * Optional method. Default behaviour is to use the ttys array | ||
| 24 | * | ||
| 25 | * void (*remove)(struct tty_driver *self, struct tty_struct *tty) | ||
| 26 | * | ||
| 27 | * Remove a closed tty from the tty driver internal tables. Used in | ||
| 28 | * conjunction with lookup and remove methods. | ||
| 29 | * | ||
| 30 | * Optional method. Default behaviour is to use the ttys array | ||
| 31 | * | ||
| 10 | * int (*open)(struct tty_struct * tty, struct file * filp); | 32 | * int (*open)(struct tty_struct * tty, struct file * filp); |
| 11 | * | 33 | * |
| 12 | * This routine is called when a particular tty device is opened. | 34 | * This routine is called when a particular tty device is opened. |
| @@ -21,6 +43,11 @@ | |||
| 21 | * | 43 | * |
| 22 | * Required method. | 44 | * Required method. |
| 23 | * | 45 | * |
| 46 | * void (*shutdown)(struct tty_struct * tty); | ||
| 47 | * | ||
| 48 | * This routine is called when a particular tty device is closed for | ||
| 49 | * the last time freeing up the resources. | ||
| 50 | * | ||
| 24 | * int (*write)(struct tty_struct * tty, | 51 | * int (*write)(struct tty_struct * tty, |
| 25 | * const unsigned char *buf, int count); | 52 | * const unsigned char *buf, int count); |
| 26 | * | 53 | * |
| @@ -180,6 +207,14 @@ | |||
| 180 | * not force errors here if they are not resizable objects (eg a serial | 207 | * not force errors here if they are not resizable objects (eg a serial |
| 181 | * line). See tty_do_resize() if you need to wrap the standard method | 208 | * line). See tty_do_resize() if you need to wrap the standard method |
| 182 | * in your own logic - the usual case. | 209 | * in your own logic - the usual case. |
| 210 | * | ||
| 211 | * void (*set_termiox)(struct tty_struct *tty, struct termiox *new); | ||
| 212 | * | ||
| 213 | * Called when the device receives a termiox based ioctl. Passes down | ||
| 214 | * the requested data from user space. This method will not be invoked | ||
| 215 | * unless the tty also has a valid tty->termiox pointer. | ||
| 216 | * | ||
| 217 | * Optional: Called under the termios lock | ||
| 183 | */ | 218 | */ |
| 184 | 219 | ||
| 185 | #include <linux/fs.h> | 220 | #include <linux/fs.h> |
| @@ -190,8 +225,13 @@ struct tty_struct; | |||
| 190 | struct tty_driver; | 225 | struct tty_driver; |
| 191 | 226 | ||
| 192 | struct tty_operations { | 227 | struct tty_operations { |
| 228 | struct tty_struct * (*lookup)(struct tty_driver *driver, | ||
| 229 | struct inode *inode, int idx); | ||
| 230 | int (*install)(struct tty_driver *driver, struct tty_struct *tty); | ||
| 231 | void (*remove)(struct tty_driver *driver, struct tty_struct *tty); | ||
| 193 | int (*open)(struct tty_struct * tty, struct file * filp); | 232 | int (*open)(struct tty_struct * tty, struct file * filp); |
| 194 | void (*close)(struct tty_struct * tty, struct file * filp); | 233 | void (*close)(struct tty_struct * tty, struct file * filp); |
| 234 | void (*shutdown)(struct tty_struct *tty); | ||
| 195 | int (*write)(struct tty_struct * tty, | 235 | int (*write)(struct tty_struct * tty, |
| 196 | const unsigned char *buf, int count); | 236 | const unsigned char *buf, int count); |
| 197 | int (*put_char)(struct tty_struct *tty, unsigned char ch); | 237 | int (*put_char)(struct tty_struct *tty, unsigned char ch); |
| @@ -220,6 +260,7 @@ struct tty_operations { | |||
| 220 | unsigned int set, unsigned int clear); | 260 | unsigned int set, unsigned int clear); |
| 221 | int (*resize)(struct tty_struct *tty, struct tty_struct *real_tty, | 261 | int (*resize)(struct tty_struct *tty, struct tty_struct *real_tty, |
| 222 | struct winsize *ws); | 262 | struct winsize *ws); |
| 263 | int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); | ||
| 223 | #ifdef CONFIG_CONSOLE_POLL | 264 | #ifdef CONFIG_CONSOLE_POLL |
| 224 | int (*poll_init)(struct tty_driver *driver, int line, char *options); | 265 | int (*poll_init)(struct tty_driver *driver, int line, char *options); |
| 225 | int (*poll_get_char)(struct tty_driver *driver, int line); | 266 | int (*poll_get_char)(struct tty_driver *driver, int line); |
| @@ -229,6 +270,7 @@ struct tty_operations { | |||
| 229 | 270 | ||
| 230 | struct tty_driver { | 271 | struct tty_driver { |
| 231 | int magic; /* magic number for this structure */ | 272 | int magic; /* magic number for this structure */ |
| 273 | struct kref kref; /* Reference management */ | ||
| 232 | struct cdev cdev; | 274 | struct cdev cdev; |
| 233 | struct module *owner; | 275 | struct module *owner; |
| 234 | const char *driver_name; | 276 | const char *driver_name; |
| @@ -242,7 +284,6 @@ struct tty_driver { | |||
| 242 | short subtype; /* subtype of tty driver */ | 284 | short subtype; /* subtype of tty driver */ |
| 243 | struct ktermios init_termios; /* Initial termios */ | 285 | struct ktermios init_termios; /* Initial termios */ |
| 244 | int flags; /* tty driver flags */ | 286 | int flags; /* tty driver flags */ |
| 245 | int refcount; /* for loadable tty drivers */ | ||
| 246 | struct proc_dir_entry *proc_entry; /* /proc fs entry */ | 287 | struct proc_dir_entry *proc_entry; /* /proc fs entry */ |
| 247 | struct tty_driver *other; /* only used for the PTY driver */ | 288 | struct tty_driver *other; /* only used for the PTY driver */ |
| 248 | 289 | ||
| @@ -264,12 +305,19 @@ struct tty_driver { | |||
| 264 | 305 | ||
| 265 | extern struct list_head tty_drivers; | 306 | extern struct list_head tty_drivers; |
| 266 | 307 | ||
| 267 | struct tty_driver *alloc_tty_driver(int lines); | 308 | extern struct tty_driver *alloc_tty_driver(int lines); |
| 268 | void put_tty_driver(struct tty_driver *driver); | 309 | extern void put_tty_driver(struct tty_driver *driver); |
| 269 | void tty_set_operations(struct tty_driver *driver, | 310 | extern void tty_set_operations(struct tty_driver *driver, |
| 270 | const struct tty_operations *op); | 311 | const struct tty_operations *op); |
| 271 | extern struct tty_driver *tty_find_polling_driver(char *name, int *line); | 312 | extern struct tty_driver *tty_find_polling_driver(char *name, int *line); |
| 272 | 313 | ||
| 314 | extern void tty_driver_kref_put(struct tty_driver *driver); | ||
| 315 | extern inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d) | ||
| 316 | { | ||
| 317 | kref_get(&d->kref); | ||
| 318 | return d; | ||
| 319 | } | ||
| 320 | |||
| 273 | /* tty driver magic number */ | 321 | /* tty driver magic number */ |
| 274 | #define TTY_DRIVER_MAGIC 0x5402 | 322 | #define TTY_DRIVER_MAGIC 0x5402 |
| 275 | 323 | ||
