diff options
author | ru <ru@FreeBSD.org> | 2005-12-20 14:26:47 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2005-12-20 14:26:47 +0000 |
commit | c062801e068f9684bdff72d4789f78f61f46e395 (patch) | |
tree | 15729f4adda4bf8dd316692f3ce6bc511287b5e2 | |
parent | 7245d518e8613a91f727a587f0d552cafff8e692 (diff) | |
download | FreeBSD-src-c062801e068f9684bdff72d4789f78f61f46e395.zip FreeBSD-src-c062801e068f9684bdff72d4789f78f61f46e395.tar.gz |
Stop creating duplicate "smb" devices when unloading/loading smb.ko,
using the protection mechanisms described in device_add_child(9).
-rw-r--r-- | sys/dev/smbus/smb.c | 4 | ||||
-rw-r--r-- | sys/dev/smbus/smbus.c | 24 |
2 files changed, 4 insertions, 24 deletions
diff --git a/sys/dev/smbus/smb.c b/sys/dev/smbus/smb.c index 4c1c5b1..8073cc5 100644 --- a/sys/dev/smbus/smb.c +++ b/sys/dev/smbus/smb.c @@ -97,7 +97,9 @@ static struct cdevsw smb_cdevsw = { static void smb_identify(driver_t *driver, device_t parent) { - BUS_ADD_CHILD(parent, 0, "smb", -1); + + if (!device_find_child(parent, "smb", -1)) + device_add_child(parent, "smb", -1); } static int diff --git a/sys/dev/smbus/smbus.c b/sys/dev/smbus/smbus.c index ed9c468..d8c0a76 100644 --- a/sys/dev/smbus/smbus.c +++ b/sys/dev/smbus/smbus.c @@ -49,17 +49,14 @@ static devclass_t smbus_devclass; * Device methods */ static int smbus_probe(device_t); -static int smbus_attach(device_t); -static int smbus_add_child(device_t dev, int order, const char *name, int unit); static device_method_t smbus_methods[] = { /* device interface */ DEVMETHOD(device_probe, smbus_probe), - DEVMETHOD(device_attach, smbus_attach), + DEVMETHOD(device_attach, bus_generic_attach), DEVMETHOD(device_detach, bus_generic_detach), /* bus interface */ - DEVMETHOD(bus_add_child, smbus_add_child), DEVMETHOD(bus_print_child, bus_generic_print_child), { 0, 0 } @@ -84,25 +81,6 @@ smbus_probe(device_t dev) return (0); } -static int -smbus_attach(device_t dev) -{ - device_add_child(dev, NULL, -1); - bus_generic_attach(dev); - - return (0); -} - -static int -smbus_add_child(device_t dev, int order, const char *name, int unit) -{ - device_add_child_ordered(dev, order, name, unit); - - bus_generic_attach(dev); - - return (0); -} - void smbus_generic_intr(device_t dev, u_char devaddr, char low, char high) { |