version 1.53, 2019/07/10 14:30:39 |
version 1.54, 2019/07/12 06:30:55 |
|
|
* allocate a new slot and register the given call-backs |
* allocate a new slot and register the given call-backs |
*/ |
*/ |
struct slot * |
struct slot * |
slot_new(struct dev *d, struct opt *opt, char *who, |
slot_new(struct dev *d, struct opt *opt, unsigned int id, char *who, |
struct slotops *ops, void *arg, int mode) |
struct slotops *ops, void *arg, int mode) |
{ |
{ |
char *p; |
char *p; |
|
|
} |
} |
|
|
/* |
/* |
|
* find the free slot with the least unit number and same id |
|
*/ |
|
for (i = 0; i < DEV_NSLOT; i++) { |
|
s = unit[i]; |
|
if (s != NULL && s->ops == NULL && s->id == id) |
|
goto found; |
|
} |
|
|
|
/* |
* find the free slot with the least unit number |
* find the free slot with the least unit number |
*/ |
*/ |
for (i = 0; i < DEV_NSLOT; i++) { |
for (i = 0; i < DEV_NSLOT; i++) { |
s = unit[i]; |
s = unit[i]; |
if (s != NULL && s->ops == NULL) |
if (s != NULL && s->ops == NULL) { |
|
s->id = id; |
goto found; |
goto found; |
|
} |
} |
} |
|
|
/* |
/* |
|
|
for (i = 0; unit[i] != NULL; i++) |
for (i = 0; unit[i] != NULL; i++) |
; /* nothing */ |
; /* nothing */ |
s->unit = i; |
s->unit = i; |
|
s->id = id; |
goto found; |
goto found; |
} |
} |
|
|