Module Name: src Committed By: msaitoh Date: Mon Mar 25 09:20:46 UTC 2019
Modified Files: src/sys/dev/mii: acphy.c atphy.c bmtphy.c brgphy.c ciphy.c dmphy.c gentbi.c icsphy.c iophy.c mii.c mii_physubr.c nsphy.c pnaphy.c qsphy.c rdcphy.c rgephy.c rlphy.c sqphy.c tlphy.c tqphy.c ukphy.c ukphy_subr.c urlphy.c Log Message: KNF. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/dev/mii/acphy.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/mii/atphy.c cvs rdiff -u -r1.34 -r1.35 src/sys/dev/mii/bmtphy.c cvs rdiff -u -r1.82 -r1.83 src/sys/dev/mii/brgphy.c cvs rdiff -u -r1.31 -r1.32 src/sys/dev/mii/ciphy.c cvs rdiff -u -r1.42 -r1.43 src/sys/dev/mii/dmphy.c src/sys/dev/mii/tqphy.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/mii/gentbi.c cvs rdiff -u -r1.53 -r1.54 src/sys/dev/mii/icsphy.c src/sys/dev/mii/sqphy.c cvs rdiff -u -r1.40 -r1.41 src/sys/dev/mii/iophy.c cvs rdiff -u -r1.52 -r1.53 src/sys/dev/mii/mii.c cvs rdiff -u -r1.85 -r1.86 src/sys/dev/mii/mii_physubr.c cvs rdiff -u -r1.63 -r1.64 src/sys/dev/mii/nsphy.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/mii/pnaphy.c cvs rdiff -u -r1.51 -r1.52 src/sys/dev/mii/qsphy.c src/sys/dev/mii/rgephy.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/mii/rdcphy.c cvs rdiff -u -r1.35 -r1.36 src/sys/dev/mii/rlphy.c cvs rdiff -u -r1.65 -r1.66 src/sys/dev/mii/tlphy.c cvs rdiff -u -r1.50 -r1.51 src/sys/dev/mii/ukphy.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/mii/ukphy_subr.c cvs rdiff -u -r1.33 -r1.34 src/sys/dev/mii/urlphy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/mii/acphy.c diff -u src/sys/dev/mii/acphy.c:1.27 src/sys/dev/mii/acphy.c:1.28 --- src/sys/dev/mii/acphy.c:1.27 Sun Feb 24 17:22:21 2019 +++ src/sys/dev/mii/acphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: acphy.c,v 1.27 2019/02/24 17:22:21 christos Exp $ */ +/* $NetBSD: acphy.c,v 1.28 2019/03/25 09:20:46 msaitoh Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acphy.c,v 1.27 2019/02/24 17:22:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acphy.c,v 1.28 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -87,9 +87,9 @@ acphymatch(device_t parent, cfdata_t mat struct mii_attach_args *ma = aux; if (mii_phy_match(ma, acphys) != NULL) - return (10); + return 10; - return (0); + return 0; } static void @@ -114,9 +114,7 @@ acphyattach(device_t parent, device_t se PHY_RESET(sc); - /* - * XXX Check MCR_FX_SEL to set MIIF_HAVE_FIBER? - */ + /* XXX Check MCR_FX_SEL to set MIIF_HAVE_FIBER? */ PHY_READ(sc, MII_BMSR, &sc->mii_capabilities); sc->mii_capabilities &= ma->mii_capmask; @@ -148,11 +146,9 @@ acphy_service(struct mii_softc *sc, stru switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -163,12 +159,10 @@ acphy_service(struct mii_softc *sc, stru if (IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -176,19 +170,17 @@ acphy_service(struct mii_softc *sc, stru break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); + return 0; break; case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -196,7 +188,7 @@ acphy_service(struct mii_softc *sc, stru /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void Index: src/sys/dev/mii/atphy.c diff -u src/sys/dev/mii/atphy.c:1.20 src/sys/dev/mii/atphy.c:1.21 --- src/sys/dev/mii/atphy.c:1.20 Sun Feb 24 17:22:21 2019 +++ src/sys/dev/mii/atphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atphy.c,v 1.20 2019/02/24 17:22:21 christos Exp $ */ +/* $NetBSD: atphy.c,v 1.21 2019/03/25 09:20:46 msaitoh Exp $ */ /* $OpenBSD: atphy.c,v 1.1 2008/09/25 20:47:16 brad Exp $ */ /*- @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: atphy.c,v 1.20 2019/02/24 17:22:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: atphy.c,v 1.21 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -174,9 +174,7 @@ atphy_service(struct mii_softc *sc, stru switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) return 0; break; @@ -192,9 +190,7 @@ atphy_service(struct mii_softc *sc, stru return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -239,29 +235,21 @@ atphy_service(struct mii_softc *sc, stru PHY_WRITE(sc, MII_100T2CR, 0); PHY_WRITE(sc, MII_ANAR, anar); - /* - * Start autonegotiation. - */ + /* Start autonegotiation. */ PHY_WRITE(sc, MII_BMCR, bmcr | BMCR_AUTOEN | BMCR_STARTNEG); done: break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) return 0; - /* - * Is the interface even up? - */ + /* Is the interface even up? */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return 0; - /* - * Only used for autonegotiation. - */ + /* Only used for autonegotiation. */ if ((IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) && (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T)) { sc->mii_ticks = 0; @@ -283,9 +271,7 @@ done: if (sc->mii_ticks++ == 0) break; - /* - * Only retry autonegotiation every mii_anegticks seconds. - */ + /* Only retry autonegotiation every mii_anegticks seconds. */ if (sc->mii_ticks <= sc->mii_anegticks) break; Index: src/sys/dev/mii/bmtphy.c diff -u src/sys/dev/mii/bmtphy.c:1.34 src/sys/dev/mii/bmtphy.c:1.35 --- src/sys/dev/mii/bmtphy.c:1.34 Sun Feb 24 17:22:21 2019 +++ src/sys/dev/mii/bmtphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: bmtphy.c,v 1.34 2019/02/24 17:22:21 christos Exp $ */ +/* $NetBSD: bmtphy.c,v 1.35 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bmtphy.c,v 1.34 2019/02/24 17:22:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bmtphy.c,v 1.35 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -110,9 +110,9 @@ bmtphymatch(device_t parent, cfdata_t ma struct mii_attach_args *ma = aux; if (mii_phy_match(ma, bmtphys) != NULL) - return (10); + return 10; - return (0); + return 0; } static void @@ -138,9 +138,7 @@ bmtphyattach(device_t parent, device_t s PHY_RESET(sc); - /* - * XXX Check AUX_STS_FX_MODE to set MIIF_HAVE_FIBER? - */ + /* XXX Check AUX_STS_FX_MODE to set MIIF_HAVE_FIBER? */ PHY_READ(sc, MII_BMSR, &sc->mii_capabilities); sc->mii_capabilities &= ma->mii_capmask; @@ -160,11 +158,9 @@ bmtphy_service(struct mii_softc *sc, str switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -175,12 +171,10 @@ bmtphy_service(struct mii_softc *sc, str if (IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -188,19 +182,17 @@ bmtphy_service(struct mii_softc *sc, str break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); + return 0; break; case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -208,7 +200,7 @@ bmtphy_service(struct mii_softc *sc, str /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void Index: src/sys/dev/mii/brgphy.c diff -u src/sys/dev/mii/brgphy.c:1.82 src/sys/dev/mii/brgphy.c:1.83 --- src/sys/dev/mii/brgphy.c:1.82 Mon Feb 25 04:56:30 2019 +++ src/sys/dev/mii/brgphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: brgphy.c,v 1.82 2019/02/25 04:56:30 msaitoh Exp $ */ +/* $NetBSD: brgphy.c,v 1.83 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.82 2019/02/25 04:56:30 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.83 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -189,9 +189,9 @@ brgphymatch(device_t parent, cfdata_t ma struct mii_attach_args *ma = aux; if (mii_phy_match(ma, brgphys) != NULL) - return (10); + return 10; - return (0); + return 0; } static void @@ -313,7 +313,7 @@ brgphy_service(struct mii_softc *sc, str case MII_POLLSTAT: /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -324,7 +324,7 @@ brgphy_service(struct mii_softc *sc, str if (IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } /* If the interface is not up, don't do anything. */ @@ -379,14 +379,14 @@ setit: PHY_WRITE(sc, MII_100T2CR, gig); break; default: - return (EINVAL); + return EINVAL; } break; case MII_TICK: /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; /* Is the interface even up? */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) @@ -428,7 +428,7 @@ setit: case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -461,7 +461,7 @@ setit: /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void @@ -651,9 +651,11 @@ brgphy_5708s_status(struct mii_softc *sc if (mii->mii_media_active & IFM_FDX) { if (xstat & BRGPHY_5708S_PG0_1000X_STAT1_TX_PAUSE) - mii->mii_media_active |= IFM_FLOW | IFM_ETH_TXPAUSE; + mii->mii_media_active + |= IFM_FLOW | IFM_ETH_TXPAUSE; if (xstat & BRGPHY_5708S_PG0_1000X_STAT1_RX_PAUSE) - mii->mii_media_active |= IFM_FLOW | IFM_ETH_RXPAUSE; + mii->mii_media_active + |= IFM_FLOW | IFM_ETH_RXPAUSE; } } else mii->mii_media_active = ife->ifm_media; @@ -761,7 +763,7 @@ brgphy_mii_phy_auto(struct mii_softc *sc PHY_WRITE(sc, MII_BMCR, BMCR_AUTOEN | BMCR_STARTNEG); PHY_WRITE(sc, BRGPHY_MII_IMR, 0xFF00); - return (EJUSTRETURN); + return EJUSTRETURN; } void @@ -874,56 +876,71 @@ brgphy_reset(struct mii_softc *sc) } /* Handle any bnx (NetXtreme II) workarounds. */ } else if (bsc->sc_isbnx) { + uint32_t chip_num = _BNX_CHIP_NUM(bsc->sc_chipid); + uint32_t chip_id = _BNX_CHIP_ID(bsc->sc_chipid); + uint32_t chip_rev = _BNX_CHIP_REV(bsc->sc_chipid); + if ((sc->mii_mpd_oui == MII_OUI_BROADCOM2) && sc->mii_mpd_model == MII_MODEL_BROADCOM2_BCM5708S) { - /* Store autoneg capabilities/results in digital block (Page 0) */ - PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, BRGPHY_5708S_DIG3_PG2); + /* + * Store autoneg capabilities/results in digital block + * (Page 0) + */ + PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, + BRGPHY_5708S_DIG3_PG2); PHY_WRITE(sc, BRGPHY_5708S_PG2_DIGCTL_3_0, BRGPHY_5708S_PG2_DIGCTL_3_0_USE_IEEE); - PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, BRGPHY_5708S_DIG_PG0); + PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, + BRGPHY_5708S_DIG_PG0); /* Enable fiber mode and autodetection */ PHY_READ(sc, BRGPHY_5708S_PG0_1000X_CTL1, ®); - PHY_WRITE(sc, BRGPHY_5708S_PG0_1000X_CTL1, reg | - BRGPHY_5708S_PG0_1000X_CTL1_AUTODET_EN | + PHY_WRITE(sc, BRGPHY_5708S_PG0_1000X_CTL1, reg | + BRGPHY_5708S_PG0_1000X_CTL1_AUTODET_EN | BRGPHY_5708S_PG0_1000X_CTL1_FIBER_MODE); /* Enable parallel detection */ PHY_READ(sc, BRGPHY_5708S_PG0_1000X_CTL2, ®); - PHY_WRITE(sc, BRGPHY_5708S_PG0_1000X_CTL2, + PHY_WRITE(sc, BRGPHY_5708S_PG0_1000X_CTL2, reg | BRGPHY_5708S_PG0_1000X_CTL2_PAR_DET_EN); - /* Advertise 2.5G support through next page during autoneg */ + /* + * Advertise 2.5G support through next page during + * autoneg + */ if (bsc->sc_phyflags & BNX_PHY_2_5G_CAPABLE_FLAG) { PHY_READ(sc, BRGPHY_5708S_ANEG_NXT_PG_XMIT1, ®); - PHY_WRITE(sc, BRGPHY_5708S_ANEG_NXT_PG_XMIT1, + PHY_WRITE(sc, BRGPHY_5708S_ANEG_NXT_PG_XMIT1, reg | BRGPHY_5708S_ANEG_NXT_PG_XMIT1_25G); } /* Increase TX signal amplitude */ - if ((_BNX_CHIP_ID(bsc->sc_chipid) == BNX_CHIP_ID_5708_A0) || - (_BNX_CHIP_ID(bsc->sc_chipid) == BNX_CHIP_ID_5708_B0) || - (_BNX_CHIP_ID(bsc->sc_chipid) == BNX_CHIP_ID_5708_B1)) { - PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, + if ((chip_id == BNX_CHIP_ID_5708_A0) || + (chip_id == BNX_CHIP_ID_5708_B0) || + (chip_id == BNX_CHIP_ID_5708_B1)) { + PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, BRGPHY_5708S_TX_MISC_PG5); PHY_READ(sc, BRGPHY_5708S_PG5_TXACTL1, ®); PHY_WRITE(sc, BRGPHY_5708S_PG5_TXACTL1, reg & ~BRGPHY_5708S_PG5_TXACTL1_VCM); - PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, + PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, BRGPHY_5708S_DIG_PG0); } - /* Backplanes use special driver/pre-driver/pre-emphasis values. */ + /* + * Backplanes use special + * driver/pre-driver/pre-emphasis values. + */ if ((bsc->sc_shared_hwcfg & BNX_SHARED_HW_CFG_PHY_BACKPLANE) && (bsc->sc_port_hwcfg & BNX_PORT_HW_CFG_CFG_TXCTL3_MASK)) { - PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, - BRGPHY_5708S_TX_MISC_PG5); - PHY_WRITE(sc, BRGPHY_5708S_PG5_TXACTL3, - bsc->sc_port_hwcfg & - BNX_PORT_HW_CFG_CFG_TXCTL3_MASK); - PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, - BRGPHY_5708S_DIG_PG0); + PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, + BRGPHY_5708S_TX_MISC_PG5); + PHY_WRITE(sc, BRGPHY_5708S_PG5_TXACTL3, + bsc->sc_port_hwcfg & + BNX_PORT_HW_CFG_CFG_TXCTL3_MASK); + PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, + BRGPHY_5708S_DIG_PG0); } } else if ((sc->mii_mpd_oui == MII_OUI_BROADCOM2) && (sc->mii_mpd_model == MII_MODEL_BROADCOM2_BCM5709S)) { @@ -977,9 +994,9 @@ brgphy_reset(struct mii_softc *sc) PHY_WRITE(sc, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_COMBO_IEEE0); - } else if (_BNX_CHIP_NUM(bsc->sc_chipid) == BNX_CHIP_NUM_5709) { - if (_BNX_CHIP_REV(bsc->sc_chipid) == BNX_CHIP_REV_Ax || - _BNX_CHIP_REV(bsc->sc_chipid) == BNX_CHIP_REV_Bx) + } else if (chip_num == BNX_CHIP_NUM_5709) { + if ((chip_rev == BNX_CHIP_REV_Ax) || + (chip_rev == BNX_CHIP_REV_Bx)) brgphy_disable_early_dac(sc); /* Set Jumbo frame settings in the PHY. */ Index: src/sys/dev/mii/ciphy.c diff -u src/sys/dev/mii/ciphy.c:1.31 src/sys/dev/mii/ciphy.c:1.32 --- src/sys/dev/mii/ciphy.c:1.31 Sun Feb 24 17:22:21 2019 +++ src/sys/dev/mii/ciphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ciphy.c,v 1.31 2019/02/24 17:22:21 christos Exp $ */ +/* $NetBSD: ciphy.c,v 1.32 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 2004 @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ciphy.c,v 1.31 2019/02/24 17:22:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ciphy.c,v 1.32 2019/03/25 09:20:46 msaitoh Exp $"); /* * Driver for the Cicada CS8201 10/100/1000 copper PHY. @@ -94,9 +94,9 @@ ciphymatch(device_t parent, cfdata_t mat struct mii_attach_args *ma = aux; if (mii_phy_match(ma, ciphys) != NULL) - return (10); + return 10; - return (0); + return 0; } static void @@ -143,11 +143,9 @@ ciphy_service(struct mii_softc *sc, stru switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -158,12 +156,10 @@ ciphy_service(struct mii_softc *sc, stru if (IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -172,12 +168,10 @@ ciphy_service(struct mii_softc *sc, stru switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: #ifdef foo - /* - * If we're already in auto mode, just return. - */ + /* If we're already in auto mode, just return. */ PHY_READ(sc, MII_BMCR, ®); if (reg & BMCR_AUTOEN) - return (0); + return 0; #endif (void) mii_phy_auto(sc, 0); break; @@ -193,9 +187,8 @@ setit: if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { speed |= BMCR_FDX; gig = GTCR_ADV_1000TFDX; - } else { + } else gig = GTCR_ADV_1000THDX; - } PHY_WRITE(sc, MII_GTCR, 0); PHY_WRITE(sc, MII_BMCR, speed); @@ -220,8 +213,7 @@ setit: PHY_WRITE(sc, MII_GTCR, gig | GTCR_MAN_MS | GTCR_ADV_MS); } else { - PHY_WRITE(sc, MII_GTCR, - gig | GTCR_MAN_MS); + PHY_WRITE(sc, MII_GTCR, gig | GTCR_MAN_MS); } break; case IFM_NONE: @@ -229,26 +221,20 @@ setit: break; case IFM_100_T4: default: - return (EINVAL); + return EINVAL; } break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; - /* - * Is the interface even up? - */ + /* Is the interface even up? */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); + return 0; - /* - * Only used for autonegotiation. - */ + /* Only used for autonegotiation. */ if ((IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) && (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T)) { /* @@ -284,14 +270,12 @@ setit: if (sc->mii_ticks++ == 0) break; - /* - * Only retry autonegotiation every N seconds. - */ + /* Only retry autonegotiation every N seconds. */ if (sc->mii_ticks <= MII_ANEGTICKS_GIGE) break; mii_phy_auto(sc, 0); - return (0); + return 0; } /* Update the media status. */ @@ -307,7 +291,7 @@ setit: ciphy_fixup(sc); } mii_phy_update(sc, cmd); - return (0); + return 0; } static void @@ -406,7 +390,7 @@ ciphy_fixup(struct mii_softc *sc) speed = status & CIPHY_AUXCSR_SPEED; if (device_is_a(device_parent(sc->mii_dev), "nfe")) { - /* need to set for 2.5V RGMII for NVIDIA adapters */ + /* Need to set for 2.5V RGMII for NVIDIA adapters */ PHY_SETBIT(sc, CIPHY_MII_ECTL1, CIPHY_INTSEL_RGMII); PHY_SETBIT(sc, CIPHY_MII_ECTL1, CIPHY_IOVOL_2500MV); } @@ -444,9 +428,8 @@ ciphy_fixup(struct mii_softc *sc) if ((speed == CIPHY_SPEED10 || speed == CIPHY_SPEED100) && (status & CIPHY_AUXCSR_FDX)) { PHY_SETBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); - } else { + } else PHY_CLRBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); - } break; case MII_MODEL_CICADA_VSC8211: Index: src/sys/dev/mii/dmphy.c diff -u src/sys/dev/mii/dmphy.c:1.42 src/sys/dev/mii/dmphy.c:1.43 --- src/sys/dev/mii/dmphy.c:1.42 Mon Mar 25 07:34:13 2019 +++ src/sys/dev/mii/dmphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dmphy.c,v 1.42 2019/03/25 07:34:13 msaitoh Exp $ */ +/* $NetBSD: dmphy.c,v 1.43 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmphy.c,v 1.42 2019/03/25 07:34:13 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dmphy.c,v 1.43 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -236,13 +236,13 @@ dmphy_status(struct mii_softc *sc) PHY_READ(sc, MII_DMPHY_DSCSR, &dscsr); if (dscsr & DSCSR_100FDX) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; + mii->mii_media_active |= IFM_100_TX | IFM_FDX; else if (dscsr & DSCSR_100HDX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; + mii->mii_media_active |= IFM_100_TX | IFM_HDX; else if (dscsr & DSCSR_10FDX) - mii->mii_media_active |= IFM_10_T|IFM_FDX; + mii->mii_media_active |= IFM_10_T | IFM_FDX; else if (dscsr & DSCSR_10HDX) - mii->mii_media_active |= IFM_10_T|IFM_HDX; + mii->mii_media_active |= IFM_10_T | IFM_HDX; else mii->mii_media_active |= IFM_NONE; } else Index: src/sys/dev/mii/tqphy.c diff -u src/sys/dev/mii/tqphy.c:1.42 src/sys/dev/mii/tqphy.c:1.43 --- src/sys/dev/mii/tqphy.c:1.42 Sun Feb 24 17:22:21 2019 +++ src/sys/dev/mii/tqphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: tqphy.c,v 1.42 2019/02/24 17:22:21 christos Exp $ */ +/* $NetBSD: tqphy.c,v 1.43 2019/03/25 09:20:46 msaitoh Exp $ */ /* * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tqphy.c,v 1.42 2019/02/24 17:22:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tqphy.c,v 1.43 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -108,11 +108,11 @@ tqphymatch(device_t parent, cfdata_t mat /* The DIAG register is unreliable on early revisions. */ if (MII_MODEL(ma->mii_id2) == MII_MODEL_xxTSC_78Q2120 && MII_REV(ma->mii_id2) <= 3) - return (0); - return (10); + return 0; + return 10; } - return (0); + return 0; } static void @@ -135,9 +135,7 @@ tqphyattach(device_t parent, device_t se sc->mii_flags = ma->mii_flags; sc->mii_anegticks = MII_ANEGTICKS; - /* - * Apparently, we can't do loopback on this PHY. - */ + /* Apparently, we can't do loopback on this PHY. */ sc->mii_flags |= MIIF_NOLOOP; PHY_RESET(sc); @@ -160,11 +158,9 @@ tqphy_service(struct mii_softc *sc, stru switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -175,12 +171,10 @@ tqphy_service(struct mii_softc *sc, stru if (IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -188,19 +182,17 @@ tqphy_service(struct mii_softc *sc, stru break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); + return 0; break; case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -208,7 +200,7 @@ tqphy_service(struct mii_softc *sc, stru /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void Index: src/sys/dev/mii/gentbi.c diff -u src/sys/dev/mii/gentbi.c:1.28 src/sys/dev/mii/gentbi.c:1.29 --- src/sys/dev/mii/gentbi.c:1.28 Tue Jan 22 03:42:27 2019 +++ src/sys/dev/mii/gentbi.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: gentbi.c,v 1.28 2019/01/22 03:42:27 msaitoh Exp $ */ +/* $NetBSD: gentbi.c,v 1.29 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: gentbi.c,v 1.28 2019/01/22 03:42:27 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gentbi.c,v 1.29 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -108,22 +108,22 @@ gentbimatch(device_t parent, cfdata_t ma rv = (*mii->mii_readreg)(parent, ma->mii_phyno, MII_BMSR, &bmsr); if ((rv != 0) || (bmsr & BMSR_EXTSTAT) == 0 || (bmsr & BMSR_MEDIAMASK) != 0) - return (0); + return 0; rv = (*mii->mii_readreg)(parent, ma->mii_phyno, MII_EXTSR, &extsr); - if ((rv != 0) || ((extsr & (EXTSR_1000TFDX|EXTSR_1000THDX)) != 0)) - return (0); + if ((rv != 0) || ((extsr & (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)) + return 0; - if (extsr & (EXTSR_1000XFDX|EXTSR_1000XHDX)) { + if (extsr & (EXTSR_1000XFDX | EXTSR_1000XHDX)) { /* * We think this is a generic TBI. Return a match * priority higher than ukphy, but lower than what * specific drivers will return. */ - return (2); + return 2; } - return (0); + return 0; } static void @@ -186,11 +186,9 @@ gentbi_service(struct mii_softc *sc, str switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -201,12 +199,10 @@ gentbi_service(struct mii_softc *sc, str if (IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -214,19 +210,17 @@ gentbi_service(struct mii_softc *sc, str break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); + return 0; break; case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -234,7 +228,7 @@ gentbi_service(struct mii_softc *sc, str /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void Index: src/sys/dev/mii/icsphy.c diff -u src/sys/dev/mii/icsphy.c:1.53 src/sys/dev/mii/icsphy.c:1.54 --- src/sys/dev/mii/icsphy.c:1.53 Sun Feb 24 17:22:21 2019 +++ src/sys/dev/mii/icsphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: icsphy.c,v 1.53 2019/02/24 17:22:21 christos Exp $ */ +/* $NetBSD: icsphy.c,v 1.54 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: icsphy.c,v 1.53 2019/02/24 17:22:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: icsphy.c,v 1.54 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -106,9 +106,9 @@ icsphymatch(device_t parent, cfdata_t ma struct mii_attach_args *ma = aux; if (mii_phy_match(ma, icsphys) != NULL) - return (10); + return 10; - return (0); + return 0; } static void @@ -152,11 +152,9 @@ icsphy_service(struct mii_softc *sc, str switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -167,12 +165,10 @@ icsphy_service(struct mii_softc *sc, str if (IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -180,19 +176,17 @@ icsphy_service(struct mii_softc *sc, str break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); + return 0; break; case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -200,7 +194,7 @@ icsphy_service(struct mii_softc *sc, str /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void @@ -258,7 +252,7 @@ icsphy_reset(struct mii_softc *sc) { mii_phy_reset(sc); - /* set powerdown feature */ + /* Set powerdown feature */ switch (sc->mii_mpd_model) { case MII_MODEL_ICS_1890: case MII_MODEL_ICS_1893: @@ -266,7 +260,7 @@ icsphy_reset(struct mii_softc *sc) break; case MII_MODEL_ICS_1892: PHY_WRITE(sc, MII_ICSPHY_ECR2, - ECR2_10AUTOPWRDN|ECR2_100AUTOPWRDN); + ECR2_10AUTOPWRDN | ECR2_100AUTOPWRDN); break; default: /* 1889 have no ECR2 */ @@ -276,5 +270,5 @@ icsphy_reset(struct mii_softc *sc) * There is no description that the reset do auto-negotiation in the * data sheet. */ - PHY_WRITE(sc, MII_BMCR, BMCR_S100|BMCR_STARTNEG|BMCR_FDX); + PHY_WRITE(sc, MII_BMCR, BMCR_S100 | BMCR_STARTNEG | BMCR_FDX); } Index: src/sys/dev/mii/sqphy.c diff -u src/sys/dev/mii/sqphy.c:1.53 src/sys/dev/mii/sqphy.c:1.54 --- src/sys/dev/mii/sqphy.c:1.53 Sun Feb 24 17:22:21 2019 +++ src/sys/dev/mii/sqphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sqphy.c,v 1.53 2019/02/24 17:22:21 christos Exp $ */ +/* $NetBSD: sqphy.c,v 1.54 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sqphy.c,v 1.53 2019/02/24 17:22:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sqphy.c,v 1.54 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -109,9 +109,9 @@ sqphymatch(device_t parent, cfdata_t mat struct mii_attach_args *ma = aux; if (mii_phy_match(ma, sqphys) != NULL) - return (10); + return 10; - return (0); + return 0; } static void @@ -164,11 +164,9 @@ sqphy_service(struct mii_softc *sc, stru switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -179,12 +177,10 @@ sqphy_service(struct mii_softc *sc, stru if (IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -192,19 +188,17 @@ sqphy_service(struct mii_softc *sc, stru break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); + return 0; break; case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -212,7 +206,7 @@ sqphy_service(struct mii_softc *sc, stru /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void @@ -247,9 +241,8 @@ sqphy_status(struct mii_softc *sc) return; } /* - * Note: don't get fancy here -- the 80225 only - * supports the SPD_DET and DPLX_DET bits in - * the STATUS register. + * Note: don't get fancy here -- the 80225 only supports the + * SPD_DET and DPLX_DET bits in the STATUS register. */ PHY_READ(sc, MII_SQPHY_STATUS, &status); if (status & STATUS_SPD_DET) Index: src/sys/dev/mii/iophy.c diff -u src/sys/dev/mii/iophy.c:1.40 src/sys/dev/mii/iophy.c:1.41 --- src/sys/dev/mii/iophy.c:1.40 Sun Feb 24 17:22:21 2019 +++ src/sys/dev/mii/iophy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: iophy.c,v 1.40 2019/02/24 17:22:21 christos Exp $ */ +/* $NetBSD: iophy.c,v 1.41 2019/03/25 09:20:46 msaitoh Exp $ */ /* * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: iophy.c,v 1.40 2019/02/24 17:22:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: iophy.c,v 1.41 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -101,9 +101,9 @@ iophymatch(device_t parent, cfdata_t mat struct mii_attach_args *ma = aux; if (mii_phy_match(ma, iophys) != NULL) - return (10); + return 10; - return (0); + return 0; } static void @@ -146,11 +146,9 @@ iophy_service(struct mii_softc *sc, stru switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -161,12 +159,10 @@ iophy_service(struct mii_softc *sc, stru if (IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -174,19 +170,17 @@ iophy_service(struct mii_softc *sc, stru break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); + return 0; break; case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -194,7 +188,7 @@ iophy_service(struct mii_softc *sc, stru /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void @@ -230,11 +224,10 @@ iophy_status(struct mii_softc *sc) PHY_READ(sc, MII_IOPHY_EXT0, &ext0); if (ext0 & EXT0_SPEED) { - if ((bmsr & BMSR_100TXFDX) || (bmsr & BMSR_100TXHDX)) { + if ((bmsr & BMSR_100TXFDX) || (bmsr & BMSR_100TXHDX)) mii->mii_media_active |= IFM_100_TX; - } else if (bmsr & BMSR_100T4) { + else if (bmsr & BMSR_100T4) mii->mii_media_active |= IFM_100_T4; - } } else mii->mii_media_active |= IFM_10_T; Index: src/sys/dev/mii/mii.c diff -u src/sys/dev/mii/mii.c:1.52 src/sys/dev/mii/mii.c:1.53 --- src/sys/dev/mii/mii.c:1.52 Tue Jan 22 03:42:27 2019 +++ src/sys/dev/mii/mii.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: mii.c,v 1.52 2019/01/22 03:42:27 msaitoh Exp $ */ +/* $NetBSD: mii.c,v 1.53 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mii.c,v 1.52 2019/01/22 03:42:27 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mii.c,v 1.53 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -109,7 +109,7 @@ mii_attach(device_t parent, struct mii_d rv = (*mii->mii_readreg)(parent, ma.mii_phyno, MII_BMSR, &bmsr); if ((rv != 0) || bmsr == 0 || bmsr == 0xffff || - (bmsr & (BMSR_EXTSTAT|BMSR_MEDIAMASK)) == 0) { + (bmsr & (BMSR_EXTSTAT | BMSR_MEDIAMASK)) == 0) { /* Assume no PHY at this address. */ continue; } @@ -145,9 +145,7 @@ mii_attach(device_t parent, struct mii_d child = device_private(config_found_sm_loc(parent, "mii", locs, &ma, mii_print, config_stdsubmatch)); if (child) { - /* - * Link it up in the parent's MII data. - */ + /* Link it up in the parent's MII data. */ callout_init(&child->mii_nway_ch, 0); LIST_INSERT_HEAD(&mii->mii_phys, child, mii_list); child->mii_offset = offset; @@ -194,12 +192,13 @@ mii_print(void *aux, const char *pnp) MII_REV(ma->mii_id2), pnp); aprint_normal(" phy %d", ma->mii_phyno); - return (UNCONF); + return UNCONF; } static inline int phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) { + if (!device_is_active(sc->mii_dev)) return ENXIO; return PHY_SERVICE(sc, mii, cmd); @@ -226,9 +225,9 @@ mii_mediachg(struct mii_data *mii) LIST_FOREACH(child, &mii->mii_phys, mii_list) { rv = phy_service(child, mii, MII_MEDIACHG); if (rv) - return (rv); + return rv; } - return (0); + return 0; } /* Index: src/sys/dev/mii/mii_physubr.c diff -u src/sys/dev/mii/mii_physubr.c:1.85 src/sys/dev/mii/mii_physubr.c:1.86 --- src/sys/dev/mii/mii_physubr.c:1.85 Mon Mar 25 07:34:13 2019 +++ src/sys/dev/mii/mii_physubr.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: mii_physubr.c,v 1.85 2019/03/25 07:34:13 msaitoh Exp $ */ +/* $NetBSD: mii_physubr.c,v 1.86 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.85 2019/03/25 07:34:13 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.86 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -88,23 +88,23 @@ static const struct mii_media mii_media_ 0, }, /* 10baseT */ - { BMCR_S10, ANAR_CSMA|ANAR_10, + { BMCR_S10, ANAR_CSMA | ANAR_10, 0, }, /* 10baseT-FDX */ - { BMCR_S10|BMCR_FDX, ANAR_CSMA|ANAR_10_FD, + { BMCR_S10|BMCR_FDX, ANAR_CSMA | ANAR_10_FD, 0, }, /* 100baseT4 */ - { BMCR_S100, ANAR_CSMA|ANAR_T4, + { BMCR_S100, ANAR_CSMA | ANAR_T4, 0, }, /* 100baseTX */ - { BMCR_S100, ANAR_CSMA|ANAR_TX, + { BMCR_S100, ANAR_CSMA | ANAR_TX, 0, }, /* 100baseTX-FDX */ - { BMCR_S100|BMCR_FDX, ANAR_CSMA|ANAR_TX_FD, + { BMCR_S100|BMCR_FDX, ANAR_CSMA | ANAR_TX_FD, 0, }, /* 1000baseX */ @@ -143,7 +143,7 @@ mii_phy_setmedia(struct mii_softc *sc) */ PHY_READ(sc, MII_BMCR, &bmcr); if ((bmcr & BMCR_AUTOEN) == 0 || - (sc->mii_flags & (MIIF_FORCEANEG|MIIF_DOPAUSE))) + (sc->mii_flags & (MIIF_FORCEANEG | MIIF_DOPAUSE))) (void) mii_phy_auto(sc, 1); return; } @@ -162,7 +162,7 @@ mii_phy_setmedia(struct mii_softc *sc) if (mii->mii_media.ifm_media & IFM_ETH_MASTER) { switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_1000_T: - gtcr |= GTCR_MAN_MS|GTCR_ADV_MS; + gtcr |= GTCR_MAN_MS | GTCR_ADV_MS; break; default: @@ -594,6 +594,7 @@ mii_phy_delete_media(struct mii_softc *s int mii_phy_activate(device_t self, enum devact act) { + switch (act) { case DVACT_DEACTIVATE: /* XXX Invalidate parent's media setting? */ Index: src/sys/dev/mii/nsphy.c diff -u src/sys/dev/mii/nsphy.c:1.63 src/sys/dev/mii/nsphy.c:1.64 --- src/sys/dev/mii/nsphy.c:1.63 Sun Feb 24 17:22:21 2019 +++ src/sys/dev/mii/nsphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nsphy.c,v 1.63 2019/02/24 17:22:21 christos Exp $ */ +/* $NetBSD: nsphy.c,v 1.64 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsphy.c,v 1.63 2019/02/24 17:22:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsphy.c,v 1.64 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -103,9 +103,9 @@ nsphymatch(device_t parent, cfdata_t mat struct mii_attach_args *ma = aux; if (mii_phy_match(ma, nsphys) != NULL) - return (10); + return 10; - return (0); + return 0; } static void @@ -148,11 +148,9 @@ nsphy_service(struct mii_softc *sc, stru switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (ife != NULL && IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -163,12 +161,10 @@ nsphy_service(struct mii_softc *sc, stru if (ife != NULL && IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -211,19 +207,17 @@ nsphy_service(struct mii_softc *sc, stru break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (ife != NULL && IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); + return 0; break; case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -231,7 +225,7 @@ nsphy_service(struct mii_softc *sc, stru /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void @@ -281,15 +275,15 @@ nsphy_status(struct mii_softc *sc) PHY_READ(sc, MII_ANLPAR, &anlpar); result = anar & anlpar; if (result & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; + mii->mii_media_active |= IFM_100_TX | IFM_FDX; else if (result & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; + mii->mii_media_active |= IFM_100_T4 | IFM_HDX; else if (result & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; + mii->mii_media_active |= IFM_100_TX | IFM_HDX; else if (result & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; + mii->mii_media_active |= IFM_10_T | IFM_FDX; else if (result & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; + mii->mii_media_active |= IFM_10_T | IFM_HDX; else mii->mii_media_active |= IFM_NONE; return; Index: src/sys/dev/mii/pnaphy.c diff -u src/sys/dev/mii/pnaphy.c:1.23 src/sys/dev/mii/pnaphy.c:1.24 --- src/sys/dev/mii/pnaphy.c:1.23 Sun Feb 24 17:22:21 2019 +++ src/sys/dev/mii/pnaphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: pnaphy.c,v 1.23 2019/02/24 17:22:21 christos Exp $ */ +/* $NetBSD: pnaphy.c,v 1.24 2019/03/25 09:20:46 msaitoh Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -47,7 +47,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pnaphy.c,v 1.23 2019/02/24 17:22:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pnaphy.c,v 1.24 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -91,10 +91,10 @@ pnaphymatch(device_t parent, cfdata_t ma * Match higher than ukphy, but lower than a specific * driver would match. */ - return (2); + return 2; } - return (0); + return 0; } static void @@ -114,7 +114,7 @@ pnaphyattach(device_t parent, device_t s sc->mii_phy = ma->mii_phyno; sc->mii_funcs = &pnaphy_funcs; sc->mii_pdata = mii; - sc->mii_flags = ma->mii_flags | MIIF_IS_HPNA; /* force HomePNA */ + sc->mii_flags = ma->mii_flags | MIIF_IS_HPNA; /* Force HomePNA */ sc->mii_anegticks = MII_ANEGTICKS; PHY_RESET(sc); @@ -137,11 +137,9 @@ pnaphy_service(struct mii_softc *sc, str switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -152,12 +150,10 @@ pnaphy_service(struct mii_softc *sc, str if (IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -165,19 +161,17 @@ pnaphy_service(struct mii_softc *sc, str break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); + return 0; break; case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -185,7 +179,7 @@ pnaphy_service(struct mii_softc *sc, str /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void Index: src/sys/dev/mii/qsphy.c diff -u src/sys/dev/mii/qsphy.c:1.51 src/sys/dev/mii/qsphy.c:1.52 --- src/sys/dev/mii/qsphy.c:1.51 Sun Feb 24 17:22:21 2019 +++ src/sys/dev/mii/qsphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: qsphy.c,v 1.51 2019/02/24 17:22:21 christos Exp $ */ +/* $NetBSD: qsphy.c,v 1.52 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: qsphy.c,v 1.51 2019/02/24 17:22:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: qsphy.c,v 1.52 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -102,9 +102,9 @@ qsphymatch(device_t parent, cfdata_t mat struct mii_attach_args *ma = aux; if (mii_phy_match(ma, qsphys) != NULL) - return (10); + return 10; - return (0); + return 0; } static void @@ -151,7 +151,7 @@ qsphy_service(struct mii_softc *sc, stru * If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -162,7 +162,7 @@ qsphy_service(struct mii_softc *sc, stru if (IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } /* @@ -179,15 +179,15 @@ qsphy_service(struct mii_softc *sc, stru * If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); + return 0; break; case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -195,7 +195,7 @@ qsphy_service(struct mii_softc *sc, stru /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void @@ -233,19 +233,19 @@ qsphy_status(struct mii_softc *sc) PHY_READ(sc, MII_QSPHY_PCTL, &pctl); switch (pctl & PCTL_OPMASK) { case PCTL_10_T: - mii->mii_media_active |= IFM_10_T|IFM_HDX; + mii->mii_media_active |= IFM_10_T | IFM_HDX; break; case PCTL_10_T_FDX: - mii->mii_media_active |= IFM_10_T|IFM_FDX; + mii->mii_media_active |= IFM_10_T | IFM_FDX; break; case PCTL_100_TX: - mii->mii_media_active |= IFM_100_TX|IFM_HDX; + mii->mii_media_active |= IFM_100_TX | IFM_HDX; break; case PCTL_100_TX_FDX: - mii->mii_media_active |= IFM_100_TX|IFM_FDX; + mii->mii_media_active |= IFM_100_TX | IFM_FDX; break; case PCTL_100_T4: - mii->mii_media_active |= IFM_100_T4|IFM_HDX; + mii->mii_media_active |= IFM_100_T4 | IFM_HDX; break; default: /* Erg... this shouldn't happen. */ Index: src/sys/dev/mii/rgephy.c diff -u src/sys/dev/mii/rgephy.c:1.51 src/sys/dev/mii/rgephy.c:1.52 --- src/sys/dev/mii/rgephy.c:1.51 Tue Feb 26 05:26:10 2019 +++ src/sys/dev/mii/rgephy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rgephy.c,v 1.51 2019/02/26 05:26:10 msaitoh Exp $ */ +/* $NetBSD: rgephy.c,v 1.52 2019/03/25 09:20:46 msaitoh Exp $ */ /* * Copyright (c) 2003 @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rgephy.c,v 1.51 2019/02/26 05:26:10 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rgephy.c,v 1.52 2019/03/25 09:20:46 msaitoh Exp $"); /* @@ -147,7 +147,7 @@ rgephy_attach(device_t parent, device_t #ifdef __FreeBSD__ ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst), - BMCR_LOOP|BMCR_S100); + BMCR_LOOP | BMCR_S100); #endif PHY_READ(sc, MII_BMSR, &sc->mii_capabilities); @@ -184,9 +184,7 @@ rgephy_service(struct mii_softc *sc, str switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) return 0; break; @@ -202,9 +200,7 @@ rgephy_service(struct mii_softc *sc, str return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -216,9 +212,7 @@ rgephy_service(struct mii_softc *sc, str switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: #ifdef foo - /* - * If we're already in auto mode, just return. - */ + /* If we're already in auto mode, just return. */ PHY_READ(sc, MII_BMCR, ®); if (reg & BMCR_AUTOEN) return 0; @@ -249,30 +243,30 @@ rgephy_service(struct mii_softc *sc, str if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) { PHY_WRITE(sc, MII_100T2CR, 0); PHY_WRITE(sc, MII_ANAR, anar); - PHY_WRITE(sc, MII_BMCR, speed | - BMCR_AUTOEN | BMCR_STARTNEG); + PHY_WRITE(sc, MII_BMCR, + speed | BMCR_AUTOEN | BMCR_STARTNEG); break; } /* - * When setting the link manually, one side must - * be the master and the other the slave. However - * ifmedia doesn't give us a good way to specify - * this, so we fake it by using one of the LINK - * flags. If LINK0 is set, we program the PHY to - * be a master, otherwise it's a slave. + * When setting the link manually, one side must be the + * master and the other the slave. However ifmedia + * doesn't give us a good way to specify this, so we + * fake it by using one of the LINK flags. If LINK0 is + * set, we program the PHY to be a master, otherwise + * it's a slave. */ if ((mii->mii_ifp->if_flags & IFF_LINK0)) { PHY_WRITE(sc, MII_100T2CR, - gig|GTCR_MAN_MS|GTCR_ADV_MS); + gig | GTCR_MAN_MS | GTCR_ADV_MS); } else { - PHY_WRITE(sc, MII_100T2CR, gig|GTCR_MAN_MS); + PHY_WRITE(sc, MII_100T2CR, gig | GTCR_MAN_MS); } - PHY_WRITE(sc, MII_BMCR, speed | - BMCR_AUTOEN | BMCR_STARTNEG); + PHY_WRITE(sc, MII_BMCR, + speed | BMCR_AUTOEN | BMCR_STARTNEG); break; case IFM_NONE: - PHY_WRITE(sc, MII_BMCR, BMCR_ISO|BMCR_PDOWN); + PHY_WRITE(sc, MII_BMCR, BMCR_ISO | BMCR_PDOWN); break; case IFM_100_T4: default: @@ -281,21 +275,15 @@ rgephy_service(struct mii_softc *sc, str break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) return 0; - /* - * Is the interface even up? - */ + /* Is the interface even up? */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return 0; - /* - * Only used for autonegotiation. - */ + /* Only used for autonegotiation. */ if ((IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) && (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T)) { /* @@ -465,7 +453,6 @@ rgephy_status(struct mii_softc *sc) } } - static int rgephy_mii_phy_auto(struct mii_softc *mii) { @@ -536,11 +523,10 @@ PHY_CLRBIT(struct mii_softc *sc, int y, } /* - * Initialize RealTek PHY per the datasheet. The DSP in the PHYs of - * existing revisions of the 8169S/8110S chips need to be tuned in - * order to reliably negotiate a 1000Mbps link. This is only needed - * for rev 0 and rev 1 of the PHY. Later versions work without - * any fixups. + * Initialize RealTek PHY per the datasheet. The DSP in the PHYs of existing + * revisions of the 8169S/8110S chips need to be tuned in order to reliably + * negotiate a 1000Mbps link. This is only needed for rev 0 and rev 1 of the + * PHY. Later versions work without any fixups. */ static void rgephy_load_dspcode(struct mii_softc *sc) Index: src/sys/dev/mii/rdcphy.c diff -u src/sys/dev/mii/rdcphy.c:1.3 src/sys/dev/mii/rdcphy.c:1.4 --- src/sys/dev/mii/rdcphy.c:1.3 Sun Feb 24 17:22:21 2019 +++ src/sys/dev/mii/rdcphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rdcphy.c,v 1.3 2019/02/24 17:22:21 christos Exp $ */ +/* $NetBSD: rdcphy.c,v 1.4 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 2010, Pyun YongHyeon <yong...@freebsd.org> @@ -33,7 +33,7 @@ * Driver for the RDC Semiconductor R6040 10/100 PHY. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rdcphy.c,v 1.3 2019/02/24 17:22:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rdcphy.c,v 1.4 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -84,9 +84,9 @@ rdcphymatch(device_t parent, cfdata_t ma struct mii_attach_args *ma = aux; if (mii_phy_match(ma, rdcphys) != NULL) - return (10); + return 10; - return (0); + return 0; } static void @@ -137,9 +137,7 @@ rdcphy_service(struct mii_softc *sc, str break; case MII_MEDIACHG: - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -148,14 +146,13 @@ rdcphy_service(struct mii_softc *sc, str case IFM_100_TX: case IFM_10_T: /* - * Report fake lost link event to parent - * driver. This will stop MAC of parent - * driver and make it possible to reconfigure - * MAC after completion of link establishment. - * Note, the parent MAC seems to require - * restarting MAC when underlying any PHY - * configuration was changed even if the - * resolved speed/duplex was not changed at + * Report fake lost link event to parent driver. This + * will stop MAC of parent driver and make it possible + * to reconfigure MAC after completion of link + * establishment. + * Note, the parent MAC seems to require restarting MAC + * when underlying any PHY configuration was changed + * even if the resolved speed/duplex was not changed at * all. */ mii->mii_media_status = 0; @@ -163,7 +160,7 @@ rdcphy_service(struct mii_softc *sc, str rsc->sc_mii_link_tick = RDCPHY_MANNEG_TICK; /* Immediately report link down. */ mii_phy_update(sc, MII_MEDIACHG); - return (0); + return 0; default: break; } @@ -171,23 +168,22 @@ rdcphy_service(struct mii_softc *sc, str case MII_TICK: if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); + return 0; if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) { /* - * It seems the PHY hardware does not correctly - * report link status changes when manual link - * configuration is in progress. It is also - * possible for the PHY to complete establishing - * a link within one second such that mii(4) - * did not notice the link change. To workaround - * the issue, emulate lost link event and wait - * for 3 seconds when manual link configuration - * is in progress. 3 seconds would be long - * enough to absorb transient link flips. + * It seems the PHY hardware does not correctly report + * link status changes when manual link configuration + * is in progress. It is also possible for the PHY to + * complete establishing a link within one second such + * that mii(4) did not notice the link change. + * To workaround the issue, emulate lost link event and + * wait for 3 seconds when manual link configuration + * is in progress. 3 seconds would be long enough to + * absorb transient link flips. */ if (rsc->sc_mii_link_tick > 0) { rsc->sc_mii_link_tick--; - return (0); + return 0; } } break; @@ -198,7 +194,7 @@ rdcphy_service(struct mii_softc *sc, str /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void Index: src/sys/dev/mii/rlphy.c diff -u src/sys/dev/mii/rlphy.c:1.35 src/sys/dev/mii/rlphy.c:1.36 --- src/sys/dev/mii/rlphy.c:1.35 Fri Mar 8 09:59:15 2019 +++ src/sys/dev/mii/rlphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rlphy.c,v 1.35 2019/03/08 09:59:15 msaitoh Exp $ */ +/* $NetBSD: rlphy.c,v 1.36 2019/03/25 09:20:46 msaitoh Exp $ */ /* $OpenBSD: rlphy.c,v 1.20 2005/07/31 05:27:30 pvalchev Exp $ */ /* @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rlphy.c,v 1.35 2019/03/08 09:59:15 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rlphy.c,v 1.36 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -92,7 +92,7 @@ rlphymatch(device_t parent, cfdata_t mat return 0; if (mii_phy_match(ma, rlphys) != NULL) - return (10); + return 10; if (MII_OUI(ma->mii_id1, ma->mii_id2) != 0 || MII_MODEL(ma->mii_id2) != 0) @@ -152,9 +152,7 @@ rlphy_service(struct mii_softc *sc, stru { struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - /* - * Can't isolate the RTL8139 phy, so it has to be the only one. - */ + /* Can't isolate the RTL8139 phy, so it has to be the only one. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) panic("rlphy_service: attempt to isolate phy"); @@ -163,9 +161,7 @@ rlphy_service(struct mii_softc *sc, stru break; case MII_MEDIACHG: - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -173,15 +169,11 @@ rlphy_service(struct mii_softc *sc, stru break; case MII_TICK: - /* - * Is the interface even up? - */ + /* Is the interface even up? */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); + return 0; - /* - * Only used for autonegotiation. - */ + /* Only used for autonegotiation. */ if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) break; @@ -193,7 +185,7 @@ rlphy_service(struct mii_softc *sc, stru case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -201,7 +193,7 @@ rlphy_service(struct mii_softc *sc, stru /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void @@ -247,15 +239,15 @@ rlphy_status(struct mii_softc *sc) result = anar & anlpar; if (result != 0) { if (result & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; + mii->mii_media_active |= IFM_100_TX | IFM_FDX; else if (result & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; + mii->mii_media_active |= IFM_100_T4 | IFM_HDX; else if (result & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; + mii->mii_media_active |= IFM_100_TX | IFM_HDX; else if (result & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; + mii->mii_media_active |= IFM_10_T | IFM_FDX; else if (result & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; + mii->mii_media_active |= IFM_10_T | IFM_HDX; else mii->mii_media_active |= IFM_NONE; return; Index: src/sys/dev/mii/tlphy.c diff -u src/sys/dev/mii/tlphy.c:1.65 src/sys/dev/mii/tlphy.c:1.66 --- src/sys/dev/mii/tlphy.c:1.65 Tue Mar 5 02:13:15 2019 +++ src/sys/dev/mii/tlphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: tlphy.c,v 1.65 2019/03/05 02:13:15 msaitoh Exp $ */ +/* $NetBSD: tlphy.c,v 1.66 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tlphy.c,v 1.65 2019/03/05 02:13:15 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tlphy.c,v 1.66 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -117,9 +117,9 @@ tlphymatch(device_t parent, cfdata_t mat struct mii_attach_args *ma = aux; if (mii_phy_match(ma, tlphys) != NULL) - return (10); + return 10; - return (0); + return 0; } static void @@ -148,11 +148,10 @@ tlphyattach(device_t parent, device_t se PHY_RESET(sc); /* - * Note that if we're on a device that also supports 100baseTX, - * we are not going to want to use the built-in 10baseT port, - * since there will be another PHY on the MII wired up to the - * UTP connector. The parent indicates this to us by specifying - * the TLPHY_MEDIA_NO_10_T bit. + * Note that if we're on a device that also supports 100baseTX, we are + * not going to want to use the built-in 10baseT port, since there will + * be another PHY on the MII wired up to the UTP connector. The parent + * indicates this to us by specifying the TLPHY_MEDIA_NO_10_T bit. */ tsc->sc_tlphycap = tlsc->tl_product->tp_tlphymedia; if ((tsc->sc_tlphycap & TLPHY_MEDIA_NO_10_T) == 0) { @@ -168,12 +167,12 @@ tlphyattach(device_t parent, device_t se aprint_normal_dev(self, ""); if (tsc->sc_tlphycap) { if (tsc->sc_tlphycap & TLPHY_MEDIA_10_2) { - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_2, 0, - sc->mii_inst), 0); + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_2, 0, sc->mii_inst), + 0); PRINT("10base2"); } else if (tsc->sc_tlphycap & TLPHY_MEDIA_10_5) { - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_5, 0, - sc->mii_inst), 0); + ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_5, 0, sc->mii_inst), + 0); PRINT("10base5"); } } @@ -211,11 +210,9 @@ tlphy_service(struct mii_softc *sc, stru switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -226,12 +223,10 @@ tlphy_service(struct mii_softc *sc, stru if (IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -258,23 +253,21 @@ tlphy_service(struct mii_softc *sc, stru break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; /* * XXX WHAT ABOUT CHECKING LINK ON THE BNC/AUI?! */ if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); + return 0; break; case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -282,7 +275,7 @@ tlphy_service(struct mii_softc *sc, stru /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void @@ -324,10 +317,9 @@ tlphy_status(struct mii_softc *sc) mii->mii_media_active |= IFM_LOOP; /* - * Grr, braindead ThunderLAN PHY doesn't have any way to - * tell which media is actually active. (Note it also - * doesn't self-configure after autonegotiation.) We - * just have to report what's in the BMCR. + * Grr, braindead ThunderLAN PHY doesn't have any way to tell which + * media is actually active. (Note it also doesn't self-configure + * after autonegotiation.) We just have to report what's in the BMCR. */ if (bmcr & BMCR_FDX) mii->mii_media_active |= IFM_FDX; @@ -360,7 +352,7 @@ tlphy_auto(struct tlphy_softc *tsc, int tlphy_acomp(tsc); } - return (error); + return error; } static void Index: src/sys/dev/mii/ukphy.c diff -u src/sys/dev/mii/ukphy.c:1.50 src/sys/dev/mii/ukphy.c:1.51 --- src/sys/dev/mii/ukphy.c:1.50 Tue Jan 22 03:42:27 2019 +++ src/sys/dev/mii/ukphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ukphy.c,v 1.50 2019/01/22 03:42:27 msaitoh Exp $ */ +/* $NetBSD: ukphy.c,v 1.51 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ukphy.c,v 1.50 2019/01/22 03:42:27 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ukphy.c,v 1.51 2019/03/25 09:20:46 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_mii.h" @@ -98,7 +98,7 @@ ukphymatch(device_t parent, cfdata_t mat /* * We know something is here, so always match at a low priority. */ - return (1); + return 1; } static void @@ -159,11 +159,9 @@ ukphy_service(struct mii_softc *sc, stru switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: @@ -174,12 +172,10 @@ ukphy_service(struct mii_softc *sc, stru if (IFM_INST(ife->ifm_media) != sc->mii_inst) { PHY_READ(sc, MII_BMCR, ®); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - return (0); + return 0; } - /* - * If the interface is not up, don't do anything. - */ + /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; @@ -187,19 +183,17 @@ ukphy_service(struct mii_softc *sc, stru break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; if (mii_phy_tick(sc) == EJUSTRETURN) - return (0); + return 0; break; case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -207,5 +201,5 @@ ukphy_service(struct mii_softc *sc, stru /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } Index: src/sys/dev/mii/ukphy_subr.c diff -u src/sys/dev/mii/ukphy_subr.c:1.14 src/sys/dev/mii/ukphy_subr.c:1.15 --- src/sys/dev/mii/ukphy_subr.c:1.14 Tue Jan 22 03:42:27 2019 +++ src/sys/dev/mii/ukphy_subr.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ukphy_subr.c,v 1.14 2019/01/22 03:42:27 msaitoh Exp $ */ +/* $NetBSD: ukphy_subr.c,v 1.15 2019/03/25 09:20:46 msaitoh Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ukphy_subr.c,v 1.14 2019/01/22 03:42:27 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ukphy_subr.c,v 1.15 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -102,20 +102,20 @@ ukphy_status(struct mii_softc *phy) gtcr = gtsr = 0; if ((gtcr & GTCR_ADV_1000TFDX) && (gtsr & GTSR_LP_1000TFDX)) - mii->mii_media_active |= IFM_1000_T|IFM_FDX; + mii->mii_media_active |= IFM_1000_T | IFM_FDX; else if ((gtcr & GTCR_ADV_1000THDX) && (gtsr & GTSR_LP_1000THDX)) - mii->mii_media_active |= IFM_1000_T|IFM_HDX; + mii->mii_media_active |= IFM_1000_T | IFM_HDX; else if (result & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; + mii->mii_media_active |= IFM_100_TX | IFM_FDX; else if (result & ANLPAR_T4) - mii->mii_media_active |= IFM_100_T4|IFM_HDX; + mii->mii_media_active |= IFM_100_T4 | IFM_HDX; else if (result & ANLPAR_TX) - mii->mii_media_active |= IFM_100_TX|IFM_HDX; + mii->mii_media_active |= IFM_100_TX | IFM_HDX; else if (result & ANLPAR_10_FD) - mii->mii_media_active |= IFM_10_T|IFM_FDX; + mii->mii_media_active |= IFM_10_T | IFM_FDX; else if (result & ANLPAR_10) - mii->mii_media_active |= IFM_10_T|IFM_HDX; + mii->mii_media_active |= IFM_10_T | IFM_HDX; else mii->mii_media_active |= IFM_NONE; Index: src/sys/dev/mii/urlphy.c diff -u src/sys/dev/mii/urlphy.c:1.33 src/sys/dev/mii/urlphy.c:1.34 --- src/sys/dev/mii/urlphy.c:1.33 Tue Jan 22 03:42:27 2019 +++ src/sys/dev/mii/urlphy.c Mon Mar 25 09:20:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: urlphy.c,v 1.33 2019/01/22 03:42:27 msaitoh Exp $ */ +/* $NetBSD: urlphy.c,v 1.34 2019/03/25 09:20:46 msaitoh Exp $ */ /* * Copyright (c) 2001, 2002 * Shingo WATANABE <n...@nabechan.org>. All rights reserved. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: urlphy.c,v 1.33 2019/01/22 03:42:27 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: urlphy.c,v 1.34 2019/03/25 09:20:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -77,20 +77,16 @@ urlphy_match(device_t parent, cfdata_t m { struct mii_attach_args *ma = aux; - /* - * RTL8150 reports OUI == 0, MODEL == 0 - */ + /* RTL8150 reports OUI == 0, MODEL == 0 */ if (MII_OUI(ma->mii_id1, ma->mii_id2) != 0 && MII_MODEL(ma->mii_id2) != 0) - return (0); + return 0; - /* - * Make sure the parent is an 'url' device. - */ + /* Make sure the parent is an 'url' device. */ if (!device_is_a(parent, "url")) - return(0); + return 0; - return (10); + return 10; } static void @@ -145,19 +141,15 @@ urlphy_service(struct mii_softc *sc, str switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ + /* If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; break; case MII_MEDIACHG: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; /* If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) @@ -167,15 +159,13 @@ urlphy_service(struct mii_softc *sc, str break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ + /* If we're not currently selected, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return (0); + return 0; /* Just bail now if the interface is down. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); + return 0; /* * If we're not doing autonegotiation, we don't need to do @@ -207,23 +197,21 @@ urlphy_service(struct mii_softc *sc, str if (sc->mii_ticks++ == 0) break; - /* - * Only retry autonegotiation every N seconds. - */ + /* Only retry autonegotiation every N seconds. */ KASSERT(sc->mii_anegticks != 0); if (sc->mii_ticks <= sc->mii_anegticks) - return (0); + return 0; PHY_RESET(sc); if (mii_phy_auto(sc, 0) == EJUSTRETURN) - return (0); + return 0; break; case MII_DOWN: mii_phy_down(sc); - return (0); + return 0; } /* Update the media status. */ @@ -232,7 +220,7 @@ urlphy_service(struct mii_softc *sc, str /* Callback if something changed. */ mii_phy_update(sc, cmd); - return (0); + return 0; } static void