From owner-svn-src-all@freebsd.org Fri Jun 9 20:38:19 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE711BFCE3B; Fri, 9 Jun 2017 20:38:19 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8AA217BBDA; Fri, 9 Jun 2017 20:38:19 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v59KcIhQ071172; Fri, 9 Jun 2017 20:38:18 GMT (envelope-from loos@FreeBSD.org) Received: (from loos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v59KcI6L071171; Fri, 9 Jun 2017 20:38:18 GMT (envelope-from loos@FreeBSD.org) Message-Id: <201706092038.v59KcI6L071171@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: loos set sender to loos@FreeBSD.org using -f From: Luiz Otavio O Souza Date: Fri, 9 Jun 2017 20:38:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319760 - head/sys/dev/etherswitch/e6000sw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jun 2017 20:38:19 -0000 Author: loos Date: Fri Jun 9 20:38:18 2017 New Revision: 319760 URL: https://svnweb.freebsd.org/changeset/base/319760 Log: Remove an unnecessary variable from the switch softc structure and make the functions that are used as booleans return real boolean values. Sponsored by: Rubicon Communications, LLC (Netgate) Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c ============================================================================== --- head/sys/dev/etherswitch/e6000sw/e6000sw.c Fri Jun 9 20:26:42 2017 (r319759) +++ head/sys/dev/etherswitch/e6000sw/e6000sw.c Fri Jun 9 20:38:18 2017 (r319760) @@ -69,7 +69,6 @@ typedef struct e6000sw_softc { struct ifnet *ifp[E6000SW_MAX_PORTS]; char *ifname[E6000SW_MAX_PORTS]; device_t miibus[E6000SW_MAX_PORTS]; - struct mii_data *mii[E6000SW_MAX_PORTS]; struct proc *kproc; uint32_t cpuports_mask; @@ -121,9 +120,9 @@ static int e6000sw_atu_mac_table(device_t, e6000sw_sof int); static int e6000sw_get_pvid(e6000sw_softc_t *, int, int *); static int e6000sw_set_pvid(e6000sw_softc_t *, int, int); -static __inline int e6000sw_is_cpuport(e6000sw_softc_t *, int); -static __inline int e6000sw_is_fixedport(e6000sw_softc_t *, int); -static __inline int e6000sw_is_phyport(e6000sw_softc_t *, int); +static __inline bool e6000sw_is_cpuport(e6000sw_softc_t *, int); +static __inline bool e6000sw_is_fixedport(e6000sw_softc_t *, int); +static __inline bool e6000sw_is_phyport(e6000sw_softc_t *, int); static __inline struct mii_data *e6000sw_miiforphy(e6000sw_softc_t *, unsigned int); @@ -278,7 +277,7 @@ e6000sw_parse_child_fdt(device_t dev, phandle_t child, *fixed_mask |= (1 << port); device_printf(dev, "fixed port at %d\n", port); } else { - device_printf(dev, "PHY at %d\n", port); + device_printf(dev, "PHY at port %d\n", port); } return (0); @@ -319,7 +318,6 @@ e6000sw_attach_miibus(e6000sw_softc_t *sc, int port) if (err != 0) return (err); - sc->mii[port] = device_get_softc(sc->miibus[port]); return (0); } @@ -413,8 +411,8 @@ e6000sw_poll_done(e6000sw_softc_t *sc) for (i = 0; i < E6000SW_SMI_TIMEOUT; i++) { - if (!(e6000sw_readreg(sc, REG_GLOBAL2, SMI_PHY_CMD_REG) & - (1 << PHY_CMD_SMI_BUSY))) + if ((e6000sw_readreg(sc, REG_GLOBAL2, SMI_PHY_CMD_REG) & + (1 << PHY_CMD_SMI_BUSY)) == 0) return (0); pause("e6000sw PHY poll", hz/1000); @@ -915,27 +913,27 @@ e6000sw_writereg(e6000sw_softc_t *sc, int addr, int re } } -static __inline int +static __inline bool e6000sw_is_cpuport(e6000sw_softc_t *sc, int port) { - return (sc->cpuports_mask & (1 << port)); + return ((sc->cpuports_mask & (1 << port)) ? true : false); } -static __inline int +static __inline bool e6000sw_is_fixedport(e6000sw_softc_t *sc, int port) { - return (sc->fixed_mask & (1 << port)); + return ((sc->fixed_mask & (1 << port)) ? true : false); } -static __inline int +static __inline bool e6000sw_is_phyport(e6000sw_softc_t *sc, int port) { uint32_t phy_mask; phy_mask = ~(sc->fixed_mask | sc->cpuports_mask); - return (phy_mask & (1 << port)); + return ((phy_mask & (1 << port)) ? true : false); } static __inline int @@ -999,6 +997,7 @@ static void e6000sw_tick (void *arg) { e6000sw_softc_t *sc; + struct mii_data *mii; struct mii_softc *miisc; uint16_t portstatus; int port; @@ -1014,14 +1013,18 @@ e6000sw_tick (void *arg) if (!e6000sw_is_phyport(sc, port)) continue; - portstatus = e6000sw_readreg(sc, REG_PORT(port), PORT_STATUS); + mii = e6000sw_miiforphy(sc, port); + if (mii == NULL) + continue; + portstatus = e6000sw_readreg(sc, REG_PORT(port), + PORT_STATUS); + e6000sw_update_ifmedia(portstatus, - &sc->mii[port]->mii_media_status, - &sc->mii[port]->mii_media_active); + &mii->mii_media_status, &mii->mii_media_active); - LIST_FOREACH(miisc, &sc->mii[port]->mii_phys, mii_list) { - if (IFM_INST(sc->mii[port]->mii_media.ifm_cur->ifm_media) + LIST_FOREACH(miisc, &mii->mii_phys, mii_list) { + if (IFM_INST(mii->mii_media.ifm_cur->ifm_media) != miisc->mii_inst) continue; mii_phy_update(miisc, MII_POLLSTAT);