From d5f65fcbd72eca05cd537f06d3013fc04a6290a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Schmidt?= Date: Fri, 26 May 2000 13:59:05 +0000 Subject: [PATCH] If devclass_alloc_unit() is called with a wired unit #, and this is buzy, only search upwards for a free slot to use.. This broke unit numbering on ATA systems where PCI attached controllers come before the mainboard ones... Reviewed by: dfr --- sys/kern/subr_bus.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index ddd1e4f6b6b0..ffade1907ba3 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -350,27 +350,22 @@ devclass_alloc_unit(devclass_t dc, int *unitp) PDEBUG(("unit %d in devclass %s", unit, DEVCLANAME(dc))); - /* - * If we have been given a wired unit number, check for existing - * device. - */ + /* If we have been given a wired unit number, check for existing device */ if (unit != -1) { if (unit >= 0 && unit < dc->maxunit && dc->devices[unit] != NULL) { if (bootverbose) printf("%s-: %s%d exists, using next available unit number\n", dc->name, dc->name, unit); - unit = -1; + /* find the next available slot */ + while (++unit < dc->maxunit && dc->devices[unit] != NULL) + ; } } - - /* - * We ended up with an unwired device, so let's find the next available - * slot for it. - */ - if (unit == -1) { + else { + /* Unwired device, find the next available slot for it */ unit = 0; while (unit < dc->maxunit && dc->devices[unit] != NULL) - unit++; + unit++; } /*