diff --git a/sys/dev/iicbus/iicbb.c b/sys/dev/iicbus/iicbb.c index 977d52a01249..ed1d7b846d31 100644 --- a/sys/dev/iicbus/iicbb.c +++ b/sys/dev/iicbus/iicbb.c @@ -149,22 +149,9 @@ iicbb_attach(device_t dev) static int iicbb_detach(device_t dev) { - struct iicbb_softc *sc = (struct iicbb_softc *)device_get_softc(dev); - device_t child; - /* - * We need to save child because the detach indirectly causes - * sc->iicbus to be zeroed. Since we added the device - * unconditionally in iicbb_attach, we need to make sure we - * delete it here. See iicbb_child_detached. We need that - * callback in case newbus detached our children w/o detaching - * us (say iicbus is a module and unloaded w/o iicbb being - * unloaded). - */ - child = sc->iicbus; bus_generic_detach(dev); - if (child) - device_delete_child(dev, child); + device_delete_children(dev); return (0); } diff --git a/sys/dev/iicbus/iicbus.c b/sys/dev/iicbus/iicbus.c index 4ee480e677e6..df29b09b4c06 100644 --- a/sys/dev/iicbus/iicbus.c +++ b/sys/dev/iicbus/iicbus.c @@ -135,6 +135,7 @@ iicbus_detach(device_t dev) iicbus_reset(dev, IIC_FASTEST, 0, NULL); bus_generic_detach(dev); + device_delete_children(dev); mtx_destroy(&sc->lock); return (0); } diff --git a/sys/dev/iicbus/iicoc.c b/sys/dev/iicbus/iicoc.c index 45f1692fa479..c55d6fe4dc89 100644 --- a/sys/dev/iicbus/iicoc.c +++ b/sys/dev/iicbus/iicoc.c @@ -229,6 +229,7 @@ static int iicoc_detach(device_t dev) { bus_generic_detach(dev); + device_delete_children(dev); return (0); } diff --git a/sys/dev/iicbus/iicsmb.c b/sys/dev/iicbus/iicsmb.c index 27f1d2b05529..d8f35c6e3baf 100644 --- a/sys/dev/iicbus/iicsmb.c +++ b/sys/dev/iicbus/iicsmb.c @@ -167,11 +167,9 @@ static int iicsmb_detach(device_t dev) { struct iicsmb_softc *sc = (struct iicsmb_softc *)device_get_softc(dev); - + bus_generic_detach(dev); - if (sc->smbus) { - device_delete_child(dev, sc->smbus); - } + device_delete_children(dev); mtx_destroy(&sc->lock); return (0);