X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=drivers%2Ftty%2Ftty_mutex.c;h=d09293bc0e041417cc15047f84eec0ccd01298eb;hb=58594a804233d863ee344adf7554571d831f6c23;hp=4486741190c47d52d8079f360081d99085ce82c4;hpb=32c9edc4e356063e0218362d452a269cfa6798ee;p=firefly-linux-kernel-4.4.55.git diff --git a/drivers/tty/tty_mutex.c b/drivers/tty/tty_mutex.c index 4486741190c4..d09293bc0e04 100644 --- a/drivers/tty/tty_mutex.c +++ b/drivers/tty/tty_mutex.c @@ -4,18 +4,8 @@ #include #include -/* - * Nested tty locks are necessary for releasing pty pairs. - * The stable lock order is master pty first, then slave pty. - */ - /* Legacy tty mutex glue */ -enum { - TTY_MUTEX_NORMAL, - TTY_MUTEX_SLAVE, -}; - /* * Getting the big tty mutex. */ @@ -32,6 +22,14 @@ void __lockfunc tty_lock(struct tty_struct *tty) } EXPORT_SYMBOL(tty_lock); +int tty_lock_interruptible(struct tty_struct *tty) +{ + if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty)) + return -EIO; + tty_kref_get(tty); + return mutex_lock_interruptible(&tty->legacy_mutex); +} + void __lockfunc tty_unlock(struct tty_struct *tty) { if (tty->magic != TTY_MAGIC) { @@ -46,12 +44,8 @@ EXPORT_SYMBOL(tty_unlock); void __lockfunc tty_lock_slave(struct tty_struct *tty) { - if (tty && tty != tty->link) { - WARN_ON(!mutex_is_locked(&tty->link->legacy_mutex) || - !tty->driver->type == TTY_DRIVER_TYPE_PTY || - !tty->driver->type == PTY_TYPE_SLAVE); + if (tty && tty != tty->link) tty_lock(tty); - } } void __lockfunc tty_unlock_slave(struct tty_struct *tty) @@ -62,5 +56,5 @@ void __lockfunc tty_unlock_slave(struct tty_struct *tty) void tty_set_lock_subclass(struct tty_struct *tty) { - lockdep_set_subclass(&tty->legacy_mutex, TTY_MUTEX_SLAVE); + lockdep_set_subclass(&tty->legacy_mutex, TTY_LOCK_SLAVE); }