diff mbox

[RFC,1/2] phy: core: Fix of_phy_provider_lookup to return PHY provider for sub node

Message ID 1404486474-28312-2-git-send-email-kishon@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kishon Vijay Abraham I July 4, 2014, 3:07 p.m. UTC
Fixed of_phy_provider_lookup to return 'phy_provider' if _of_phy_get
passes the node pointer of the sub-node of phy provider node. This is
needed when phy provider implements multiple PHYs and each PHY is
modelled as the sub-node of PHY provider device node.

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

Comments

Lee Jones July 7, 2014, 1:43 p.m. UTC | #1
On Fri, 04 Jul 2014, Kishon Vijay Abraham I wrote:

> Fixed of_phy_provider_lookup to return 'phy_provider' if _of_phy_get
> passes the node pointer of the sub-node of phy provider node. This is
> needed when phy provider implements multiple PHYs and each PHY is
> modelled as the sub-node of PHY provider device node.
> 
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  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 c64a2f3..a4a1f783 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -86,10 +86,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);

How about this instead:

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

Patch

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index c64a2f3..a4a1f783 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -86,10 +86,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);