mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Lucas Stach <l.stach@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2] net: phy: scan PHYs referenced by phandle
Date: Thu, 25 Jan 2018 08:20:00 +0100	[thread overview]
Message-ID: <20180125072000.z2bxgyvakaa7vcpz@pengutronix.de> (raw)
In-Reply-To: <20180123144325.28926-1-l.stach@pengutronix.de>

On Tue, Jan 23, 2018 at 03:43:25PM +0100, Lucas Stach wrote:
> If we point to a PHY node by phandle, that PHY might well be on a MDIO
> bus that hasn't been scanned when we look for the PHY. Fortunately we
> know exactly where to look for the PHY, so make sure to scan the bus
> at the right address.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
> v2: Only enter MII bus loop when the address property was found.
> ---
>  drivers/net/phy/phy.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 35a9ce7ea823..2b8fa63c0641 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -319,6 +319,8 @@ static struct phy_device *of_mdio_find_phy(struct eth_device *edev)
>  {
>  	struct device_d *dev;
>  	struct device_node *phy_node;
> +	struct mii_bus *bus;
> +	int addr;
>  
>  	if (!IS_ENABLED(CONFIG_OFDEVICE))
>  		return NULL;
> @@ -340,6 +342,16 @@ static struct phy_device *of_mdio_find_phy(struct eth_device *edev)
>  	if (!phy_node)
>  		return NULL;
>  
> +	if (!of_property_read_u32(phy_node, "reg", &addr)) {
> +		for_each_mii_bus(bus) {
> +			if (bus->parent->device_node == phy_node->parent) {
> +				struct phy_device *phy = mdiobus_scan(bus, addr);
> +				if (!IS_ERR(phy))
> +					return phy;
> +			}
> +		}
> +	}
> +
>  	bus_for_each_device(&mdio_bus_type, dev) {
>  		if (dev->device_node == phy_node)
>  			return container_of(dev, struct phy_device, dev);
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2018-01-25  7:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-23 14:43 Lucas Stach
2018-01-25  7:20 ` Sascha Hauer [this message]

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=20180125072000.z2bxgyvakaa7vcpz@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=l.stach@pengutronix.de \
    /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