From owner-svn-src-all@FreeBSD.ORG Fri Nov 6 20:23:43 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 315FD1065695; Fri, 6 Nov 2009 20:23:43 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 15FB68FC16; Fri, 6 Nov 2009 20:23:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nA6KNgMx027662; Fri, 6 Nov 2009 20:23:42 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nA6KNgLt027659; Fri, 6 Nov 2009 20:23:42 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200911062023.nA6KNgLt027659@svn.freebsd.org> From: John Baldwin Date: Fri, 6 Nov 2009 20:23:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199001 - in stable/7/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Nov 2009 20:23:43 -0000 Author: jhb Date: Fri Nov 6 20:23:42 2009 New Revision: 199001 URL: http://svn.freebsd.org/changeset/base/199001 Log: MFC 198367: Set the devclass_t pointer specified in the DRIVER_MODULE() macro sooner so it is always valid when a driver's identify routine is called. Modified: stable/7/sys/kern/subr_bus.c stable/7/sys/sys/bus.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/subr_bus.c ============================================================================== --- stable/7/sys/kern/subr_bus.c Fri Nov 6 20:23:16 2009 (r199000) +++ stable/7/sys/kern/subr_bus.c Fri Nov 6 20:23:42 2009 (r199001) @@ -858,9 +858,10 @@ devclass_find(const char *classname) * @param driver the driver to register */ int -devclass_add_driver(devclass_t dc, driver_t *driver) +devclass_add_driver(devclass_t dc, driver_t *driver, devclass_t *dcp) { driverlink_t dl; + const char *parentname; int i; PDEBUG(("%s", DRIVERNAME(driver))); @@ -878,9 +879,17 @@ devclass_add_driver(devclass_t dc, drive kobj_class_compile((kobj_class_t) driver); /* - * Make sure the devclass which the driver is implementing exists. + * If the driver has any base classes, make the + * devclass inherit from the devclass of the driver's + * first base class. This will allow the system to + * search for drivers in both devclasses for children + * of a device using this driver. */ - devclass_find_internal(driver->name, NULL, TRUE); + if (driver->baseclasses) + parentname = driver->baseclasses[0]->name; + else + parentname = NULL; + *dcp = devclass_find_internal(driver->name, parentname, TRUE); dl->driver = driver; TAILQ_INSERT_TAIL(&dc->drivers, dl, link); @@ -3853,27 +3862,8 @@ driver_module_handler(module_t mod, int driver = dmd->dmd_driver; PDEBUG(("Loading module: driver %s on bus %s", DRIVERNAME(driver), dmd->dmd_busname)); - error = devclass_add_driver(bus_devclass, driver); - if (error) - break; - - /* - * If the driver has any base classes, make the - * devclass inherit from the devclass of the driver's - * first base class. This will allow the system to - * search for drivers in both devclasses for children - * of a device using this driver. - */ - if (driver->baseclasses) { - const char *parentname; - parentname = driver->baseclasses[0]->name; - *dmd->dmd_devclass = - devclass_find_internal(driver->name, - parentname, TRUE); - } else { - *dmd->dmd_devclass = - devclass_find_internal(driver->name, NULL, TRUE); - } + error = devclass_add_driver(bus_devclass, driver, + dmd->dmd_devclass); break; case MOD_UNLOAD: Modified: stable/7/sys/sys/bus.h ============================================================================== --- stable/7/sys/sys/bus.h Fri Nov 6 20:23:16 2009 (r199000) +++ stable/7/sys/sys/bus.h Fri Nov 6 20:23:42 2009 (r199001) @@ -432,7 +432,8 @@ void device_verbose(device_t dev); /* * Access functions for devclass. */ -int devclass_add_driver(devclass_t dc, kobj_class_t driver); +int devclass_add_driver(devclass_t dc, kobj_class_t driver, + devclass_t *dcp); int devclass_delete_driver(devclass_t dc, kobj_class_t driver); devclass_t devclass_create(const char *classname); devclass_t devclass_find(const char *classname);