diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2014-12-11 15:49:16 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-12-11 21:00:08 -0500 |
commit | 9697f1cde9901c00298fd1313b4aaf96f287bf7a (patch) | |
tree | 2298b1c69843267ef079f7d7486caf1f3e433c79 /net/dsa | |
parent | 53013c77437c9b00658fc112b4e0aecd221c512a (diff) |
net: dsa: propagate error code from dsa_slave_phy_setup
In case we cannot attach to our slave netdevice PHY, error out and
propagate that error up to the caller: dsa_slave_create().
Fixes: 0d8bcdd383b8 ("net: dsa: allow for more complex PHY setups")
Signed-off-by: Andrey Volkov <andrey.volkov@nexvision.fr>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r-- | net/dsa/slave.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c index da64ba9d825d..515569ffde8a 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c | |||
@@ -512,7 +512,7 @@ static int dsa_slave_fixed_link_update(struct net_device *dev, | |||
512 | } | 512 | } |
513 | 513 | ||
514 | /* slave device setup *******************************************************/ | 514 | /* slave device setup *******************************************************/ |
515 | static void dsa_slave_phy_setup(struct dsa_slave_priv *p, | 515 | static int dsa_slave_phy_setup(struct dsa_slave_priv *p, |
516 | struct net_device *slave_dev) | 516 | struct net_device *slave_dev) |
517 | { | 517 | { |
518 | struct dsa_switch *ds = p->parent; | 518 | struct dsa_switch *ds = p->parent; |
@@ -533,7 +533,7 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p, | |||
533 | ret = of_phy_register_fixed_link(port_dn); | 533 | ret = of_phy_register_fixed_link(port_dn); |
534 | if (ret) { | 534 | if (ret) { |
535 | netdev_err(slave_dev, "failed to register fixed PHY\n"); | 535 | netdev_err(slave_dev, "failed to register fixed PHY\n"); |
536 | return; | 536 | return ret; |
537 | } | 537 | } |
538 | phy_is_fixed = true; | 538 | phy_is_fixed = true; |
539 | phy_dn = port_dn; | 539 | phy_dn = port_dn; |
@@ -556,7 +556,7 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p, | |||
556 | if (!p->phy) { | 556 | if (!p->phy) { |
557 | p->phy = ds->slave_mii_bus->phy_map[p->port]; | 557 | p->phy = ds->slave_mii_bus->phy_map[p->port]; |
558 | if (!p->phy) | 558 | if (!p->phy) |
559 | return; | 559 | return -ENODEV; |
560 | 560 | ||
561 | phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, | 561 | phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, |
562 | p->phy_interface); | 562 | p->phy_interface); |
@@ -564,6 +564,8 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p, | |||
564 | netdev_info(slave_dev, "attached PHY at address %d [%s]\n", | 564 | netdev_info(slave_dev, "attached PHY at address %d [%s]\n", |
565 | p->phy->addr, p->phy->drv->name); | 565 | p->phy->addr, p->phy->drv->name); |
566 | } | 566 | } |
567 | |||
568 | return 0; | ||
567 | } | 569 | } |
568 | 570 | ||
569 | int dsa_slave_suspend(struct net_device *slave_dev) | 571 | int dsa_slave_suspend(struct net_device *slave_dev) |
@@ -656,12 +658,17 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent, | |||
656 | p->old_link = -1; | 658 | p->old_link = -1; |
657 | p->old_duplex = -1; | 659 | p->old_duplex = -1; |
658 | 660 | ||
659 | dsa_slave_phy_setup(p, slave_dev); | 661 | ret = dsa_slave_phy_setup(p, slave_dev); |
662 | if (ret) { | ||
663 | free_netdev(slave_dev); | ||
664 | return NULL; | ||
665 | } | ||
660 | 666 | ||
661 | ret = register_netdev(slave_dev); | 667 | ret = register_netdev(slave_dev); |
662 | if (ret) { | 668 | if (ret) { |
663 | netdev_err(master, "error %d registering interface %s\n", | 669 | netdev_err(master, "error %d registering interface %s\n", |
664 | ret, slave_dev->name); | 670 | ret, slave_dev->name); |
671 | phy_disconnect(p->phy); | ||
665 | free_netdev(slave_dev); | 672 | free_netdev(slave_dev); |
666 | return NULL; | 673 | return NULL; |
667 | } | 674 | } |