aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty_io.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-08-07 15:47:42 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-10 16:29:58 -0400
commit7f0bc6a68ed93f3b4ad77b94df5ef32446c583e3 (patch)
treec51b79c16850d6a23347072aec81bf6acd3c97af /drivers/tty/tty_io.c
parent2312e4f3b2f17cac2cf257c759ad48eb80fdf230 (diff)
TTY: pass flags to alloc_tty_driver
We need to allow drivers that use neither tty_port_install nor tty_port_register_device to link a tty_port to a tty somehow. To avoid a race with open, this has to be performed before tty_register_device. But currently tty_driver->ports is allocated even in tty_register_device because we do not know whether this is the PTY driver. The PTY driver is special here due to an excessive count of lines it declares to handle. We cannot handle tty_ports there this way. To circumvent this, we start passing tty_driver flags to alloc_tty_driver already and we create tty_alloc_driver for this purpose. There we can allocate tty_driver->ports and do all the magic between tty_alloc_driver and tty_register_device. Later we will introduce tty_port_link_device function for that purpose. All drivers should eventually switch to this new tty driver allocation interface. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/tty_io.c')
-rw-r--r--drivers/tty/tty_io.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 690224483fab..098a7c72b640 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3061,21 +3061,37 @@ void tty_unregister_device(struct tty_driver *driver, unsigned index)
3061} 3061}
3062EXPORT_SYMBOL(tty_unregister_device); 3062EXPORT_SYMBOL(tty_unregister_device);
3063 3063
3064struct tty_driver *__alloc_tty_driver(int lines, struct module *owner) 3064/**
3065 * __tty_alloc_driver -- allocate tty driver
3066 * @lines: count of lines this driver can handle at most
3067 * @owner: module which is repsonsible for this driver
3068 * @flags: some of TTY_DRIVER_* flags, will be set in driver->flags
3069 *
3070 * This should not be called directly, some of the provided macros should be
3071 * used instead. Use IS_ERR and friends on @retval.
3072 */
3073struct tty_driver *__tty_alloc_driver(unsigned int lines, struct module *owner,
3074 unsigned long flags)
3065{ 3075{
3066 struct tty_driver *driver; 3076 struct tty_driver *driver;
3067 3077
3078 if (!lines)
3079 return ERR_PTR(-EINVAL);
3080
3068 driver = kzalloc(sizeof(struct tty_driver), GFP_KERNEL); 3081 driver = kzalloc(sizeof(struct tty_driver), GFP_KERNEL);
3069 if (driver) { 3082 if (!driver)
3070 kref_init(&driver->kref); 3083 return ERR_PTR(-ENOMEM);
3071 driver->magic = TTY_DRIVER_MAGIC; 3084
3072 driver->num = lines; 3085 kref_init(&driver->kref);
3073 driver->owner = owner; 3086 driver->magic = TTY_DRIVER_MAGIC;
3074 /* later we'll move allocation of tables here */ 3087 driver->num = lines;
3075 } 3088 driver->owner = owner;
3089 driver->flags = flags;
3090 /* later we'll move allocation of tables here */
3091
3076 return driver; 3092 return driver;
3077} 3093}
3078EXPORT_SYMBOL(__alloc_tty_driver); 3094EXPORT_SYMBOL(__tty_alloc_driver);
3079 3095
3080static void destruct_tty_driver(struct kref *kref) 3096static void destruct_tty_driver(struct kref *kref)
3081{ 3097{