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:
parent
7245d518e8
commit
c062801e06
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user