diff options
| -rw-r--r-- | drivers/char/ip2/ip2main.c | 6 | ||||
| -rw-r--r-- | drivers/char/pty.c | 5 | ||||
| -rw-r--r-- | drivers/char/tty_io.c | 110 | ||||
| -rw-r--r-- | drivers/net/wan/Kconfig | 2 | ||||
| -rw-r--r-- | include/linux/tty_driver.h | 15 |
5 files changed, 80 insertions, 58 deletions
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c index 66f52a28c40b..6774572d3759 100644 --- a/drivers/char/ip2/ip2main.c +++ b/drivers/char/ip2/ip2main.c | |||
| @@ -264,8 +264,8 @@ static int tracewrap; | |||
| 264 | /**********/ | 264 | /**********/ |
| 265 | 265 | ||
| 266 | #if defined(MODULE) && defined(IP2DEBUG_OPEN) | 266 | #if defined(MODULE) && defined(IP2DEBUG_OPEN) |
| 267 | #define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] refc=%d, ttyc=%d, modc=%x -> %s\n", \ | 267 | #define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] ttyc=%d, modc=%x -> %s\n", \ |
| 268 | tty->name,(pCh->flags),ip2_tty_driver->refcount, \ | 268 | tty->name,(pCh->flags), \ |
| 269 | tty->count,/*GET_USE_COUNT(module)*/0,s) | 269 | tty->count,/*GET_USE_COUNT(module)*/0,s) |
| 270 | #else | 270 | #else |
| 271 | #define DBG_CNT(s) | 271 | #define DBG_CNT(s) |
| @@ -2893,7 +2893,7 @@ ip2_ipl_ioctl (struct file *pFile, UINT cmd, ULONG arg ) | |||
| 2893 | case 13: | 2893 | case 13: |
| 2894 | switch ( cmd ) { | 2894 | switch ( cmd ) { |
| 2895 | case 64: /* Driver - ip2stat */ | 2895 | case 64: /* Driver - ip2stat */ |
| 2896 | rc = put_user(ip2_tty_driver->refcount, pIndex++ ); | 2896 | rc = put_user(-1, pIndex++ ); |
| 2897 | rc = put_user(irq_counter, pIndex++ ); | 2897 | rc = put_user(irq_counter, pIndex++ ); |
| 2898 | rc = put_user(bh_counter, pIndex++ ); | 2898 | rc = put_user(bh_counter, pIndex++ ); |
| 2899 | break; | 2899 | break; |
diff --git a/drivers/char/pty.c b/drivers/char/pty.c index 6e148ade7353..0fdfa0517140 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c | |||
| @@ -571,8 +571,11 @@ static void __init unix98_pty_init(void) | |||
| 571 | if (tty_register_driver(pts_driver)) | 571 | if (tty_register_driver(pts_driver)) |
| 572 | panic("Couldn't register Unix98 pts driver"); | 572 | panic("Couldn't register Unix98 pts driver"); |
| 573 | 573 | ||
| 574 | /* FIXME: WTF */ | ||
| 575 | #if 0 | ||
| 574 | pty_table[1].data = &ptm_driver->refcount; | 576 | pty_table[1].data = &ptm_driver->refcount; |
| 575 | register_sysctl_table(pty_root_table); | 577 | #endif |
| 578 | register_sysctl_table(pty_root_table); | ||
| 576 | 579 | ||
| 577 | /* Now create the /dev/ptmx special device */ | 580 | /* Now create the /dev/ptmx special device */ |
| 578 | tty_default_fops(&ptmx_fops); | 581 | tty_default_fops(&ptmx_fops); |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index ac41af8763d1..47aa437effe2 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
| @@ -276,7 +276,7 @@ static struct tty_driver *get_tty_driver(dev_t device, int *index) | |||
| 276 | if (device < base || device >= base + p->num) | 276 | if (device < base || device >= base + p->num) |
| 277 | continue; | 277 | continue; |
| 278 | *index = device - base; | 278 | *index = device - base; |
| 279 | return p; | 279 | return tty_driver_kref_get(p); |
| 280 | } | 280 | } |
| 281 | return NULL; | 281 | return NULL; |
| 282 | } | 282 | } |
| @@ -320,7 +320,7 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line) | |||
| 320 | 320 | ||
| 321 | if (tty_line >= 0 && tty_line <= p->num && p->ops && | 321 | if (tty_line >= 0 && tty_line <= p->num && p->ops && |
| 322 | p->ops->poll_init && !p->ops->poll_init(p, tty_line, str)) { | 322 | p->ops->poll_init && !p->ops->poll_init(p, tty_line, str)) { |
| 323 | res = p; | 323 | res = tty_driver_kref_get(p); |
| 324 | *line = tty_line; | 324 | *line = tty_line; |
| 325 | break; | 325 | break; |
| 326 | } | 326 | } |
| @@ -1410,7 +1410,7 @@ int tty_init_dev(struct tty_driver *driver, int idx, | |||
| 1410 | *o_ltp_loc = o_ltp; | 1410 | *o_ltp_loc = o_ltp; |
| 1411 | o_tty->termios = *o_tp_loc; | 1411 | o_tty->termios = *o_tp_loc; |
| 1412 | o_tty->termios_locked = *o_ltp_loc; | 1412 | o_tty->termios_locked = *o_ltp_loc; |
| 1413 | driver->other->refcount++; | 1413 | tty_driver_kref_get(driver->other); |
| 1414 | if (driver->subtype == PTY_TYPE_MASTER) | 1414 | if (driver->subtype == PTY_TYPE_MASTER) |
| 1415 | o_tty->count++; | 1415 | o_tty->count++; |
| 1416 | 1416 | ||
| @@ -1438,7 +1438,7 @@ int tty_init_dev(struct tty_driver *driver, int idx, | |||
| 1438 | /* Compatibility until drivers always set this */ | 1438 | /* Compatibility until drivers always set this */ |
| 1439 | tty->termios->c_ispeed = tty_termios_input_baud_rate(tty->termios); | 1439 | tty->termios->c_ispeed = tty_termios_input_baud_rate(tty->termios); |
| 1440 | tty->termios->c_ospeed = tty_termios_baud_rate(tty->termios); | 1440 | tty->termios->c_ospeed = tty_termios_baud_rate(tty->termios); |
| 1441 | driver->refcount++; | 1441 | tty_driver_kref_get(driver); |
| 1442 | tty->count++; | 1442 | tty->count++; |
| 1443 | 1443 | ||
| 1444 | /* | 1444 | /* |
| @@ -1530,8 +1530,7 @@ static void release_one_tty(struct kref *kref) | |||
| 1530 | else | 1530 | else |
| 1531 | tty_shutdown(tty); | 1531 | tty_shutdown(tty); |
| 1532 | tty->magic = 0; | 1532 | tty->magic = 0; |
| 1533 | /* FIXME: locking on tty->driver->refcount */ | 1533 | tty_driver_kref_put(driver); |
| 1534 | tty->driver->refcount--; | ||
| 1535 | module_put(driver->owner); | 1534 | module_put(driver->owner); |
| 1536 | 1535 | ||
| 1537 | file_list_lock(); | 1536 | file_list_lock(); |
| @@ -1854,7 +1853,7 @@ retry_open: | |||
| 1854 | mutex_unlock(&tty_mutex); | 1853 | mutex_unlock(&tty_mutex); |
| 1855 | return -ENXIO; | 1854 | return -ENXIO; |
| 1856 | } | 1855 | } |
| 1857 | driver = tty->driver; | 1856 | driver = tty_driver_kref_get(tty->driver); |
| 1858 | index = tty->index; | 1857 | index = tty->index; |
| 1859 | filp->f_flags |= O_NONBLOCK; /* Don't let /dev/tty block */ | 1858 | filp->f_flags |= O_NONBLOCK; /* Don't let /dev/tty block */ |
| 1860 | /* noctty = 1; */ | 1859 | /* noctty = 1; */ |
| @@ -1865,14 +1864,14 @@ retry_open: | |||
| 1865 | #ifdef CONFIG_VT | 1864 | #ifdef CONFIG_VT |
| 1866 | if (device == MKDEV(TTY_MAJOR, 0)) { | 1865 | if (device == MKDEV(TTY_MAJOR, 0)) { |
| 1867 | extern struct tty_driver *console_driver; | 1866 | extern struct tty_driver *console_driver; |
| 1868 | driver = console_driver; | 1867 | driver = tty_driver_kref_get(console_driver); |
| 1869 | index = fg_console; | 1868 | index = fg_console; |
| 1870 | noctty = 1; | 1869 | noctty = 1; |
| 1871 | goto got_driver; | 1870 | goto got_driver; |
| 1872 | } | 1871 | } |
| 1873 | #endif | 1872 | #endif |
| 1874 | if (device == MKDEV(TTYAUX_MAJOR, 1)) { | 1873 | if (device == MKDEV(TTYAUX_MAJOR, 1)) { |
| 1875 | driver = console_device(&index); | 1874 | driver = tty_driver_kref_get(console_device(&index)); |
| 1876 | if (driver) { | 1875 | if (driver) { |
| 1877 | /* Don't let /dev/console block */ | 1876 | /* Don't let /dev/console block */ |
| 1878 | filp->f_flags |= O_NONBLOCK; | 1877 | filp->f_flags |= O_NONBLOCK; |
| @@ -1891,6 +1890,7 @@ retry_open: | |||
| 1891 | got_driver: | 1890 | got_driver: |
| 1892 | retval = tty_init_dev(driver, index, &tty, 0); | 1891 | retval = tty_init_dev(driver, index, &tty, 0); |
| 1893 | mutex_unlock(&tty_mutex); | 1892 | mutex_unlock(&tty_mutex); |
| 1893 | tty_driver_kref_put(driver); | ||
| 1894 | if (retval) | 1894 | if (retval) |
| 1895 | return retval; | 1895 | return retval; |
| 1896 | 1896 | ||
| @@ -2866,7 +2866,6 @@ int tty_put_char(struct tty_struct *tty, unsigned char ch) | |||
| 2866 | return tty->ops->put_char(tty, ch); | 2866 | return tty->ops->put_char(tty, ch); |
| 2867 | return tty->ops->write(tty, &ch, 1); | 2867 | return tty->ops->write(tty, &ch, 1); |
| 2868 | } | 2868 | } |
| 2869 | |||
| 2870 | EXPORT_SYMBOL_GPL(tty_put_char); | 2869 | EXPORT_SYMBOL_GPL(tty_put_char); |
| 2871 | 2870 | ||
| 2872 | struct class *tty_class; | 2871 | struct class *tty_class; |
| @@ -2909,6 +2908,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index, | |||
| 2909 | 2908 | ||
| 2910 | return device_create_drvdata(tty_class, device, dev, NULL, name); | 2909 | return device_create_drvdata(tty_class, device, dev, NULL, name); |
| 2911 | } | 2910 | } |
| 2911 | EXPORT_SYMBOL(tty_register_device); | ||
| 2912 | 2912 | ||
| 2913 | /** | 2913 | /** |
| 2914 | * tty_unregister_device - unregister a tty device | 2914 | * tty_unregister_device - unregister a tty device |
| @@ -2926,8 +2926,6 @@ void tty_unregister_device(struct tty_driver *driver, unsigned index) | |||
| 2926 | device_destroy(tty_class, | 2926 | device_destroy(tty_class, |
| 2927 | MKDEV(driver->major, driver->minor_start) + index); | 2927 | MKDEV(driver->major, driver->minor_start) + index); |
| 2928 | } | 2928 | } |
| 2929 | |||
| 2930 | EXPORT_SYMBOL(tty_register_device); | ||
| 2931 | EXPORT_SYMBOL(tty_unregister_device); | 2929 | EXPORT_SYMBOL(tty_unregister_device); |
| 2932 | 2930 | ||
| 2933 | struct tty_driver *alloc_tty_driver(int lines) | 2931 | struct tty_driver *alloc_tty_driver(int lines) |
| @@ -2936,27 +2934,70 @@ struct tty_driver *alloc_tty_driver(int lines) | |||
| 2936 | 2934 | ||
| 2937 | driver = kzalloc(sizeof(struct tty_driver), GFP_KERNEL); | 2935 | driver = kzalloc(sizeof(struct tty_driver), GFP_KERNEL); |
| 2938 | if (driver) { | 2936 | if (driver) { |
| 2937 | kref_init(&driver->kref); | ||
| 2939 | driver->magic = TTY_DRIVER_MAGIC; | 2938 | driver->magic = TTY_DRIVER_MAGIC; |
| 2940 | driver->num = lines; | 2939 | driver->num = lines; |
| 2941 | /* later we'll move allocation of tables here */ | 2940 | /* later we'll move allocation of tables here */ |
| 2942 | } | ||
