aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tty_io.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-06-01 16:53:08 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-10 16:47:44 -0400
commitddcd9fb66ae7f448b517242c10a31d4e17bcad45 (patch)
tree54c5894f3c1dd45580cd45c621bbeb9174da879b /drivers/char/tty_io.c
parent203652192634c1fce5e79df0a8ff2fabfaefd3ab (diff)
tty: remove tty_lock_nested
This changes all remaining users of tty_lock_nested to be non-recursive, which lets us kill this function. As a consequence, we won't need to keep the lock count any more, which allows more simplifications later. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char/tty_io.c')
-rw-r--r--drivers/char/tty_io.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index bb22cf495435..dcf7d368639e 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -492,10 +492,8 @@ EXPORT_SYMBOL_GPL(tty_wakeup);
492 * tasklist_lock to walk task list for hangup event 492 * tasklist_lock to walk task list for hangup event
493 * ->siglock to protect ->signal/->sighand 493 * ->siglock to protect ->signal/->sighand
494 */ 494 */
495static void do_tty_hangup(struct work_struct *work) 495void tty_vhangup_locked(struct tty_struct *tty)
496{ 496{
497 struct tty_struct *tty =
498 container_of(work, struct tty_struct, hangup_work);
499 struct file *cons_filp = NULL; 497 struct file *cons_filp = NULL;
500 struct file *filp, *f = NULL; 498 struct file *filp, *f = NULL;
501 struct task_struct *p; 499 struct task_struct *p;
@@ -517,8 +515,6 @@ static void do_tty_hangup(struct work_struct *work)
517 /* inuse_filps is protected by the single tty lock, 515 /* inuse_filps is protected by the single tty lock,
518 this really needs to change if we want to flush the 516 this really needs to change if we want to flush the
519 workqueue with the lock held */ 517 workqueue with the lock held */
520 tty_lock_nested(); /* called with BTM held from pty_close and
521 others */
522 check_tty_count(tty, "do_tty_hangup"); 518 check_tty_count(tty, "do_tty_hangup");
523 519
524 file_list_lock(); 520 file_list_lock();
@@ -598,11 +594,20 @@ static void do_tty_hangup(struct work_struct *work)
598 */ 594 */
599 set_bit(TTY_HUPPED, &tty->flags); 595 set_bit(TTY_HUPPED, &tty->flags);
600 tty_ldisc_enable(tty); 596 tty_ldisc_enable(tty);
601 tty_unlock();
602 if (f) 597 if (f)
603 fput(f); 598 fput(f);
604} 599}
605 600
601static void do_tty_hangup(struct work_struct *work)
602{
603 struct tty_struct *tty =
604 container_of(work, struct tty_struct, hangup_work);
605
606 tty_lock();
607 tty_vhangup_locked(tty);
608 tty_unlock();
609}
610
606/** 611/**
607 * tty_hangup - trigger a hangup event 612 * tty_hangup - trigger a hangup event
608 * @tty: tty to hangup 613 * @tty: tty to hangup
@@ -638,7 +643,9 @@ void tty_vhangup(struct tty_struct *tty)
638 643
639 printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf)); 644 printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf));
640#endif 645#endif
641 do_tty_hangup(&tty->hangup_work); 646 tty_lock();
647 tty_vhangup_locked(tty);
648 tty_unlock();
642} 649}
643 650
644EXPORT_SYMBOL(tty_vhangup); 651EXPORT_SYMBOL(tty_vhangup);
@@ -719,10 +726,12 @@ void disassociate_ctty(int on_exit)
719 tty = get_current_tty(); 726 tty = get_current_tty();
720 if (tty) { 727 if (tty) {
721 tty_pgrp = get_pid(tty->pgrp); 728 tty_pgrp = get_pid(tty->pgrp);
722 tty_lock_nested(); /* see above */ 729 if (on_exit) {
723 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) 730 tty_lock();
724 tty_vhangup(tty); 731 if (tty->driver->type != TTY_DRIVER_TYPE_PTY)
725 tty_unlock(); 732 tty_vhangup_locked(tty);
733 tty_unlock();
734 }
726 tty_kref_put(tty); 735 tty_kref_put(tty);
727 } else if (on_exit) { 736 } else if (on_exit) {
728 struct pid *old_pgrp; 737 struct pid *old_pgrp;
@@ -1213,18 +1222,14 @@ static int tty_driver_install_tty(struct tty_driver *driver,
1213 int ret; 1222 int ret;
1214 1223
1215 if (driver->ops->install) { 1224 if (driver->ops->install) {
1216 tty_lock_nested(); /* already called with BTM held */
1217 ret = driver->ops->install(driver, tty); 1225 ret = driver->ops->install(driver, tty);
1218 tty_unlock();
1219 return ret; 1226 return ret;
1220 } 1227 }
1221 1228
1222 if (tty_init_termios(tty) == 0) { 1229 if (tty_init_termios(tty) == 0) {
1223 tty_lock_nested();
1224 tty_driver_kref_get(driver); 1230 tty_driver_kref_get(driver);
1225 tty->count++; 1231 tty->count++;
1226 driver->ttys[idx] = tty; 1232 driver->ttys[idx] = tty;
1227 tty_unlock();
1228 return 0; 1233 return 0;
1229 } 1234 }
1230 return -ENOMEM; 1235 return -ENOMEM;
@@ -1317,15 +1322,11 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx,
1317 struct tty_struct *tty; 1322 struct tty_struct *tty;
1318 int retval; 1323 int retval;
1319 1324
1320 tty_lock_nested(); /* always called with tty lock held already */
1321
1322 /* Check if pty master is being opened multiple times */ 1325 /* Check if pty master is being opened multiple times */
1323 if (driver->subtype == PTY_TYPE_MASTER && 1326 if (driver->subtype == PTY_TYPE_MASTER &&
1324 (driver->flags & TTY_DRIVER_DEVPTS_MEM) && !first_ok) { 1327 (driver->flags & TTY_DRIVER_DEVPTS_MEM) && !first_ok) {
1325 tty_unlock();
1326 return ERR_PTR(-EIO); 1328 return ERR_PTR(-EIO);
1327 } 1329 }
1328 tty_unlock();
1329 1330
1330 /* 1331 /*
1331 * First time open is complex, especially for PTY devices. 1332 * First time open is complex, especially for PTY devices.
@@ -1369,9 +1370,7 @@ release_mem_out:
1369 if (printk_ratelimit()) 1370 if (printk_ratelimit())
1370 printk(KERN_INFO "tty_init_dev: ldisc open failed, " 1371 printk(KERN_INFO "tty_init_dev: ldisc open failed, "
1371 "clearing slot %d\n", idx); 1372 "clearing slot %d\n", idx);
1372 tty_lock_nested();
1373 release_tty(tty, idx); 1373 release_tty(tty, idx);
1374 tty_unlock();
1375 return ERR_PTR(retval); 1374 return ERR_PTR(retval);
1376} 1375}
1377 1376