net: of_mdio improvements
Subsystems (5)
cover net: of_mdio improvements
Hi all,
This patchset contains a few improvements to the MDIO device tree parsing code such as refactoring and parsing the "max-speed" property which is defined in the ePAPR specification.
Thanks!
Florian Fainelli (7):
net: of_mdio: factor PHY registration from of_mdiobus_register
net: of_mdio: use PHY_MAX_ADDR constant
net: of_mdio: do not overwrite PHY interrupt configuration
net: phy: breakdown PHY_*_FEATURES defines
net: of_mdio: parse "max-speed" property to set PHY supported features
arc_emac: remove custom "max-speed" parsing code
Documentation: update Ethernet PHY devices binding with 'max-speed'
Documentation/devicetree/bindings/net/phy.txt | 1 + drivers/net/ethernet/arc/emac.h | 2 - drivers/net/ethernet/arc/emac_main.c | 20 +--- drivers/of/of_mdio.c | 135 ++++++++++++++------------ include/linux/phy.h | 23 +++-- 5 files changed, 89 insertions(+), 92 deletions(-)
Signature · 1 line
1.8.3.2
PATCH 1/7 net: of_mdio: factor PHY registration from of_mdiobus_register
From: Florian Fainelli <[email protected]>
Since commit 779d835e ("net: of_mdio: scan mdiobus for PHYs without reg property") we have two foreach loops which do pretty much the same thing. Factor the PHY device registration in a function helper:of_mdiobus_register_phy() which takes care of the details and allows for future PHY specific extensions.
--- drivers/of/of_mdio.c | 109 ++++++++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 63 deletions(-)
drivers/of/of_mdio.c +46 -63
@@ -22,6 +22,47 @@MODULE_AUTHOR ("Grant Likely <[email protected]>" );MODULE_LICENSE ("GPL" ); +static int of_mdiobus_register_phy (struct mii_bus *mdio,struct device_node *child, +u32 addr) +{ +struct phy_device *phy; +bool is_c45; +int rc; + + is_c45 =of_device_is_compatible (child, +"ethernet-phy-ieee802.3-c45" ); + + phy =get_phy_device (mdio, addr, is_c45); +if (!phy ||IS_ERR (phy)) +return 1 ; + +if (mdio->irq) { + mdio->irq[addr] = +irq_of_parse_and_map (child,0 ); +if (!mdio->irq[addr]) + mdio->irq[addr] =PHY_POLL ; + } + +/* Associate the OF node with the device structure so it +* can be looked up later */ +of_node_get (child); + phy->dev.of_node = child; + +/* All data is now stored in the phy struct; +* register it */ + rc =phy_device_register (phy); +if (rc) { +phy_device_free (phy); +of_node_put (child); +return 1 ; + } + +dev_dbg (&mdio->dev,"registered phy %s at address %i\n" , + child->name, addr); + +return 0 ; +} +/** * of_mdiobus_register - Register mii_bus and create PHYs from the device tree * @mdio: pointer to mii_bus structure
@@ -32,11 +73,10 @@ MODULE_LICENSE("GPL");*/ int of_mdiobus_register (struct mii_bus *mdio,struct device_node *np) { -struct phy_device *phy;struct device_node *child;const __be32 *paddr;u32 addr; -bool is_c45, scanphys = false; +bool scanphys = false;int rc, i, len;/* Mask out all PHYs from auto probing. Instead the PHYs listed in
@@ -73,38 +113,9 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)continue ; } -if (mdio->irq) { - mdio->irq[addr] =irq_of_parse_and_map (child,0 ); -if (!mdio->irq[addr]) - mdio->irq[addr] =PHY_POLL ; - } - - is_c45 =of_device_is_compatible (child, -"ethernet-phy-ieee802.3-c45" ); - phy =get_phy_device (mdio, addr, is_c45); - -if (!phy ||IS_ERR (phy)) { -dev_err (&mdio->dev, -"cannot get PHY at address %i\n" , - addr); -continue ; - } - -/* Associate the OF node with the device structure so it -* can be looked up later */ -of_node_get (child); - phy->dev.of_node = child; - -/* All data is now stored in the phy struct; register it */ - rc =phy_device_register (phy); -if (rc) { -phy_device_free (phy); -of_node_put (child); + rc =of_mdiobus_register_phy (mdio, child, addr); +if (rc)continue ; - } - -dev_dbg (&mdio->dev,"registered phy %s at address %i\n" , - child->name, addr); }if (!scanphys)
@@ -117,9 +128,6 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)if (paddr)continue ; - is_c45 =of_device_is_compatible (child, -"ethernet-phy-ieee802.3-c45" ); -for (addr =0 ; addr <PHY_MAX_ADDR ; addr++) {/* skip already registered PHYs */ if (mdio->phy_map[addr])
@@ -129,34 +137,9 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)dev_info (&mdio->dev,"scan phy %s at address %i\n" , child->name, addr); - phy =get_phy_device (mdio, addr, is_c45); -if (!phy ||IS_ERR (phy)) + rc =of_mdiobus_register_phy (mdio, child, addr); +if (rc)continue ; - -if (mdio->irq) { - mdio->irq[addr] = -irq_of_parse_and_map (child,0 ); -if (!mdio->irq[addr]) - mdio->irq[addr] =PHY_POLL ; - } - -/* Associate the OF node with the device structure so it -* can be looked up later */ -of_node_get (child); - phy->dev.of_node = child; - -/* All data is now stored in the phy struct; -* register it */ - rc =phy_device_register (phy); -if (rc) { -phy_device_free (phy); -of_node_put (child); -continue ; - } - -dev_info (&mdio->dev,"registered phy %s at address %i\n" , - child->name, addr); -break ; } }
Signature · 1 line
1.8.3.2
Re: [PATCH 1/7] net: of_mdio: factor PHY registration from of_mdiobus_register
Quoted 9 lines · Florian Fainelli
From: Florian Fainelli <[email protected]>
Since commit
779d835e("net:of_mdio: scan mdiobus for PHYs without reg property") we have two foreach loops which do pretty much the same thing. Factor the PHY device registration in a function helper:of_mdiobus_register_phy()which takes care of the details and allows for future PHY specific extensions.Signed-off-by Florian Fainelli <[email protected]>
A couple of formatting nits, but otherwise:
BTW, unless David has objections, I'd like to see this file moved to drivers/net. He tends to merge the of_mdio.c changes anyway. We've moved most other subsystem parsing code out of drivers/of.
Quoted 11 lines
--- drivers/of/of_mdio.c | 109 ++++++++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 63 deletions(-)drivers/of/of_mdio.c +0
-0@@ -22,6 +22,47 @@MODULE_AUTHOR ("Grant Likely <[email protected]>" );MODULE_LICENSE ("GPL" );
drivers/of/of_mdio.c line 33
Quoted 10 lines
drivers/of/of_mdio.c +9
-0+static int of_mdiobus_register_phy (struct mii_bus *mdio,struct device_node *child, +u32 addr) +{ +struct phy_device *phy; +bool is_c45; +int rc; + + is_c45 =of_device_is_compatible (child, +"ethernet-phy-ieee802.3-c45" );
This looks like it can be 1 line.
drivers/of/of_mdio.c line 41
Quoted 8 lines
drivers/of/of_mdio.c +8
-0+ + phy =get_phy_device (mdio, addr, is_c45); +if (!phy ||IS_ERR (phy)) +return 1 ; + +if (mdio->irq) { + mdio->irq[addr] = +irq_of_parse_and_map (child,0 );
ditto
Quoted 129 lines
drivers/of/of_mdio.c +29
-63+if (!mdio->irq[addr]) + mdio->irq[addr] =PHY_POLL ; + } + +/* Associate the OF node with the device structure so it +* can be looked up later */ +of_node_get (child); + phy->dev.of_node = child; + +/* All data is now stored in the phy struct; +* register it */ + rc =phy_device_register (phy); +if (rc) { +phy_device_free (phy); +of_node_put (child); +return 1 ; + } + +dev_dbg (&mdio->dev,"registered phy %s at address %i\n" , + child->name, addr); + +return 0 ; +} +/** * of_mdiobus_register - Register mii_bus and create PHYs from the device tree * @mdio: pointer to mii_bus structure @@ -32,11 +73,10 @@ MODULE_LICENSE("GPL");*/ int of_mdiobus_register (struct mii_bus *mdio,struct device_node *np) { -struct phy_device *phy;struct device_node *child;const __be32 *paddr;u32 addr; -bool is_c45, scanphys = false; +bool scanphys = false;int rc, i, len;/* Mask out all PHYs from auto probing. Instead the PHYs listed in @@ -73,38 +113,9 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)continue ; } -if (mdio->irq) { - mdio->irq[addr] =irq_of_parse_and_map (child,0 ); -if (!mdio->irq[addr]) - mdio->irq[addr] =PHY_POLL ; - } - - is_c45 =of_device_is_compatible (child, -"ethernet-phy-ieee802.3-c45" ); - phy =get_phy_device (mdio, addr, is_c45); - -if (!phy ||IS_ERR (phy)) { -dev_err (&mdio->dev, -"cannot get PHY at address %i\n" , - addr); -continue ; - } - -/* Associate the OF node with the device structure so it -* can be looked up later */ -of_node_get (child); - phy->dev.of_node = child; - -/* All data is now stored in the phy struct; register it */ - rc =phy_device_register (phy); -if (rc) { -phy_device_free (phy); -of_node_put (child); + rc =of_mdiobus_register_phy (mdio, child, addr); +if (rc)continue ; - } - -dev_dbg (&mdio->dev,"registered phy %s at address %i\n" , - child->name, addr); }if (!scanphys)@@ -117,9 +128,6 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)if (paddr)continue ; - is_c45 =of_device_is_compatible (child, -"ethernet-phy-ieee802.3-c45" ); -for (addr =0 ; addr <PHY_MAX_ADDR ; addr++) {/* skip already registered PHYs */ if (mdio->phy_map[addr])@@ -129,34 +137,9 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)dev_info (&mdio->dev,"scan phy %s at address %i\n" , child->name, addr); - phy =get_phy_device (mdio, addr, is_c45); -if (!phy ||IS_ERR (phy)) + rc =of_mdiobus_register_phy (mdio, child, addr); +if (rc)continue ; - -if (mdio->irq) { - mdio->irq[addr] = -irq_of_parse_and_map (child,0 ); -if (!mdio->irq[addr]) - mdio->irq[addr] =PHY_POLL ; - } - -/* Associate the OF node with the device structure so it -* can be looked up later */ -of_node_get (child); - phy->dev.of_node = child; - -/* All data is now stored in the phy struct; -* register it */ - rc =phy_device_register (phy); -if (rc) { -phy_device_free (phy); -of_node_put (child); -continue ; - } - -dev_info (&mdio->dev,"registered phy %s at address %i\n" , - child->name, addr); -break ; } }
A message that is not in the archive (sent off-list or not yet received): 1386283936-26104-1-git-send-email-florian-p3rKhJxN3npAfugRpC6u6w@public.gmane.org
PATCH 2/7 net: of_mdio: use PHY_MAX_ADDR constant
From: Florian Fainelli <[email protected]>
Use the PHY_MAX_ADDR constant for checking if a MDIO bus address is valid instead of using a plain "32".
--- drivers/of/of_mdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/of_mdio.c +1 -1
@@ -107,7 +107,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) } addr =be32_to_cpup (paddr); -if (addr >=32 ) { +if (addr >=PHY_MAX_ADDR ) {dev_err (&mdio->dev,"%s PHY address %i is too large\n" , child->full_name, addr);continue ;
Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/7] net: of_mdio: use PHY_MAX_ADDR constant
Quoted 6 lines · Florian Fainelli
From: Florian Fainelli <[email protected]>
Use the
PHY_MAX_ADDRconstant for checking if a MDIO bus address is valid instead of using a plain "32".Signed-off-by Florian Fainelli <[email protected]>
Quoted 20 lines
--- drivers/of/of_mdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/of/of_mdio.c +1
-1@@ -107,7 +107,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) } addr =be32_to_cpup (paddr); -if (addr >=32 ) { +if (addr >=PHY_MAX_ADDR ) {dev_err (&mdio->dev,"%s PHY address %i is too large\n" , child->full_name, addr);continue ;Signature · 1 line
1.8.3.2
PATCH 3/7 net: of_mdio: do not overwrite PHY interrupt configuration
In reply to Florian FainelliFrom: Florian Fainelli <[email protected]>
If irq_of_parse_and_map fails to find an interrupt line for a given PHY, we will force the PHY interrupt to be PHY_POLL, completely overriding the previous value that the MDIO bus may have set for us (e.g:PHY_IGNORE_INTERRUPT). In case of failure, just restore the previous value.
--- drivers/of/of_mdio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/of/of_mdio.c +3 -2
@@ -27,7 +27,7 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi {struct phy_device *phy;bool is_c45; -int rc; +int rc, prev_irq; is_c45 =of_device_is_compatible (child,"ethernet-phy-ieee802.3-c45" );
@@ -37,10 +37,11 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chireturn 1 ;if (mdio->irq) { + prev_irq= mdio->irq[addr]; mdio->irq[addr] =irq_of_parse_and_map (child,0 );if (!mdio->irq[addr]) - mdio->irq[addr] =PHY_POLL ; + mdio->irq[addr] = prev_irq; }/* Associate the OF node with the device structure so it
Signature · 1 line
1.8.3.2
Re: [PATCH 3/7] net: of_mdio: do not overwrite PHY interrupt configuration
Hello.
Quoted 17 lines · Florian Fainelli
From: Florian Fainelli <[email protected]>
If
irq_of_parse_and_mapfails to find an interrupt line for a given PHY, we will force the PHY interrupt to bePHY_POLL, completely overriding the previous value that the MDIO bus may have set for us (e.g:PHY_IGNORE_INTERRUPT). In case of failure, just restore the previous value.Signed-off-by Florian Fainelli <[email protected]>--- drivers/of/of_mdio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/of/of_mdio.c +0
-0
[...]
drivers/of/of_mdio.c static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi · line 40
Quoted 5 lines
drivers/of/of_mdio.c +1
-0@@ -37,10 +37,11 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chireturn 1 ;if (mdio->irq) { + prev_irq= mdio->irq[addr];
You forgot space before =.
WBR, Sergei
Re: [PATCH 3/7] net: of_mdio: do not overwrite PHY interrupt configuration
In reply to Florian FainelliQuoted 27 lines · Florian Fainelli
From: Florian Fainelli <[email protected]>
If
irq_of_parse_and_mapfails to find an interrupt line for a given PHY, we will force the PHY interrupt to bePHY_POLL, completely overriding the previous value that the MDIO bus may have set for us (e.g:PHY_IGNORE_INTERRUPT). In case of failure, just restore the previous value.Signed-off-by Florian Fainelli <[email protected]>--- drivers/of/of_mdio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/of/of_mdio.c +1
-1@@ -27,7 +27,7 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi {struct phy_device *phy;bool is_c45; -int rc; +int rc, prev_irq; is_c45 =of_device_is_compatible (child,"ethernet-phy-ieee802.3-c45" );
drivers/of/of_mdio.c static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi · line 45
Quoted 10 lines
drivers/of/of_mdio.c +2
-1@@ -37,10 +37,11 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chireturn 1 ;if (mdio->irq) { + prev_irq= mdio->irq[addr]; mdio->irq[addr] =irq_of_parse_and_map (child,0 );if (!mdio->irq[addr]) - mdio->irq[addr] =PHY_POLL ; + mdio->irq[addr] = prev_irq; }
Nit, the logic is a little weird the way it is written after the change. I'd rather see:
if (mdio->irq) {
irq = irq_of_parse_and_map(child, 0);
if (irq)
mdio->irq[addr] = irq;
}Or even more concise:
if (mdio->irq && irq = irq_of_parse_and_map(child, 0)) mdio->irq[addr] = irq;
g.
Regardless,
g.
PATCH 4/7 net: phy: breakdown PHY_*_FEATURES defines
In reply to Florian FainelliFrom: Florian Fainelli <[email protected]>
Breakdown the PHY_*_FEATURES into per speed defines such that we can easily re-use them individually.
--- include/linux/phy.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
include/linux/phy.h +16 -7
@@ -27,18 +27,27 @@#include <linux/atomic.h> -#define PHY_BASIC_FEATURES (SUPPORTED_10baseT_Half | \ - SUPPORTED_10baseT_Full | \ - SUPPORTED_100baseT_Half | \ - SUPPORTED_100baseT_Full | \ - SUPPORTED_Autoneg | \ +#define PHY_DEFAULT_FEATURES (SUPPORTED_Autoneg | \ SUPPORTED_TP | \ SUPPORTED_MII) -#define PHY_GBIT_FEATURES (PHY_BASIC_FEATURES | \ - SUPPORTED_1000baseT_Half | \ +#define PHY_10BT_FEATURES (SUPPORTED_10baseT_Half | \ + SUPPORTED_10baseT_Full) + +#define PHY_100BT_FEATURES (SUPPORTED_100baseT_Half | \ + SUPPORTED_100baseT_Full) + +#define PHY_1000BT_FEATURES (SUPPORTED_1000baseT_Half | \ SUPPORTED_1000baseT_Full) +#define PHY_BASIC_FEATURES (PHY_10BT_FEATURES | \ + PHY_100BT_FEATURES | \ + PHY_DEFAULT_FEATURES) + +#define PHY_GBIT_FEATURES (PHY_BASIC_FEATURES | \ + PHY_1000BT_FEATURES) + +/* * Set phydev->irq to PHY_POLL if interrupts are not supported, * or not desired for this PHY. Set to PHY_IGNORE_INTERRUPT if
Signature · 1 line
1.8.3.2
PATCH 5/7 net: of_mdio: parse "max-speed" property to set PHY supported features
In reply to Florian FainelliFrom: Florian Fainelli <[email protected]>
The "max-speed" property is defined per the ePAPR specification to express the maximum speed a PHY supports. Use that property, if present to set the phydev->supported features which properly restricts the PHY within the range of defined speeds.
--- drivers/of/of_mdio.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
drivers/of/of_mdio.c +24 -1
@@ -22,12 +22,30 @@MODULE_AUTHOR ("Grant Likely <[email protected]>" );MODULE_LICENSE ("GPL" ); +static void of_set_phy_supported (struct phy_device *phydev,u32 max_speed) +{ + phydev->supported |=PHY_DEFAULT_FEATURES ; + +switch (max_speed) { +default : +return ; + +case SPEED_1000 : + phydev->supported |=PHY_1000BT_FEATURES ; +case SPEED_100 : + phydev->supported |=PHY_100BT_FEATURES ; +case SPEED_10 : + phydev->supported |=PHY_10BT_FEATURES ; + } +} +static int of_mdiobus_register_phy (struct mii_bus *mdio,struct device_node *child,u32 addr) {struct phy_device *phy;bool is_c45;int rc, prev_irq; +u32 max_speed =0 ; is_c45 =of_device_is_compatible (child,"ethernet-phy-ieee802.3-c45" );
@@ -58,8 +76,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chireturn 1 ; } +/* Set phydev->supported based on the "max-speed" property +* if present */ +if (!of_property_read_u32 (child,"max-speed" , &max_speed)) +of_set_phy_supported (phy, max_speed); +dev_dbg (&mdio->dev,"registered phy %s at address %i\n" , - child->name, addr); + child->name, addr);return 0 ; }
Signature · 1 line
1.8.3.2
Re: [PATCH 5/7] net: of_mdio: parse "max-speed" property to set PHY supported features
Hello.
Quoted 16 lines · Florian Fainelli
From: Florian Fainelli <[email protected]>
The "max-speed" property is defined per the ePAPR specification to express the maximum speed a PHY supports. Use that property, if present to set the
phydev->supportedfeatures which properly restricts the PHY within the range of defined speeds.Signed-off-by Florian Fainelli <[email protected]>--- drivers/of/of_mdio.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)drivers/of/of_mdio.c +0
-0
[...]
drivers/of/of_mdio.c static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi · line 80
Quoted 6 lines
drivers/of/of_mdio.c +2
-0@@ -58,8 +76,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chireturn 1 ; } +/* Set phydev->supported based on the "max-speed" property +* if present */
Preferred multi-line comment style is this:
/*
* bla
* bla
*/
WBR, Sergei
Re: [PATCH 5/7] net: of_mdio: parse "max-speed" property to set PHY supported features
2013/12/5 Sergei Shtylyov <[email protected]>:
Quoted 11 lines
drivers/of/of_mdio.c static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi · line 80
Quoted 3 lines
drivers/of/of_mdio.c +2
-0+/* Set phydev->supported based on the "max-speed" property +* if present */ Preferred multi-line comment style is this:
/*
* bla
* bla
*/
All other comments in this file are:
/* bla
* bla
*/
which is why I used the same style.
Signature · 1 line
Florian
Re: [PATCH 5/7] net: of_mdio: parse "max-speed" property to set PHY supported features
Quoted 4 lines · Florian Fainelli
2013/12/5 Sergei Shtylyov <[email protected]>:
Quoted 3 lines
Quoted 3 lines
drivers/of/of_mdio.c +2
-0+/* Set phydev->supported based on the "max-speed" property +* if present */
[]
Quoted 7 lines
All other comments in this file are:
/* bla
* bla
*/which is why I used the same style.
Kind of. This should be:
/* Set phydev->supported based on the "max-speed" property * if present */
Or if you want to use all 80 columns:
/* Set phydev->supported based on the "max-speed" property if present */
or maybe
/* Set phydev->supported using the "max-speed" property (if present) */
David Miller
maintainerRe: [PATCH 5/7] net: of_mdio: parse "max-speed" property to set PHY supported features
In reply to Florian FainelliFrom: Florian Fainelli <[email protected]>
Date: Thu, 5 Dec 2013 15:53:41 -0800
Quoted 13 lines
2013/12/5 Sergei Shtylyov <[email protected]>:
Quoted 11 lines
drivers/of/of_mdio.c static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi · line 80
Quoted 3 lines
drivers/of/of_mdio.c +2
-0+/* Set phydev->supported based on the "max-speed" property +* if present */ Preferred multi-line comment style is this:
/*
* bla
* bla
*/
Quoted 7 lines
All other comments in this file are:
/* bla
* bla
*/which is why I used the same style.
And this is the preferred format for networking, as documented in Documentation/networking/netdev-FAQ.txt
Re: [PATCH 5/7] net: of_mdio: parse "max-speed" property to set PHY supported features
In reply to Florian FainelliQuoted 20 lines · Florian Fainelli
From: Florian Fainelli <[email protected]>
The "max-speed" property is defined per the ePAPR specification to express the maximum speed a PHY supports. Use that property, if present to set the
phydev->supportedfeatures which properly restricts the PHY within the range of defined speeds.Signed-off-by Florian Fainelli <[email protected]>--- drivers/of/of_mdio.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)drivers/of/of_mdio.c +0
-0@@ -22,12 +22,30 @@MODULE_AUTHOR ("Grant Likely <[email protected]>" );MODULE_LICENSE ("GPL" );
drivers/of/of_mdio.c line 34
Quoted 10 lines
drivers/of/of_mdio.c +10
-0+static void of_set_phy_supported (struct phy_device *phydev,u32 max_speed) +{ + phydev->supported |=PHY_DEFAULT_FEATURES ; + +switch (max_speed) { +default : +return ; + +case SPEED_1000 : + phydev->supported |=PHY_1000BT_FEATURES ;
This assumes the speed is not already set. Do you need to first mask speeds out?
No need to support 10G PHYs?
A fall-thru note would be helpful here.
Quoted 33 lines
drivers/of/of_mdio.c +14
-1+case SPEED_100 : + phydev->supported |=PHY_100BT_FEATURES ; +case SPEED_10 : + phydev->supported |=PHY_10BT_FEATURES ; + } +} +static int of_mdiobus_register_phy (struct mii_bus *mdio,struct device_node *child,u32 addr) {struct phy_device *phy;bool is_c45;int rc, prev_irq; +u32 max_speed =0 ; is_c45 =of_device_is_compatible (child,"ethernet-phy-ieee802.3-c45" );@@ -58,8 +76,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chireturn 1 ; } +/* Set phydev->supported based on the "max-speed" property +* if present */ +if (!of_property_read_u32 (child,"max-speed" , &max_speed)) +of_set_phy_supported (phy, max_speed); +dev_dbg (&mdio->dev,"registered phy %s at address %i\n" , - child->name, addr); + child->name, addr);return 0 ; }
Re: [PATCH 5/7] net: of_mdio: parse "max-speed" property to set PHY supported features
In reply to Florian FainelliQuoted 17 lines · Florian Fainelli
From: Florian Fainelli <[email protected]>
The "max-speed" property is defined per the ePAPR specification to express the maximum speed a PHY supports. Use that property, if present to set the
phydev->supportedfeatures which properly restricts the PHY within the range of defined speeds.Signed-off-by Florian Fainelli <[email protected]>--- drivers/of/of_mdio.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)drivers/of/of_mdio.c +0
-0
drivers/of/of_mdio.c line 31
Quoted 10 lines
drivers/of/of_mdio.c +7
-0@@ -22,12 +22,30 @@MODULE_AUTHOR ("Grant Likely <[email protected]>" );MODULE_LICENSE ("GPL" ); +static void of_set_phy_supported (struct phy_device *phydev,u32 max_speed) +{ + phydev->supported |=PHY_DEFAULT_FEATURES ; + +switch (max_speed) { +default : +return ;
No need for a default clause.
Quoted 21 lines
drivers/of/of_mdio.c +11
-0+ +case SPEED_1000 : + phydev->supported |=PHY_1000BT_FEATURES ; +case SPEED_100 : + phydev->supported |=PHY_100BT_FEATURES ; +case SPEED_10 : + phydev->supported |=PHY_10BT_FEATURES ; + } +} +static int of_mdiobus_register_phy (struct mii_bus *mdio,struct device_node *child,u32 addr) {struct phy_device *phy;bool is_c45;int rc, prev_irq; +u32 max_speed =0 ; is_c45 =of_device_is_compatible (child,"ethernet-phy-ieee802.3-c45" );
drivers/of/of_mdio.c static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi · line 83
Quoted 8 lines
drivers/of/of_mdio.c +5
-0@@ -58,8 +76,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chireturn 1 ; } +/* Set phydev->supported based on the "max-speed" property +* if present */ +if (!of_property_read_u32 (child,"max-speed" , &max_speed)) +of_set_phy_supported (phy, max_speed); +
Why the separate function? There is no need since there is only one caller and the block is very short. Just do this:
if (!of_property_read_u32(child, "max-speed", &max_speed)) {
phydev->supported |= PHY_DEFAULT_FEATURES;
switch (max_speed) {
case SPEED_1000:
phydev->supported |= PHY_1000BT_FEATURES;
case SPEED_100:
phydev->supported |= PHY_100BT_FEATURES;
case SPEED_10:
phydev->supported |= PHY_10BT_FEATURES;
}
}drivers/of/of_mdio.c static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi · line 85
Quoted 3 lines
drivers/of/of_mdio.c +1
-1dev_dbg (&mdio->dev,"registered phy %s at address %i\n" , - child->name, addr); + child->name, addr);
Unrelated whitespace change. I wouldn't even bother with changing this. It adds noise.
However, those are style concerns. The content looks fine.
g.
PATCH 6/7 arc_emac: remove custom "max-speed" parsing code
In reply to Florian FainelliFrom: Florian Fainelli <[email protected]>
The ARC emac driver was the only in-tree to parse a PHY device 'max-speed' property but yet failed to do it correctly because 'max-speed' is supposed to set a PHY device supported features, not the advertising features as it was done.
Now that of_mdiobus_register() takes care of doing that, remove the custom 'max-speed' parsing code.
--- drivers/net/ethernet/arc/emac.h | 2 -- drivers/net/ethernet/arc/emac_main.c | 20 +------------------- 2 files changed, 1 insertion(+), 21 deletions(-)
drivers/net/ethernet/arc/emac.h +0 -2
@@ -122,7 +122,6 @@ struct buffer_state {* @link: PHY's last seen link state. * @duplex: PHY's last set duplex mode. * @speed: PHY's last set speed. -* @max_speed: Maximum supported by current system network data-rate. */ struct arc_emac_priv {/* Devices */
@@ -152,7 +151,6 @@ struct arc_emac_priv {unsigned int link;unsigned int duplex;unsigned int speed; -unsigned int max_speed; };/**
drivers/net/ethernet/arc/emac_main.c +1 -19
@@ -381,17 +381,7 @@ static int arc_emac_open(struct net_device *ndev) phy_dev->autoneg =AUTONEG_ENABLE ; phy_dev->speed =0 ; phy_dev->duplex =0 ; - phy_dev->advertising = phy_dev->supported; - -if (priv->max_speed >100 ) { - phy_dev->advertising &=PHY_GBIT_FEATURES ; - }else if (priv->max_speed <=100 ) { - phy_dev->advertising &=PHY_BASIC_FEATURES ; -if (priv->max_speed <=10 ) { - phy_dev->advertising &= ~SUPPORTED_100baseT_Half; - phy_dev->advertising &= ~SUPPORTED_100baseT_Full; - } - } + phy_dev->advertising &= phy_dev->supported; priv->last_rx_bd =0 ;
@@ -704,14 +694,6 @@ static int arc_emac_probe(struct platform_device *pdev)/* Set poll rate so that it polls every 1 ms */ arc_reg_set (priv,R_POLLRATE , clock_frequency /1000000 ); -/* Get max speed of operation from device tree */ -if (of_property_read_u32 (pdev->dev.of_node,"max-speed" , - &priv->max_speed)) { -dev_err (&pdev->dev,"failed to retrieve <max-speed> from device tree\n" ); - err = -EINVAL ; - goto out; - } - ndev->irq = irq;dev_info (&pdev->dev,"IRQ is %d\n" , ndev->irq);
Signature · 1 line
1.8.3.2
PATCH 7/7 Documentation: update Ethernet PHY devices binding with 'max-speed'
In reply to Florian FainelliFrom: Florian Fainelli <[email protected]>
The 'max-speed' property is optional but defined in the ePAPR specification and now supported by the Linux Device Tree parsing infrastructure.
--- Documentation/devicetree/bindings/net/phy.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/net/phy.txt +1 -0
@@ -22,6 +22,7 @@ Optional Properties: specifications. If neither of these are specified, the default is to assume clause 22. The compatible list may also contain other elements. +- max-speed: Maximum PHY supported speed (10, 100, 1000...) Example:
Signature · 1 line
1.8.3.2
David Miller
maintainerFrom: Florian Fainelli <[email protected]>
Date: Thu, 5 Dec 2013 14:52:09 -0800
Quoted 3 lines
This patchset contains a few improvements to the MDIO device tree parsing code such as refactoring and parsing the "max-speed" property which is defined in the ePAPR specification.
Series applied, thanks. I fixed up the missing space in the assignment.