Compaq AA-RNG2A-TE Network Card User Manual


 
struct el_softc *sc = el_softc[unit];
struct ifnet *ifp = &sc->is_if;
1 Declares as an argument a pointer to a bus data structure and a
controller data structure for this controller. The controller data
structure contains such information as the controller type, the controller
name, and the current status of the controller. This completely identifies
the adapter that is being unattached.
2 Declares a unit variable and initializes it to the controller number for
this controller. This controller number identifies the specific 3Com
3C5x9 controller that is being unattached. The controller number is
contained in the ctlr_num member of the controller data structure
for this device.
7.2 Verifying That the Interface Has Shut Down
The following code verifies that the interface is down. Make sure that other
errors returned by if_detach do not stop interface shutdown.
status = if_detach(ifp);
1
if (status == EBUSY) 2
return(status);
else if (status == ESUCCESS)
3
detachpfilter(sc->is_ed);
ifp->if_flags &= ~IFF_RUNNING;
4
1 Calls if_detach to remove this interface from the list of active
interfaces.
2 If the interface is still in use, it cannot be detached, so failure is
returned.
3 If the interface is not in use, detaches it from the list of those that the
packet filter monitors.
4 Marks the interface as no longer running.
7.3 Obtaining the Simple Lock and Shutting Down the
Device
The following code shows how the el_unattach( ) routine obtains the
simple lock, shuts down the device, and releases the simple lock:
s = splimp();
1
simple_lock(&sc->el_softc_lock); 2
el_shutdown(sc); 3
simple_unlock(&sc->el_softc_lock); 4
splx(s); 5
1 Calls the splimp( ) routine to mask all LAN hardware interrupts.
Upon successful completion, splimp( ) stores an integer value in the
72 Implementing the unattach Routine