[PATCH] phy: phy-core: Support modelling multi-PHY PHY nodes as subnodes of PHY PROVIDER

From: Kishon Vijay Abraham I
Date: Thu May 15 2014 - 02:02:57 EST


When a single PHY provider implementing multiple PHYs is represented in dt,
the PHYs should be modelled as sub nodes of the PHY PROVIDER node.

So the consumers using the PHY will have the phandle of the sub node rather
than the phandle of the PHY PROVIDER. Amended *of_phy_provider_lookup* in
PHY core to return the PHY PROVIDER even when the phandle of the PHY PROVIDERs
sub node is provided.

Signed-off-by: Kishon Vijay Abraham I <kishon@xxxxxx>
---
drivers/phy/phy-core.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 03cf8fb..124c6ec 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -83,10 +83,18 @@ static struct phy *phy_lookup(struct device *device, const
char *port)
static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
{
struct phy_provider *phy_provider;
+ struct device_node *child;

list_for_each_entry(phy_provider, &phy_provider_list, list) {
- if (phy_provider->dev->of_node == node)
+ if (phy_provider->dev->of_node != node) {
+ for_each_child_of_node(phy_provider->dev->of_node,
+ child) {
+ if (child == node)
+ return phy_provider;
+ }
+ } else {
return phy_provider;
+ }
}

return ERR_PTR(-EPROBE_DEFER);
--
1.7.9.5

Thanks
Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/