Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 330251
b: refs/heads/master
c: 92057a4
h: refs/heads/master
i:
  330249: 54fa80a
  330247: 236b243
v: v3
  • Loading branch information
Benjamin Herrenschmidt committed Sep 5, 2012
1 parent f88ff35 commit a97cdb2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 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: baa436b3676ac0eea48dfbeaf7babf53a2305bba
refs/heads/master: 92057a493af4bb56928a762ad0423200b835d995
33 changes: 26 additions & 7 deletions trunk/drivers/tty/hvc/hvc_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,20 @@ static void hvc_port_destruct(struct tty_port *port)
kfree(hp);
}

static void hvc_check_console(int index)
{
/* Already enabled, bail out */
if (hvc_console.flags & CON_ENABLED)
return;

/* If this index is what the user requested, then register
* now (setup won't fail at this point). It's ok to just
* call register again if previously .setup failed.
*/
if (index == hvc_console.index)
register_console(&hvc_console);
}

/*
* hvc_instantiate() is an early console discovery method which locates
* consoles * prior to the vio subsystem discovering them. Hotplugged
Expand Down Expand Up @@ -275,12 +289,8 @@ int hvc_instantiate(uint32_t vtermno, int index, const struct hv_ops *ops)
if (last_hvc < index)
last_hvc = index;

/* if this index is what the user requested, then register
* now (setup won't fail at this point). It's ok to just
* call register again if previously .setup failed.
*/
if (index == hvc_console.index)
register_console(&hvc_console);
/* check if we need to re-register the kernel console */
hvc_check_console(index);

return 0;
}
Expand Down Expand Up @@ -858,10 +868,15 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
i = ++last_hvc;

hp->index = i;
cons_ops[i] = ops;
vtermnos[i] = vtermno;

list_add_tail(&(hp->next), &hvc_structs);
spin_unlock(&hvc_structs_lock);

/* check if we need to re-register the kernel console */
hvc_check_console(i);

return hp;
}
EXPORT_SYMBOL_GPL(hvc_alloc);
Expand All @@ -874,8 +889,12 @@ int hvc_remove(struct hvc_struct *hp)
tty = tty_port_tty_get(&hp->port);

spin_lock_irqsave(&hp->lock, flags);
if (hp->index < MAX_NR_HVC_CONSOLES)
if (hp->index < MAX_NR_HVC_CONSOLES) {
console_lock();
vtermnos[hp->index] = -1;
cons_ops[hp->index] = NULL;
console_unlock();
}

/* Don't whack hp->irq because tty_hangup() will need to free the irq. */

Expand Down

0 comments on commit a97cdb2

Please sign in to comment.