aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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
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')
-rw-r--r--drivers/char/pty.c2
-rw-r--r--drivers/char/selection.c4
-rw-r--r--drivers/char/tty_io.c41
-rw-r--r--drivers/char/tty_ldisc.c3
4 files changed, 24 insertions, 26 deletions
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index de22ea952832..f2d7a76fab54 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -62,7 +62,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
62 if (tty->driver == ptm_driver) 62 if (tty->driver == ptm_driver)
63 devpts_pty_kill(tty->link); 63 devpts_pty_kill(tty->link);
64#endif 64#endif
65 tty_vhangup(tty->link); 65 tty_vhangup_locked(tty->link);
66 } 66 }
67} 67}
68 68
diff --git a/drivers/char/selection.c b/drivers/char/selection.c
index 75889cd9375f..ebae344ce910 100644
--- a/drivers/char/selection.c
+++ b/drivers/char/selection.c
@@ -313,7 +313,8 @@ int paste_selection(struct tty_struct *tty)
313 struct tty_ldisc *ld; 313 struct tty_ldisc *ld;
314 DECLARE_WAITQUEUE(wait, current); 314 DECLARE_WAITQUEUE(wait, current);
315 315
316 tty_lock_nested(); /* always called with BTM from vt_ioctl */ 316 /* always called with BTM from vt_ioctl */
317 WARN_ON(!tty_locked());
317 318
318 acquire_console_sem(); 319 acquire_console_sem();
319 poke_blanked_console(); 320 poke_blanked_console();
@@ -343,6 +344,5 @@ int paste_selection(struct tty_struct *tty)
343 __set_current_state(TASK_RUNNING); 344 __set_current_state(TASK_RUNNING);
344 345
345 tty_ldisc_deref(ld); 346 tty_ldisc_deref(ld);
346 tty_unlock();
347 return 0; 347 return 0;
348} 348}
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
diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c
index 0f494799da89..412f9775d19c 100644
--- a/drivers/char/tty_ldisc.c
+++ b/drivers/char/tty_ldisc.c
@@ -450,9 +450,8 @@ static int tty_ldisc_open(struct tty_struct *tty, struct tty_ldisc *ld)
450 if (ld->ops->open) { 450 if (ld->ops->open) {
451 int ret; 451 int ret;
452 /* BTM here locks versus a hangup event */ 452 /* BTM here locks versus a hangup event */
453 tty_lock_nested(); /* always held here already */ 453 WARN_ON(!tty_locked());
454 ret = ld->ops->open(tty); 454 ret = ld->ops->open(tty);
455 tty_unlock();
456 return ret; 455 return ret;
457 } 456 }
458 return 0; 457 return 0;