aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/smbus
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>2005-12-20 14:26:47 +0000
committerRuslan Ermilov <ru@FreeBSD.org>2005-12-20 14:26:47 +0000
commitd01c2eedae44ffd3c645e67259dfc76b866fe2c3 (patch)
tree15729f4adda4bf8dd316692f3ce6bc511287b5e2 /sys/dev/smbus
parentb898bb1be347ddd4e7bab391966e69c261b28123 (diff)
downloadsrc-d01c2eedae44ffd3c645e67259dfc76b866fe2c3.tar.gz
src-d01c2eedae44ffd3c645e67259dfc76b866fe2c3.zip
Stop creating duplicate "smb" devices when unloading/loading smb.ko,
using the protection mechanisms described in device_add_child(9).
Notes
Notes: svn path=/head/; revision=153556
Diffstat (limited to 'sys/dev/smbus')
-rw-r--r--sys/dev/smbus/smb.c4
-rw-r--r--sys/dev/smbus/smbus.c24
2 files changed, 4 insertions, 24 deletions
diff --git a/sys/dev/smbus/smb.c b/sys/dev/smbus/smb.c
index 4c1c5b199f91..8073cc5945b0 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 ed9c468e66e3..d8c0a76203d2 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)
{