aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-10-13 05:44:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 12:51:44 -0400
commitfe6e29fdb1a7b94891bbdd3c67358fe4ed14639d (patch)
treea1b9524ec42081e6573dd5a77bbb881117c6a73b
parent8dff04ea316125639120c0a565ce0346b892fef7 (diff)
tty: simplify ktermios allocation
Copy the simplification from the pty unix98 special case to the generic one. This allows us to kill off driver->termios_locked entirely which is nice. We have to whack bits of the cris driver as it meddles in places it shouldn't providing its own arrays that were never used anyway. Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/char/tty_io.c46
-rw-r--r--drivers/serial/crisv10.c3
2 files changed, 7 insertions, 42 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 959083961024..502cad68f83c 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1235,27 +1235,20 @@ struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver,
1235 1235
1236int tty_init_termios(struct tty_struct *tty) 1236int tty_init_termios(struct tty_struct *tty)
1237{ 1237{
1238 struct ktermios *tp, *ltp; 1238 struct ktermios *tp;
1239 int idx = tty->index; 1239 int idx = tty->index;
1240 1240
1241 tp = tty->driver->termios[idx]; 1241 tp = tty->driver->termios[idx];
1242 ltp = tty->driver->termios_locked[idx];
1243 if (tp == NULL) { 1242 if (tp == NULL) {
1244 WARN_ON(ltp != NULL); 1243 tp = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL);
1245 tp = kmalloc(sizeof(struct ktermios), GFP_KERNEL); 1244 if (tp == NULL)
1246 ltp = kzalloc(sizeof(struct ktermios), GFP_KERNEL);
1247 if (tp == NULL || ltp == NULL) {
1248 kfree(tp);
1249 kfree(ltp);
1250 return -ENOMEM; 1245 return -ENOMEM;
1251 }
1252 memcpy(tp, &tty->driver->init_termios, 1246 memcpy(tp, &tty->driver->init_termios,
1253 sizeof(struct ktermios)); 1247 sizeof(struct ktermios));
1254 tty->driver->termios[idx] = tp; 1248 tty->driver->termios[idx] = tp;
1255 tty->driver->termios_locked[idx] = ltp;
1256 } 1249 }
1257 tty->termios = tp; 1250 tty->termios = tp;
1258 tty->termios_locked = ltp; 1251 tty->termios_locked = tp + 1;
1259 1252
1260 /* Compatibility until drivers always set this */ 1253 /* Compatibility until drivers always set this */
1261 tty->termios->c_ispeed = tty_termios_input_baud_rate(tty->termios); 1254 tty->termios->c_ispeed = tty_termios_input_baud_rate(tty->termios);
@@ -1439,10 +1432,6 @@ void tty_free_termios(struct tty_struct *tty)
1439 tp = tty->termios; 1432 tp = tty->termios;
1440 tty->driver->termios[idx] = NULL; 1433 tty->driver->termios[idx] = NULL;
1441 kfree(tp); 1434 kfree(tp);
1442
1443 tp = tty->termios_locked;
1444 tty->driver->termios_locked[idx] = NULL;
1445 kfree(tp);
1446 } 1435 }
1447} 1436}
1448EXPORT_SYMBOL(tty_free_termios); 1437EXPORT_SYMBOL(tty_free_termios);
@@ -1575,12 +1564,6 @@ void tty_release_dev(struct file *filp)
1575 idx, tty->name); 1564 idx, tty->name);
1576 return; 1565 return;
1577 } 1566 }
1578 if (tty->termios_locked != tty->driver->termios_locked[idx]) {
1579 printk(KERN_DEBUG "tty_release_dev: driver.termios_locked[%d] not "
1580 "termios_locked for (%s)\n",
1581 idx, tty->name);
1582 return;
1583 }
1584 } 1567 }
1585#endif 1568#endif
1586 1569
@@ -1604,13 +1587,6 @@ void tty_release_dev(struct file *filp)
1604 idx, tty->name); 1587 idx, tty->name);
1605 return; 1588 return;
1606 } 1589 }
1607 if (o_tty->termios_locked !=
1608 tty->driver->other->termios_locked[idx]) {
1609 printk(KERN_DEBUG "tty_release_dev: other->termios_locked["
1610 "%d] not o_termios_locked for (%s)\n",
1611 idx, tty->name);
1612 return;
1613 }
1614 if (o_tty->link != tty) { 1590 if (o_tty->link != tty) {
1615 printk(KERN_DEBUG "tty_release_dev: bad pty pointers\n"); 1591 printk(KERN_DEBUG "tty_release_dev: bad pty pointers\n");
1616 return; 1592 return;
@@ -2930,18 +2906,13 @@ static void destruct_tty_driver(struct kref *kref)
2930 driver->termios[i] = NULL; 2906 driver->termios[i] = NULL;
2931 kfree(tp); 2907 kfree(tp);
2932 } 2908 }
2933 tp = driver->termios_locked[i];
2934 if (tp) {
2935 driver->termios_locked[i] = NULL;
2936 kfree(tp);
2937 }
2938 if (!(driver->flags & TTY_DRIVER_DYNAMIC_DEV)) 2909 if (!(driver->flags & TTY_DRIVER_DYNAMIC_DEV))
2939 tty_unregister_device(driver, i); 2910 tty_unregister_device(driver, i);
2940 } 2911 }
2941 p = driver->ttys; 2912 p = driver->ttys;
2942 proc_tty_unregister_driver(driver); 2913 proc_tty_unregister_driver(driver);
2943 driver->ttys = NULL; 2914 driver->ttys = NULL;
2944 driver->termios = driver->termios_locked = NULL; 2915 driver->termios = NULL;
2945 kfree(p); 2916 kfree(p);
2946 cdev_del(&driver->cdev); 2917 cdev_del(&driver->cdev);
2947 } 2918 }
@@ -2978,7 +2949,7 @@ int tty_register_driver(struct tty_driver *driver)
2978 void **p = NULL; 2949 void **p = NULL;
2979 2950
2980 if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM) && driver->num) { 2951 if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM) && driver->num) {
2981 p = kzalloc(driver->num * 3 * sizeof(void *), GFP_KERNEL); 2952 p = kzalloc(driver->num * 2 * sizeof(void *), GFP_KERNEL);
2982 if (!p) 2953 if (!p)
2983 return -ENOMEM; 2954 return -ENOMEM;
2984 } 2955 }
@@ -3002,12 +2973,9 @@ int tty_register_driver(struct tty_driver *driver)
3002 if (p) { 2973 if (p) {
3003 driver->ttys = (struct tty_struct **)p; 2974 driver->ttys = (struct tty_struct **)p;
3004 driver->termios = (struct ktermios **)(p + driver->num); 2975 driver->termios = (struct ktermios **)(p + driver->num);
3005 driver->termios_locked = (struct ktermios **)
3006 (p + driver->num * 2);
3007 } else { 2976 } else {
3008 driver->ttys = NULL; 2977 driver->ttys = NULL;
3009 driver->termios = NULL; 2978 driver->termios = NULL;
3010 driver->termios_locked = NULL;
3011 } 2979 }
3012 2980
3013 cdev_init(&driver->cdev, &tty_fops); 2981 cdev_init(&driver->cdev, &tty_fops);
@@ -3016,7 +2984,7 @@ int tty_register_driver(struct tty_driver *driver)
3016 if (error) { 2984 if (error) {
3017 unregister_chrdev_region(dev, driver->num); 2985 unregister_chrdev_region(dev, driver->num);
3018 driver->ttys = NULL; 2986 driver->ttys = NULL;
3019 driver->termios = driver->termios_locked = NULL; 2987 driver->termios = NULL;
3020 kfree(p); 2988 kfree(p);
3021 return error; 2989 return error;
3022 } 2990 }
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index a467c77d8a13..211c21797ce0 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -457,7 +457,6 @@ static struct e100_serial rs_table[] = {
457#define NR_PORTS (sizeof(rs_table)/sizeof(struct e100_serial)) 457#define NR_PORTS (sizeof(rs_table)/sizeof(struct e100_serial))
458 458
459static struct ktermios *serial_termios[NR_PORTS]; 459static struct ktermios *serial_termios[NR_PORTS];
460static struct ktermios *serial_termios_locked[NR_PORTS];
461#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER 460#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
462static struct fast_timer fast_timers[NR_PORTS]; 461static struct fast_timer fast_timers[NR_PORTS];
463#endif 462#endif
@@ -4448,8 +4447,6 @@ rs_init(void)
4448 driver->init_termios.c_ispeed = 115200; 4447 driver->init_termios.c_ispeed = 115200;
4449 driver->init_termios.c_ospeed = 115200; 4448 driver->init_termios.c_ospeed = 115200;
4450 driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 4449 driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
4451 driver->termios = serial_termios;
4452 driver->termios_locked = serial_termios_locked;
4453 4450
4454 tty_set_operations(driver, &rs_ops); 4451 tty_set_operations(driver, &rs_ops);
4455 serial_driver = driver; 4452 serial_driver = driver;