Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 4222
b: refs/heads/master
c: 6f24808
h: refs/heads/master
v: v3
  • Loading branch information
Milton Miller authored and Linus Torvalds committed Jul 8, 2005
1 parent 1bee64f commit 15e2188
Show file tree
Hide file tree
Showing 2 changed files with 30 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: 837dcfaf46d147f1d2c64cbbecb832dd9075c39d
refs/heads/master: 6f24808eeb54eed5994128a863cd25c40f36cfac
36 changes: 29 additions & 7 deletions trunk/drivers/char/hvc_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ static struct list_head hvc_structs = LIST_HEAD_INIT(hvc_structs);
static DEFINE_SPINLOCK(hvc_structs_lock);

/*
* This value is used to associate a tty->index value to a hvc_struct based
* upon order of exposure via hvc_probe().
* This value is used to assign a tty->index value to a hvc_struct based
* 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
Expand Down Expand Up @@ -224,9 +225,10 @@ static int __init hvc_console_init(void)
console_initcall(hvc_console_init);

/*
* hvc_instantiate() is an early console discovery method which locates consoles
* prior to the vio subsystem discovering them. Hotplugged vty adapters do NOT
* get an hvc_instantiate() callback since the appear after early console init.
* hvc_instantiate() is an early console discovery method which locates
* consoles * prior to the vio subsystem discovering them. Hotplugged
* vty adapters do NOT get an hvc_instantiate() callback since they
* appear after early console init.
*/
int hvc_instantiate(uint32_t vtermno, int index)
{
Expand All @@ -237,6 +239,11 @@ int hvc_instantiate(uint32_t vtermno, int index)
return -1;

vtermnos[index] = vtermno;

/* reserve all indices upto and including this index */
if (last_hvc < index)
last_hvc = index;

return 0;
}

Expand Down Expand Up @@ -697,6 +704,7 @@ static int __devinit hvc_probe(
const struct vio_device_id *id)
{
struct hvc_struct *hp;
int i;

/* probed with invalid parameters. */
if (!dev || !id)
Expand All @@ -717,7 +725,21 @@ static int __devinit hvc_probe(

spin_lock_init(&hp->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);
spin_unlock(&hvc_structs_lock);

Expand Down

0 comments on commit 15e2188

Please sign in to comment.