From 410a3399eda18f416cf581d4c768d81a9363f811 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Mon, 11 Mar 2013 16:44:43 -0400 Subject: [PATCH] --- yaml --- r: 364271 b: refs/heads/master c: 734de249fbe2fbf594c30202a343f0772b6d18fe h: refs/heads/master i: 364269: 9709620e2a11f51c7eec7d31340060158ad688f1 364267: 25b2b0085c0feb331859c587806939c296e076e8 364263: cb5e9109eb58fa52efd3ed2f8e3c2e34aa1603e8 364255: 86fe476a520aefc94cd988846f2a4dd92c539298 v: v3 --- [refs] | 2 +- trunk/drivers/tty/tty_ldisc.c | 46 +++++++++++++++++------------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/[refs] b/[refs] index def5aa091e01..b4590f85c671 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: f48070457c728a1ff8f327240e70483cebabf83b +refs/heads/master: 734de249fbe2fbf594c30202a343f0772b6d18fe diff --git a/trunk/drivers/tty/tty_ldisc.c b/trunk/drivers/tty/tty_ldisc.c index f26ef1ace4f1..4e46c1721b9d 100644 --- a/trunk/drivers/tty/tty_ldisc.c +++ b/trunk/drivers/tty/tty_ldisc.c @@ -179,6 +179,29 @@ static struct tty_ldisc *tty_ldisc_get(int disc) return ld; } +/** + * tty_ldisc_put - release the ldisc + * + * Complement of tty_ldisc_get(). + */ +static inline void tty_ldisc_put(struct tty_ldisc *ld) +{ + unsigned long flags; + + if (WARN_ON_ONCE(!ld)) + return; + + raw_spin_lock_irqsave(&tty_ldisc_lock, flags); + + /* unreleased reader reference(s) will cause this WARN */ + WARN_ON(!atomic_dec_and_test(&ld->users)); + + ld->ops->refcount--; + module_put(ld->ops->owner); + kfree(ld); + raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); +} + static void *tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos) { return (*pos < NR_LDISCS) ? pos : NULL; @@ -328,29 +351,6 @@ void tty_ldisc_deref(struct tty_ldisc *ld) } EXPORT_SYMBOL_GPL(tty_ldisc_deref); -/** - * tty_ldisc_put - release the ldisc - * - * Complement of tty_ldisc_get(). - */ -static inline void tty_ldisc_put(struct tty_ldisc *ld) -{ - unsigned long flags; - - if (WARN_ON_ONCE(!ld)) - return; - - raw_spin_lock_irqsave(&tty_ldisc_lock, flags); - - /* unreleased reader reference(s) will cause this WARN */ - WARN_ON(!atomic_dec_and_test(&ld->users)); - - ld->ops->refcount--; - module_put(ld->ops->owner); - kfree(ld); - raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); -} - /** * tty_ldisc_enable - allow ldisc use * @tty: terminal to activate ldisc on