Source-Changes-HG archive

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

[src/trunk]: src/sys No functional change:



details:   https://anonhg.NetBSD.org/src/rev/722ff32a6191
branches:  trunk
changeset: 451621:722ff32a6191
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed May 29 06:17:27 2019 +0000

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

diffstat:

 sys/arch/arm/omap/if_cpsw.c         |  41 ++++++++++----------
 sys/arch/arm/ti/if_cpsw.c           |  41 ++++++++++----------
 sys/arch/mips/ralink/ralink_eth.c   |  59 ++++++++++++++---------------
 sys/arch/newsmips/apbus/if_tlp_ap.c |  24 ++++++------
 sys/dev/ic/ax88190.c                |  26 ++++++------
 sys/dev/ic/dl10019.c                |  25 ++++++------
 sys/dev/ic/elink3.c                 |  73 ++++++++++++++++++------------------
 sys/dev/pci/if_tlp_pci.c            |  49 ++++++++++++------------
 8 files changed, 168 insertions(+), 170 deletions(-)

diffs (truncated from 907 to 300 lines):

diff -r a4d23d122b0f -r 722ff32a6191 sys/arch/arm/omap/if_cpsw.c
--- a/sys/arch/arm/omap/if_cpsw.c       Wed May 29 05:06:39 2019 +0000
+++ b/sys/arch/arm/omap/if_cpsw.c       Wed May 29 06:17:27 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cpsw.c,v 1.24 2019/05/29 05:05:24 msaitoh Exp $     */
+/*     $NetBSD: if_cpsw.c,v 1.25 2019/05/29 06:17:27 msaitoh Exp $     */
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.24 2019/05/29 05:05:24 msaitoh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.25 2019/05/29 06:17:27 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -394,6 +394,7 @@
        prop_dictionary_t dict = device_properties(self);
        struct ethercom * const ec = &sc->sc_ec;
        struct ifnet * const ifp = &ec->ec_if;
+       struct mii_data * const mii = &sc->sc_mii;
        int error;
        u_int i;
 
@@ -508,7 +509,7 @@
        bus_dmamap_create(sc->sc_bdt, ETHER_MIN_LEN, 1, ETHER_MIN_LEN, 0,
            BUS_DMA_WAITOK, &sc->sc_txpad_dm);
        bus_dmamap_load(sc->sc_bdt, sc->sc_txpad_dm, sc->sc_txpad,
-           ETHER_MIN_LEN, NULL, BUS_DMA_WAITOK|BUS_DMA_WRITE);
+           ETHER_MIN_LEN, NULL, BUS_DMA_WAITOK | BUS_DMA_WRITE);
        bus_dmamap_sync(sc->sc_bdt, sc->sc_txpad_dm, 0, ETHER_MIN_LEN,
            BUS_DMASYNC_PREWRITE);
 
@@ -528,14 +529,13 @@
 
        cpsw_stop(ifp, 0);
 
-       sc->sc_mii.mii_ifp = ifp;
-       sc->sc_mii.mii_readreg = cpsw_mii_readreg;
-       sc->sc_mii.mii_writereg = cpsw_mii_writereg;
-       sc->sc_mii.mii_statchg = cpsw_mii_statchg;
+       mii->mii_ifp = ifp;
+       mii->mii_readreg = cpsw_mii_readreg;
+       mii->mii_writereg = cpsw_mii_writereg;
+       mii->mii_statchg = cpsw_mii_statchg;
 
-       sc->sc_ec.ec_mii = &sc->sc_mii;
-       ifmedia_init(&sc->sc_mii.mii_media, 0, ether_mediachange,
-           ether_mediastatus);
+       sc->sc_ec.ec_mii = mii;
+       ifmedia_init(&mii->mii_media, 0, ether_mediachange, ether_mediastatus);
 
        /* Initialize MDIO */
        cpsw_write_4(sc, MDIOCONTROL,
@@ -543,13 +543,12 @@
        /* Clear ALE */
        cpsw_write_4(sc, CPSW_ALE_CONTROL, ALECTL_CLEAR_TABLE);
 
-       mii_attach(self, &sc->sc_mii, 0xffffffff, MII_PHY_ANY, 0, 0);
-       if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
+       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");
                sc->sc_phy_has_1000t = false;
-               ifmedia_add(&sc->sc_mii.mii_media,
-                   IFM_ETHER|IFM_MANUAL, 0, NULL);
-               ifmedia_set(&sc->sc_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 {
                sc->sc_phy_has_1000t = cpsw_phy_has_1000t(sc);
                if (sc->sc_phy_has_1000t) {
@@ -564,7 +563,7 @@
                            GMIISEL_GMII1_SEL(RGMII_MODE));
                }
 
-               ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
+               ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
        }
 
        if_attach(ifp);
@@ -597,7 +596,7 @@
        KERNHIST_FUNC(__func__);
        KERNHIST_CALLED_5(cpswhist, (uintptr_t)sc, 0, 0, 0);
 
-       if (__predict_false((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) !=
+       if (__predict_false((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) !=
            IFF_RUNNING)) {
                return;
        }
@@ -838,7 +837,7 @@
        rdp->rx_mb[i] = m;
 
        error = bus_dmamap_load_mbuf(sc->sc_bdt, rdp->rx_dm[i], rdp->rx_mb[i],
-           BUS_DMA_READ|BUS_DMA_NOWAIT);
+           BUS_DMA_READ | BUS_DMA_NOWAIT);
        if (error) {
                device_printf(sc->sc_dev, "can't load rx DMA map %d: %d\n",
                    i, error);
@@ -1076,7 +1075,7 @@
                rdp->tx_mb[i] = NULL;
        }
 
-       ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
+       ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
        ifp->if_timer = 0;
 
        if (!disable)
@@ -1152,8 +1151,8 @@
                        return 1;
                }
 
-               if ((dw[3] & (CPDMA_BD_SOP|CPDMA_BD_EOP)) !=
-                   (CPDMA_BD_SOP|CPDMA_BD_EOP)) {
+               if ((dw[3] & (CPDMA_BD_SOP | CPDMA_BD_EOP)) !=
+                   (CPDMA_BD_SOP | CPDMA_BD_EOP)) {
                        //Debugger();
                }
 
diff -r a4d23d122b0f -r 722ff32a6191 sys/arch/arm/ti/if_cpsw.c
--- a/sys/arch/arm/ti/if_cpsw.c Wed May 29 05:06:39 2019 +0000
+++ b/sys/arch/arm/ti/if_cpsw.c Wed May 29 06:17:27 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cpsw.c,v 1.5 2019/05/29 05:05:24 msaitoh Exp $      */
+/*     $NetBSD: if_cpsw.c,v 1.6 2019/05/29 06:17:27 msaitoh Exp $      */
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.5 2019/05/29 05:05:24 msaitoh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.6 2019/05/29 06:17:27 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -401,6 +401,7 @@
        prop_dictionary_t dict = device_properties(self);
        struct ethercom * const ec = &sc->sc_ec;
        struct ifnet * const ifp = &ec->ec_if;
+       struct mii_data * const mii = &sc->sc_mii;
        const int phandle = faa->faa_phandle;
        bus_addr_t addr;
        bus_size_t size;
@@ -544,7 +545,7 @@
        bus_dmamap_create(sc->sc_bdt, ETHER_MIN_LEN, 1, ETHER_MIN_LEN, 0,
            BUS_DMA_WAITOK, &sc->sc_txpad_dm);
        bus_dmamap_load(sc->sc_bdt, sc->sc_txpad_dm, sc->sc_txpad,
-           ETHER_MIN_LEN, NULL, BUS_DMA_WAITOK|BUS_DMA_WRITE);
+           ETHER_MIN_LEN, NULL, BUS_DMA_WAITOK | BUS_DMA_WRITE);
        bus_dmamap_sync(sc->sc_bdt, sc->sc_txpad_dm, 0, ETHER_MIN_LEN,
            BUS_DMASYNC_PREWRITE);
 
@@ -564,14 +565,13 @@
 
        cpsw_stop(ifp, 0);
 
-       sc->sc_mii.mii_ifp = ifp;
-       sc->sc_mii.mii_readreg = cpsw_mii_readreg;
-       sc->sc_mii.mii_writereg = cpsw_mii_writereg;
-       sc->sc_mii.mii_statchg = cpsw_mii_statchg;
+       mii->mii_ifp = ifp;
+       mii->mii_readreg = cpsw_mii_readreg;
+       mii->mii_writereg = cpsw_mii_writereg;
+       mii->mii_statchg = cpsw_mii_statchg;
 
-       sc->sc_ec.ec_mii = &sc->sc_mii;
-       ifmedia_init(&sc->sc_mii.mii_media, 0, ether_mediachange,
-           ether_mediastatus);
+       sc->sc_ec.ec_mii = mii;
+       ifmedia_init(&mii->mii_media, 0, ether_mediachange, ether_mediastatus);
 
        /* Initialize MDIO */
        cpsw_write_4(sc, MDIOCONTROL,
@@ -579,13 +579,12 @@
        /* Clear ALE */
        cpsw_write_4(sc, CPSW_ALE_CONTROL, ALECTL_CLEAR_TABLE);
 
-       mii_attach(self, &sc->sc_mii, 0xffffffff, MII_PHY_ANY, 0, 0);
-       if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
+       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");
                sc->sc_phy_has_1000t = false;
-               ifmedia_add(&sc->sc_mii.mii_media,
-                   IFM_ETHER|IFM_MANUAL, 0, NULL);
-               ifmedia_set(&sc->sc_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 {
                sc->sc_phy_has_1000t = cpsw_phy_has_1000t(sc);
                if (sc->sc_phy_has_1000t) {
@@ -602,7 +601,7 @@
 #endif
                }
 
-               ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
+               ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
        }
 
        if_attach(ifp);
@@ -635,7 +634,7 @@
        KERNHIST_FUNC(__func__);
        KERNHIST_CALLED_5(cpswhist, sc, 0, 0, 0);
 
-       if (__predict_false((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) !=
+       if (__predict_false((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) !=
            IFF_RUNNING)) {
                return;
        }
@@ -876,7 +875,7 @@
        rdp->rx_mb[i] = m;
 
        error = bus_dmamap_load_mbuf(sc->sc_bdt, rdp->rx_dm[i], rdp->rx_mb[i],
-           BUS_DMA_READ|BUS_DMA_NOWAIT);
+           BUS_DMA_READ | BUS_DMA_NOWAIT);
        if (error) {
                device_printf(sc->sc_dev, "can't load rx DMA map %d: %d\n",
                    i, error);
@@ -1114,7 +1113,7 @@
                rdp->tx_mb[i] = NULL;
        }
 
-       ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
+       ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
        ifp->if_timer = 0;
 
        if (!disable)
@@ -1190,8 +1189,8 @@
                        return 1;
                }
 
-               if ((dw[3] & (CPDMA_BD_SOP|CPDMA_BD_EOP)) !=
-                   (CPDMA_BD_SOP|CPDMA_BD_EOP)) {
+               if ((dw[3] & (CPDMA_BD_SOP | CPDMA_BD_EOP)) !=
+                   (CPDMA_BD_SOP | CPDMA_BD_EOP)) {
                        //Debugger();
                }
 
diff -r a4d23d122b0f -r 722ff32a6191 sys/arch/mips/ralink/ralink_eth.c
--- a/sys/arch/mips/ralink/ralink_eth.c Wed May 29 05:06:39 2019 +0000
+++ b/sys/arch/mips/ralink/ralink_eth.c Wed May 29 06:17:27 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ralink_eth.c,v 1.16 2019/05/29 05:06:39 msaitoh Exp $  */
+/*     $NetBSD: ralink_eth.c,v 1.17 2019/05/29 06:17:28 msaitoh Exp $  */
 /*-
  * Copyright (c) 2011 CradlePoint Technology, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
 /* ralink_eth.c -- Ralink Ethernet Driver */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ralink_eth.c,v 1.16 2019/05/29 05:06:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ralink_eth.c,v 1.17 2019/05/29 06:17:28 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -311,6 +311,7 @@
 {
        ralink_eth_softc_t * const sc = device_private(self);
        const struct mainbus_attach_args *ma = aux;
+       struct mii_data *mii = &sc->sc_mii;
        int error;
        int i;
 
@@ -478,30 +479,28 @@
         * Initialize our media structures.
         * This may probe the PHY, if present.
         */
-       sc->sc_mii.mii_ifp = ifp;
-       sc->sc_mii.mii_readreg = ralink_eth_mii_read;
-       sc->sc_mii.mii_writereg = ralink_eth_mii_write;
-       sc->sc_mii.mii_statchg = ralink_eth_mii_statchg;
-       sc->sc_ethercom.ec_mii = &sc->sc_mii;
-       ifmedia_init(&sc->sc_mii.mii_media, 0, ether_mediachange,
-           ether_mediastatus);
-       mii_attach(sc->sc_dev, &sc->sc_mii, ~0, MII_PHY_ANY, MII_OFFSET_ANY,
-           MIIF_FORCEANEG|MIIF_DOPAUSE|MIIF_NOISOLATE);
+       mii->mii_ifp = ifp;
+       mii->mii_readreg = ralink_eth_mii_read;
+       mii->mii_writereg = ralink_eth_mii_write;
+       mii->mii_statchg = ralink_eth_mii_statchg;
+       sc->sc_ethercom.ec_mii = mii;
+       ifmedia_init(mii->mii_media, 0, ether_mediachange, ether_mediastatus);
+       mii_attach(sc->sc_dev, mii, ~0, MII_PHY_ANY, MII_OFFSET_ANY,
+           MIIF_FORCEANEG | MIIF_DOPAUSE | MIIF_NOISOLATE);
 
-       if (LIST_EMPTY(&sc->sc_mii.mii_phys)) {
+       if (LIST_EMPTY(&mii->mii_phys)) {
 #if 1
-               ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_1000_T|
-                   IFM_FDX|IFM_ETH_RXPAUSE|IFM_ETH_TXPAUSE, 0, NULL);
-               ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_1000_T|
-                   IFM_FDX|IFM_ETH_RXPAUSE|IFM_ETH_TXPAUSE);
+               ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_1000_T |
+                   IFM_FDX | IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE, 0, NULL);
+               ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_1000_T |



Home | Main Index | Thread Index | Old Index