aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/hvc_console.c
diff options
context:
space:
mode:
authorMilton Miller <miltonm@bga.com>2005-07-07 20:56:17 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-07 21:23:38 -0400
commit6f24808eeb54eed5994128a863cd25c40f36cfac (patch)
tree19a4567d9e9d6b2b7f8d7be84068d6e734495b59 /drivers/char/hvc_console.c
parent837dcfaf46d147f1d2c64cbbecb832dd9075c39d (diff)
[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: Milton Miller <miltonm@bga.com> Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/hvc_console.c')
-rw-r--r--drivers/char/hvc_console.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index f0a1456a597e..4b776f4eb467 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -102,10 +102,11 @@ static struct list_head hvc_structs = LIST_HEAD_INIT(hvc_structs);
102static DEFINE_SPINLOCK(hvc_structs_lock); 102static DEFINE_SPINLOCK(hvc_structs_lock);
103 103
104/* 104/*
105 * This value is used to associate a tty->index value to a hvc_struct based 105 * This value is used to assign a tty->index value to a hvc_struct based
106 * upon order of exposure via hvc_probe(). 106 * upon order of exposure via hvc_probe(), when we can not match it to
107 * a console canidate registered with hvc_instantiate().
107 */ 108 */
108static int hvc_count = -1; 109static int last_hvc = -1;
109 110
110/* 111/*
111 * Do not call this function with either the hvc_strucst_lock or the hvc_struct 112 * 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)
224console_initcall(hvc_console_init); 225console_initcall(hvc_console_init);
225 226
226/* 227/*
227 * hvc_instantiate() is an early console discovery method which locates consoles 228 * hvc_instantiate() is an early console discovery method which locates
228 * prior to the vio subsystem discovering them. Hotplugged vty adapters do NOT 229 * consoles * prior to the vio subsystem discovering them. Hotplugged
229 * get an hvc_instantiate() callback since the appear after early console init. 230 * vty adapters do NOT get an hvc_instantiate() callback since they
231 * appear after early console init.
230 */ 232 */
231int hvc_instantiate(uint32_t vtermno, int index) 233int hvc_instantiate(uint32_t vtermno, int index)
232{ 234{
@@ -237,6 +239,11 @@ int hvc_instantiate(uint32_t vtermno, int index)
237 return -1; 239 return -1;
238 240
239 vtermnos[index] = vtermno; 241 vtermnos[index] = vtermno;
242
243 /* reserve all indices upto and including this index */
244 if (last_hvc < index)
245 last_hvc = index;
246
240 return 0; 247 return 0;
241} 248}
242 249
@@ -697,6 +704,7 @@ static int __devinit hvc_probe(
697 const struct vio_device_id *id) 704 const struct vio_device_id *id)
698{ 705{
699 struct hvc_struct *hp; 706 struct hvc_struct *hp;
707 int i;
700 708
701 /* probed with invalid parameters. */ 709 /* probed with invalid parameters. */
702 if (!dev || !id) 710 if (!dev || !id)
@@ -717,7 +725,21 @@ static int __devinit hvc_probe(
717 725
718 spin_lock_init(&hp->lock); 726 spin_lock_init(&hp->lock);
719 spin_lock(&hvc_structs_lock); 727 spin_lock(&hvc_structs_lock);
720 hp->index = ++hvc_count; 728
729 /*
730 * find index to use:
731 * see if this vterm id matches one registered for console.
732 */
733 for (i=0; i < MAX_NR_HVC_CONSOLES; i++)
734 if (vtermnos[i] == hp->vtermno)
735 break;
736
737 /* no matching slot, just use a counter */
738 if (i >= MAX_NR_HVC_CONSOLES)
739 i = ++last_hvc;
740
741 hp->index = i;
742
721 list_add_tail(&(hp->next), &hvc_structs); 743 list_add_tail(&(hp->next), &hvc_structs);
722 spin_unlock(&hvc_structs_lock); 744 spin_unlock(&hvc_structs_lock);
723 745