Commit 1838fa89 authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller

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: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cbabb0ac
...@@ -260,11 +260,6 @@ static int dsa_user_port_apply(struct dsa_port *port) ...@@ -260,11 +260,6 @@ static int dsa_user_port_apply(struct dsa_port *port)
const char *name = port->name; const char *name = port->name;
int err; int err;
if (port->dn)
name = of_get_property(port->dn, "label", NULL);
if (!name)
name = "eth%d";
err = dsa_slave_create(port, name); err = dsa_slave_create(port, name);
if (err) { if (err) {
dev_warn(ds->dev, "Failed to create slave %d: %d\n", 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,6 +559,7 @@ static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn)
{ {
struct device_node *ethernet = of_parse_phandle(dn, "ethernet", 0); struct device_node *ethernet = of_parse_phandle(dn, "ethernet", 0);
struct device_node *link = of_parse_phandle(dn, "link", 0); struct device_node *link = of_parse_phandle(dn, "link", 0);
const char *name = of_get_property(dn, "label", NULL);
if (ethernet) { if (ethernet) {
struct net_device *master; struct net_device *master;
...@@ -577,7 +573,11 @@ static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn) ...@@ -577,7 +573,11 @@ static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn)
} else if (link) { } else if (link) {
dp->type = DSA_PORT_TYPE_DSA; dp->type = DSA_PORT_TYPE_DSA;
} else { } else {
if (!name)
name = "eth%d";
dp->type = DSA_PORT_TYPE_USER; dp->type = DSA_PORT_TYPE_USER;
dp->name = name;
} }
dp->dn = dn; dp->dn = dn;
......
...@@ -115,6 +115,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, ...@@ -115,6 +115,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
name = cd->port_names[i]; name = cd->port_names[i];
if (name == NULL) if (name == NULL)
continue; continue;
dp->name = name;
if (!strcmp(name, "cpu")) { if (!strcmp(name, "cpu")) {
if (dst->cpu_dp) { if (dst->cpu_dp) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment