Why device driver unload can fail in Solaris?
at Sunday, June 01, 2008
This requires basic understanding of some driver development terminology like detach, dev_ops, _fini, mod_remove etc. During driver unload, __fini routine is called. This routine prepares the driver (i.e., the Kernel module) for unloading. If the module determines that it can be unloaded, then __fini routine returns the values from mod_remove.
The detach routine uninitializes the instances of the device. This is to be done prior to completing unload.The dev_ops is a structure used to specify device autoconfiguration entry points in the driver.
Under certain conditions on the Solaris OS, a device driver cannot be unloaded. What are those conditions?
- If a driver has no detach routine (
nodevis specified in the driver'sdev_ops(9S)for its detach routine). - If EBUSY is returned from the driver's
_fini()routine. - If the driver has a positive number of references to it.
- If the driver has a
bus_opsstructure specified in itsdev_opsstructure, and it has children attached to it (therefore it is a nexus driver). - If the driver has no
dev_opsat all!




