From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 2/5] mdio_bus: Port of_mdio_find_bus() from Linux kernel
Date: Tue, 28 Nov 2017 20:55:03 -0800 [thread overview]
Message-ID: <20171129045506.17149-2-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20171129045506.17149-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
next prev parent reply other threads:[~2017-11-29 4:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-29 4:55 [PATCH 1/5] ARM: vybrid: zii: Make use of DT code " Andrey Smirnov
2017-11-29 4:55 ` Andrey Smirnov [this message]
2017-11-29 4:55 ` [PATCH 3/5] net: phy: Port MDIO bus miltiplexer framework " Andrey Smirnov
2017-12-01 11:12 ` Sascha Hauer
2017-12-04 15:13 ` Andrey Smirnov
2017-11-29 4:55 ` [PATCH 4/5] net: phy: Port GPIO controlled MDIO multiplexer driver Andrey Smirnov
2017-11-29 4:55 ` [PATCH 5/5] net: mdio-mux: Avoid probing multiplexed busses Andrey Smirnov
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=20171129045506.17149-2-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