diff options
author | jhb <jhb@FreeBSD.org> | 2006-09-11 19:41:31 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2006-09-11 19:41:31 +0000 |
commit | 7be67f8a9364ca4407a48ee5c7af19164cc6a058 (patch) | |
tree | 8dede9a77a810fe11c00d0e49e437ddb74494ec2 /sys | |
parent | 0b24ec1e7cefed500ff17d6182344e8365af41fc (diff) | |
download | FreeBSD-src-7be67f8a9364ca4407a48ee5c7af19164cc6a058.zip FreeBSD-src-7be67f8a9364ca4407a48ee5c7af19164cc6a058.tar.gz |
Add a default method for BUS_ADD_CHILD() that just calls
device_add_child_ordered(). Previously, a device driver that wanted to
add a new child device in its identify routine had to know if the parent
driver had a custom bus_add_child method and use BUS_ADD_CHILD() in that
case, otherwise use device_add_child(). Getting it wrong in either
direction would result in panics or failure to add the child device. Now,
BUS_ADD_CHILD() always works isolating child drivers from having to know
intimate details about the parent driver.
Discussed with: imp
MFC after: 1 week
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/bus_if.m | 2 | ||||
-rw-r--r-- | sys/kern/subr_bus.c | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m index 529b506..bd848f2 100644 --- a/sys/kern/bus_if.m +++ b/sys/kern/bus_if.m @@ -194,7 +194,7 @@ METHOD device_t add_child { int _order; const char *_name; int _unit; -}; +} DEFAULT bus_generic_add_child; /** * @brief Allocate a system resource diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 3f0a9e2..75b179d 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -2839,6 +2839,13 @@ resource_list_purge(struct resource_list *rl) } } +device_t +bus_generic_add_child(device_t dev, int order, const char *name, int unit) +{ + + return (device_add_child_ordered(dev, order, name, unit)); +} + /** * @brief Helper function for implementing DEVICE_PROBE() * |