Date: Mon, 10 Jul 2006 21:38:05 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 101241 for review Message-ID: <200607102138.k6ALc50l085125@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=101241 Change 101241 by imp@imp_lighthouse on 2006/07/10 21:37:21 First cut, and a rough one at that, at allowing hints to have a dual meaning. The traditional "I claim there's a device here" as well as "If you find a device here, prefer this device mapping, if you please." We create a function to ask the bus if there's a better unit number for this device than the one we're trying, if the device has a wildcarded unit number. Affected files ... .. //depot/projects/arm/src/sys/kern/bus_if.m#3 edit .. //depot/projects/arm/src/sys/kern/subr_bus.c#11 edit Differences ... ==== //depot/projects/arm/src/sys/kern/bus_if.m#3 (text+ko) ==== @@ -529,3 +529,20 @@ const char * _dname; int _dunit; }; + +/** + * @brief Asks the bus to give us a hand hinting this device. + * + * Before we probe a child of a bus that's been wildcarded, we call the + * bus to see if there's any 'hints' as to unit number for the child + * presented for this kind of device. + * + * @param _dev the bus device + * @param _child child to hint + * @param _dunit the unit number of the device + */ +METHOD void hint_device_unit { + device_t _dev; + device_t _child; + int *_dunit; +}; ==== //depot/projects/arm/src/sys/kern/subr_bus.c#11 (text+ko) ==== @@ -1697,10 +1697,10 @@ int device_probe_child(device_t dev, device_t child) { - devclass_t dc; + devclass_t dc, childdc; driverlink_t best = 0; driverlink_t dl; - int result, pri = 0; + int unit, result, pri = 0; int hasclass = (child->devclass != 0); GIANT_REQUIRED; @@ -1724,7 +1724,18 @@ device_set_driver(child, dl->driver); if (!hasclass) device_set_devclass(child, dl->driver->name); - + if (child->flags & DF_WILDCARD) { + unit = child->unit; + BUS_HINT_DEVICE_UNIT(dev, child, &unit); + if (unit != child->unit) { + childdc = child->devclass; + devclass_delete_device(childdc, child); + if (childdc->devices[unit] != NULL) + continue; + child->unit = unit; + devclass_add_device(childdc, child); + } + } /* Fetch any flags for the device before probing. */ resource_int_value(dl->driver->name, child->unit, "flags", &child->devflags);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607102138.k6ALc50l085125>