PERFORCE change 124098 for review
Maxim Zhuravlev
thioretic at FreeBSD.org
Wed Jul 25 19:07:23 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=124098
Change 124098 by thioretic at thioretic on 2007/07/25 19:06:25
Modify root_bus_module_handler() according new realities.
Some cleanups.
Affected files ...
.. //depot/projects/soc2007/thioretic_gidl/kern/subr_bus.c#21 edit
Differences ...
==== //depot/projects/soc2007/thioretic_gidl/kern/subr_bus.c#21 (text+ko) ====
@@ -809,6 +809,14 @@
static driverinfo_list_t driverinfos = TAILQ_HEAD_INITIALIZER(driverinfos);
+/**
+ * @internal
+ *
+ * Is used, when a driver s used in an API function,
+ * but is not in driverinfos. Eg. may happen, if
+ * device_set_driver is called by a bus with driver, set
+ * to kobj_class, which wasn't registered by DRIVER_MODULE().
+ */
static drv_internal_t
driverinfo_create_driver_drv_internal (driver_t *driver){
drv_internal_t new_drv;
@@ -850,6 +858,7 @@
return (NULL);
di->driver = driver->devops;
di->flags = driver->flags;
+ di->topology_ops = kobj_create (di->driver, M_BUS, M_NOWAIT|M_ZERO);
TAILQ_INSERT_TAIL(&driverinfos, di, link);
bus_data_generation_update();
@@ -1410,7 +1419,6 @@
if (!drv_intnl && !(di = driverinfo_add_driver(intnl)))
if (drv_intnl) free (drv_intnl);
}
- di->topology_ops = kobj_create (di->driver, M_BUS, M_NOWAIT|M_ZERO);
/*
* Make sure the devclass which the driver is implementing exists.
@@ -2006,7 +2014,7 @@
device_set_driver (dev, driver);
if (DEVICE_PROBE(dev)<=0){
- driver_attach(dev);
+ device_attach(dev);
}
}
@@ -3348,11 +3356,14 @@
device_set_devclass(dev, 0);
TAILQ_REMOVE(&dev->drivers[dev->driver_level], dev->driver, link);
free(dev->driver);
- device_sysctl_fini(dev);
+// device_sysctl_fini(dev);
if(!dev->raw){
dev->state = (dev->driver_level == DRL_LOWEST) ? DS_NOTPRESENT :
DS_ATTACHED;
}
+ dev->driver = (!TAILQ_EMPTY(&dev->drivers[DRL_LOWEST])) ?
+ TAILQ_FIRST(&dev->drivers[DRL_LOWEST]) : NULL;
+ dev->driver_level=DRL_LOWEST;
return (error);
}
@@ -4361,7 +4372,7 @@
device_t parent;
parent = device_get_parent (dev);
if (!parent)
- return (0);
+ return (NULL);
return (BUS_ALLOC_RESOURCE(parent, dev, type, rid, start, end,
count, flags));
}
@@ -4670,10 +4681,9 @@
case MOD_LOAD:
TAILQ_INIT(&bus_data_devices);
kobj_class_compile((kobj_class_t) &root_driver);
- root_bus = make_device(NULL, "root", 0/*, NULL*/);
+ root_bus = make_device(NULL, "root", 0);
root_bus->desc = "System root bus";
- kobj_init((kobj_t) root_bus, (kobj_class_t) &root_driver);
- root_bus->driver = &root_driver;
+ device_set_driver(root_bus, root_driver);
root_bus->state = DS_ATTACHED;
root_devclass = devclass_find_internal("root", 0, FALSE, FALSE);
devinit();
@@ -4749,7 +4759,7 @@
*out = malloc (sizeof(char*)*(count+1), M_BUS, M_NOWAIT|M_ZERO);
count=0;
do {
- while (*ptr!='|' && *ptr!='\0') num++, ptr++;
+ while (*ptr!='|' && *ptr!='\0') {num++; ptr++;}
newpar = malloc ((num+1)*sizeof(char), M_BUS, M_NOWAIT|M_ZERO);
if (!newpar) return(0);
strlcpy(newpar, cptr, num+1);
@@ -4965,8 +4975,8 @@
(dev->flags&DF_WILDCARD? "wildcard,":""),
(dev->flags&DF_DESCMALLOCED? "descmalloced,":""),
(dev->flags&DF_REBID? "rebiddable,":""),
- (dev->ivars? "":"no "),
- ((TAILQ_FIRST(&(dev->drivers[DRL_LOWEST])))->softc? "":"no "),
+ ((!TAILQ_EMPTY(&dev->drivers[DRL_LOWEST])) && (TAILQ_FIRST(&dev->drivers[DRL_LOWEST]))->ivars? "":"no "),
+ ((!TAILQ_EMPTY(&dev->drivers[DRL_LOWEST])) && (TAILQ_FIRST(&dev->drivers[DRL_LOWEST]))->softc? "":"no "),
dev->busy));
}
More information about the p4-projects
mailing list