diff options
author | brooks <brooks@FreeBSD.org> | 2003-10-30 19:45:58 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2003-10-30 19:45:58 +0000 |
commit | 38e31120fcd40193d407e469c46607ecc302ab68 (patch) | |
tree | 7d01fdeb4d415c1bae5c7bd03a9a32e71d3a786d /sys | |
parent | 24760267308bc1cdadffe3933510627f1a8ebec9 (diff) | |
download | FreeBSD-src-38e31120fcd40193d407e469c46607ecc302ab68.zip FreeBSD-src-38e31120fcd40193d407e469c46607ecc302ab68.tar.gz |
There is no way to enter the attach routine twice with the same softc
without a detach call in between so don't try to deal with that
possiability.
This is a diff-reduction commit for the upcoming if_xname conversion.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/cm/smc90cx6.c | 40 | ||||
-rw-r--r-- | sys/dev/cs/if_cs.c | 134 | ||||
-rw-r--r-- | sys/dev/ed/if_ed.c | 84 | ||||
-rw-r--r-- | sys/dev/sbni/if_sbni.c | 36 | ||||
-rw-r--r-- | sys/dev/xe/if_xe.c | 30 | ||||
-rw-r--r-- | sys/i386/isa/if_rdp.c | 34 |
6 files changed, 173 insertions, 185 deletions
diff --git a/sys/dev/cm/smc90cx6.c b/sys/dev/cm/smc90cx6.c index 82f4ea7..ff4bfe9 100644 --- a/sys/dev/cm/smc90cx6.c +++ b/sys/dev/cm/smc90cx6.c @@ -312,34 +312,32 @@ cm_attach(sc, unit) */ cm_stop(sc); - if (!ifp->if_name) { - ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "cm"; - ifp->if_output = arc_output; - ifp->if_start = cm_start; - ifp->if_ioctl = cm_ioctl; - ifp->if_watchdog = cm_watchdog; - ifp->if_init = cm_init; - /* XXX IFQ_SET_READY(&ifp->if_snd); */ - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; - ifp->if_timer = 0; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; - - arc_ifattach(ifp, linkaddress); + ifp->if_softc = sc; + ifp->if_unit = unit; + ifp->if_name = "cm"; + ifp->if_output = arc_output; + ifp->if_start = cm_start; + ifp->if_ioctl = cm_ioctl; + ifp->if_watchdog = cm_watchdog; + ifp->if_init = cm_init; + /* XXX IFQ_SET_READY(&ifp->if_snd); */ + ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + ifp->if_timer = 0; + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; + + arc_ifattach(ifp, linkaddress); #ifdef CMSOFTCOPY - sc->sc_rxcookie = softintr_establish(IPL_SOFTNET, cm_srint, sc); - sc->sc_txcookie = softintr_establish(IPL_SOFTNET, - (void (*)(void *))cm_start, ifp); + sc->sc_rxcookie = softintr_establish(IPL_SOFTNET, cm_srint, sc); + sc->sc_txcookie = softintr_establish(IPL_SOFTNET, + (void (*)(void *))cm_start, ifp); #endif #if __FreeBSD_version < 500000 - callout_init(&sc->sc_recon_ch); + callout_init(&sc->sc_recon_ch); #else - callout_init(&sc->sc_recon_ch, 0); + callout_init(&sc->sc_recon_ch, 0); #endif - } if_printf(ifp, "link addr 0x%02x (%d)\n", linkaddress, linkaddress); return 0; diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c index f2892db..f09bb3d 100644 --- a/sys/dev/cs/if_cs.c +++ b/sys/dev/cs/if_cs.c @@ -582,85 +582,83 @@ cs_attach(struct cs_softc *sc, int unit, int flags) cs_stop( sc ); - if (!ifp->if_name) { - ifp->if_softc=sc; - ifp->if_unit=unit; - ifp->if_name="cs"; - ifp->if_output=ether_output; - ifp->if_start=cs_start; - ifp->if_ioctl=cs_ioctl; - ifp->if_watchdog=cs_watchdog; - ifp->if_init=cs_init; - ifp->if_snd.ifq_maxlen= IFQ_MAXLEN; - /* - * MIB DATA - */ - /* - ifp->if_linkmib=&sc->mibdata; - ifp->if_linkmiblen=sizeof sc->mibdata; - */ + ifp->if_softc=sc; + ifp->if_unit=unit; + ifp->if_name="cs"; + ifp->if_output=ether_output; + ifp->if_start=cs_start; + ifp->if_ioctl=cs_ioctl; + ifp->if_watchdog=cs_watchdog; + ifp->if_init=cs_init; + ifp->if_snd.ifq_maxlen= IFQ_MAXLEN; + /* + * MIB DATA + */ + /* + ifp->if_linkmib=&sc->mibdata; + ifp->if_linkmiblen=sizeof sc->mibdata; + */ - ifp->if_flags=(IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST ); + ifp->if_flags=(IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST ); - /* - * this code still in progress (DMA support) - * - - sc->recv_ring=malloc(CS_DMA_BUFFER_SIZE<<1, M_DEVBUF, M_NOWAIT); - if (sc->recv_ring == NULL) { - log(LOG_ERR,CS_NAME - "%d: Couldn't allocate memory for NIC\n", unit); - return(0); - } - if ((sc->recv_ring-(sc->recv_ring & 0x1FFFF)) - < (128*1024-CS_DMA_BUFFER_SIZE)) - sc->recv_ring+=16*1024; + /* + * this code still in progress (DMA support) + * + + sc->recv_ring=malloc(CS_DMA_BUFFER_SIZE<<1, M_DEVBUF, M_NOWAIT); + if (sc->recv_ring == NULL) { + log(LOG_ERR,CS_NAME + "%d: Couldn't allocate memory for NIC\n", unit); + return(0); + } + if ((sc->recv_ring-(sc->recv_ring & 0x1FFFF)) + < (128*1024-CS_DMA_BUFFER_SIZE)) + sc->recv_ring+=16*1024; - */ + */ - sc->buffer=malloc(ETHER_MAX_LEN-ETHER_CRC_LEN,M_DEVBUF,M_NOWAIT); - if (sc->buffer == NULL) { - if_printf(ifp, "Couldn't allocate memory for NIC\n"); - return(0); - } + sc->buffer=malloc(ETHER_MAX_LEN-ETHER_CRC_LEN,M_DEVBUF,M_NOWAIT); + if (sc->buffer == NULL) { + if_printf(ifp, "Couldn't allocate memory for NIC\n"); + return(0); + } - /* - * Initialize the media structures. - */ - ifmedia_init(&sc->media, 0, cs_mediachange, cs_mediastatus); - - if (sc->adapter_cnf & A_CNF_10B_T) { - ifmedia_add(&sc->media, IFM_ETHER|IFM_10_T, 0, NULL); - if (sc->chip_type != CS8900) { - ifmedia_add(&sc->media, - IFM_ETHER|IFM_10_T|IFM_FDX, 0, NULL); - ifmedia_add(&sc->media, - IFM_ETHER|IFM_10_T|IFM_HDX, 0, NULL); - } - } + /* + * Initialize the media structures. + */ + ifmedia_init(&sc->media, 0, cs_mediachange, cs_mediastatus); - if (sc->adapter_cnf & A_CNF_10B_2) - ifmedia_add(&sc->media, IFM_ETHER|IFM_10_2, 0, NULL); + if (sc->adapter_cnf & A_CNF_10B_T) { + ifmedia_add(&sc->media, IFM_ETHER|IFM_10_T, 0, NULL); + if (sc->chip_type != CS8900) { + ifmedia_add(&sc->media, + IFM_ETHER|IFM_10_T|IFM_FDX, 0, NULL); + ifmedia_add(&sc->media, + IFM_ETHER|IFM_10_T|IFM_HDX, 0, NULL); + } + } - if (sc->adapter_cnf & A_CNF_AUI) - ifmedia_add(&sc->media, IFM_ETHER|IFM_10_5, 0, NULL); + if (sc->adapter_cnf & A_CNF_10B_2) + ifmedia_add(&sc->media, IFM_ETHER|IFM_10_2, 0, NULL); - if (sc->adapter_cnf & A_CNF_MEDIA) - ifmedia_add(&sc->media, IFM_ETHER|IFM_AUTO, 0, NULL); + if (sc->adapter_cnf & A_CNF_AUI) + ifmedia_add(&sc->media, IFM_ETHER|IFM_10_5, 0, NULL); - /* Set default media from EEPROM */ - switch (sc->adapter_cnf & A_CNF_MEDIA_TYPE) { - case A_CNF_MEDIA_AUTO: media = IFM_ETHER|IFM_AUTO; break; - case A_CNF_MEDIA_10B_T: media = IFM_ETHER|IFM_10_T; break; - case A_CNF_MEDIA_10B_2: media = IFM_ETHER|IFM_10_2; break; - case A_CNF_MEDIA_AUI: media = IFM_ETHER|IFM_10_5; break; - default: if_printf(ifp, "adapter has no media\n"); - } - ifmedia_set(&sc->media, media); - cs_mediaset(sc, media); + if (sc->adapter_cnf & A_CNF_MEDIA) + ifmedia_add(&sc->media, IFM_ETHER|IFM_AUTO, 0, NULL); - ether_ifattach(ifp, sc->arpcom.ac_enaddr); + /* Set default media from EEPROM */ + switch (sc->adapter_cnf & A_CNF_MEDIA_TYPE) { + case A_CNF_MEDIA_AUTO: media = IFM_ETHER|IFM_AUTO; break; + case A_CNF_MEDIA_10B_T: media = IFM_ETHER|IFM_10_T; break; + case A_CNF_MEDIA_10B_2: media = IFM_ETHER|IFM_10_2; break; + case A_CNF_MEDIA_AUI: media = IFM_ETHER|IFM_10_5; break; + default: if_printf(ifp, "adapter has no media\n"); } + ifmedia_set(&sc->media, media); + cs_mediaset(sc, media); + + ether_ifattach(ifp, sc->arpcom.ac_enaddr); if (bootverbose) if_printf(ifp, "ethernet address %6D\n", diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c index 0f584aa..0c6a0f6 100644 --- a/sys/dev/ed/if_ed.c +++ b/sys/dev/ed/if_ed.c @@ -1713,51 +1713,49 @@ ed_attach(sc, unit, flags) */ ed_stop(sc); - if (!ifp->if_name) { - /* - * Initialize ifnet structure - */ - ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "ed"; - ifp->if_output = ether_output; - ifp->if_start = ed_start; - ifp->if_ioctl = ed_ioctl; - ifp->if_watchdog = ed_watchdog; - ifp->if_init = ed_init; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; - ifp->if_linkmib = &sc->mibdata; - ifp->if_linkmiblen = sizeof sc->mibdata; - /* - * XXX - should do a better job. - */ - if (sc->chip_type == ED_CHIP_TYPE_WD790) - sc->mibdata.dot3StatsEtherChipSet = - DOT3CHIPSET(dot3VendorWesternDigital, - dot3ChipSetWesternDigital83C790); - else - sc->mibdata.dot3StatsEtherChipSet = - DOT3CHIPSET(dot3VendorNational, - dot3ChipSetNational8390); - sc->mibdata.dot3Compliance = DOT3COMPLIANCE_COLLS; + /* + * Initialize ifnet structure + */ + ifp->if_softc = sc; + ifp->if_unit = unit; + ifp->if_name = "ed"; + ifp->if_output = ether_output; + ifp->if_start = ed_start; + ifp->if_ioctl = ed_ioctl; + ifp->if_watchdog = ed_watchdog; + ifp->if_init = ed_init; + ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + ifp->if_linkmib = &sc->mibdata; + ifp->if_linkmiblen = sizeof sc->mibdata; + /* + * XXX - should do a better job. + */ + if (sc->chip_type == ED_CHIP_TYPE_WD790) + sc->mibdata.dot3StatsEtherChipSet = + DOT3CHIPSET(dot3VendorWesternDigital, + dot3ChipSetWesternDigital83C790); + else + sc->mibdata.dot3StatsEtherChipSet = + DOT3CHIPSET(dot3VendorNational, + dot3ChipSetNational8390); + sc->mibdata.dot3Compliance = DOT3COMPLIANCE_COLLS; - /* - * Set default state for ALTPHYS flag (used to disable the - * tranceiver for AUI operation), based on compile-time - * config option. - */ - if (flags & ED_FLAGS_DISABLE_TRANCEIVER) - ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | - IFF_MULTICAST | IFF_ALTPHYS); - else - ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | - IFF_MULTICAST); + /* + * Set default state for ALTPHYS flag (used to disable the + * tranceiver for AUI operation), based on compile-time + * config option. + */ + if (flags & ED_FLAGS_DISABLE_TRANCEIVER) + ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | + IFF_MULTICAST | IFF_ALTPHYS); + else + ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | + IFF_MULTICAST); - /* - * Attach the interface - */ - ether_ifattach(ifp, sc->arpcom.ac_enaddr); - } + /* + * Attach the interface + */ + ether_ifattach(ifp, sc->arpcom.ac_enaddr); /* device attach does transition from UNCONFIGURED to IDLE state */ /* diff --git a/sys/dev/sbni/if_sbni.c b/sys/dev/sbni/if_sbni.c index d932a68..1697a41 100644 --- a/sys/dev/sbni/if_sbni.c +++ b/sys/dev/sbni/if_sbni.c @@ -226,26 +226,24 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags) set_initial_values(sc, flags); callout_handle_init(&sc->wch); - if (!ifp->if_name) { - /* Initialize ifnet structure */ - ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "sbni"; - ifp->if_init = sbni_init; - ifp->if_start = sbni_start; - ifp->if_output = ether_output; - ifp->if_ioctl = sbni_ioctl; - ifp->if_watchdog = sbni_watchdog; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; - - /* report real baud rate */ - csr0 = sbni_inb(sc, CSR0); - ifp->if_baudrate = - (csr0 & 0x01 ? 500000 : 2000000) / (1 << flags.rate); + /* Initialize ifnet structure */ + ifp->if_softc = sc; + ifp->if_unit = unit; + ifp->if_name = "sbni"; + ifp->if_init = sbni_init; + ifp->if_start = sbni_start; + ifp->if_output = ether_output; + ifp->if_ioctl = sbni_ioctl; + ifp->if_watchdog = sbni_watchdog; + ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + + /* report real baud rate */ + csr0 = sbni_inb(sc, CSR0); + ifp->if_baudrate = + (csr0 & 0x01 ? 500000 : 2000000) / (1 << flags.rate); - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ether_ifattach(ifp, sc->arpcom.ac_enaddr); - } + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + ether_ifattach(ifp, sc->arpcom.ac_enaddr); /* device attach does transition from UNCONFIGURED to IDLE state */ if_printf(ifp, "speed %ld, address %6D, rxl ", diff --git a/sys/dev/xe/if_xe.c b/sys/dev/xe/if_xe.c index 3a6175a..6158e7d 100644 --- a/sys/dev/xe/if_xe.c +++ b/sys/dev/xe/if_xe.c @@ -218,22 +218,20 @@ xe_attach (device_t dev) scp->autoneg_status = XE_AUTONEG_NONE; /* Initialise the ifnet structure */ - if (!scp->ifp->if_name) { - scp->ifp->if_softc = scp; - scp->ifp->if_name = "xe"; - scp->ifp->if_unit = device_get_unit(dev); - scp->ifp->if_timer = 0; - scp->ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); - scp->ifp->if_linkmib = &scp->mibdata; - scp->ifp->if_linkmiblen = sizeof scp->mibdata; - scp->ifp->if_output = ether_output; - scp->ifp->if_start = xe_start; - scp->ifp->if_ioctl = xe_ioctl; - scp->ifp->if_watchdog = xe_watchdog; - scp->ifp->if_init = xe_init; - scp->ifp->if_baudrate = 100000000; - scp->ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; - } + scp->ifp->if_softc = scp; + scp->ifp->if_name = "xe"; + scp->ifp->if_unit = device_get_unit(dev); + scp->ifp->if_timer = 0; + scp->ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); + scp->ifp->if_linkmib = &scp->mibdata; + scp->ifp->if_linkmiblen = sizeof scp->mibdata; + scp->ifp->if_output = ether_output; + scp->ifp->if_start = xe_start; + scp->ifp->if_ioctl = xe_ioctl; + scp->ifp->if_watchdog = xe_watchdog; + scp->ifp->if_init = xe_init; + scp->ifp->if_baudrate = 100000000; + scp->ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; /* Initialise the ifmedia structure */ ifmedia_init(scp->ifm, 0, xe_media_change, xe_media_status); diff --git a/sys/i386/isa/if_rdp.c b/sys/i386/isa/if_rdp.c index 0fda869..e9ba78a 100644 --- a/sys/i386/isa/if_rdp.c +++ b/sys/i386/isa/if_rdp.c @@ -591,25 +591,23 @@ rdp_attach(struct isa_device *isa_dev) */ rdp_stop(sc); - if (!ifp->if_name) { - /* - * Initialize ifnet structure - */ - ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "rdp"; - ifp->if_start = rdp_start; - ifp->if_ioctl = rdp_ioctl; - ifp->if_watchdog = rdp_watchdog; - ifp->if_init = rdp_init; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; + /* + * Initialize ifnet structure + */ + ifp->if_softc = sc; + ifp->if_unit = unit; + ifp->if_name = "rdp"; + ifp->if_start = rdp_start; + ifp->if_ioctl = rdp_ioctl; + ifp->if_watchdog = rdp_watchdog; + ifp->if_init = rdp_init; + ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; - /* - * Attach the interface - */ - ether_ifattach(ifp, sc->arpcom.ac_enaddr); - } + /* + * Attach the interface + */ + ether_ifattach(ifp, sc->arpcom.ac_enaddr); /* * Print additional info when attached |