diff options
author | marius <marius@FreeBSD.org> | 2006-12-02 15:32:34 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2006-12-02 15:32:34 +0000 |
commit | 923629baa0e29adb56de97ed5d8fd54e71cd3b49 (patch) | |
tree | 25749fe19f52ff6e7be4f3431382ac173c7c08fc /sys/dev/mii/rlphy.c | |
parent | 2db40ccfce7ea070a08fa10f3969ee21f4d49779 (diff) | |
download | FreeBSD-src-923629baa0e29adb56de97ed5d8fd54e71cd3b49.zip FreeBSD-src-923629baa0e29adb56de97ed5d8fd54e71cd3b49.tar.gz |
Add a helper function mii_phy_dev_probe(), which wraps around the
mii_phy_match() API and takes care of the PHY device probe based on
the struct mii_phydesc array and the match return value provided.
Convert PHY drivers to take advantage of mii_phy_dev_probe(),
converting drivers to provide a mii_phydesc table in the first
place where necessary.
Reviewed by: yongari
MFC after: 2 weeks
Diffstat (limited to 'sys/dev/mii/rlphy.c')
-rw-r--r-- | sys/dev/mii/rlphy.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/sys/dev/mii/rlphy.c b/sys/dev/mii/rlphy.c index 3541198..f672000 100644 --- a/sys/dev/mii/rlphy.c +++ b/sys/dev/mii/rlphy.c @@ -82,26 +82,27 @@ DRIVER_MODULE(rlphy, miibus, rlphy_driver, rlphy_devclass, 0, 0); static int rlphy_service(struct mii_softc *, struct mii_data *, int); static void rlphy_status(struct mii_softc *); +static const struct mii_phydesc rlphys[] = { + MII_PHY_DESC(REALTEK, RTL8201L), + MII_PHY_END +}; + static int rlphy_probe(device_t dev) { struct mii_attach_args *ma; - device_t parent; - - ma = device_get_ivars(dev); - parent = device_get_parent(device_get_parent(dev)); + const char *nic; + int rv; - /* Test for RealTek 8201L PHY */ - if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_REALTEK && - MII_MODEL(ma->mii_id2) == MII_MODEL_REALTEK_RTL8201L) { - device_set_desc(dev, MII_STR_REALTEK_RTL8201L); - return (BUS_PROBE_DEFAULT); - } + rv = mii_phy_dev_probe(dev, rlphys, BUS_PROBE_DEFAULT); + if (rv <= 0) + return (rv); /* - * RealTek PHY doesn't have vendor/device ID registers: - * the rl driver fakes up a return value of all zeros. + * RealTek interal PHYs don't have vendor/device ID registers; + * the `re' and `rl' drivers fake up a return value of all zeros. */ + ma = device_get_ivars(dev); if (MII_OUI(ma->mii_id1, ma->mii_id2) != 0 || MII_MODEL(ma->mii_id2) != 0) return (ENXIO); @@ -109,8 +110,8 @@ rlphy_probe(device_t dev) /* * Make sure the parent is an `rl' or an `re'. */ - if (strcmp(device_get_name(parent), "rl") != 0 && - strcmp(device_get_name(parent), "re") != 0) + nic = device_get_name(device_get_parent(device_get_parent(dev))); + if (strcmp(nic, "rl") != 0 && strcmp(nic, "re") != 0) return (ENXIO); device_set_desc(dev, "RealTek internal media interface"); |