TTY changes for 2.5.58
Subsystems (5)
PATCH 1/1 TTY changes for 2.5.58
Here are some minor tty patches. They add a struct module to the tty_driver structure and then increment and decrement the driver's reference when the tty device assigned to that driver is in use. This is much like other subsystems do.
This patch was posted to lkml and no one objected to it.
I've also included a patch that adds this support to the tty drivers in the drivers/usb/ directory.
Please pull from:
bk://kernel.bkbits.net/gregkh/linux/tty-2.5
thanks,
greg k-h
drivers/char/tty_io.c | 7 +++++++ drivers/usb/class/bluetty.c | 7 +------ drivers/usb/class/cdc-acm.c | 4 +--- drivers/usb/serial/usb-serial.c | 1 + include/linux/tty_driver.h | 1 + 5 files changed, 11 insertions(+), 9 deletions(-)
-----
[email protected], 2003-01-14 16:57:38-08:00, [email protected]
TTY: Added .owner for tty drivers in the drivers/usb/ directory
drivers/usb/class/bluetty.c | 7 +------ drivers/usb/class/cdc-acm.c | 4 +--- drivers/usb/serial/usb-serial.c | 1 + 3 files changed, 3 insertions(+), 9 deletions(-)
------
[email protected], 2003-01-14 16:51:58-08:00, [email protected]
TTY: add module reference counting for tty drivers.
Note, there are still races with unloading modules, this patch does not fix that...
drivers/char/tty_io.c | 7 +++++++ include/linux/tty_driver.h | 1 + 2 files changed, 8 insertions(+)
------
PATCH 1/1 TTY changes for 2.5.58
ChangeSet 1.1025, 2003/01/14 16:51:58-08:00, [email protected]
TTY: add module reference counting for tty drivers.
Note, there are still races with unloading modules, this patch does not fix that...
drivers/char/tty_io.c +7 -0
@@ -833,6 +833,11 @@* and locked termios may be retained.) */ +if (!try_module_get (driver->owner)) { + retval = -ENODEV ; + goto end_init; + } + o_tty =NULL ; tp = o_tp =NULL ; ltp = o_ltp =NULL ;
@@ -991,6 +996,7 @@free_tty_struct (tty); fail_no_mem: +module_put (driver->owner); retval = -ENOMEM ; goto end_init;
@@ -1033,6 +1039,7 @@ tty->magic =0 ; (*tty->driver.refcount)--;list_del (&tty->tty_files); +module_put (tty->driver.owner);free_tty_struct (tty); }
include/linux/tty_driver.h +1 -0
@@ -120,6 +120,7 @@struct tty_driver {int magic;/* magic number for this structure */ +struct module *owner;const char *driver_name;const char *name;int name_base;/* offset of printed name */
ChangeSet 1.1026, 2003/01/14 16:57:38-08:00, [email protected]
TTY: Added .owner for tty drivers in the drivers/usb/ directory
drivers/usb/class/bluetty.c +1 -6
@@ -1107,20 +1107,17 @@return -EIO ; } -MOD_INC_USE_COUNT ;info ("USB Bluetooth converter detected" );for (minor =0 ; minor <BLUETOOTH_TTY_MINORS && bluetooth_table[minor]; ++minor) ;if (bluetooth_table[minor]) {err ("No more free Bluetooth devices" ); -MOD_DEC_USE_COUNT ;return -ENODEV ; }if (!(bluetooth =kmalloc (sizeof (struct usb_bluetooth ),GFP_KERNEL ))) {err ("Out of memory" ); -MOD_DEC_USE_COUNT ;return -ENOMEM ; }
@@ -1236,7 +1233,6 @@/* free up any memory that we allocated */ kfree (bluetooth); -MOD_DEC_USE_COUNT ;return -EIO ; }
@@ -1295,13 +1291,12 @@ }else {info ("device disconnected" ); } - -MOD_DEC_USE_COUNT ; }static struct tty_driver bluetooth_tty_driver = { .magic =TTY_DRIVER_MAGIC , + .owner =THIS_MODULE , .driver_name ="usb-bluetooth" , .name ="usb/ttub/%d" , .major =BLUETOOTH_TTY_MAJOR ,
drivers/usb/class/cdc-acm.c +1 -3
@@ -320,8 +320,6 @@ tty->driver_data = acm; acm->tty = tty; -MOD_INC_USE_COUNT ; -lock_kernel ();if (acm->used++) {
@@ -369,7 +367,6 @@kfree (acm); } } -MOD_DEC_USE_COUNT ; }static int acm_tty_write (struct tty_struct *tty,int from_user,const unsigned char *buf,int count)
@@ -724,6 +721,7 @@static struct tty_driver acm_tty_driver = { .magic =TTY_DRIVER_MAGIC , + .owner =THIS_MODULE , .driver_name ="acm" , .name ="usb/acm/%d" , .major =ACM_TTY_MAJOR ,
drivers/usb/serial/usb-serial.c +1 -0
@@ -1257,6 +1257,7 @@struct tty_driver usb_serial_tty_driver = { .magic =TTY_DRIVER_MAGIC , + .owner =THIS_MODULE , .driver_name ="usbserial" , #ifndef CONFIG_DEVFS_FS .name = "ttyUSB",