1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-16 15:11:52 +00:00

Improve an API by about 4 lines per driver.

This commit is contained in:
Poul-Henning Kamp 2002-04-28 19:01:32 +00:00
parent 3aae18bde8
commit 83549c664b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=95665
17 changed files with 21 additions and 67 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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");

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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 = ", "

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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