aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2017-10-27 15:55:14 -0400
committerDavid S. Miller <davem@davemloft.net>2017-11-01 11:47:03 +0900
commitfd223e2e66eb076b5dda586db9a5a3c99f76f99a (patch)
tree4b7e73df61eb1f13c3ba39a01781a28c01e017e9 /net
parentnet: dsa: get ports within parsing code (diff)
downloadlinux-dev-fd223e2e66eb076b5dda586db9a5a3c99f76f99a.tar.xz
linux-dev-fd223e2e66eb076b5dda586db9a5a3c99f76f99a.zip
net: dsa: add port parse functions
Add symmetrical DSA port parsing functions for pdata and device tree, used to parse and validate a given port node or platform data. They don't do much for the moment but will be extended later on to assign a port type and get device references. 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')
-rw-r--r--net/dsa/dsa2.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 9d57f8dee9a1..a0ee91cd3814 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -590,9 +590,17 @@ static int dsa_dst_parse(struct dsa_switch_tree *dst)
return 0;
}
+static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn)
+{
+ dp->dn = dn;
+
+ return 0;
+}
+
static int dsa_parse_ports_of(struct device_node *dn, struct dsa_switch *ds)
{
struct device_node *ports, *port;
+ struct dsa_port *dp;
u32 reg;
int err;
@@ -610,22 +618,45 @@ static int dsa_parse_ports_of(struct device_node *dn, struct dsa_switch *ds)
if (reg >= ds->num_ports)
return -EINVAL;
- ds->ports[reg].dn = port;
+ dp = &ds->ports[reg];
+
+ err = dsa_port_parse_of(dp, port);
+ if (err)
+ return err;
}
return 0;
}
+static int dsa_port_parse(struct dsa_port *dp, const char *name,
+ struct device *dev)
+{
+ dp->name = name;
+
+ return 0;
+}
+
static int dsa_parse_ports(struct dsa_chip_data *cd, struct dsa_switch *ds)
{
bool valid_name_found = false;
+ struct dsa_port *dp;
+ struct device *dev;
+ const char *name;
unsigned int i;
+ int err;
for (i = 0; i < DSA_MAX_PORTS; i++) {
- if (!cd->port_names[i])
+ name = cd->port_names[i];
+ dev = cd->netdev[i];
+ dp = &ds->ports[i];
+
+ if (!name)
continue;
- ds->ports[i].name = cd->port_names[i];
+ err = dsa_port_parse(dp, name, dev);
+ if (err)
+ return err;
+
valid_name_found = true;
}