mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH v2 2/6] mdio_bus: Port of_mdio_find_bus() from Linux kernel
Date: Mon,  4 Dec 2017 07:27:14 -0800	[thread overview]
Message-ID: <20171204152718.10674-3-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20171204152718.10674-1-andrew.smirnov@gmail.com>

Port of_mdio_find_bus() from Linux kernel. This function is used in
MDIO multiplexor infrastructure added in following commit.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/net/phy/mdio_bus.c | 27 +++++++++++++++++++++++++++
 include/linux/phy.h        |  2 ++
 2 files changed, 29 insertions(+)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 012b90e83..6ae85692d 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -206,6 +206,33 @@ struct mii_bus *mdiobus_get_bus(int busnum)
 	return NULL;
 }
 
+/**
+ * of_mdio_find_bus - Given an mii_bus node, find the mii_bus.
+ * @mdio_bus_np: Pointer to the mii_bus.
+ *
+ * Returns a reference to the mii_bus, or NULL if none found.
+ *
+ * Because the association of a device_node and mii_bus is made via
+ * mdiobus_register(), the mii_bus cannot be found before it is
+ * registered with mdiobus_register().
+ *
+ */
+struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np)
+{
+	struct mii_bus *mii;
+
+	if (!mdio_bus_np)
+		return NULL;
+
+	for_each_mii_bus(mii)
+		if (mii->dev.device_node == mdio_bus_np)
+			return mii;
+
+	return NULL;
+}
+EXPORT_SYMBOL(of_mdio_find_bus);
+
+
 /**
  * mdio_bus_match - determine if given PHY driver supports the given PHY device
  * @dev: target PHY device
diff --git a/include/linux/phy.h b/include/linux/phy.h
index d7b10afbc..809f06fb1 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -116,6 +116,8 @@ int mdiobus_detect(struct device_d *dev);
 
 struct mii_bus *mdiobus_get_bus(int busnum);
 
+struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np);
+
 /**
  * mdiobus_read - Convenience function for reading a given MII mgmt register
  * @bus: the mii_bus struct
-- 
2.14.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2017-12-04 15:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-04 15:27 [PATCH v2 0/6] MDIO bus multiplexer support Andrey Smirnov
2017-12-04 15:27 ` [PATCH v2 1/6] ARM: vybrid: zii: Make use of DT code from Linux kernel Andrey Smirnov
2017-12-04 15:27 ` Andrey Smirnov [this message]
2017-12-04 15:27 ` [PATCH v2 3/6] net: phy: Port MDIO bus miltiplexer framework " Andrey Smirnov
2017-12-04 15:27 ` [PATCH v2 4/6] net: phy: Port GPIO controlled MDIO multiplexer driver Andrey Smirnov
2017-12-04 15:27 ` [PATCH v2 5/6] net: mdio-mux: Avoid probing multiplexed busses Andrey Smirnov
2017-12-04 15:27 ` [PATCH v2 6/6] zii_vf610_dev_defconfig: Select MDIO bus GPIO multiplexer Andrey Smirnov
2017-12-06 14:49 ` [PATCH v2 0/6] MDIO bus multiplexer support Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171204152718.10674-3-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox