Stop creating duplicate "smb" devices when unloading/loading smb.ko,

using the protection mechanisms described in device_add_child(9).
This commit is contained in:
Ruslan Ermilov 2005-12-20 14:26:47 +00:00
parent b898bb1be3
commit d01c2eedae
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=153556
2 changed files with 4 additions and 24 deletions

View File

@ -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

View File

@ -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)
{