diff options
author | ache <ache@FreeBSD.org> | 2001-10-28 23:32:35 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-10-28 23:32:35 +0000 |
commit | eefa4f61d307fe99132b7f9900b62791de396476 (patch) | |
tree | 30e6f3d5f8c9bbe015b80a39f5fb62bc92afc49c /sys/kern/subr_bus.c | |
parent | 4037e00a247415670f6c86658f9d821a47468cba (diff) | |
download | FreeBSD-src-eefa4f61d307fe99132b7f9900b62791de396476.zip FreeBSD-src-eefa4f61d307fe99132b7f9900b62791de396476.tar.gz |
1) In devclass_alloc_unit(), skip duplicated wired devices (i.e. with fixed
number) instead of allocating next free unit for them. If someone needs
fixed place, he must specify it correctly. "Allocating next" is especially bad
because leads to double device detection and to "repeat make_dev panic" as
result. This can happens if the same devices present somewhere on PCI bus,
hints and ACPI. Making them present in one place only not always
possible, "sc" f.e. can't be removed from hints, it results to no console at
all.
2) In make_device(), detect when devclass_add_device() fails, free dev and
return. I.e. add missing error checking. This part needed to finish fix in 1),
but must be done this way in anycase, with old variant too.
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r-- | sys/kern/subr_bus.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 098b89b..d97f0f5 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -353,13 +353,10 @@ devclass_alloc_unit(devclass_t dc, int *unitp) if (unit != -1) { if (unit >= 0 && unit < dc->maxunit && dc->devices[unit] != NULL) { - /* find the next available slot */ - while (++unit < dc->maxunit && - dc->devices[unit] != NULL) - continue; if (bootverbose) - printf("%s-: %s%d already exists, using %s%d instead\n", - dc->name, dc->name, *unitp, dc->name, unit); + printf("%s-: %s%d already exists, skipping it\n", + dc->name, dc->name, *unitp); + return (EEXIST); } } else { /* Unwired device, find the next available slot for it */ @@ -460,7 +457,7 @@ make_device(device_t parent, const char *name, int unit) dev = malloc(sizeof(struct device), M_BUS, M_NOWAIT|M_ZERO); if (!dev) - return (0); + return (NULL); dev->parent = parent; TAILQ_INIT(&dev->children); @@ -478,7 +475,10 @@ make_device(device_t parent, const char *name, int unit) dev->flags |= DF_WILDCARD; if (name) { dev->flags |= DF_FIXEDCLASS; - devclass_add_device(dc, dev); + if (devclass_add_device(dc, dev)) { + kobj_delete((kobj_t) dev, M_BUS); + return (NULL); + } } dev->ivars = NULL; dev->softc = NULL; |