diff options
Diffstat (limited to 'include/linux/tty_driver.h')
| -rw-r--r-- | include/linux/tty_driver.h | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 6e6dbb7447b6..dd976cfb6131 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h | |||
| @@ -45,14 +45,9 @@ | |||
| 45 | * | 45 | * |
| 46 | * void (*shutdown)(struct tty_struct * tty); | 46 | * void (*shutdown)(struct tty_struct * tty); |
| 47 | * | 47 | * |
| 48 | * This routine is called synchronously when a particular tty device | 48 | * This routine is called under the tty lock when a particular tty device |
| 49 | * is closed for the last time freeing up the resources. | 49 | * is closed for the last time. It executes before the tty resources |
| 50 | * Note that tty_shutdown() is not called if ops->shutdown is defined. | 50 | * are freed so may execute while another function holds a tty kref. |
| 51 | * This means one is responsible to take care of calling ops->remove (e.g. | ||
| 52 | * via tty_driver_remove_tty) and releasing tty->termios. | ||
| 53 | * Note that this hook may be called from *all* the contexts where one | ||
| 54 | * uses tty refcounting (e.g. tty_port_tty_get). | ||
| 55 | * | ||
| 56 | * | 51 | * |
| 57 | * void (*cleanup)(struct tty_struct * tty); | 52 | * void (*cleanup)(struct tty_struct * tty); |
| 58 | * | 53 | * |
| @@ -294,18 +289,18 @@ struct tty_operations { | |||
| 294 | struct tty_driver { | 289 | struct tty_driver { |
| 295 | int magic; /* magic number for this structure */ | 290 | int magic; /* magic number for this structure */ |
| 296 | struct kref kref; /* Reference management */ | 291 | struct kref kref; /* Reference management */ |
| 297 | struct cdev cdev; | 292 | struct cdev *cdevs; |
| 298 | struct module *owner; | 293 | struct module *owner; |
| 299 | const char *driver_name; | 294 | const char *driver_name; |
| 300 | const char *name; | 295 | const char *name; |
| 301 | int name_base; /* offset of printed name */ | 296 | int name_base; /* offset of printed name */ |
| 302 | int major; /* major device number */ | 297 | int major; /* major device number */ |
| 303 | int minor_start; /* start of minor device number */ | 298 | int minor_start; /* start of minor device number */ |
| 304 | int num; /* number of devices allocated */ | 299 | unsigned int num; /* number of devices allocated */ |
| 305 | short type; /* type of tty driver */ | 300 | short type; /* type of tty driver */ |
| 306 | short subtype; /* subtype of tty driver */ | 301 | short subtype; /* subtype of tty driver */ |
| 307 | struct ktermios init_termios; /* Initial termios */ | 302 | struct ktermios init_termios; /* Initial termios */ |
| 308 | int flags; /* tty driver flags */ | 303 | unsigned long flags; /* tty driver flags */ |
| 309 | struct proc_dir_entry *proc_entry; /* /proc fs entry */ | 304 | struct proc_dir_entry *proc_entry; /* /proc fs entry */ |
| 310 | struct tty_driver *other; /* only used for the PTY driver */ | 305 | struct tty_driver *other; /* only used for the PTY driver */ |
| 311 | 306 | ||
| @@ -313,6 +308,7 @@ struct tty_driver { | |||
| 313 | * Pointer to the tty data structures | 308 | * Pointer to the tty data structures |
| 314 | */ | 309 | */ |
| 315 | struct tty_struct **ttys; | 310 | struct tty_struct **ttys; |
| 311 | struct tty_port **ports; | ||
| 316 | struct ktermios **termios; | 312 | struct ktermios **termios; |
| 317 | void *driver_state; | 313 | void *driver_state; |
| 318 | 314 | ||
| @@ -326,7 +322,8 @@ struct tty_driver { | |||
| 326 | 322 | ||
| 327 | extern struct list_head tty_drivers; | 323 | extern struct list_head tty_drivers; |
| 328 | 324 | ||
| 329 | extern struct tty_driver *__alloc_tty_driver(int lines, struct module *owner); | 325 | extern struct tty_driver *__tty_alloc_driver(unsigned int lines, |
| 326 | struct module *owner, unsigned long flags); | ||
| 330 | extern void put_tty_driver(struct tty_driver *driver); | 327 | extern void put_tty_driver(struct tty_driver *driver); |
| 331 | extern void tty_set_operations(struct tty_driver *driver, | 328 | extern void tty_set_operations(struct tty_driver *driver, |
| 332 | const struct tty_operations *op); | 329 | const struct tty_operations *op); |
| @@ -334,7 +331,21 @@ extern struct tty_driver *tty_find_polling_driver(char *name, int *line); | |||
| 334 | 331 | ||
| 335 | extern void tty_driver_kref_put(struct tty_driver *driver); | 332 | extern void tty_driver_kref_put(struct tty_driver *driver); |
| 336 | 333 | ||
| 337 | #define alloc_tty_driver(lines) __alloc_tty_driver(lines, THIS_MODULE) | 334 | /* Use TTY_DRIVER_* flags below */ |
| 335 | #define tty_alloc_driver(lines, flags) \ | ||
| 336 | __tty_alloc_driver(lines, THIS_MODULE, flags) | ||
| 337 | |||
| 338 | /* | ||
| 339 | * DEPRECATED Do not use this in new code, use tty_alloc_driver instead. | ||
| 340 | * (And change the return value checks.) | ||
| 341 | */ | ||
| 342 | static inline struct tty_driver *alloc_tty_driver(unsigned int lines) | ||
| 343 | { | ||
| 344 | struct tty_driver *ret = tty_alloc_driver(lines, 0); | ||
| 345 | if (IS_ERR(ret)) | ||
| 346 | return NULL; | ||
| 347 | return ret; | ||
| 348 | } | ||
| 338 | 349 | ||
| 339 | static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d) | 350 | static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d) |
| 340 | { | 351 | { |
| @@ -380,6 +391,14 @@ static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d) | |||
| 380 | * the requested timeout to the caller instead of using a simple | 391 | * the requested timeout to the caller instead of using a simple |
| 381 | * on/off interface. | 392 | * on/off interface. |
| 382 | * | 393 | * |
| 394 | * TTY_DRIVER_DYNAMIC_ALLOC -- do not allocate structures which are | ||
| 395 | * needed per line for this driver as it would waste memory. | ||
| 396 | * The driver will take care. | ||
| 397 | * | ||
| 398 | * TTY_DRIVER_UNNUMBERED_NODE -- do not create numbered /dev nodes. In | ||
| 399 | * other words create /dev/ttyprintk and not /dev/ttyprintk0. | ||
| 400 | * Applicable only when a driver for a single tty device is | ||
| 401 | * being allocated. | ||
| 383 | */ | 402 | */ |
| 384 | #define TTY_DRIVER_INSTALLED 0x0001 | 403 | #define TTY_DRIVER_INSTALLED 0x0001 |
| 385 | #define TTY_DRIVER_RESET_TERMIOS 0x0002 | 404 | #define TTY_DRIVER_RESET_TERMIOS 0x0002 |
| @@ -387,6 +406,8 @@ static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d) | |||
| 387 | #define TTY_DRIVER_DYNAMIC_DEV 0x0008 | 406 | #define TTY_DRIVER_DYNAMIC_DEV 0x0008 |
| 388 | #define TTY_DRIVER_DEVPTS_MEM 0x0010 | 407 | #define TTY_DRIVER_DEVPTS_MEM 0x0010 |
| 389 | #define TTY_DRIVER_HARDWARE_BREAK 0x0020 | 408 | #define TTY_DRIVER_HARDWARE_BREAK 0x0020 |
| 409 | #define TTY_DRIVER_DYNAMIC_ALLOC 0x0040 | ||
| 410 | #define TTY_DRIVER_UNNUMBERED_NODE 0x0080 | ||
| 390 | 411 | ||
| 391 | /* tty driver types */ | 412 | /* tty driver types */ |
| 392 | #define TTY_DRIVER_TYPE_SYSTEM 0x0001 | 413 | #define TTY_DRIVER_TYPE_SYSTEM 0x0001 |
