Source-Changes-HG archive

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

[src/trunk]: src/sys Simplify MII structure initialization and reference. No ...



details:   https://anonhg.NetBSD.org/src/rev/1f0b8632f49d
branches:  trunk
changeset: 451659:1f0b8632f49d
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu May 30 02:32:17 2019 +0000

description:
Simplify MII structure initialization and reference. No functional change.

diffstat:

 sys/arch/arm/ep93xx/epe.c        |  23 ++++++++++++-----------
 sys/arch/arm/omap/omapl1x_emac.c |  30 ++++++++++++++----------------
 sys/arch/sgimips/mace/if_mec.c   |  29 ++++++++++++++---------------
 sys/dev/ic/lan9118.c             |  25 +++++++++++++------------
 sys/dev/ic/mtd803.c              |  24 ++++++++++++------------
 sys/dev/ic/rtl8169.c             |  21 +++++++++++----------
 sys/dev/ic/smc91cxx.c            |  27 ++++++++++++++-------------
 sys/dev/pci/if_bce.c             |  28 ++++++++++++++--------------
 sys/dev/pci/if_lii.c             |  22 +++++++++++-----------
 sys/dev/pci/if_sk.c              |  35 +++++++++++++++++------------------
 10 files changed, 132 insertions(+), 132 deletions(-)

diffs (truncated from 608 to 300 lines):

diff -r 3a904bccc7d4 -r 1f0b8632f49d sys/arch/arm/ep93xx/epe.c
--- a/sys/arch/arm/ep93xx/epe.c Thu May 30 01:20:41 2019 +0000
+++ b/sys/arch/arm/ep93xx/epe.c Thu May 30 02:32:17 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: epe.c,v 1.43 2019/05/28 07:41:46 msaitoh Exp $ */
+/*     $NetBSD: epe.c,v 1.44 2019/05/30 02:32:17 msaitoh Exp $ */
 
 /*
  * Copyright (c) 2004 Jesse Off
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: epe.c,v 1.43 2019/05/28 07:41:46 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: epe.c,v 1.44 2019/05/30 02:32:17 msaitoh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -284,6 +284,7 @@
        char *addr;
        int rsegs, err, i;
        struct ifnet * ifp = &sc->sc_ec.ec_if;
+       struct mii_data *mii = &sc->sc_mii;
        int mdcdiv = DEFAULT_MDCDIV;
 
        callout_init(&sc->epe_tick_ch, 0);
@@ -396,16 +397,16 @@
                mdcdiv = device_cfdata(sc->sc_dev)->cf_flags;
        EPE_WRITE(SelfCtl, (SelfCtl_MDCDIV(mdcdiv) | SelfCtl_PSPRS));
 
-       sc->sc_mii.mii_ifp = ifp;
-       sc->sc_mii.mii_readreg = epe_mii_readreg;
-       sc->sc_mii.mii_writereg = epe_mii_writereg;
-       sc->sc_mii.mii_statchg = epe_statchg;
-       sc->sc_ec.ec_mii = &sc->sc_mii;
-       ifmedia_init(&sc->sc_mii.mii_media, IFM_IMASK, epe_mediachange,
+       mii->mii_ifp = ifp;
+       mii->mii_readreg = epe_mii_readreg;
+       mii->mii_writereg = epe_mii_writereg;
+       mii->mii_statchg = epe_statchg;
+       sc->sc_ec.ec_mii = mii;
+       ifmedia_init(&mii->mii_media, IFM_IMASK, epe_mediachange,
                ether_mediastatus);
-       mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
-               MII_OFFSET_ANY, 0);
-       ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER | IFM_AUTO);
+       mii_attach(sc->sc_dev, mii, 0xffffffff, MII_PHY_ANY,
+           MII_OFFSET_ANY, 0);
+       ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
 
        EPE_WRITE(BMCtl, BMCtl_RxEn | BMCtl_TxEn);
        EPE_WRITE(IntEn, IntEn_REOFIE);
diff -r 3a904bccc7d4 -r 1f0b8632f49d sys/arch/arm/omap/omapl1x_emac.c
--- a/sys/arch/arm/omap/omapl1x_emac.c  Thu May 30 01:20:41 2019 +0000
+++ b/sys/arch/arm/omap/omapl1x_emac.c  Thu May 30 02:32:17 2019 +0000
@@ -30,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: omapl1x_emac.c,v 1.10 2019/05/29 06:21:56 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omapl1x_emac.c,v 1.11 2019/05/30 02:32:17 msaitoh Exp $");
 
 #include "opt_omapl1x.h"
 
@@ -1197,6 +1197,7 @@
 {
        struct emac_softc * const sc = device_private(self);
        struct ifnet * const ifp = &sc->sc_if;
+       struct mii_data *mii = &sc->sc_mii;
        struct tipb_attach_args *tipb = aux;
        const char * const xname = device_xname(self);
        prop_dictionary_t dict = device_properties(self);
@@ -1320,26 +1321,23 @@
        }
 
        /* mii related stuff */
-       sc->sc_mii.mii_ifp = ifp;
-       sc->sc_mii.mii_readreg = emac_mii_readreg;
-       sc->sc_mii.mii_writereg = emac_mii_writereg;
-       sc->sc_mii.mii_statchg = emac_mii_statchg;
-       sc->sc_ec.ec_mii = &sc->sc_mii;
+       mii->mii_ifp = ifp;
+       mii->mii_readreg = emac_mii_readreg;
+       mii->mii_writereg = emac_mii_writereg;
+       mii->mii_statchg = emac_mii_statchg;
+       sc->sc_ec.ec_mii = mii;
 
        EMAC_WRITE(sc, MACMDIOCONTROL, __BIT(30) | __BIT(18) |
                   EMAC_MDIO_CLKDIV);
 
-       ifmedia_init(&sc->sc_mii.mii_media, 0, ether_mediachange,
-           ether_mediastatus);
-       mii_attach(self, &sc->sc_mii, 0xffffffff, MII_PHY_ANY, 0, 0);
-       if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
+       ifmedia_init(&mii->mii_media, 0, ether_mediachange, ether_mediastatus);
+       mii_attach(self, mii, 0xffffffff, MII_PHY_ANY, 0, 0);
+       if (LIST_FIRST(&mii->mii_phys) == NULL) {
                aprint_error_dev(self, "no PHY found!\n");
-               ifmedia_add(&sc->sc_mii.mii_media,
-                   IFM_ETHER | IFM_MANUAL, 0, NULL);
-               ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER | IFM_MANUAL);
-       } else {
-               ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER | IFM_AUTO);
-       }
+               ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_MANUAL, 0, NULL);
+               ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_MANUAL);
+       } else
+               ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
 
        strlcpy(ifp->if_xname, xname, IFNAMSIZ);
        ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
diff -r 3a904bccc7d4 -r 1f0b8632f49d sys/arch/sgimips/mace/if_mec.c
--- a/sys/arch/sgimips/mace/if_mec.c    Thu May 30 01:20:41 2019 +0000
+++ b/sys/arch/sgimips/mace/if_mec.c    Thu May 30 02:32:17 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_mec.c,v 1.60 2019/05/28 07:41:48 msaitoh Exp $ */
+/* $NetBSD: if_mec.c,v 1.61 2019/05/30 02:32:17 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2004, 2008 Izumi Tsutsui.  All rights reserved.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mec.c,v 1.60 2019/05/28 07:41:48 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mec.c,v 1.61 2019/05/30 02:32:17 msaitoh Exp $");
 
 #include "opt_ddb.h"
 
@@ -430,6 +430,7 @@
        struct mec_softc *sc = device_private(self);
        struct mace_attach_args *maa = aux;
        struct ifnet *ifp = &sc->sc_ethercom.ec_if;
+       struct mii_data *mii = &sc->sc_mii;
        uint64_t address, command;
        const char *macaddr;
        struct mii_softc *child;
@@ -572,26 +573,24 @@
 
        /* Done, now attach everything */
 
-       sc->sc_mii.mii_ifp = ifp;
-       sc->sc_mii.mii_readreg = mec_mii_readreg;
-       sc->sc_mii.mii_writereg = mec_mii_writereg;
-       sc->sc_mii.mii_statchg = mec_statchg;
+       mii->mii_ifp = ifp;
+       mii->mii_readreg = mec_mii_readreg;
+       mii->mii_writereg = mec_mii_writereg;
+       mii->mii_statchg = mec_statchg;
 
        /* Set up PHY properties */
-       sc->sc_ethercom.ec_mii = &sc->sc_mii;
-       ifmedia_init(&sc->sc_mii.mii_media, 0, ether_mediachange,
-           ether_mediastatus);
-       mii_attach(self, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
-           MII_OFFSET_ANY, 0);
+       sc->sc_ethercom.ec_mii = mii;
+       ifmedia_init(&mii->mii_media, 0, ether_mediachange, ether_mediastatus);
+       mii_attach(self, mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, 0);
 
-       child = LIST_FIRST(&sc->sc_mii.mii_phys);
+       child = LIST_FIRST(&mii->mii_phys);
        if (child == NULL) {
                /* No PHY attached */
-               ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER | IFM_MANUAL,
+               ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_MANUAL,
                    0, NULL);
-               ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER | IFM_MANUAL);
+               ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_MANUAL);
        } else {
-               ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER | IFM_AUTO);
+               ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
                sc->sc_phyaddr = child->mii_phy;
        }
 
diff -r 3a904bccc7d4 -r 1f0b8632f49d sys/dev/ic/lan9118.c
--- a/sys/dev/ic/lan9118.c      Thu May 30 01:20:41 2019 +0000
+++ b/sys/dev/ic/lan9118.c      Thu May 30 02:32:17 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lan9118.c,v 1.34 2019/05/28 07:41:48 msaitoh Exp $     */
+/*     $NetBSD: lan9118.c,v 1.35 2019/05/30 02:32:18 msaitoh Exp $     */
 /*
  * Copyright (c) 2008 KIYOHARA Takashi
  * All rights reserved.
@@ -25,7 +25,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lan9118.c,v 1.34 2019/05/28 07:41:48 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lan9118.c,v 1.35 2019/05/30 02:32:18 msaitoh Exp $");
 
 /*
  * The LAN9118 Family
@@ -156,6 +156,7 @@
 lan9118_attach(struct lan9118_softc *sc)
 {
        struct ifnet *ifp = &sc->sc_ec.ec_if;
+       struct mii_data *mii = &sc->sc_mii;
        uint32_t val, irq_cfg;
        int timo, i;
 
@@ -232,19 +233,19 @@
        sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_MTU;
 #endif
 
-       sc->sc_ec.ec_mii = &sc->sc_mii;
-       ifmedia_init(&sc->sc_mii.mii_media, 0,
+       sc->sc_ec.ec_mii = mii;
+       ifmedia_init(&mii->mii_media, 0,
            lan9118_ifm_change, lan9118_ifm_status);
-       sc->sc_mii.mii_ifp = ifp;
-       sc->sc_mii.mii_readreg = lan9118_miibus_readreg;
-       sc->sc_mii.mii_writereg = lan9118_miibus_writereg;
-       sc->sc_mii.mii_statchg = lan9118_miibus_statchg;
+       mii->mii_ifp = ifp;
+       mii->mii_readreg = lan9118_miibus_readreg;
+       mii->mii_writereg = lan9118_miibus_writereg;
+       mii->mii_statchg = lan9118_miibus_statchg;
 
        /*
         * Number of instance of Internal PHY is always 0.  External PHY
         * number that above.
         */
-       mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, 1, MII_OFFSET_ANY, 0);
+       mii_attach(sc->sc_dev, mii, 0xffffffff, 1, MII_OFFSET_ANY, 0);
 
        if (sc->sc_id == LAN9118_ID_9115 || sc->sc_id == LAN9118_ID_9117 ||
            sc->sc_id == LAN9218_ID_9215 || sc->sc_id == LAN9218_ID_9217) {
@@ -271,15 +272,15 @@
                        delay(1);       /* Once wait more 5 cycle */
 
                        /* Call mii_attach, avoid at phy1. */
-                       mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff,
+                       mii_attach(sc->sc_dev, mii, 0xffffffff,
                            0, MII_OFFSET_ANY, 0);
                        for (i = 2; i < MII_NPHY; i++)
-                               mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff,
+                               mii_attach(sc->sc_dev, mii, 0xffffffff,
                                    i, MII_OFFSET_ANY, 0);
                }
        }
 
-       ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER | IFM_AUTO);
+       ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
 
        /* Attach the interface. */
        if_attach(ifp);
diff -r 3a904bccc7d4 -r 1f0b8632f49d sys/dev/ic/mtd803.c
--- a/sys/dev/ic/mtd803.c       Thu May 30 01:20:41 2019 +0000
+++ b/sys/dev/ic/mtd803.c       Thu May 30 02:32:17 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mtd803.c,v 1.39 2019/05/28 07:41:48 msaitoh Exp $ */
+/* $NetBSD: mtd803.c,v 1.40 2019/05/30 02:32:18 msaitoh Exp $ */
 
 /*-
  *
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mtd803.c,v 1.39 2019/05/28 07:41:48 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mtd803.c,v 1.40 2019/05/30 02:32:18 msaitoh Exp $");
 
 
 #include <sys/param.h>
@@ -130,6 +130,7 @@
 mtd_config(struct mtd_softc *sc)
 {
        struct ifnet *ifp = &sc->ethercom.ec_if;
+       struct mii_data *mii = &sc->mii;
        int i;
 
        /* Read station address */
@@ -148,22 +149,21 @@
        IFQ_SET_READY(&ifp->if_snd);
 
        /* Setup MII interface */
-       sc->mii.mii_ifp = ifp;
-       sc->mii.mii_readreg = mtd_mii_readreg;
-       sc->mii.mii_writereg = mtd_mii_writereg;
-       sc->mii.mii_statchg = mtd_mii_statchg;
+       mii->mii_ifp = ifp;
+       mii->mii_readreg = mtd_mii_readreg;
+       mii->mii_writereg = mtd_mii_writereg;
+       mii->mii_statchg = mtd_mii_statchg;
 
-       sc->ethercom.ec_mii = &sc->mii;
-       ifmedia_init(&sc->mii.mii_media, 0, ether_mediachange,
-           ether_mediastatus);
+       sc->ethercom.ec_mii = mii;
+       ifmedia_init(&mii->mii_media, 0, ether_mediachange, ether_mediastatus);
 
-       mii_attach(sc->dev, &sc->mii, 0xffffffff, MII_PHY_ANY, 0, 0);
+       mii_attach(sc->dev, mii, 0xffffffff, MII_PHY_ANY, 0, 0);
 
-       if (LIST_FIRST(&sc->mii.mii_phys) == NULL) {
+       if (LIST_FIRST(&mii->mii_phys) == NULL) {
                aprint_error_dev(sc->dev, "Unable to configure MII\n");
                return 1;
        } else



Home | Main Index | Thread Index | Old Index