lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 28 Feb 2016 17:41:19 +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 11/32] net: dsa: Keep a reference to the switch device for component matching

The switch devices are component slaves. Such devices have a "switch"
property in the DSA device tree which is a phandle to the switch
device. When the slaves bind they register to DSA. So the DSA can
match the switch to the correct switch instance in the device tree,
keep a reference to the device tree node during parsing of the device
tree.

Signed-off-by: Andrew Lunn <andrew@...n.ch>
---
 Documentation/devicetree/bindings/net/dsa/dsa.txt | 2 ++
 include/net/dsa.h                                 | 3 +++
 net/dsa/dsa.c                                     | 6 +++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.txt b/Documentation/devicetree/bindings/net/dsa/dsa.txt
index 5fdbbcdf8c4b..f99e5694a61f 100644
--- a/Documentation/devicetree/bindings/net/dsa/dsa.txt
+++ b/Documentation/devicetree/bindings/net/dsa/dsa.txt
@@ -27,6 +27,8 @@ Each of these switch child nodes should have the following required properties:
 
 A switch child node has the following optional property:
 
+- switch		: A phandle to a switch device.
+
 - eeprom-length		: Set to the length of an EEPROM connected to the
 			  switch. Must be set if the switch can not detect
 			  the presence and/or size of a connected EEPROM,
diff --git a/include/net/dsa.h b/include/net/dsa.h
index f6b8001a500f..ea4cfdf1b549 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -48,6 +48,9 @@ struct dsa_chip_data {
 	 */
 	struct device_node *of_node;
 
+	/* Device tree node pointer for the switch chip device. */
+	struct device_node *of_chip;
+
 	/*
 	 * The names of the switch's ports.  Use "cpu" to
 	 * designate the switch port that the cpu is connected to,
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index a139c35061a1..f2af801554ec 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -662,7 +662,7 @@ static void dsa_of_free_platform_data(struct dsa_platform_data *pd)
 static int dsa_of_probe(struct device *dev, struct dsa_platform_data *pd)
 {
 	struct device_node *np = dev->of_node;
-	struct device_node *child, *mdio, *ethernet, *port;
+	struct device_node *child, *chip, *mdio, *ethernet, *port;
 	struct mii_bus *mdio_bus, *mdio_bus_switch;
 	struct net_device *ethernet_dev;
 	struct dsa_chip_data *cd;
@@ -712,6 +712,10 @@ static int dsa_of_probe(struct device *dev, struct dsa_platform_data *pd)
 
 		cd->of_node = child;
 
+		chip = of_parse_phandle(child, "switch", 0);
+		if (chip)
+			cd->of_chip = chip;
+
 		/* When assigning the host device, increment its refcount */
 		cd->host_dev = get_device(&mdio_bus->dev);
 
-- 
2.7.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ