[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1253396244-7885-5-git-send-email-gregkh@suse.de>
Date: Sat, 19 Sep 2009 14:36:10 -0700
From: Greg Kroah-Hartman <gregkh@...e.de>
To: linux-kernel@...r.kernel.org
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Alan Cox <alan@...rguk.ukuu.org.uk>,
OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>,
Greg Kroah-Hartman <gregkh@...e.de>
Subject: [PATCH 05/79] tty-ldisc: get rid of tty_ldisc_try_get() helper function
From: Linus Torvalds <torvalds@...ux-foundation.org>
Now that the /proc/tty/ldiscs handling doesn't play games with 'struct
ldisc' any more, the only remaining user of 'tty_ldisc_try_get()' is
'tty_ldisc_get()' (note the lack of 'try').
And we're actually much better off folding the logic directly into that
file, since the 'try' part was always about trying to get the ldisc
operations, not the ldisc itself: and making that explicit inside of
'tty_ldisc_get()' clarifies the whole semantics.
Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Alan Cox <alan@...rguk.ukuu.org.uk>
Cc: OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>,
Tested-by: Sergey Senozhatsky <sergey.senozhatsky@...l.by>
Signed-off-by: Greg Kroah-Hartman <gregkh@...e.de>
---
drivers/char/tty_ldisc.c | 51 ++++++++++++++++++----------------------------
1 files changed, 20 insertions(+), 31 deletions(-)
diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c
index cbfacc0..aafdbae 100644
--- a/drivers/char/tty_ldisc.c
+++ b/drivers/char/tty_ldisc.c
@@ -175,34 +175,6 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
}
/**
- * tty_ldisc_try_get - try and reference an ldisc
- * @disc: ldisc number
- *
- * Attempt to open and lock a line discipline into place. Return
- * the line discipline refcounted or an error.
- */
-
-static struct tty_ldisc *tty_ldisc_try_get(int disc)
-{
- struct tty_ldisc *ld;
- struct tty_ldisc_ops *ldops;
-
- ld = kmalloc(sizeof(struct tty_ldisc), GFP_KERNEL);
- if (ld == NULL)
- return ERR_PTR(-ENOMEM);
-
- ldops = get_ldops(disc);
- if (IS_ERR(ldops)) {
- kfree(ld);
- return ERR_CAST(ldops);
- }
-
- ld->ops = ldops;
- atomic_set(&ld->users, 1);
- return ld;
-}
-
-/**
* tty_ldisc_get - take a reference to an ldisc
* @disc: ldisc number
*
@@ -218,14 +190,31 @@ static struct tty_ldisc *tty_ldisc_try_get(int disc)
static struct tty_ldisc *tty_ldisc_get(int disc)
{
struct tty_ldisc *ld;
+ struct tty_ldisc_ops *ldops;
if (disc < N_TTY || disc >= NR_LDISCS)
return ERR_PTR(-EINVAL);
- ld = tty_ldisc_try_get(disc);
- if (IS_ERR(ld)) {
+
+ /*
+ * Get the ldisc ops - we may need to request them to be loaded
+ * dynamically and try again.
+ */
+ ldops = get_ldops(disc);
+ if (IS_ERR(ldops)) {
request_module("tty-ldisc-%d", disc);
- ld = tty_ldisc_try_get(disc);
+ ldops = get_ldops(disc);
+ if (IS_ERR(ldops))
+ return ERR_CAST(ldops);
+ }
+
+ ld = kmalloc(sizeof(struct tty_ldisc), GFP_KERNEL);
+ if (ld == NULL) {
+ put_ldops(ldops);
+ return ERR_PTR(-ENOMEM);
}
+
+ ld->ops = ldops;
+ atomic_set(&ld->users, 1);
return ld;
}
--
1.6.4.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists