Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_bus.c
Show First 20 Lines • Show All 1,680 Lines • ▼ Show 20 Lines | devclass_alloc_unit(devclass_t dc, device_t dev, int *unitp) | ||||
* extend the table to make room for all units up to and including | * extend the table to make room for all units up to and including | ||||
* this one. | * this one. | ||||
*/ | */ | ||||
if (unit >= dc->maxunit) { | if (unit >= dc->maxunit) { | ||||
device_t *newlist, *oldlist; | device_t *newlist, *oldlist; | ||||
int newsize; | int newsize; | ||||
oldlist = dc->devices; | oldlist = dc->devices; | ||||
newsize = roundup((unit + 1), MINALLOCSIZE / sizeof(device_t)); | newsize = roundup((unit + 1), | ||||
MAX(1, MINALLOCSIZE / sizeof(device_t))); | |||||
newlist = malloc(sizeof(device_t) * newsize, M_BUS, M_NOWAIT); | newlist = malloc(sizeof(device_t) * newsize, M_BUS, M_NOWAIT); | ||||
if (!newlist) | if (!newlist) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
if (oldlist != NULL) | if (oldlist != NULL) | ||||
bcopy(oldlist, newlist, sizeof(device_t) * dc->maxunit); | bcopy(oldlist, newlist, sizeof(device_t) * dc->maxunit); | ||||
bzero(newlist + dc->maxunit, | bzero(newlist + dc->maxunit, | ||||
sizeof(device_t) * (newsize - dc->maxunit)); | sizeof(device_t) * (newsize - dc->maxunit)); | ||||
dc->devices = newlist; | dc->devices = newlist; | ||||
▲ Show 20 Lines • Show All 4,324 Lines • Show Last 20 Lines |