aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-03-05 08:51:50 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 14:30:21 -0500
commit1a54a76d5171f3ffd89eb69f6f38d535724e3d05 (patch)
tree6d6491bdddb6356dd08813299f1af49c1b1ddc5f
parenta8fbc974c347a798fd0c6f0bffe7bf46b8c6dfb6 (diff)
TTY: let alloc_tty_driver deduce the owner automatically
Like the rest of the kernel, make a stub from alloc_tty_driver which calls __alloc_tty_driver with proper owner. This will save us one more assignment on the driver side. Also this fixes some drivers which didn't set the owner. This allowed user to remove the module from the system even though a tty from the driver is still open. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/tty_io.c5
-rw-r--r--include/linux/tty_driver.h5
2 files changed, 7 insertions, 3 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index f105ce5c8e6e..bd95cea3173b 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3049,7 +3049,7 @@ void tty_unregister_device(struct tty_driver *driver, unsigned index)
3049} 3049}
3050EXPORT_SYMBOL(tty_unregister_device); 3050EXPORT_SYMBOL(tty_unregister_device);
3051 3051
3052struct tty_driver *alloc_tty_driver(int lines) 3052struct tty_driver *__alloc_tty_driver(int lines, struct module *owner)
3053{ 3053{
3054 struct tty_driver *driver; 3054 struct tty_driver *driver;
3055 3055
@@ -3058,11 +3058,12 @@ struct tty_driver *alloc_tty_driver(int lines)
3058 kref_init(&driver->kref); 3058 kref_init(&driver->kref);
3059 driver->magic = TTY_DRIVER_MAGIC; 3059 driver->magic = TTY_DRIVER_MAGIC;
3060 driver->num = lines; 3060 driver->num = lines;
3061 driver->owner = owner;
3061 /* later we'll move allocation of tables here */ 3062 /* later we'll move allocation of tables here */
3062 } 3063 }
3063 return driver; 3064 return driver;
3064} 3065}
3065EXPORT_SYMBOL(alloc_tty_driver); 3066EXPORT_SYMBOL(__alloc_tty_driver);
3066 3067
3067static void destruct_tty_driver(struct kref *kref) 3068static void destruct_tty_driver(struct kref *kref)
3068{ 3069{
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index 5cf685086dd3..6e65493a5e6c 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -234,6 +234,7 @@
234 * if provided (otherwise EINVAL will be returned). 234 * if provided (otherwise EINVAL will be returned).
235 */ 235 */
236 236
237#include <linux/export.h>
237#include <linux/fs.h> 238#include <linux/fs.h>
238#include <linux/list.h> 239#include <linux/list.h>
239#include <linux/cdev.h> 240#include <linux/cdev.h>
@@ -324,7 +325,7 @@ struct tty_driver {
324 325
325extern struct list_head tty_drivers; 326extern struct list_head tty_drivers;
326 327
327extern struct tty_driver *alloc_tty_driver(int lines); 328extern struct tty_driver *__alloc_tty_driver(int lines, struct module *owner);
328extern void put_tty_driver(struct tty_driver *driver); 329extern void put_tty_driver(struct tty_driver *driver);
329extern void tty_set_operations(struct tty_driver *driver, 330extern void tty_set_operations(struct tty_driver *driver,
330 const struct tty_operations *op); 331 const struct tty_operations *op);
@@ -332,6 +333,8 @@ extern struct tty_driver *tty_find_polling_driver(char *name, int *line);
332 333
333extern void tty_driver_kref_put(struct tty_driver *driver); 334extern void tty_driver_kref_put(struct tty_driver *driver);
334 335
336#define alloc_tty_driver(lines) __alloc_tty_driver(lines, THIS_MODULE)
337
335static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d) 338static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)
336{ 339{
337 kref_get(&d->kref); 340 kref_get(&d->kref);