* [PATCH net-next 0/2] net: phy: use generic PHY ability readers if callback get_features isn't set @ 2019-04-03 18:17 Heiner Kallweit 2019-04-03 18:19 ` [PATCH net-next 1/2] net: phy: allow a PHY driver to define neither features nor get_features Heiner Kallweit 2019-04-03 18:20 ` [PATCH net-next 2/2] net: phy: realtek: remove setting callback get_features and use phylib fallback Heiner Kallweit 0 siblings, 2 replies; 7+ messages in thread From: Heiner Kallweit @ 2019-04-03 18:17 UTC (permalink / raw) To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev 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. Heiner Kallweit (2): net: phy: allow a PHY driver to define neither features nor get_features net: phy: realtek: remove setting callback get_features and use phylib fallback drivers/net/phy/phy_device.c | 17 +++++++++++------ drivers/net/phy/realtek.c | 10 ---------- 2 files changed, 11 insertions(+), 16 deletions(-) -- 2.21.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next 1/2] net: phy: allow a PHY driver to define neither features nor get_features 2019-04-03 18:17 [PATCH net-next 0/2] net: phy: use generic PHY ability readers if callback get_features isn't set Heiner Kallweit @ 2019-04-03 18:19 ` Heiner Kallweit 2019-04-03 20:46 ` Andrew Lunn 2019-04-03 18:20 ` [PATCH net-next 2/2] net: phy: realtek: remove setting callback get_features and use phylib fallback Heiner Kallweit 1 sibling, 1 reply; 7+ messages in thread From: Heiner Kallweit @ 2019-04-03 18:19 UTC (permalink / raw) To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev 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(-) 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; } -- 2.21.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/2] net: phy: allow a PHY driver to define neither features nor get_features 2019-04-03 18:19 ` [PATCH net-next 1/2] net: phy: allow a PHY driver to define neither features nor get_features Heiner Kallweit @ 2019-04-03 20:46 ` Andrew Lunn 2019-04-03 20:59 ` Heiner Kallweit 0 siblings, 1 reply; 7+ messages in thread From: Andrew Lunn @ 2019-04-03 20:46 UTC (permalink / raw) To: Heiner Kallweit; +Cc: Florian Fainelli, David Miller, netdev > @@ -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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/2] net: phy: allow a PHY driver to define neither features nor get_features 2019-04-03 20:46 ` Andrew Lunn @ 2019-04-03 20:59 ` Heiner Kallweit 0 siblings, 0 replies; 7+ messages in thread From: Heiner Kallweit @ 2019-04-03 20:59 UTC (permalink / raw) To: Andrew Lunn; +Cc: Florian Fainelli, David Miller, netdev 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 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next 2/2] net: phy: realtek: remove setting callback get_features and use phylib fallback 2019-04-03 18:17 [PATCH net-next 0/2] net: phy: use generic PHY ability readers if callback get_features isn't set Heiner Kallweit 2019-04-03 18:19 ` [PATCH net-next 1/2] net: phy: allow a PHY driver to define neither features nor get_features Heiner Kallweit @ 2019-04-03 18:20 ` Heiner Kallweit 2019-04-03 20:55 ` Andrew Lunn 1 sibling, 1 reply; 7+ messages in thread From: Heiner Kallweit @ 2019-04-03 18:20 UTC (permalink / raw) To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev Now that phylib uses genphy_read_abilities() as fallback, we don't have to set callback get_features any longer. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> --- drivers/net/phy/realtek.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 5ecbd41ed..d6a10f323 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -199,11 +199,9 @@ static struct phy_driver realtek_drvs[] = { { PHY_ID_MATCH_EXACT(0x00008201), .name = "RTL8201CP Ethernet", - .get_features = genphy_read_abilities, }, { PHY_ID_MATCH_EXACT(0x001cc816), .name = "RTL8201F Fast Ethernet", - .get_features = genphy_read_abilities, .ack_interrupt = &rtl8201_ack_interrupt, .config_intr = &rtl8201_config_intr, .suspend = genphy_suspend, @@ -213,14 +211,12 @@ static struct phy_driver realtek_drvs[] = { }, { PHY_ID_MATCH_EXACT(0x001cc910), .name = "RTL8211 Gigabit Ethernet", - .get_features = genphy_read_abilities, .config_aneg = rtl8211_config_aneg, .read_mmd = &genphy_read_mmd_unsupported, .write_mmd = &genphy_write_mmd_unsupported, }, { PHY_ID_MATCH_EXACT(0x001cc912), .name = "RTL8211B Gigabit Ethernet", - .get_features = genphy_read_abilities, .ack_interrupt = &rtl821x_ack_interrupt, .config_intr = &rtl8211b_config_intr, .read_mmd = &genphy_read_mmd_unsupported, @@ -230,14 +226,12 @@ static struct phy_driver realtek_drvs[] = { }, { PHY_ID_MATCH_EXACT(0x001cc913), .name = "RTL8211C Gigabit Ethernet", - .get_features = genphy_read_abilities, .config_init = rtl8211c_config_init, .read_mmd = &genphy_read_mmd_unsupported, .write_mmd = &genphy_write_mmd_unsupported, }, { PHY_ID_MATCH_EXACT(0x001cc914), .name = "RTL8211DN Gigabit Ethernet", - .get_features = genphy_read_abilities, .ack_interrupt = rtl821x_ack_interrupt, .config_intr = rtl8211e_config_intr, .suspend = genphy_suspend, @@ -245,7 +239,6 @@ static struct phy_driver realtek_drvs[] = { }, { PHY_ID_MATCH_EXACT(0x001cc915), .name = "RTL8211E Gigabit Ethernet", - .get_features = genphy_read_abilities, .ack_interrupt = &rtl821x_ack_interrupt, .config_intr = &rtl8211e_config_intr, .suspend = genphy_suspend, @@ -253,7 +246,6 @@ static struct phy_driver realtek_drvs[] = { }, { PHY_ID_MATCH_EXACT(0x001cc916), .name = "RTL8211F Gigabit Ethernet", - .get_features = genphy_read_abilities, .config_init = &rtl8211f_config_init, .ack_interrupt = &rtl8211f_ack_interrupt, .config_intr = &rtl8211f_config_intr, @@ -264,7 +256,6 @@ static struct phy_driver realtek_drvs[] = { }, { PHY_ID_MATCH_EXACT(0x001cc800), .name = "Generic Realtek PHY", - .get_features = genphy_read_abilities, .suspend = genphy_suspend, .resume = genphy_resume, .read_page = rtl821x_read_page, @@ -272,7 +263,6 @@ static struct phy_driver realtek_drvs[] = { }, { PHY_ID_MATCH_EXACT(0x001cc961), .name = "RTL8366RB Gigabit Ethernet", - .get_features = genphy_read_abilities, .config_init = &rtl8366rb_config_init, /* These interrupts are handled by the irq controller * embedded inside the RTL8366RB, they get unmasked when the -- 2.21.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 2/2] net: phy: realtek: remove setting callback get_features and use phylib fallback 2019-04-03 18:20 ` [PATCH net-next 2/2] net: phy: realtek: remove setting callback get_features and use phylib fallback Heiner Kallweit @ 2019-04-03 20:55 ` Andrew Lunn 2019-04-03 21:06 ` Heiner Kallweit 0 siblings, 1 reply; 7+ messages in thread From: Andrew Lunn @ 2019-04-03 20:55 UTC (permalink / raw) To: Heiner Kallweit; +Cc: Florian Fainelli, David Miller, netdev On Wed, Apr 03, 2019 at 08:20:09PM +0200, Heiner Kallweit wrote: > Now that phylib uses genphy_read_abilities() as fallback, we don't have > to set callback get_features any longer. Hi Heiner I wonder how many PHY drivers we will break if we just remove .features everywhere? Maybe we should create patches for the Marvell driver and the Broadcom drivers. I and Florian can test them. Andrew ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 2/2] net: phy: realtek: remove setting callback get_features and use phylib fallback 2019-04-03 20:55 ` Andrew Lunn @ 2019-04-03 21:06 ` Heiner Kallweit 0 siblings, 0 replies; 7+ messages in thread From: Heiner Kallweit @ 2019-04-03 21:06 UTC (permalink / raw) To: Andrew Lunn; +Cc: Florian Fainelli, David Miller, netdev On 03.04.2019 22:55, Andrew Lunn wrote: > On Wed, Apr 03, 2019 at 08:20:09PM +0200, Heiner Kallweit wrote: >> Now that phylib uses genphy_read_abilities() as fallback, we don't have >> to set callback get_features any longer. > > Hi Heiner > > I wonder how many PHY drivers we will break if we just remove > .features everywhere? > At least I have seen no C22 PHY yet that couldn't be handled by genphy_read_abilities. Just for non-TP modes there might be an issue. genphy_read_abilities only sets TP and MII, if a driver checks for e.g. ETHTOOL_LINK_MODE_FIBRE_BIT we may have some work. > Maybe we should create patches for the Marvell driver and the Broadcom > drivers. I and Florian can test them. > > Andrew > Heiner ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-04-03 21:06 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-04-03 18:17 [PATCH net-next 0/2] net: phy: use generic PHY ability readers if callback get_features isn't set Heiner Kallweit 2019-04-03 18:19 ` [PATCH net-next 1/2] net: phy: allow a PHY driver to define neither features nor get_features Heiner Kallweit 2019-04-03 20:46 ` Andrew Lunn 2019-04-03 20:59 ` Heiner Kallweit 2019-04-03 18:20 ` [PATCH net-next 2/2] net: phy: realtek: remove setting callback get_features and use phylib fallback Heiner Kallweit 2019-04-03 20:55 ` Andrew Lunn 2019-04-03 21:06 ` Heiner Kallweit
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.