[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1456677700-23027-13-git-send-email-andrew@lunn.ch>
Date: Sun, 28 Feb 2016 17:41:20 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Florian Fainelli <f.fainelli@...il.com>,
Vivien Didelot <vivien.didelot@...oirfairelinux.com>,
netdev <netdev@...r.kernel.org>
Cc: Andrew Lunn <andrew@...n.ch>
Subject: [PATCH RFC v2 12/32] net: dsa: Add slave component matches based on a phandle to the slave.
Switch devices are component slaves. Such devices have a "switch"
property in the DSA device tree which is a phandle to the switch
device. Add a component match on the device node.
Signed-off-by: Andrew Lunn <andrew@...n.ch>
---
net/dsa/dsa.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index f2af801554ec..73a3fd561ef3 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -886,18 +886,25 @@ static void dsa_finish_dst(struct dsa_switch_tree *dst, struct device *parent,
}
}
+static int compare_of(struct device *dev, void *data)
+{
+ return dev->of_node == data;
+}
+
static int dsa_probe(struct platform_device *pdev)
{
struct dsa_platform_data *pd = pdev->dev.platform_data;
+ struct device_node *np = pdev->dev.of_node;
struct component_match *match = NULL;
+ struct device_node *chip;
struct net_device *dev;
struct dsa_switch_tree *dst;
- int ret;
+ int i, ret;
pr_notice_once("Distributed Switch Architecture driver version %s\n",
dsa_driver_version);
- if (pdev->dev.of_node) {
+ if (np) {
pd = devm_kzalloc(&pdev->dev, sizeof(*pd), GFP_KERNEL);
if (!pd)
return -ENOMEM;
@@ -941,6 +948,12 @@ static int dsa_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dst);
+ for (i = 0; i < pd->nr_chips; i++) {
+ chip = pd->chip[i].of_chip;
+ if (chip)
+ component_match_add(&pdev->dev, &match, compare_of,
+ chip);
+ }
return component_master_add_with_match(&pdev->dev, &dsa_ops, match);
--
2.7.0
Powered by blists - more mailing lists