NAME | SYNOPSIS | INTERFACE LEVEL | PARAMETERS | DESCRIPTION | RETURN VALUES | CONTEXT | SEE ALSO
#include <sys/ddi.h> #include <sys/sunddi.h>intprefixdetach(dev_info_t *dip, ddi_detach_cmd_t cmd);
Solaris DDI specific (Solaris DDI). This entry point is required. If it is nodev, the device will not support suspend/resume or power management. See cpr(7), pm(7), and pm(9E).
A pointer to the device's dev_info structure.
Type of detach; the driver should return DDI_FAILURE if any value other than DDI_DETACH, DDI_PM_SUSPEND, or DDI_SUSPEND is passed to it.
The detach() function is the complement of the attach(9E) routine.
If cmd is set to DDI_DETACH, detach() is used to remove the state associated with a given instance of a device node prior to the removal of that instance from the system.
The detach() function will be called once for each instance of the device for which there has been a successful attach() once there are no longer any opens on the device. An attached instance of a driver will only be successfully detached once. The detach() function should clean up any per instance data initialized in attach(9E) and call kmem_free(9F) to free any heap allocations. For information on how to unregister interrupt handlers see ddi_add_intr(9F). This should also include putting the underlying device into a quiescent state so that it will not generate interrupts.
Drivers that set up timeout(9F) routines should ensure that they are cancelled before returning DDI_SUCCESS from detach().
If detach() determines a particular instance of the device cannot be removed when requested because of some exceptional condition, detach() must return DDI_FAILURE, which prevents the particular device instance from being detached. This will also prevent the driver from being unloaded. A driver instance failing the detach must ensure that no per instance data or state is modified or freed that would compromise the system or subsequent driver operation.
The system guarantees that the function will only be called for a particular dev_info node after (and not concurrently with) a successful attach(9E) of that device. The system also guarantees that detach() will only be called when there are no outstanding open(9E) calls on the device.
If cmd is set to DDI_PM_SUSPEND detach() is used to suspend all activity of a device before power is (possibly) removed from the device. In this case, detach() may be called with outstanding open(9E) requests. It must save the hardware state of the device to memory and block incoming or existing requests until attach(9E) is called with a command value of DDI_PM_RESUME. When the driver receives a request, it should call ddi_dev_is_needed(9F) to request to the framework that the device be resumed.
The DDI_PM_SUSPEND cmd is issued when the device is being suspended prior to setting component 0 of the device to power level 0. See pm(7) and power(9E). A return of DDI_FAILURE will result in component 0 of the device not being set to power level 0.
If cmd is set to DDI_SUSPEND, detach() is used to suspend all activity of a device before power is (possibly) removed from the device. In this case, detach() may be called with outstanding open(9E) requests. It must save the hardware state of the device to memory and block incoming or existing requests until attach() is called with DDI_RESUME.
The DDI_SUSPEND cmd is issued when the entire system is being suspended and power removed from it or when the system must be made quiescent. It will be issued only to devices which have a reg property or which export a pm-hardware-state property with the value needs-suspend-resume.
If the device is used to store file systems, then after DDI_SUSPEND is issued, the device should still honor dump(9E) requests (calling ddi_dev_is_needed(9F) if the device has also been suspended with DDI_PM_SUSPEND), as this entry point may be used by cpr(7) to save the system state. It must do this, however, without disturbing the saved hardware state of the device.
Before returning successfully from a call to detach() with a command of DDI_SUSPEND, the driver must cancel any outstanding timeouts and make any driver threads quiescent.
If DDI_FAILURE is returned for the DDI_SUSPEND cmd, either the operation to suspend the system or to make it quiescent will be aborted.
For DDI_DETACH, the state associated with the given device was successfully removed. For DDI_SUSPEND and DDI_PM_SUSPEND, the driver was successfully suspended.
The operation failed or the request was not understood. The associated state is unchanged.
This function is called from user context only.
cpr(7), pm(7), attach(9E), dump(9E), open(9E), pm(9E), power(9E), ddi_add_intr(9F), ddi_dev_is_needed(9F), ddi_map_regs(9F), kmem_free(9F), timeout(9F)
NAME | SYNOPSIS | INTERFACE LEVEL | PARAMETERS | DESCRIPTION | RETURN VALUES | CONTEXT | SEE ALSO