Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Remove more cruft left over from copying bits of oth...



details:   https://anonhg.NetBSD.org/src/rev/9902fa4d4cf4
branches:  trunk
changeset: 516204:9902fa4d4cf4
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Oct 18 15:09:15 2001 +0000

description:
Remove more cruft left over from copying bits of other drivers.

diffstat:

 sys/dev/ic/gem.c         |  40 ++++++++++++----------------------------
 sys/dev/ic/gemvar.h      |  14 ++------------
 sys/dev/pci/if_gem_pci.c |  14 ++++++--------
 3 files changed, 20 insertions(+), 48 deletions(-)

diffs (198 lines):

diff -r b2f19218c212 -r 9902fa4d4cf4 sys/dev/ic/gem.c
--- a/sys/dev/ic/gem.c  Thu Oct 18 14:50:17 2001 +0000
+++ b/sys/dev/ic/gem.c  Thu Oct 18 15:09:15 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gem.c,v 1.5 2001/10/18 06:28:17 thorpej Exp $ */
+/*     $NetBSD: gem.c,v 1.6 2001/10/18 15:09:15 thorpej Exp $ */
 
 /*
  * 
@@ -108,8 +108,6 @@
 int            gem_tint __P((struct gem_softc *));
 void           gem_power __P((int, void *));
 
-static int     ether_cmp __P((u_char *, u_char *));
-
 /* Default buffer copy routines */
 void   gem_copytobuf_contig __P((struct gem_softc *, void *, int, int));
 void   gem_copyfrombuf_contig __P((struct gem_softc *, void *, int, int));
@@ -125,13 +123,14 @@
 
 
 /*
- * gem_config:
+ * gem_attach:
  *
  *     Attach a Gem interface to the system.
  */
 void
-gem_config(sc)
+gem_attach(sc, enaddr)
        struct gem_softc *sc;
+       const uint8_t *enaddr;
 {
        struct ifnet *ifp = &sc->sc_ethercom.ec_if;
        struct mii_data *mii = &sc->sc_mii;
@@ -224,7 +223,7 @@
 
        /* Announce ourselves. */
        printf("%s: Ethernet address %s\n", sc->sc_dev.dv_xname,
-           ether_sprintf(sc->sc_enaddr));
+           ether_sprintf(enaddr));
 
        /* Initialize ifnet structure. */
        strcpy(ifp->if_xname, sc->sc_dev.dv_xname);
@@ -314,7 +313,7 @@
 
        /* Attach the interface. */
        if_attach(ifp);
-       ether_ifattach(ifp, sc->sc_enaddr);
+       ether_ifattach(ifp, enaddr);
 
        sc->sc_sh = shutdownhook_establish(gem_shutdown, sc);
        if (sc->sc_sh == NULL)
@@ -823,22 +822,6 @@
        return (0);
 }
 
-/*
- * Compare two Ether/802 addresses for equality, inlined and unrolled for
- * speed.
- */
-static __inline__ int
-ether_cmp(a, b)
-       u_char *a, *b;
-{       
-        
-       if (a[5] != b[5] || a[4] != b[4] || a[3] != b[3] ||
-           a[2] != b[2] || a[1] != b[1] || a[0] != b[0])
-               return (0);
-       return (1);
-}
-
-
 void
 gem_init_regs(struct gem_softc *sc)
 {
@@ -865,7 +848,8 @@
                /* Dunno.... */
                bus_space_write_4(t, h, GEM_MAC_CONTROL_TYPE, 0x8088);
                bus_space_write_4(t, h, GEM_MAC_RANDOM_SEED,
-                       ((sc->sc_enaddr[5]<<8)|sc->sc_enaddr[4])&0x3ff);
+                       ((LLADDR(ifp->if_sadl)[5]<<8)|
+                        LLADDR(ifp->if_sadl)[4])&0x3ff);
                /* Secondary MAC addr set to 0:0:0:0:0:0 */
                bus_space_write_4(t, h, GEM_MAC_ADDR3, 0);
                bus_space_write_4(t, h, GEM_MAC_ADDR4, 0);
@@ -910,11 +894,11 @@
         * Set the station address.
         */
        bus_space_write_4(t, h, GEM_MAC_ADDR0, 
-               (sc->sc_enaddr[4]<<8) | sc->sc_enaddr[5]);
+               (LLADDR(ifp->if_sadl)[4]<<8) | LLADDR(ifp->if_sadl)[5]);
        bus_space_write_4(t, h, GEM_MAC_ADDR1, 
-               (sc->sc_enaddr[2]<<8) | sc->sc_enaddr[3]);
+               (LLADDR(ifp->if_sadl)[2]<<8) | LLADDR(ifp->if_sadl)[3]);
        bus_space_write_4(t, h, GEM_MAC_ADDR2, 
-               (sc->sc_enaddr[0]<<8) | sc->sc_enaddr[1]);
+               (LLADDR(ifp->if_sadl)[0]<<8) | LLADDR(ifp->if_sadl)[1]);
 
 }
 
@@ -1807,7 +1791,7 @@
 
        ETHER_FIRST_MULTI(step, ec, enm);
        while (enm != NULL) {
-               if (ether_cmp(enm->enm_addrlo, enm->enm_addrhi)) {
+               if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
                        /*
                         * We must listen to a range of multicast addresses.
                         * For now, just accept all multicasts, rather than
diff -r b2f19218c212 -r 9902fa4d4cf4 sys/dev/ic/gemvar.h
--- a/sys/dev/ic/gemvar.h       Thu Oct 18 14:50:17 2001 +0000
+++ b/sys/dev/ic/gemvar.h       Thu Oct 18 15:09:15 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gemvar.h,v 1.3 2001/10/18 06:28:17 thorpej Exp $ */
+/*     $NetBSD: gemvar.h,v 1.4 2001/10/18 15:09:15 thorpej Exp $ */
 
 /*
  * 
@@ -202,7 +202,6 @@
        int                     sc_inited;
        int                     sc_debug;
        void                    *sc_sh;         /* shutdownhook cookie */
-       u_int8_t                sc_enaddr[ETHER_ADDR_LEN]; /* MAC address */
 
        /* Special hardware hooks */
        void    (*sc_hwreset) __P((struct gem_softc *));
@@ -283,22 +282,13 @@
 } while (0)
 
 #ifdef _KERNEL
-void   gem_attach __P((struct gem_softc *, const u_int8_t *));
-int    gem_activate __P((struct device *, enum devact));
-int    gem_detach __P((struct gem_softc *));
+void   gem_attach __P((struct gem_softc *, const uint8_t *));
 int    gem_intr __P((void *));
-int    gem_read_srom __P((struct gem_softc *));
-int    gem_srom_crcok __P((const u_int8_t *));
-int    gem_isv_srom __P((const u_int8_t *));
-int    gem_isv_srom_enaddr __P((struct gem_softc *, u_int8_t *));
-int    gem_parse_old_srom __P((struct gem_softc *, u_int8_t *));
 
 int    gem_mediachange __P((struct ifnet *));
 void   gem_mediastatus __P((struct ifnet *, struct ifmediareq *));
 
-void   gem_config __P((struct gem_softc *));
 void   gem_reset __P((struct gem_softc *));
-int    gem_intr __P((void *));
 #endif /* _KERNEL */
 
 
diff -r b2f19218c212 -r 9902fa4d4cf4 sys/dev/pci/if_gem_pci.c
--- a/sys/dev/pci/if_gem_pci.c  Thu Oct 18 14:50:17 2001 +0000
+++ b/sys/dev/pci/if_gem_pci.c  Thu Oct 18 15:09:15 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_gem_pci.c,v 1.6 2001/10/18 06:28:18 thorpej Exp $ */
+/*     $NetBSD: if_gem_pci.c,v 1.7 2001/10/18 15:09:15 thorpej Exp $ */
 
 /*
  * 
@@ -122,6 +122,7 @@
        pci_intr_handle_t ih;
        const char *intrstr;
        char devinfo[256];
+       uint8_t enaddr[ETHER_ADDR_LEN];
 
        pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
        printf(": %s (rev. 0x%02x)\n", devinfo, PCI_REVISION(pa->pa_class));
@@ -149,7 +150,7 @@
 #ifdef __sparc__
        {
                extern void myetheraddr __P((u_char *));
-               myetheraddr(sc->sc_enaddr);
+               myetheraddr(enaddr);
        }
 #endif /* __sparc__ */
 #ifdef macppc
@@ -163,8 +164,7 @@
                        return;
                }
 
-               OF_getprop(node, "local-mac-address", sc->sc_enaddr,
-                   sizeof(sc->sc_enaddr));
+               OF_getprop(node, "local-mac-address", enaddr, sizeof(enaddr));
        }
 #endif /* macppc */
 
@@ -184,8 +184,6 @@
        }
        printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
 
-       /*
-        * call the main configure
-        */
-       gem_config(sc);
+       /* Finish off the attach. */
+       gem_attach(sc, enaddr);
 }



Home | Main Index | Thread Index | Old Index