7
Implementing the unattach Routine
The el_unattach( ) routine is called to stop the device and to free memory
and other resources prior to unloading the driver or powering off the bus
to which the device is attached. The el_unattach( ) routine undoes
everything that was performed by the el_probe( ) and el_attach( )
routines.
______________________ Note _______________________
The PCMCIA bus does not support the el_unattach( ) routine.
The el_unattach( ) routine performs the following tasks:
• Verifies that the interface has shut down (Section 7.2)
• Obtains and releases the simple lock (Section 7.3)
• Disables the interrupt handler (Section 7.4)
• Terminates the autosense thread (Section 7.5)
• Unregisters the PCMCIA event callback routine (Section 7.6)
• Stops the polling process (Section 7.7)
• Unregisters the shutdown interface (Section 7.8)
• Terminates the simple lock (Section 7.9)
• Unregisters the card from the hardware management database
(Section 7.10)
• Frees data structures and resources used by the adapter (Section 7.11)
7.1 Setting Up the el_unattach Routine
The following code shows how to set up the el_unattach( ) routine:
static int el_unattach(struct bus *bus, 1
struct controller *ctlr)
{
int unit = ctlr->ctlr_num;
2
int s, status;
Implementing the unattach Routine 7–1