The following example demonstrates the _fini(9E) routine.
int
_fini(void)
{
int error;
error = mod_remove(&modlinkage);
if (error != 0) {
return (error);
}
/*
* Cleanup resources allocated in _init()
*/
ddi_soft_state_fini(&xxstatep);
return (0);
}
Similarly, in _fini(), the driver should release any resources that were allocated in _init() and must remove itself from the system module list.
_fini() may be called when the driver is attached to hardware instances. In this case, mod_remove(9F) returns failure. Therefore, driver resources should not be released until mod_remove(9F) returns success.