diff --git a/sys/arch/arm/ep93xx/epe.c b/sys/arch/arm/ep93xx/epe.c index 08c945389e6c..cfafc1fd288b 100644 --- a/sys/arch/arm/ep93xx/epe.c +++ b/sys/arch/arm/ep93xx/epe.c @@ -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 -__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 #include @@ -284,6 +284,7 @@ epe_init(struct epe_softc *sc) 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 @@ epe_init(struct epe_softc *sc) 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 --git a/sys/arch/arm/omap/omapl1x_emac.c b/sys/arch/arm/omap/omapl1x_emac.c index f2a781c3ebbf..6705c9f1c37c 100644 --- a/sys/arch/arm/omap/omapl1x_emac.c +++ b/sys/arch/arm/omap/omapl1x_emac.c @@ -30,7 +30,7 @@ #include -__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 @@ emac_attach (device_t parent, device_t self, void *aux) { 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 @@ emac_attach (device_t parent, device_t self, void *aux) } /* 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 --git a/sys/arch/sgimips/mace/if_mec.c b/sys/arch/sgimips/mace/if_mec.c index 27974443a202..e3b982b1eae9 100644 --- a/sys/arch/sgimips/mace/if_mec.c +++ b/sys/arch/sgimips/mace/if_mec.c @@ -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 -__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 @@ mec_attach(device_t parent, device_t self, void *aux) 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 @@ mec_attach(device_t parent, device_t self, void *aux) /* 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 --git a/sys/dev/ic/lan9118.c b/sys/dev/ic/lan9118.c index e20f0635b0cc..ca548b85b062 100644 --- a/sys/dev/ic/lan9118.c +++ b/sys/dev/ic/lan9118.c @@ -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 -__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 @@ int 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 @@ lan9118_attach(struct lan9118_softc *sc) 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 @@ lan9118_attach(struct lan9118_softc *sc) 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 --git a/sys/dev/ic/mtd803.c b/sys/dev/ic/mtd803.c index 6ebb69333ac9..2515f4406d7b 100644 --- a/sys/dev/ic/mtd803.c +++ b/sys/dev/ic/mtd803.c @@ -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 -__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 @@ -130,6 +130,7 @@ int 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 @@ mtd_config(struct mtd_softc *sc) 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 - ifmedia_set(&sc->mii.mii_media, IFM_ETHER | IFM_AUTO); + ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO); if (mtd_init_desc(sc)) return 1; diff --git a/sys/dev/ic/rtl8169.c b/sys/dev/ic/rtl8169.c index 890b679b6dfe..853a9b9f20cd 100644 --- a/sys/dev/ic/rtl8169.c +++ b/sys/dev/ic/rtl8169.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtl8169.c,v 1.158 2019/04/05 23:44:59 uwe Exp $ */ +/* $NetBSD: rtl8169.c,v 1.159 2019/05/30 02:32:18 msaitoh Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.158 2019/04/05 23:44:59 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.159 2019/05/30 02:32:18 msaitoh Exp $"); /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */ /* @@ -560,6 +560,7 @@ re_attach(struct rtk_softc *sc) { uint8_t eaddr[ETHER_ADDR_LEN]; struct ifnet *ifp; + struct mii_data *mii = &sc->mii; int error = 0, i; if ((sc->sc_quirk & RTKQ_8139CPLUS) == 0) { @@ -850,16 +851,16 @@ re_attach(struct rtk_softc *sc) callout_init(&sc->rtk_tick_ch, 0); /* Do MII setup */ - sc->mii.mii_ifp = ifp; - sc->mii.mii_readreg = re_miibus_readreg; - sc->mii.mii_writereg = re_miibus_writereg; - sc->mii.mii_statchg = re_miibus_statchg; - sc->ethercom.ec_mii = &sc->mii; - ifmedia_init(&sc->mii.mii_media, IFM_IMASK, ether_mediachange, + mii->mii_ifp = ifp; + mii->mii_readreg = re_miibus_readreg; + mii->mii_writereg = re_miibus_writereg; + mii->mii_statchg = re_miibus_statchg; + sc->ethercom.ec_mii = mii; + ifmedia_init(&mii->mii_media, IFM_IMASK, ether_mediachange, ether_mediastatus); - mii_attach(sc->sc_dev, &sc->mii, 0xffffffff, MII_PHY_ANY, + mii_attach(sc->sc_dev, mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, 0); - ifmedia_set(&sc->mii.mii_media, IFM_ETHER | IFM_AUTO); + ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO); /* * Call MI attach routine. diff --git a/sys/dev/ic/smc91cxx.c b/sys/dev/ic/smc91cxx.c index 5cfe522d9d20..b909248b2494 100644 --- a/sys/dev/ic/smc91cxx.c +++ b/sys/dev/ic/smc91cxx.c @@ -1,4 +1,4 @@ -/* $NetBSD: smc91cxx.c,v 1.101 2019/04/25 10:08:45 msaitoh Exp $ */ +/* $NetBSD: smc91cxx.c,v 1.102 2019/05/30 02:32:18 msaitoh Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.101 2019/04/25 10:08:45 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.102 2019/05/30 02:32:18 msaitoh Exp $"); #include "opt_inet.h" @@ -231,7 +231,8 @@ smc91cxx_attach(struct smc91cxx_softc *sc, uint8_t *myea) struct ifnet *ifp = &sc->sc_ec.ec_if; bus_space_tag_t bst = sc->sc_bst; bus_space_handle_t bsh = sc->sc_bsh; - struct ifmedia *ifm = &sc->sc_mii.mii_media; + struct mii_data *mii = &sc->sc_mii; + struct ifmedia *ifm = &mii->mii_media; const char *idstr; uint32_t miicapabilities; uint16_t tmp; @@ -312,11 +313,11 @@ smc91cxx_attach(struct smc91cxx_softc *sc, uint8_t *myea) * Initialize our media structures and MII info. We will * probe the MII if we are on the SMC91Cxx */ - sc->sc_mii.mii_ifp = ifp; - sc->sc_mii.mii_readreg = smc91cxx_mii_readreg; - sc->sc_mii.mii_writereg = smc91cxx_mii_writereg; - sc->sc_mii.mii_statchg = smc91cxx_statchg; - sc->sc_ec.ec_mii = &sc->sc_mii; + mii->mii_ifp = ifp; + mii->mii_readreg = smc91cxx_mii_readreg; + mii->mii_writereg = smc91cxx_mii_writereg; + mii->mii_statchg = smc91cxx_statchg; + sc->sc_ec.ec_mii = mii; ifmedia_init(ifm, IFM_IMASK, smc91cxx_mediachange, smc91cxx_mediastatus); @@ -343,15 +344,15 @@ smc91cxx_attach(struct smc91cxx_softc *sc, uint8_t *myea) sc->sc_internal_phy = !(tmp & CR_AUI_SELECT); } else aprint_normal("\n"); - mii_attach(sc->sc_dev, &sc->sc_mii, miicapabilities, + mii_attach(sc->sc_dev, mii, miicapabilities, MII_PHY_ANY, MII_OFFSET_ANY, 0); - if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) { - ifmedia_add(&sc->sc_mii.mii_media, + if (LIST_FIRST(&mii->mii_phys) == NULL) { + ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL); - ifmedia_set(&sc->sc_mii.mii_media, + ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_NONE); } else { - ifmedia_set(&sc->sc_mii.mii_media, + ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO); } sc->sc_flags |= SMC_FLAGS_HAS_MII; diff --git a/sys/dev/pci/if_bce.c b/sys/dev/pci/if_bce.c index 0ca035dd5169..9a073aceb56a 100644 --- a/sys/dev/pci/if_bce.c +++ b/sys/dev/pci/if_bce.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_bce.c,v 1.51 2019/02/03 03:19:27 mrg Exp $ */ +/* $NetBSD: if_bce.c,v 1.52 2019/05/30 02:32:18 msaitoh Exp $ */ /* * Copyright (c) 2003 Clifford Wright. All rights reserved. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_bce.c,v 1.51 2019/02/03 03:19:27 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bce.c,v 1.52 2019/05/30 02:32:18 msaitoh Exp $"); #include "vlan.h" @@ -257,6 +257,7 @@ bce_attach(device_t parent, device_t self, void *aux) int error, i, pmreg, rseg; uint16_t phyval; struct ifnet *ifp; + struct mii_data *mii = &sc->bce_mii; char intrbuf[PCI_INTRSTR_LEN]; sc->bce_dev = self; @@ -424,21 +425,20 @@ bce_attach(device_t parent, device_t self, void *aux) /* Initialize our media structures and probe the MII. */ - sc->bce_mii.mii_ifp = ifp; - sc->bce_mii.mii_readreg = bce_mii_read; - sc->bce_mii.mii_writereg = bce_mii_write; - sc->bce_mii.mii_statchg = bce_statchg; + mii->mii_ifp = ifp; + mii->mii_readreg = bce_mii_read; + mii->mii_writereg = bce_mii_write; + mii->mii_statchg = bce_statchg; - sc->ethercom.ec_mii = &sc->bce_mii; - ifmedia_init(&sc->bce_mii.mii_media, 0, ether_mediachange, - ether_mediastatus); - mii_attach(sc->bce_dev, &sc->bce_mii, 0xffffffff, MII_PHY_ANY, + sc->ethercom.ec_mii = mii; + ifmedia_init(&mii->mii_media, 0, ether_mediachange, ether_mediastatus); + mii_attach(sc->bce_dev, mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, MIIF_FORCEANEG|MIIF_DOPAUSE); - if (LIST_FIRST(&sc->bce_mii.mii_phys) == NULL) { - ifmedia_add(&sc->bce_mii.mii_media, IFM_ETHER | IFM_NONE, 0, NULL); - ifmedia_set(&sc->bce_mii.mii_media, IFM_ETHER | IFM_NONE); + if (LIST_FIRST(&mii->mii_phys) == NULL) { + ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL); + ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_NONE); } else - ifmedia_set(&sc->bce_mii.mii_media, IFM_ETHER | IFM_AUTO); + ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO); /* get the phy */ sc->bce_phy = bus_space_read_1(sc->bce_btag, sc->bce_bhandle, BCE_MAGIC_PHY) & 0x1f; diff --git a/sys/dev/pci/if_lii.c b/sys/dev/pci/if_lii.c index a3fe898dd889..33c54f8e4cc9 100644 --- a/sys/dev/pci/if_lii.c +++ b/sys/dev/pci/if_lii.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_lii.c,v 1.25 2019/05/28 07:41:49 msaitoh Exp $ */ +/* $NetBSD: if_lii.c,v 1.26 2019/05/30 02:32:18 msaitoh Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lii.c,v 1.25 2019/05/28 07:41:49 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lii.c,v 1.26 2019/05/30 02:32:18 msaitoh Exp $"); #include @@ -237,6 +237,7 @@ lii_attach(device_t parent, device_t self, void *aux) struct pci_attach_args *pa = aux; uint8_t eaddr[ETHER_ADDR_LEN]; struct ifnet *ifp = &sc->sc_ec.ec_if; + struct mii_data *mii = &sc->sc_mii; pci_intr_handle_t ih; const char *intrstr; pcireg_t cmd; @@ -310,16 +311,15 @@ lii_attach(device_t parent, device_t self, void *aux) callout_init(&sc->sc_tick_ch, 0); callout_setfunc(&sc->sc_tick_ch, lii_tick, sc); - sc->sc_mii.mii_ifp = ifp; - sc->sc_mii.mii_readreg = lii_mii_readreg; - sc->sc_mii.mii_writereg = lii_mii_writereg; - sc->sc_mii.mii_statchg = lii_mii_statchg; - sc->sc_ec.ec_mii = &sc->sc_mii; - ifmedia_init(&sc->sc_mii.mii_media, IFM_IMASK, lii_media_change, + mii->mii_ifp = ifp; + mii->mii_readreg = lii_mii_readreg; + mii->mii_writereg = lii_mii_writereg; + mii->mii_statchg = lii_mii_statchg; + sc->sc_ec.ec_mii = mii; + ifmedia_init(&mii->mii_media, IFM_IMASK, lii_media_change, lii_media_status); - mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, 1, - MII_OFFSET_ANY, 0); - ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER | IFM_AUTO); + mii_attach(sc->sc_dev, mii, 0xffffffff, 1, MII_OFFSET_ANY, 0); + ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO); strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ); ifp->if_softc = sc; diff --git a/sys/dev/pci/if_sk.c b/sys/dev/pci/if_sk.c index eca33813f07f..c8f1f602d8a4 100644 --- a/sys/dev/pci/if_sk.c +++ b/sys/dev/pci/if_sk.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_sk.c,v 1.97 2019/05/28 07:41:49 msaitoh Exp $ */ +/* $NetBSD: if_sk.c,v 1.98 2019/05/30 02:32:18 msaitoh Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -115,7 +115,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_sk.c,v 1.97 2019/05/28 07:41:49 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_sk.c,v 1.98 2019/05/30 02:32:18 msaitoh Exp $"); #include #include @@ -1214,6 +1214,7 @@ void sk_attach(device_t parent, device_t self, void *aux) { struct sk_if_softc *sc_if = device_private(self); + struct mii_data *mii = &sc_if->sk_mii; struct sk_softc *sc = device_private(parent); struct skc_attach_args *sa = aux; struct sk_txmap_entry *entry; @@ -1434,35 +1435,33 @@ sk_attach(device_t parent, device_t self, void *aux) DPRINTFN(2, ("sk_attach: 1\n")); - sc_if->sk_mii.mii_ifp = ifp; + mii->mii_ifp = ifp; switch (sc->sk_type) { case SK_GENESIS: - sc_if->sk_mii.mii_readreg = sk_xmac_miibus_readreg; - sc_if->sk_mii.mii_writereg = sk_xmac_miibus_writereg; - sc_if->sk_mii.mii_statchg = sk_xmac_miibus_statchg; + mii->mii_readreg = sk_xmac_miibus_readreg; + mii->mii_writereg = sk_xmac_miibus_writereg; + mii->mii_statchg = sk_xmac_miibus_statchg; break; case SK_YUKON: case SK_YUKON_LITE: case SK_YUKON_LP: - sc_if->sk_mii.mii_readreg = sk_marv_miibus_readreg; - sc_if->sk_mii.mii_writereg = sk_marv_miibus_writereg; - sc_if->sk_mii.mii_statchg = sk_marv_miibus_statchg; + mii->mii_readreg = sk_marv_miibus_readreg; + mii->mii_writereg = sk_marv_miibus_writereg; + mii->mii_statchg = sk_marv_miibus_statchg; mii_flags = MIIF_DOPAUSE; break; } - sc_if->sk_ethercom.ec_mii = &sc_if->sk_mii; - ifmedia_init(&sc_if->sk_mii.mii_media, 0, - sk_ifmedia_upd, ether_mediastatus); - mii_attach(self, &sc_if->sk_mii, 0xffffffff, MII_PHY_ANY, + sc_if->sk_ethercom.ec_mii = mii; + ifmedia_init(&mii->mii_media, 0, sk_ifmedia_upd, ether_mediastatus); + mii_attach(self, mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, mii_flags); - if (LIST_EMPTY(&sc_if->sk_mii.mii_phys)) { + if (LIST_EMPTY(&mii->mii_phys)) { aprint_error_dev(sc_if->sk_dev, "no PHY found!\n"); - ifmedia_add(&sc_if->sk_mii.mii_media, IFM_ETHER | IFM_MANUAL, - 0, NULL); - ifmedia_set(&sc_if->sk_mii.mii_media, IFM_ETHER | IFM_MANUAL); + ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_MANUAL, 0, NULL); + ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_MANUAL); } else - ifmedia_set(&sc_if->sk_mii.mii_media, IFM_ETHER | IFM_AUTO); + ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO); callout_init(&sc_if->sk_tick_ch, 0); callout_reset(&sc_if->sk_tick_ch, hz, sk_tick, sc_if);