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-next>] [day] [month] [year] [list]
Date:   Thu, 10 Sep 2020 17:13:03 +0530
From:   Vikas Singh <vikas.singh@...esoftware.com>
To:     andrew@...n.ch, f.fainelli@...il.com, hkallweit1@...il.com,
        linux@...linux.org.uk, netdev@...r.kernel.org
Cc:     calvin.johnson@....nxp.com, kuldip.dwivedi@...esoftware.com,
        madalin.bucur@....nxp.com, vikas.singh@....com,
        Vikas Singh <vikas.singh@...esoftware.com>
Subject: [PATCH v2] net: Phy: Add PHY lookup support on MDIO bus in case of ACPI probe

The function referred to (of_mdiobus_link_mdiodev()) is only built when
CONFIG_OF_MDIO is enabled, which is again, a DT specific thing, and would
not work in case of ACPI.
Given that it is a static function so renamed of_mdiobus_link_mdiodev()
as mdiobus_link_mdiodev() and did necessary changes, finally moved it out
of the #ifdef(CONFIG_OF_MDIO) therefore make it work for both DT & ACPI.

Signed-off-by: Vikas Singh <vikas.singh@...esoftware.com>
---

Notes:
    - Add generic handling for "fwnode" and "of_node".
    - Remove duplicate loops.

 drivers/net/phy/mdio_bus.c | 43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 46b3370..b0faa95 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -434,6 +434,7 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np)
 	return d ? to_mii_bus(d) : NULL;
 }
 EXPORT_SYMBOL(of_mdio_find_bus);
+#endif
 
 /* Walk the list of subnodes of a mdio bus and look for a node that
  * matches the mdio device's address with its 'reg' property. If
@@ -441,35 +442,37 @@ EXPORT_SYMBOL(of_mdio_find_bus);
  * auto-probed phy devices to be supplied with information passed in
  * via DT.
  */
-static void of_mdiobus_link_mdiodev(struct mii_bus *bus,
-				    struct mdio_device *mdiodev)
+static void mdiobus_link_mdiodev(struct mii_bus *bus,
+				 struct mdio_device *mdiodev)
 {
 	struct device *dev = &mdiodev->dev;
-	struct device_node *child;
+	struct fwnode_handle *child;
+	int addr;
 
-	if (dev->of_node || !bus->dev.of_node)
+	if (dev->fwnode || !bus->dev.fwnode) {
+		pr_err("PHY fwnode is not available on bus for registration\n");
 		return;
+	}
 
-	for_each_available_child_of_node(bus->dev.of_node, child) {
-		int addr;
+	device_for_each_child_node(&bus->dev, child) {
+		if (!fwnode_device_is_available(child))
+			continue;
 
-		addr = of_mdio_parse_addr(dev, child);
-		if (addr < 0)
+		if (is_of_node(child)) {
+			addr = of_mdio_parse_addr(dev, to_of_node(child));
+			if (addr < 0)
+				continue;
+		} else if (fwnode_property_read_u32(child, "reg", &addr))
 			continue;
 
 		if (addr == mdiodev->addr) {
-			dev->of_node = child;
-			dev->fwnode = of_fwnode_handle(child);
-			return;
+			dev->of_node = to_of_node(child);
+			dev->fwnode = child;
+			break;
 		}
 	}
+	return;
 }
-#else /* !IS_ENABLED(CONFIG_OF_MDIO) */
-static inline void of_mdiobus_link_mdiodev(struct mii_bus *mdio,
-					   struct mdio_device *mdiodev)
-{
-}
-#endif
 
 /**
  * mdiobus_create_device_from_board_info - create a full MDIO device given
@@ -688,10 +691,10 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
 		return phydev;
 
 	/*
-	 * For DT, see if the auto-probed phy has a correspoding child
-	 * in the bus node, and set the of_node pointer in this case.
+	 * See if the auto-probed phy has a corresponding child
+	 * in the bus node, and set the of_node & fwnode pointers.
 	 */
-	of_mdiobus_link_mdiodev(bus, &phydev->mdio);
+	mdiobus_link_mdiodev(bus, &phydev->mdio);
 
 	err = phy_device_register(phydev);
 	if (err) {
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ