All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: dsa: mv88e6xxx: fix mdio bus name when using devicetree
@ 2017-05-01 14:54 Sylvain Lemieux
  2017-05-01 15:20 ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: Sylvain Lemieux @ 2017-05-01 14:54 UTC (permalink / raw)
  To: andrew, vivien.didelot; +Cc: netdev

From: Liam Beguin <lbeguin@tycoint.com>

mv88e6xxx_mdio_register automatically generates mdio buses for each switch
discovered in the devicetree. When switch nodes are embedded in other nodes,
this can cause sysfs naming collisions since full_name may be truncated.

Only use devicetree node name instead of the full devicetree path
as the mdio bus name.

Signed-off-by: Liam Beguin <lbeguin@tycoint.com>
Signed-off-by: Alexandre Messier <amessier@tycoint.com>
Signed-off-by: Sylvain Lemieux <slemieux@tycoint.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 3354f99df378..80b4387d573e 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2688,8 +2688,8 @@ static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
 	mdio_bus->external = external;
 
 	if (np) {
-		bus->name = np->full_name;
-		snprintf(bus->id, MII_BUS_ID_SIZE, "%s", np->full_name);
+		bus->name = np->name;
+		snprintf(bus->id, MII_BUS_ID_SIZE, "%s", np->name);
 	} else {
 		bus->name = "mv88e6xxx SMI";
 		snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: dsa: mv88e6xxx: fix mdio bus name when using devicetree
  2017-05-01 14:54 [PATCH] net: dsa: mv88e6xxx: fix mdio bus name when using devicetree Sylvain Lemieux
@ 2017-05-01 15:20 ` Andrew Lunn
  2017-05-02 14:26   ` Sylvain Lemieux
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2017-05-01 15:20 UTC (permalink / raw)
  To: Sylvain Lemieux; +Cc: vivien.didelot, netdev

On Mon, May 01, 2017 at 10:54:04AM -0400, Sylvain Lemieux wrote:
> From: Liam Beguin <lbeguin@tycoint.com>
> 
> mv88e6xxx_mdio_register automatically generates mdio buses for each switch
> discovered in the devicetree. When switch nodes are embedded in other nodes,
> this can cause sysfs naming collisions since full_name may be truncated.
> 
> Only use devicetree node name instead of the full devicetree path
> as the mdio bus name.

Hi Sylvain

I'm not sure this is a good idea. It probably breaks my boards:

:/sys/class/mdio_bus# ls
!mdio-mux!mdio@1!switch@0!mdio	0.1  0.4  400d0000.ethernet-1  fixed-0
!mdio-mux!mdio@2!switch@0!mdio	0.2  0.8  400d1000.ethernet-2  mv88e6xxx-0

np->name is not unique, where as np->full_name is unique.

However, i can understand your problem with truncation. Maybe a better
solution is to detect if truncation is going to happen. If so, use a
concatenation of a hash of np->full_name, and the right hand part of
np->full_name?

	Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: dsa: mv88e6xxx: fix mdio bus name when using devicetree
  2017-05-01 15:20 ` Andrew Lunn
@ 2017-05-02 14:26   ` Sylvain Lemieux
  0 siblings, 0 replies; 3+ messages in thread
From: Sylvain Lemieux @ 2017-05-02 14:26 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: vivien.didelot, netdev

Hi Andrew,

On Mon, 2017-05-01 at 17:20 +0200, Andrew Lunn wrote:
> On Mon, May 01, 2017 at 10:54:04AM -0400, Sylvain Lemieux wrote:
> > From: Liam Beguin <lbeguin@tycoint.com>
> > 
> > mv88e6xxx_mdio_register automatically generates mdio buses for each switch
> > discovered in the devicetree. When switch nodes are embedded in other nodes,
> > this can cause sysfs naming collisions since full_name may be truncated.
> > 
> > Only use devicetree node name instead of the full devicetree path
> > as the mdio bus name.
> 
> Hi Sylvain
> 
> I'm not sure this is a good idea. It probably breaks my boards:
> 
> :/sys/class/mdio_bus# ls
> !mdio-mux!mdio@1!switch@0!mdio	0.1  0.4  400d0000.ethernet-1  fixed-0
> !mdio-mux!mdio@2!switch@0!mdio	0.2  0.8  400d1000.ethernet-2  mv88e6xxx-0
> 
> np->name is not unique, where as np->full_name is unique.
> 
> However, i can understand your problem with truncation. Maybe a better
> solution is to detect if truncation is going to happen. If so, use a
> concatenation of a hash of np->full_name, and the right hand part of
> np->full_name?
> 
Thanks for the feedback.

I am currently busy on something else; I should be able to look at this
next week or the following.

Regards,
Sylvain

> 	Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-02 14:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-01 14:54 [PATCH] net: dsa: mv88e6xxx: fix mdio bus name when using devicetree Sylvain Lemieux
2017-05-01 15:20 ` Andrew Lunn
2017-05-02 14:26   ` Sylvain Lemieux

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.