diff mbox

[U-Boot] phy: fix create_phy_by_mask for when its given an actual search mask

Message ID 1400692132-6430-1-git-send-email-jcormier@criticallink.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Jonathan Cormier May 21, 2014, 5:08 p.m. UTC
From: Cormier, Jonathan <jcormier@criticallink.com>

get_phy_id returns -EIO when it can't read from a phy at a given addr.  This would cause
create_phy_by_mask to return prematurely before it had tested the other addresses in the provided mask.

Example usage:
Replace
    phydev = phy_connect(bus, phy_addr, dev, phy_if)
with
    phydev = phy_find_by_mask(bus, phy_mask, phy_if)
    if (phydev)
	phy_connect_dev(phydev, dev);

Signed-off-by: Cormier, Jonathan <jcormier@criticallink.com>
Cc: Joe Hershberger <joe.hershberger@gmail.com>
---
 drivers/net/phy/phy.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

Comments

Tom Rini June 5, 2014, 10:46 p.m. UTC | #1
On Wed, May 21, 2014 at 01:08:52PM -0400, Cormier, Jonathan wrote:

> From: Cormier, Jonathan <jcormier@criticallink.com>
> 
> get_phy_id returns -EIO when it can't read from a phy at a given addr.  This would cause
> create_phy_by_mask to return prematurely before it had tested the other addresses in the provided mask.
> 
> Example usage:
> Replace
>     phydev = phy_connect(bus, phy_addr, dev, phy_if)
> with
>     phydev = phy_find_by_mask(bus, phy_mask, phy_if)
>     if (phydev)
> 	phy_connect_dev(phydev, dev);
> 
> Signed-off-by: Cormier, Jonathan <jcormier@criticallink.com>
> Cc: Joe Hershberger <joe.hershberger@gmail.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 230ed97..aac85c4 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -609,10 +609,8 @@  static struct phy_device *create_phy_by_mask(struct mii_dev *bus,
 	while (phy_mask) {
 		int addr = ffs(phy_mask) - 1;
 		int r = get_phy_id(bus, addr, devad, &phy_id);
-		if (r < 0)
-			return ERR_PTR(r);
 		/* If the PHY ID is mostly f's, we didn't find anything */
-		if ((phy_id & 0x1fffffff) != 0x1fffffff)
+		if (r == 0 && (phy_id & 0x1fffffff) != 0x1fffffff)
 			return phy_device_create(bus, addr, phy_id, interface);
 		phy_mask &= ~(1 << addr);
 	}