Commit ee951005 authored by Russell King's avatar Russell King Committed by David S. Miller

net: phy: clean up get_phy_c22_id() invalid ID handling

Move the ID check from get_phy_device() into get_phy_c22_id(), which
simplifies get_phy_device(). The ID reading functions are now
responsible for indicating whether they found a PHY or not via their
return code - they must return -ENODEV when a PHY is not present.
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 48c54388
...@@ -761,8 +761,10 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, ...@@ -761,8 +761,10 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,
* @addr: PHY address on the MII bus * @addr: PHY address on the MII bus
* @phy_id: where to store the ID retrieved. * @phy_id: where to store the ID retrieved.
* *
* Read the 802.3 clause 22 PHY ID from the PHY at @addr on the @bus. * Read the 802.3 clause 22 PHY ID from the PHY at @addr on the @bus,
* Return the PHY ID read from the PHY in @phy_id on successful access. * placing it in @phy_id. Return zero on successful read and the ID is
* valid, %-EIO on bus access error, or %-ENODEV if no device responds
* or invalid ID.
*/ */
static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id) static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)
{ {
...@@ -784,6 +786,10 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id) ...@@ -784,6 +786,10 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)
*phy_id |= phy_reg; *phy_id |= phy_reg;
/* If the phy_id is mostly Fs, there is no device there */
if ((*phy_id & 0x1fffffff) == 0x1fffffff)
return -ENODEV;
return 0; return 0;
} }
...@@ -814,10 +820,6 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) ...@@ -814,10 +820,6 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
if (r) if (r)
return ERR_PTR(r); return ERR_PTR(r);
/* If the phy_id is mostly Fs, there is no device there */
if ((phy_id & 0x1fffffff) == 0x1fffffff)
return ERR_PTR(-ENODEV);
return phy_device_create(bus, addr, phy_id, is_c45, &c45_ids); return phy_device_create(bus, addr, phy_id, is_c45, &c45_ids);
} }
EXPORT_SYMBOL(get_phy_device); EXPORT_SYMBOL(get_phy_device);
......
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