From owner-p4-projects@FreeBSD.ORG Mon Jul 10 21:38:06 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 83DC516A4DF; Mon, 10 Jul 2006 21:38:06 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 44BEC16A4DA for ; Mon, 10 Jul 2006 21:38:06 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id EA0DF43D49 for ; Mon, 10 Jul 2006 21:38:05 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k6ALc5PQ085128 for ; Mon, 10 Jul 2006 21:38:05 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k6ALc50l085125 for perforce@freebsd.org; Mon, 10 Jul 2006 21:38:05 GMT (envelope-from imp@freebsd.org) Date: Mon, 10 Jul 2006 21:38:05 GMT Message-Id: <200607102138.k6ALc50l085125@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 101241 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jul 2006 21:38:06 -0000 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);