All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] phy: micrel: Fix finding PHY properties in MAC node.
@ 2015-12-09 18:37 Andrew Lunn
  2015-12-09 18:38 ` David Daney
  2015-12-09 18:42 ` David Daney
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Lunn @ 2015-12-09 18:37 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Florian Fainelli, dinguyen, david.daney, Andrew Lunn

commit 8b63ec1837fa ("phylib: Make PHYs children of their MDIO bus,
not the bus' parent.")  changed the parenting of PHY devices, making
them a child of the MDIO bus, instead of the MAC device. This broken
the Micrel PHY driver which has a deprecated feature of allowing PHY
properties to be placed into the MAC node.

In order to find the MAC node, we need to walk up the tree of devices
until we find one with an OF node attached.

Reported-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Suggested-by: David Daney <david.daney@cavium.com>
Fixes: 8b63ec1837fa ("phylib: Make PHYs children of their MDIO bus, not the bus' parent.")
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/micrel.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index cf6312fafea5..2493d7c035f2 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -26,6 +26,7 @@
 #include <linux/module.h>
 #include <linux/phy.h>
 #include <linux/micrel_phy.h>
+#include <linux/netdevice.h>
 #include <linux/of.h>
 #include <linux/clk.h>
 
@@ -339,9 +340,18 @@ static int ksz9021_config_init(struct phy_device *phydev)
 {
 	const struct device *dev = &phydev->dev;
 	const struct device_node *of_node = dev->of_node;
+	const struct device *dev_walker;
 
-	if (!of_node && dev->parent->of_node)
-		of_node = dev->parent->of_node;
+	/* The Micrel driver has a deprecated option to place phy OF
+	 * properties in the MAC node. Walk up the tree of devices to
+	 * find a device with an OF node.
+	 */
+	dev_walker = &phydev->dev;
+	do {
+		of_node = dev_walker->of_node;
+		dev_walker = dev_walker->parent;
+
+	} while (!of_node && dev_walker);
 
 	if (of_node) {
 		ksz9021_load_values_from_of(phydev, of_node,
-- 
2.6.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] phy: micrel: Fix finding PHY properties in MAC node.
  2015-12-09 18:37 [PATCH net] phy: micrel: Fix finding PHY properties in MAC node Andrew Lunn
@ 2015-12-09 18:38 ` David Daney
  2015-12-09 18:42 ` David Daney
  1 sibling, 0 replies; 4+ messages in thread
From: David Daney @ 2015-12-09 18:38 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: David Miller, netdev, Florian Fainelli, dinguyen, david.daney

On 12/09/2015 10:37 AM, Andrew Lunn wrote:
> commit 8b63ec1837fa ("phylib: Make PHYs children of their MDIO bus,
> not the bus' parent.")  changed the parenting of PHY devices, making
> them a child of the MDIO bus, instead of the MAC device. This broken
> the Micrel PHY driver which has a deprecated feature of allowing PHY
> properties to be placed into the MAC node.
>
> In order to find the MAC node, we need to walk up the tree of devices
> until we find one with an OF node attached.
>
> Reported-by: Dinh Nguyen <dinguyen@opensource.altera.com>
> Suggested-by: David Daney <david.daney@cavium.com>
> Fixes: 8b63ec1837fa ("phylib: Make PHYs children of their MDIO bus, not the bus' parent.")
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Acked-by: David Daney <david.daney@cavium.com>

> ---
>   drivers/net/phy/micrel.c | 14 ++++++++++++--
>   1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index cf6312fafea5..2493d7c035f2 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -26,6 +26,7 @@
>   #include <linux/module.h>
>   #include <linux/phy.h>
>   #include <linux/micrel_phy.h>
> +#include <linux/netdevice.h>
>   #include <linux/of.h>
>   #include <linux/clk.h>
>
> @@ -339,9 +340,18 @@ static int ksz9021_config_init(struct phy_device *phydev)
>   {
>   	const struct device *dev = &phydev->dev;
>   	const struct device_node *of_node = dev->of_node;
> +	const struct device *dev_walker;
>
> -	if (!of_node && dev->parent->of_node)
> -		of_node = dev->parent->of_node;
> +	/* The Micrel driver has a deprecated option to place phy OF
> +	 * properties in the MAC node. Walk up the tree of devices to
> +	 * find a device with an OF node.
> +	 */
> +	dev_walker = &phydev->dev;
> +	do {
> +		of_node = dev_walker->of_node;
> +		dev_walker = dev_walker->parent;
> +
> +	} while (!of_node && dev_walker);
>
>   	if (of_node) {
>   		ksz9021_load_values_from_of(phydev, of_node,
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] phy: micrel: Fix finding PHY properties in MAC node.
  2015-12-09 18:37 [PATCH net] phy: micrel: Fix finding PHY properties in MAC node Andrew Lunn
  2015-12-09 18:38 ` David Daney
@ 2015-12-09 18:42 ` David Daney
  2015-12-09 18:52   ` Andrew Lunn
  1 sibling, 1 reply; 4+ messages in thread
From: David Daney @ 2015-12-09 18:42 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: David Miller, netdev, Florian Fainelli, dinguyen, david.daney

On 12/09/2015 10:37 AM, Andrew Lunn wrote:
> commit 8b63ec1837fa ("phylib: Make PHYs children of their MDIO bus,
> not the bus' parent.")  changed the parenting of PHY devices, making
> them a child of the MDIO bus, instead of the MAC device. This broken
> the Micrel PHY driver which has a deprecated feature of allowing PHY
> properties to be placed into the MAC node.
>
> In order to find the MAC node, we need to walk up the tree of devices
> until we find one with an OF node attached.
>
> Reported-by: Dinh Nguyen <dinguyen@opensource.altera.com>
> Suggested-by: David Daney <david.daney@cavium.com>
> Fixes: 8b63ec1837fa ("phylib: Make PHYs children of their MDIO bus, not the bus' parent.")
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>   drivers/net/phy/micrel.c | 14 ++++++++++++--
>   1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index cf6312fafea5..2493d7c035f2 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -26,6 +26,7 @@
>   #include <linux/module.h>
>   #include <linux/phy.h>
>   #include <linux/micrel_phy.h>
> +#include <linux/netdevice.h>

No new types are introduced by the patch.  Why do we need an additional 
#include?

>   #include <linux/of.h>
>   #include <linux/clk.h>
>
> @@ -339,9 +340,18 @@ static int ksz9021_config_init(struct phy_device *phydev)
>   {
>   	const struct device *dev = &phydev->dev;
>   	const struct device_node *of_node = dev->of_node;
> +	const struct device *dev_walker;
>
> -	if (!of_node && dev->parent->of_node)
> -		of_node = dev->parent->of_node;
> +	/* The Micrel driver has a deprecated option to place phy OF
> +	 * properties in the MAC node. Walk up the tree of devices to
> +	 * find a device with an OF node.
> +	 */
> +	dev_walker = &phydev->dev;
> +	do {
> +		of_node = dev_walker->of_node;
> +		dev_walker = dev_walker->parent;
> +
> +	} while (!of_node && dev_walker);
>
>   	if (of_node) {
>   		ksz9021_load_values_from_of(phydev, of_node,
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] phy: micrel: Fix finding PHY properties in MAC node.
  2015-12-09 18:42 ` David Daney
@ 2015-12-09 18:52   ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2015-12-09 18:52 UTC (permalink / raw)
  To: David Daney; +Cc: David Miller, netdev, Florian Fainelli, dinguyen, david.daney

> >diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> >index cf6312fafea5..2493d7c035f2 100644
> >--- a/drivers/net/phy/micrel.c
> >+++ b/drivers/net/phy/micrel.c
> >@@ -26,6 +26,7 @@
> >  #include <linux/module.h>
> >  #include <linux/phy.h>
> >  #include <linux/micrel_phy.h>
> >+#include <linux/netdevice.h>
> 
> No new types are introduced by the patch.  Why do we need an
> additional #include?

We probably don't.

It took my debug patch which printed additional information, and
stripped the prints out. One of those prints needed netdev, but since
it has now gone, we probably don't need the include.

   Andrew

 
> >  #include <linux/of.h>
> >  #include <linux/clk.h>
> >
> >@@ -339,9 +340,18 @@ static int ksz9021_config_init(struct phy_device *phydev)
> >  {
> >  	const struct device *dev = &phydev->dev;
> >  	const struct device_node *of_node = dev->of_node;
> >+	const struct device *dev_walker;
> >
> >-	if (!of_node && dev->parent->of_node)
> >-		of_node = dev->parent->of_node;
> >+	/* The Micrel driver has a deprecated option to place phy OF
> >+	 * properties in the MAC node. Walk up the tree of devices to
> >+	 * find a device with an OF node.
> >+	 */
> >+	dev_walker = &phydev->dev;
> >+	do {
> >+		of_node = dev_walker->of_node;
> >+		dev_walker = dev_walker->parent;
> >+
> >+	} while (!of_node && dev_walker);
> >
> >  	if (of_node) {
> >  		ksz9021_load_values_from_of(phydev, of_node,
> >
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-09 19:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-09 18:37 [PATCH net] phy: micrel: Fix finding PHY properties in MAC node Andrew Lunn
2015-12-09 18:38 ` David Daney
2015-12-09 18:42 ` David Daney
2015-12-09 18:52   ` Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.