Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 163803
b: refs/heads/master
c: 182274f
h: refs/heads/master
i:
  163801: 480611b
  163799: a2b3863
v: v3
  • Loading branch information
Linus Torvalds authored and Live-CD User committed Sep 19, 2009
1 parent 40594e4 commit 5cd5fd6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 32 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f0de0e8d3565ee7feba6228d99763d4cea2087a6
refs/heads/master: 182274f85fc26ec3aa8c78dba8b0e7763af3c586
51 changes: 20 additions & 31 deletions trunk/drivers/char/tty_ldisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,34 +174,6 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
spin_unlock_irqrestore(&tty_ldisc_lock, flags);
}

/**
* 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
Expand All @@ -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;
}

Expand Down

0 comments on commit 5cd5fd6

Please sign in to comment.