Compaq AA-RNG2A-TE Network Card User Manual


 
if (el_softc[unit]) { 1
sc = el_softc[unit];
sc->cardout = 0;
sc->reprobe = 1;
} else {
2
MALLOC(sc, void*, sizeof(struct el_softc), M_DEVBUF, M_WAIT | M_ZERO);
if (!sc) {
3
printf("el%d: el_probe: failed to get buffer memory for softc\n",
unit);
return(0);
4
}
1 If the user removed and returned the PCMCIA card to its slot:
Locates the existing el_softc data structure for this device. The
controller number (which is stored in the unit variable) is used as
an index into the array of el_softc data structures to determine
which el_softc data structure is associated with this 3Com 3C5x9
device.
Sets the cardout member of the el_softc data structure to the
value 0 (zero) to indicate that the PCMCIA card is not currently
removed from its slot.
Sets the reprobe member of the el_softc data structure to the
value 1 to indicate that the PCMCIA card was reinserted into its slot.
2 If this is an ISA device or if the user did not remove and replace the
card, calls the MALLOC macro to allocate memory for the el_softc
data structure.
3 If MALLOC could not allocate the memory, calls the printf( ) routine to
display an appropriate message on the console terminal. The printf( )
routine also displays the controller number for the device.
4 Returns the value 0 (zero) to the bus configuration code to indicate
that the probe operation failed.
5.1.5 Allocating the ether_driver Data Structure
The following code shows how the el_probe( ) routine calls if_alloc( )
to allocate the ether_driver data structure for this device. if_alloc()
returns an ether_driver data structure, which contains the ifnet data
structure, and initializes the if_name, if_unit, and if_index fields.
Make sure that your driver allocates its ether_driver data structure in
the same way.
sc->is_ed = if_alloc("el", unit, sizeof(struct ether_driver));
1
CLEAR_LAN_COUNTERS(sc->is_ed); 2
1 Calls a routine that returns an ether_driver data structure and
initializes the ifnet portion of it.
Implementing the Autoconfiguration Support Section (probe) 57