Message ID | d177b061-a154-43d3-b20d-8ba7564772a8@gmail.com |
---|---|
State | Changes Requested |
Delegated to: | David Miller |
Headers | show |
Series | net: phy: use generic PHY ability readers if callback get_features isn't set | expand |
> @@ -2218,9 +2223,9 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner) > /* Either the features are hard coded, or dynamically > * determine. It cannot be both or neither > */ Hi Heiner The comment needs updating to match the code. > - 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; Andrew
On 03.04.2019 22:46, Andrew Lunn wrote: >> @@ -2218,9 +2223,9 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner) >> /* Either the features are hard coded, or dynamically >> * determine. It cannot be both or neither >> */ > > Hi Heiner > > The comment needs updating to match the code. > Indeed, I have to fix this. >> - 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; > > Andrew >
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 72fc714c9..3a3166a7d 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2143,12 +2143,17 @@ 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); - if (err) - goto out; + } 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); @@ -2218,9 +2223,9 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner) /* Either the features are hard coded, or dynamically * determine. It cannot be both or neither */ - 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; }
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. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> --- drivers/net/phy/phy_device.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)