*/
static bool dsa_port_is_valid(struct dsa_port *port)
{
- return !!(port->dn || port->name);
+ return port->type != DSA_PORT_TYPE_UNUSED;
}
static bool dsa_port_is_dsa(struct dsa_port *port)
{
- if (port->name && !strcmp(port->name, "dsa"))
- return true;
- else
- return !!of_parse_phandle(port->dn, "link", 0);
+ return port->type == DSA_PORT_TYPE_DSA;
}
static bool dsa_port_is_cpu(struct dsa_port *port)
{
- if (port->name && !strcmp(port->name, "cpu"))
- return true;
- else
- return !!of_parse_phandle(port->dn, "ethernet", 0);
+ return port->type == DSA_PORT_TYPE_CPU;
}
static bool dsa_ds_find_port_dn(struct dsa_switch *ds,
err = dsa_port_complete(dst, ds, port, index);
if (err != 0)
return err;
-
- port->type = DSA_PORT_TYPE_DSA;
}
return 0;
dst->cpu_dp->master = ethernet_dev;
}
- port->type = DSA_PORT_TYPE_CPU;
-
tag_protocol = ds->ops->get_tag_protocol(ds);
tag_ops = dsa_resolve_tag_protocol(tag_protocol);
if (IS_ERR(tag_ops)) {
err = dsa_cpu_parse(port, index, dst, ds);
if (err)
return err;
- } else {
- port->type = DSA_PORT_TYPE_USER;
}
}
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 *link = of_parse_phandle(dn, "link", 0);
+
+ if (ethernet) {
+ dp->type = DSA_PORT_TYPE_CPU;
+ } else if (link) {
+ dp->type = DSA_PORT_TYPE_DSA;
+ } else {
+ dp->type = DSA_PORT_TYPE_USER;
+ }
+
dp->dn = dn;
return 0;
static int dsa_port_parse(struct dsa_port *dp, const char *name,
struct device *dev)
{
+ if (!strcmp(name, "cpu")) {
+ dp->type = DSA_PORT_TYPE_CPU;
+ } else if (!strcmp(name, "dsa")) {
+ dp->type = DSA_PORT_TYPE_DSA;
+ } else {
+ dp->type = DSA_PORT_TYPE_USER;
+ }
+
dp->name = name;
return 0;