mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
net: dsa: get master device at port parsing time
Fetching the master device can be done directly when a port is parsed from device tree or pdata, instead of waiting until dsa_dst_parse. Now that -EPROBE_DEFER is returned before we add the switch to the tree, there is no need to check for this error after dsa_dst_parse. 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>
This commit is contained in:
parent
6d4e5c570c
commit
cbabb0ac01
1 changed files with 18 additions and 26 deletions
|
@ -470,27 +470,9 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
|
||||||
{
|
{
|
||||||
const struct dsa_device_ops *tag_ops;
|
const struct dsa_device_ops *tag_ops;
|
||||||
enum dsa_tag_protocol tag_protocol;
|
enum dsa_tag_protocol tag_protocol;
|
||||||
struct net_device *ethernet_dev;
|
|
||||||
struct device_node *ethernet;
|
|
||||||
|
|
||||||
if (port->dn) {
|
if (!dst->cpu_dp)
|
||||||
ethernet = of_parse_phandle(port->dn, "ethernet", 0);
|
|
||||||
if (!ethernet)
|
|
||||||
return -EINVAL;
|
|
||||||
ethernet_dev = of_find_net_device_by_node(ethernet);
|
|
||||||
if (!ethernet_dev)
|
|
||||||
return -EPROBE_DEFER;
|
|
||||||
} else {
|
|
||||||
ethernet_dev = dsa_dev_to_net_device(ds->cd->netdev[index]);
|
|
||||||
if (!ethernet_dev)
|
|
||||||
return -EPROBE_DEFER;
|
|
||||||
dev_put(ethernet_dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dst->cpu_dp) {
|
|
||||||
dst->cpu_dp = port;
|
dst->cpu_dp = port;
|
||||||
dst->cpu_dp->master = ethernet_dev;
|
|
||||||
}
|
|
||||||
|
|
||||||
tag_protocol = ds->ops->get_tag_protocol(ds);
|
tag_protocol = ds->ops->get_tag_protocol(ds);
|
||||||
tag_ops = dsa_resolve_tag_protocol(tag_protocol);
|
tag_ops = dsa_resolve_tag_protocol(tag_protocol);
|
||||||
|
@ -584,7 +566,14 @@ static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn)
|
||||||
struct device_node *link = of_parse_phandle(dn, "link", 0);
|
struct device_node *link = of_parse_phandle(dn, "link", 0);
|
||||||
|
|
||||||
if (ethernet) {
|
if (ethernet) {
|
||||||
|
struct net_device *master;
|
||||||
|
|
||||||
|
master = of_find_net_device_by_node(ethernet);
|
||||||
|
if (!master)
|
||||||
|
return -EPROBE_DEFER;
|
||||||
|
|
||||||
dp->type = DSA_PORT_TYPE_CPU;
|
dp->type = DSA_PORT_TYPE_CPU;
|
||||||
|
dp->master = master;
|
||||||
} else if (link) {
|
} else if (link) {
|
||||||
dp->type = DSA_PORT_TYPE_DSA;
|
dp->type = DSA_PORT_TYPE_DSA;
|
||||||
} else {
|
} else {
|
||||||
|
@ -631,7 +620,16 @@ static int dsa_port_parse(struct dsa_port *dp, const char *name,
|
||||||
struct device *dev)
|
struct device *dev)
|
||||||
{
|
{
|
||||||
if (!strcmp(name, "cpu")) {
|
if (!strcmp(name, "cpu")) {
|
||||||
|
struct net_device *master;
|
||||||
|
|
||||||
|
master = dsa_dev_to_net_device(dev);
|
||||||
|
if (!master)
|
||||||
|
return -EPROBE_DEFER;
|
||||||
|
|
||||||
|
dev_put(master);
|
||||||
|
|
||||||
dp->type = DSA_PORT_TYPE_CPU;
|
dp->type = DSA_PORT_TYPE_CPU;
|
||||||
|
dp->master = master;
|
||||||
} else if (!strcmp(name, "dsa")) {
|
} else if (!strcmp(name, "dsa")) {
|
||||||
dp->type = DSA_PORT_TYPE_DSA;
|
dp->type = DSA_PORT_TYPE_DSA;
|
||||||
} else {
|
} else {
|
||||||
|
@ -773,14 +771,8 @@ static int _dsa_register_switch(struct dsa_switch *ds)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dsa_dst_parse(dst);
|
err = dsa_dst_parse(dst);
|
||||||
if (err) {
|
if (err)
|
||||||
if (err == -EPROBE_DEFER) {
|
|
||||||
dsa_dst_del_ds(dst, ds, ds->index);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
goto out_del_dst;
|
goto out_del_dst;
|
||||||
}
|
|
||||||
|
|
||||||
err = dsa_dst_apply(dst);
|
err = dsa_dst_apply(dst);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue