linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] net: ag71xx: fix mdio subnode support
@ 2019-10-01  6:41 Oleksij Rempel
  2019-10-01 16:03 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Oleksij Rempel @ 2019-10-01  6:41 UTC (permalink / raw)
  To: Jay Cliburn, Chris Snook, Andrew Lunn, David S. Miller
  Cc: Oleksij Rempel, Pengutronix Kernel Team, netdev, linux-kernel

This patch is syncing driver with actual devicetree documentation:
Documentation/devicetree/bindings/net/qca,ar71xx.txt
|Optional subnodes:
|- mdio : specifies the mdio bus, used as a container for phy nodes
|  according to phy.txt in the same directory

The driver was working with fixed phy without any noticeable issues. This bug
was uncovered by introducing dsa ar9331-switch driver.
Since no one reported this bug until now, I assume no body is using it
and this patch should not brake existing system.

Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/ethernet/atheros/ag71xx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c
index 6703960c7cf5..d1101eea15c2 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -526,7 +526,7 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
 	struct device *dev = &ag->pdev->dev;
 	struct net_device *ndev = ag->ndev;
 	static struct mii_bus *mii_bus;
-	struct device_node *np;
+	struct device_node *np, *mnp;
 	int err;
 
 	np = dev->of_node;
@@ -571,7 +571,9 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
 		msleep(200);
 	}
 
-	err = of_mdiobus_register(mii_bus, np);
+	mnp = of_get_child_by_name(np, "mdio");
+	err = of_mdiobus_register(mii_bus, mnp);
+	of_node_put(mnp);
 	if (err)
 		goto mdio_err_put_clk;
 
-- 
2.23.0


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

* Re: [PATCH net v2] net: ag71xx: fix mdio subnode support
  2019-10-01  6:41 [PATCH net v2] net: ag71xx: fix mdio subnode support Oleksij Rempel
@ 2019-10-01 16:03 ` David Miller
  2019-10-01 16:43   ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2019-10-01 16:03 UTC (permalink / raw)
  To: o.rempel; +Cc: jcliburn, chris.snook, andrew, kernel, netdev, linux-kernel

From: Oleksij Rempel <o.rempel@pengutronix.de>
Date: Tue,  1 Oct 2019 08:41:47 +0200

> @@ -571,7 +571,9 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
>  		msleep(200);
>  	}
>  
> -	err = of_mdiobus_register(mii_bus, np);
> +	mnp = of_get_child_by_name(np, "mdio");
> +	err = of_mdiobus_register(mii_bus, mnp);

of_get_child_by_name() can fail, so error checking is necessary
before you pass mnp into of_mdiobus_register().

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

* Re: [PATCH net v2] net: ag71xx: fix mdio subnode support
  2019-10-01 16:03 ` David Miller
@ 2019-10-01 16:43   ` Andrew Lunn
  2019-10-01 17:27     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2019-10-01 16:43 UTC (permalink / raw)
  To: David Miller
  Cc: o.rempel, jcliburn, chris.snook, kernel, netdev, linux-kernel

On Tue, Oct 01, 2019 at 09:03:20AM -0700, David Miller wrote:
> From: Oleksij Rempel <o.rempel@pengutronix.de>
> Date: Tue,  1 Oct 2019 08:41:47 +0200
> 
> > @@ -571,7 +571,9 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
> >  		msleep(200);
> >  	}
> >  
> > -	err = of_mdiobus_register(mii_bus, np);
> > +	mnp = of_get_child_by_name(np, "mdio");
> > +	err = of_mdiobus_register(mii_bus, mnp);
> 
> of_get_child_by_name() can fail, so error checking is necessary
> before you pass mnp into of_mdiobus_register().

Hi David

/**
 *	of_get_child_by_name - Find the child node by name for a given parent
 *	@node:	parent node
 *	@name:	child name to look for.
 *
 *      This function looks for child node for given matching name
 *
 *	Returns a node pointer if found, with refcount incremented, use
 *	of_node_put() on it when done.
 *	Returns NULL if node is not found.
 */

So on error, it returns NULL. And passing NULL to
of_mdiobus_register() is the correct thing to do if there is no DT
node. of_node_put() is also O.K. with NULL.

So this is all O.K. as is.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net v2] net: ag71xx: fix mdio subnode support
  2019-10-01 16:43   ` Andrew Lunn
@ 2019-10-01 17:27     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-10-01 17:27 UTC (permalink / raw)
  To: andrew; +Cc: o.rempel, jcliburn, chris.snook, kernel, netdev, linux-kernel

From: Andrew Lunn <andrew@lunn.ch>
Date: Tue, 1 Oct 2019 18:43:40 +0200

> On Tue, Oct 01, 2019 at 09:03:20AM -0700, David Miller wrote:
>> From: Oleksij Rempel <o.rempel@pengutronix.de>
>> Date: Tue,  1 Oct 2019 08:41:47 +0200
>> 
>> > @@ -571,7 +571,9 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
>> >  		msleep(200);
>> >  	}
>> >  
>> > -	err = of_mdiobus_register(mii_bus, np);
>> > +	mnp = of_get_child_by_name(np, "mdio");
>> > +	err = of_mdiobus_register(mii_bus, mnp);
>> 
>> of_get_child_by_name() can fail, so error checking is necessary
>> before you pass mnp into of_mdiobus_register().
> 
> Hi David
> 
> /**
>  *	of_get_child_by_name - Find the child node by name for a given parent
>  *	@node:	parent node
>  *	@name:	child name to look for.
>  *
>  *      This function looks for child node for given matching name
>  *
>  *	Returns a node pointer if found, with refcount incremented, use
>  *	of_node_put() on it when done.
>  *	Returns NULL if node is not found.
>  */
> 
> So on error, it returns NULL. And passing NULL to
> of_mdiobus_register() is the correct thing to do if there is no DT
> node. of_node_put() is also O.K. with NULL.
> 
> So this is all O.K. as is.
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Aha I didn't think about it that way...

Ok I'll apply this thanks.

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

end of thread, other threads:[~2019-10-01 17:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-01  6:41 [PATCH net v2] net: ag71xx: fix mdio subnode support Oleksij Rempel
2019-10-01 16:03 ` David Miller
2019-10-01 16:43   ` Andrew Lunn
2019-10-01 17:27     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).