Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1deab17 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller
Browse files

net: phy: allow a PHY driver to define neither features nor get_features



Meanwhile we have generic functions for reading the abilities of
Clause 22 / 45 PHY's. This allows to use them as fallback in case
callback get_features isn't set. Benefit is the reduction of
boilerplate code in PHY drivers.

v2:
- adjust the comment in phy_driver_register to match the code

Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e177163d
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -2143,11 +2143,16 @@ static int phy_probe(struct device *dev)
	 */
	if (phydrv->features) {
		linkmode_copy(phydev->supported, phydrv->features);
	} else {
	} else if (phydrv->get_features) {
		err = phydrv->get_features(phydev);
	} else if (phydev->is_c45) {
		err = genphy_c45_pma_read_abilities(phydev);
	} else {
		err = genphy_read_abilities(phydev);
	}

	if (err)
		goto out;
	}

	of_set_phy_supported(phydev);
	linkmode_copy(phydev->advertising, phydev->supported);
@@ -2216,11 +2221,11 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner)
	int retval;

	/* Either the features are hard coded, or dynamically
	 * determine. It cannot be both or neither
	 * determined. It cannot be both.
	 */
	if (WARN_ON((!new_driver->features && !new_driver->get_features) ||
		    (new_driver->features && new_driver->get_features))) {
		pr_err("%s: Driver features are missing\n", new_driver->name);
	if (WARN_ON(new_driver->features && new_driver->get_features)) {
		pr_err("%s: features and get_features must not both be set\n",
		       new_driver->name);
		return -EINVAL;
	}