Index: sys/dev/iicbus/iiconf.c =================================================================== --- sys/dev/iicbus/iiconf.c +++ sys/dev/iicbus/iiconf.c @@ -128,6 +128,12 @@ ++sc->owncount; if (sc->owner == NULL) { sc->owner = dev; + /* + * Mark the device busy while it owns the bus, to + * prevent detaching the device, bus, or hardware + * controller, until ownership is relinquished. + */ + device_busy(dev); /* * Drop the lock around the call to the bus driver, it * should be allowed to sleep in the IIC_WAIT case. @@ -177,6 +183,7 @@ IICBUS_LOCK(sc); sc->owner = NULL; wakeup_one(sc); + device_unbusy(dev); } IICBUS_UNLOCK(sc); return (0);