diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2017-10-27 15:55:18 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-31 22:47:36 -0400 |
commit | 1838fa89a22cbc9ec87e995683e241a82d87e6df (patch) | |
tree | 34be73f20faedfd7c979548b5336cfcb4d61cd56 /net/dsa/dsa2.c | |
parent | cbabb0ac01052f79cf96d7b7e3d3451ffd275864 (diff) |
net: dsa: get port name at parse time
Get the optional "label" property and assign a default one directly at
parse time instead of doing it when creating the slave.
For legacy, simply assign the port name stored in cd->port_names.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/dsa2.c')
-rw-r--r-- | net/dsa/dsa2.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 8cd84c1b3dc0..3c134ff26863 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c | |||
@@ -260,11 +260,6 @@ static int dsa_user_port_apply(struct dsa_port *port) | |||
260 | const char *name = port->name; | 260 | const char *name = port->name; |
261 | int err; | 261 | int err; |
262 | 262 | ||
263 | if (port->dn) | ||
264 | name = of_get_property(port->dn, "label", NULL); | ||
265 | if (!name) | ||
266 | name = "eth%d"; | ||
267 | |||
268 | err = dsa_slave_create(port, name); | 263 | err = dsa_slave_create(port, name); |
269 | if (err) { | 264 | if (err) { |
270 | dev_warn(ds->dev, "Failed to create slave %d: %d\n", | 265 | dev_warn(ds->dev, "Failed to create slave %d: %d\n", |
@@ -564,6 +559,7 @@ static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn) | |||
564 | { | 559 | { |
565 | struct device_node *ethernet = of_parse_phandle(dn, "ethernet", 0); | 560 | struct device_node *ethernet = of_parse_phandle(dn, "ethernet", 0); |
566 | struct device_node *link = of_parse_phandle(dn, "link", 0); | 561 | struct device_node *link = of_parse_phandle(dn, "link", 0); |
562 | const char *name = of_get_property(dn, "label", NULL); | ||
567 | 563 | ||
568 | if (ethernet) { | 564 | if (ethernet) { |
569 | struct net_device *master; | 565 | struct net_device *master; |
@@ -577,7 +573,11 @@ static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn) | |||
577 | } else if (link) { | 573 | } else if (link) { |
578 | dp->type = DSA_PORT_TYPE_DSA; | 574 | dp->type = DSA_PORT_TYPE_DSA; |
579 | } else { | 575 | } else { |
576 | if (!name) | ||
577 | name = "eth%d"; | ||
578 | |||
580 | dp->type = DSA_PORT_TYPE_USER; | 579 | dp->type = DSA_PORT_TYPE_USER; |
580 | dp->name = name; | ||
581 | } | 581 | } |
582 | 582 | ||
583 | dp->dn = dn; | 583 | dp->dn = dn; |