Commit 6f24808e authored by Milton Miller's avatar Milton Miller Committed by Linus Torvalds

[PATCH] hvc_console: Match vio and console devices using vterm numbers

Use the vterm numbers to match the vio devices being probed with the indices
already allocated via the console initcall function hvc_find_vtys.

The old code required hvc_find_vtys to "guess" the matching devices the vio
subsystem would find and its probe order.
Signed-off-by: default avatarMilton Miller <miltonm@bga.com>
Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 837dcfaf
...@@ -102,10 +102,11 @@ static struct list_head hvc_structs = LIST_HEAD_INIT(hvc_structs); ...@@ -102,10 +102,11 @@ static struct list_head hvc_structs = LIST_HEAD_INIT(hvc_structs);
static DEFINE_SPINLOCK(hvc_structs_lock); static DEFINE_SPINLOCK(hvc_structs_lock);
/* /*
* This value is used to associate a tty->index value to a hvc_struct based * This value is used to assign a tty->index value to a hvc_struct based
* upon order of exposure via hvc_probe(). * upon order of exposure via hvc_probe(), when we can not match it to
* a console canidate registered with hvc_instantiate().
*/ */
static int hvc_count = -1; static int last_hvc = -1;
/* /*
* Do not call this function with either the hvc_strucst_lock or the hvc_struct * Do not call this function with either the hvc_strucst_lock or the hvc_struct
...@@ -224,9 +225,10 @@ static int __init hvc_console_init(void) ...@@ -224,9 +225,10 @@ static int __init hvc_console_init(void)
console_initcall(hvc_console_init); console_initcall(hvc_console_init);
/* /*
* hvc_instantiate() is an early console discovery method which locates consoles * hvc_instantiate() is an early console discovery method which locates
* prior to the vio subsystem discovering them. Hotplugged vty adapters do NOT * consoles * prior to the vio subsystem discovering them. Hotplugged
* get an hvc_instantiate() callback since the appear after early console init. * vty adapters do NOT get an hvc_instantiate() callback since they
* appear after early console init.
*/ */
int hvc_instantiate(uint32_t vtermno, int index) int hvc_instantiate(uint32_t vtermno, int index)
{ {
...@@ -237,6 +239,11 @@ int hvc_instantiate(uint32_t vtermno, int index) ...@@ -237,6 +239,11 @@ int hvc_instantiate(uint32_t vtermno, int index)
return -1; return -1;
vtermnos[index] = vtermno; vtermnos[index] = vtermno;
/* reserve all indices upto and including this index */
if (last_hvc < index)
last_hvc = index;
return 0; return 0;
} }
...@@ -697,6 +704,7 @@ static int __devinit hvc_probe( ...@@ -697,6 +704,7 @@ static int __devinit hvc_probe(
const struct vio_device_id *id) const struct vio_device_id *id)
{ {
struct hvc_struct *hp; struct hvc_struct *hp;
int i;
/* probed with invalid parameters. */ /* probed with invalid parameters. */
if (!dev || !id) if (!dev || !id)
...@@ -717,7 +725,21 @@ static int __devinit hvc_probe( ...@@ -717,7 +725,21 @@ static int __devinit hvc_probe(
spin_lock_init(&hp->lock); spin_lock_init(&hp->lock);
spin_lock(&hvc_structs_lock); spin_lock(&hvc_structs_lock);
hp->index = ++hvc_count;
/*
* find index to use:
* see if this vterm id matches one registered for console.
*/
for (i=0; i < MAX_NR_HVC_CONSOLES; i++)
if (vtermnos[i] == hp->vtermno)
break;
/* no matching slot, just use a counter */
if (i >= MAX_NR_HVC_CONSOLES)
i = ++last_hvc;
hp->index = i;
list_add_tail(&(hp->next), &hvc_structs); list_add_tail(&(hp->next), &hvc_structs);
spin_unlock(&hvc_structs_lock); spin_unlock(&hvc_structs_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment