From 31d6705f11945e165284217b905eeafa028ca833 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 4 Jun 2012 13:35:36 +0200 Subject: [PATCH] --- yaml --- r: 325592 b: refs/heads/master c: 04831dc154df9b83c3e5fd54b18448da507871f7 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/tty/tty_io.c | 18 +++++++++++++++++- trunk/include/linux/tty_driver.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 15b556ecc1d4..68d2d05285be 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9bb8a3d4109f3b267cca9f6f071e2298eed4f593 +refs/heads/master: 04831dc154df9b83c3e5fd54b18448da507871f7 diff --git a/trunk/drivers/tty/tty_io.c b/trunk/drivers/tty/tty_io.c index d6e045b7079a..ac96f74573d0 100644 --- a/trunk/drivers/tty/tty_io.c +++ b/trunk/drivers/tty/tty_io.c @@ -1407,6 +1407,9 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx) if (retval < 0) goto err_deinit_tty; + if (!tty->port) + tty->port = driver->ports[idx]; + /* * Structures all installed ... call the ldisc open routines. * If we fail here just call release_tty to clean up. No need @@ -3094,6 +3097,7 @@ static void destruct_tty_driver(struct kref *kref) kfree(p); cdev_del(&driver->cdev); } + kfree(driver->ports); kfree(driver); } @@ -3132,6 +3136,18 @@ int tty_register_driver(struct tty_driver *driver) if (!p) return -ENOMEM; } + /* + * There is too many lines in PTY and we won't need the array there + * since it has an ->install hook where it assigns ports properly. + */ + if (driver->type != TTY_DRIVER_TYPE_PTY) { + driver->ports = kcalloc(driver->num, sizeof(struct tty_port *), + GFP_KERNEL); + if (!driver->ports) { + error = -ENOMEM; + goto err_free_p; + } + } if (!driver->major) { error = alloc_chrdev_region(&dev, driver->minor_start, @@ -3190,7 +3206,7 @@ int tty_register_driver(struct tty_driver *driver) unregister_chrdev_region(dev, driver->num); driver->ttys = NULL; driver->termios = NULL; -err_free_p: +err_free_p: /* destruct_tty_driver will free driver->ports */ kfree(p); return error; } diff --git a/trunk/include/linux/tty_driver.h b/trunk/include/linux/tty_driver.h index 6e6dbb7447b6..04419c141b00 100644 --- a/trunk/include/linux/tty_driver.h +++ b/trunk/include/linux/tty_driver.h @@ -313,6 +313,7 @@ struct tty_driver { * Pointer to the tty data structures */ struct tty_struct **ttys; + struct tty_port **ports; struct ktermios **termios; void *driver_state;