From 83549c664b0b44225607ec54ab20aa7aeaa2472b Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sun, 28 Apr 2002 19:01:32 +0000 Subject: [PATCH] Improve an API by about 4 lines per driver. --- sys/dev/dc/dcphy.c | 5 +---- sys/dev/dc/pnphy.c | 5 +---- sys/dev/mii/acphy.c | 4 +--- sys/dev/mii/amphy.c | 6 +----- sys/dev/mii/brgphy.c | 4 +--- sys/dev/mii/dcphy.c | 5 +---- sys/dev/mii/exphy.c | 6 +----- sys/dev/mii/inphy.c | 5 +---- sys/dev/mii/lxtphy.c | 4 +--- sys/dev/mii/mii_physubr.c | 5 +++++ sys/dev/mii/mlphy.c | 6 +----- sys/dev/mii/nsphy.c | 6 +----- sys/dev/mii/pnphy.c | 5 +---- sys/dev/mii/qsphy.c | 4 +--- sys/dev/mii/rlphy.c | 6 +----- sys/dev/mii/tdkphy.c | 6 +----- sys/dev/mii/ukphy.c | 6 +----- 17 files changed, 21 insertions(+), 67 deletions(-) diff --git a/sys/dev/dc/dcphy.c b/sys/dev/dc/dcphy.c index e95786938baa..86912d70ee3a 100644 --- a/sys/dev/dc/dcphy.c +++ b/sys/dev/dc/dcphy.c @@ -196,10 +196,7 @@ static int dcphy_attach(dev) sc->mii_capabilities &= ma->mii_capmask; device_printf(dev, " "); - if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0) - printf("no media present"); - else - mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); #undef ADD diff --git a/sys/dev/dc/pnphy.c b/sys/dev/dc/pnphy.c index 56a83f4a2875..1a187d0ee454 100644 --- a/sys/dev/dc/pnphy.c +++ b/sys/dev/dc/pnphy.c @@ -153,10 +153,7 @@ static int pnphy_attach(dev) BMSR_100TXFDX|BMSR_100TXHDX|BMSR_10TFDX|BMSR_10THDX; sc->mii_capabilities &= ma->mii_capmask; device_printf(dev, " "); - if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0) - printf("no media present"); - else - mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst), BMCR_ISO); diff --git a/sys/dev/mii/acphy.c b/sys/dev/mii/acphy.c index e163db71364d..629589116d8f 100644 --- a/sys/dev/mii/acphy.c +++ b/sys/dev/mii/acphy.c @@ -161,9 +161,7 @@ static int acphy_attach(dev) sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; device_printf(dev, " "); - if (sc->mii_capabilities & BMSR_MEDIAMASK) - mii_add_media(mii, sc->mii_capabilities, - sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); MIIBUS_MEDIAINIT(sc->mii_dev); diff --git a/sys/dev/mii/amphy.c b/sys/dev/mii/amphy.c index caba3da53f8d..5692d785fe89 100644 --- a/sys/dev/mii/amphy.c +++ b/sys/dev/mii/amphy.c @@ -142,11 +142,7 @@ static int amphy_attach(dev) sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; device_printf(dev, " "); - if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0) - printf("no media present"); - else - mii_add_media(mii, sc->mii_capabilities, - sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); #undef ADD MIIBUS_MEDIAINIT(sc->mii_dev); diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c index 45366ea51e5c..132ce0641a4c 100644 --- a/sys/dev/mii/brgphy.c +++ b/sys/dev/mii/brgphy.c @@ -162,9 +162,7 @@ static int brgphy_attach(dev) sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; device_printf(dev, " "); - if (sc->mii_capabilities & BMSR_MEDIAMASK) - mii_add_media(mii, (sc->mii_capabilities & ~BMSR_ANEG), - sc->mii_inst); + mii_add_media(mii, (sc->mii_capabilities & ~BMSR_ANEG), sc->mii_inst); ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_TX, 0, sc->mii_inst), BRGPHY_BMCR_FDX); PRINT(", 1000baseTX"); diff --git a/sys/dev/mii/dcphy.c b/sys/dev/mii/dcphy.c index e95786938baa..86912d70ee3a 100644 --- a/sys/dev/mii/dcphy.c +++ b/sys/dev/mii/dcphy.c @@ -196,10 +196,7 @@ static int dcphy_attach(dev) sc->mii_capabilities &= ma->mii_capmask; device_printf(dev, " "); - if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0) - printf("no media present"); - else - mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); #undef ADD diff --git a/sys/dev/mii/exphy.c b/sys/dev/mii/exphy.c index abee3588a0d7..71ec9b7e9b69 100644 --- a/sys/dev/mii/exphy.c +++ b/sys/dev/mii/exphy.c @@ -195,11 +195,7 @@ static int exphy_attach(dev) sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; device_printf(dev, " "); - if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0) - printf("no media present"); - else - mii_add_media(mii, sc->mii_capabilities, - sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); #undef ADD MIIBUS_MEDIAINIT(sc->mii_dev); diff --git a/sys/dev/mii/inphy.c b/sys/dev/mii/inphy.c index c4bd71e20885..bb273a6eea70 100644 --- a/sys/dev/mii/inphy.c +++ b/sys/dev/mii/inphy.c @@ -144,10 +144,7 @@ inphy_attach(device_t dev) sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; device_printf(dev, " "); - if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0) - printf("no media present"); - else - mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); MIIBUS_MEDIAINIT(sc->mii_dev); diff --git a/sys/dev/mii/lxtphy.c b/sys/dev/mii/lxtphy.c index 1fef9f9de736..3c2194aaade6 100644 --- a/sys/dev/mii/lxtphy.c +++ b/sys/dev/mii/lxtphy.c @@ -178,9 +178,7 @@ static int lxtphy_attach(dev) printf("100baseFX-FDX, "); #undef ADD - if (sc->mii_capabilities & BMSR_MEDIAMASK) - mii_add_media(mii, sc->mii_capabilities, - sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); MIIBUS_MEDIAINIT(sc->mii_dev); diff --git a/sys/dev/mii/mii_physubr.c b/sys/dev/mii/mii_physubr.c index 36aeaed46544..7c908b36c5d6 100644 --- a/sys/dev/mii/mii_physubr.c +++ b/sys/dev/mii/mii_physubr.c @@ -296,6 +296,11 @@ mii_add_media(mii, bmsr, instance) { const char *sep = ""; + if ((bmsr & BMSR_MEDIAMASK) == 0) { + printf("no media present"); + return; + } + #define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) #define PRINT(s) printf("%s%s", sep, s); sep = ", " diff --git a/sys/dev/mii/mlphy.c b/sys/dev/mii/mlphy.c index 266f2624e385..0cda976c131a 100644 --- a/sys/dev/mii/mlphy.c +++ b/sys/dev/mii/mlphy.c @@ -167,11 +167,7 @@ static int mlphy_attach(dev) PHY_READ(sc, MII_BMSR) & ma->mii_capmask; ma->mii_capmask = ~sc->mii_capabilities; device_printf(dev, " "); - if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0) - printf("no media present"); - else - mii_add_media(mii, sc->mii_capabilities, - sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); #undef ADD MIIBUS_MEDIAINIT(sc->mii_dev); diff --git a/sys/dev/mii/nsphy.c b/sys/dev/mii/nsphy.c index e7bf367b518d..9059230f129e 100644 --- a/sys/dev/mii/nsphy.c +++ b/sys/dev/mii/nsphy.c @@ -181,11 +181,7 @@ static int nsphy_attach(dev) sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; device_printf(dev, " "); - if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0) - printf("no media present"); - else - mii_add_media(mii, sc->mii_capabilities, - sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); #undef ADD diff --git a/sys/dev/mii/pnphy.c b/sys/dev/mii/pnphy.c index 56a83f4a2875..1a187d0ee454 100644 --- a/sys/dev/mii/pnphy.c +++ b/sys/dev/mii/pnphy.c @@ -153,10 +153,7 @@ static int pnphy_attach(dev) BMSR_100TXFDX|BMSR_100TXHDX|BMSR_10TFDX|BMSR_10THDX; sc->mii_capabilities &= ma->mii_capmask; device_printf(dev, " "); - if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0) - printf("no media present"); - else - mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst), BMCR_ISO); diff --git a/sys/dev/mii/qsphy.c b/sys/dev/mii/qsphy.c index c419c4b23063..aeedd1e833e0 100644 --- a/sys/dev/mii/qsphy.c +++ b/sys/dev/mii/qsphy.c @@ -165,9 +165,7 @@ static int qsphy_attach(dev) sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; device_printf(dev, " "); - if (sc->mii_capabilities & BMSR_MEDIAMASK) - mii_add_media(mii, sc->mii_capabilities, - sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); MIIBUS_MEDIAINIT(sc->mii_dev); diff --git a/sys/dev/mii/rlphy.c b/sys/dev/mii/rlphy.c index 560465ba027b..898ee546758d 100644 --- a/sys/dev/mii/rlphy.c +++ b/sys/dev/mii/rlphy.c @@ -167,11 +167,7 @@ static int rlphy_attach(dev) sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; device_printf(dev, " "); - if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0) - printf("no media present"); - else - mii_add_media(mii, sc->mii_capabilities, - sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); #undef ADD MIIBUS_MEDIAINIT(sc->mii_dev); diff --git a/sys/dev/mii/tdkphy.c b/sys/dev/mii/tdkphy.c index 3a98dba5b878..4b8abde54631 100644 --- a/sys/dev/mii/tdkphy.c +++ b/sys/dev/mii/tdkphy.c @@ -148,11 +148,7 @@ tdkphy_attach(device_t dev) sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; device_printf(dev, " "); - if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0) - printf("no media present"); - else - mii_add_media(mii, sc->mii_capabilities, - sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); #undef ADD diff --git a/sys/dev/mii/ukphy.c b/sys/dev/mii/ukphy.c index 64f4411ba6e2..4bb57bad2c04 100644 --- a/sys/dev/mii/ukphy.c +++ b/sys/dev/mii/ukphy.c @@ -171,11 +171,7 @@ ukphy_attach(dev) sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; device_printf(dev, " "); - if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0) - printf("no media present"); - else - mii_add_media(mii, sc->mii_capabilities, - sc->mii_inst); + mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); #undef ADD