Commit 6436cbcd authored by Giuseppe Cavallaro's avatar Giuseppe Cavallaro Committed by David S. Miller

phy: fix phy_id detection also for broken hardware.

This patch fixes the case when the phy_ids is mostly Fs and in some case 0x0
due to broken hardware.
Signed-off-by: default avatarGiuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 75e07fc3
...@@ -227,8 +227,17 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr) ...@@ -227,8 +227,17 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr)
if (r) if (r)
return ERR_PTR(r); return ERR_PTR(r);
/* If the phy_id is all Fs or all 0s, there is no device there */ /* If the phy_id is mostly Fs, there is no device there */
if ((0xffff == phy_id) || (0x00 == phy_id)) if ((phy_id & 0x1fffffff) == 0x1fffffff)
return NULL;
/*
* Broken hardware is sometimes missing the pull down resistor on the
* MDIO line, which results in reads to non-existent devices returning
* 0 rather than 0xffff. Catch this here and treat 0 as a non-existent
* device as well.
*/
if (phy_id == 0)
return NULL; return NULL;
dev = phy_device_create(bus, addr, phy_id); dev = phy_device_create(bus, addr, phy_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment