diff options
author | Neil Armstrong <narmstrong@baylibre.com> | 2015-10-06 10:40:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-10-07 07:56:11 -0400 |
commit | 4d7f3e757c15051b4521a59791de87ce748c0eb2 (patch) | |
tree | 67a4fbcc4982a51fc30f692750cb98e3328dac1b | |
parent | d4ac35d6ed82e6c96ed5c016ea46fad31294fa7a (diff) |
net: dsa: exit probe if no switch were found
If no switch were found in dsa_setup_dst, return -ENODEV and
exit the dsa_probe cleanly.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/dsa/dsa.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index d5a162cda087..adb5325f4934 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c | |||
@@ -837,10 +837,11 @@ static inline void dsa_of_remove(struct device *dev) | |||
837 | } | 837 | } |
838 | #endif | 838 | #endif |
839 | 839 | ||
840 | static void dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev, | 840 | static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev, |
841 | struct device *parent, struct dsa_platform_data *pd) | 841 | struct device *parent, struct dsa_platform_data *pd) |
842 | { | 842 | { |
843 | int i; | 843 | int i; |
844 | unsigned configured = 0; | ||
844 | 845 | ||
845 | dst->pd = pd; | 846 | dst->pd = pd; |
846 | dst->master_netdev = dev; | 847 | dst->master_netdev = dev; |
@@ -860,9 +861,17 @@ static void dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev, | |||
860 | dst->ds[i] = ds; | 861 | dst->ds[i] = ds; |
861 | if (ds->drv->poll_link != NULL) | 862 | if (ds->drv->poll_link != NULL) |
862 | dst->link_poll_needed = 1; | 863 | dst->link_poll_needed = 1; |
864 | |||
865 | ++configured; | ||
863 | } | 866 | } |
864 | 867 | ||
865 | /* | 868 | /* |
869 | * If no switch was found, exit cleanly | ||
870 | */ | ||
871 | if (!configured) | ||
872 | return -EPROBE_DEFER; | ||
873 | |||
874 | /* | ||
866 | * If we use a tagging format that doesn't have an ethertype | 875 | * If we use a tagging format that doesn't have an ethertype |
867 | * field, make sure that all packets from this point on get | 876 | * field, make sure that all packets from this point on get |
868 | * sent to the tag format's receive function. | 877 | * sent to the tag format's receive function. |
@@ -878,6 +887,8 @@ static void dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev, | |||
878 | dst->link_poll_timer.expires = round_jiffies(jiffies + HZ); | 887 | dst->link_poll_timer.expires = round_jiffies(jiffies + HZ); |
879 | add_timer(&dst->link_poll_timer); | 888 | add_timer(&dst->link_poll_timer); |
880 | } | 889 | } |
890 | |||
891 | return 0; | ||
881 | } | 892 | } |
882 | 893 | ||
883 | static int dsa_probe(struct platform_device *pdev) | 894 | static int dsa_probe(struct platform_device *pdev) |
@@ -927,7 +938,9 @@ static int dsa_probe(struct platform_device *pdev) | |||
927 | 938 | ||
928 | platform_set_drvdata(pdev, dst); | 939 | platform_set_drvdata(pdev, dst); |
929 | 940 | ||
930 | dsa_setup_dst(dst, dev, &pdev->dev, pd); | 941 | ret = dsa_setup_dst(dst, dev, &pdev->dev, pd); |
942 | if (ret) | ||
943 | goto out; | ||
931 | 944 | ||
932 | return 0; | 945 | return 0; |
933 | 946 | ||