From 198114b063c2962ffcd3cde698db8ae572455d8e Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 15 Apr 2008 12:49:21 -0400 Subject: [PATCH] --- yaml --- r: 90889 b: refs/heads/master c: cac1f3c8a80f3fc0b4489d1d3ba29214677ffab2 h: refs/heads/master i: 90887: ba8c50c4ff918ed492635bbc67198d5c504feae2 v: v3 --- [refs] | 2 +- trunk/drivers/net/phy/phy_device.c | 38 +++++++++++++++++++++++------- trunk/include/linux/phy.h | 1 + 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/[refs] b/[refs] index 65efc970d956..fc6edf442e3d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b1394f961a90a7195ea177ee56d54fe5c37181ca +refs/heads/master: cac1f3c8a80f3fc0b4489d1d3ba29214677ffab2 diff --git a/trunk/drivers/net/phy/phy_device.c b/trunk/drivers/net/phy/phy_device.c index f4c4fd85425f..8b1121b02f98 100644 --- a/trunk/drivers/net/phy/phy_device.c +++ b/trunk/drivers/net/phy/phy_device.c @@ -86,35 +86,55 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id) EXPORT_SYMBOL(phy_device_create); /** - * get_phy_device - reads the specified PHY device and returns its @phy_device struct + * get_phy_id - reads the specified addr for its ID. * @bus: the target MII bus * @addr: PHY address on the MII bus + * @phy_id: where to store the ID retrieved. * * Description: Reads the ID registers of the PHY at @addr on the - * @bus, then allocates and returns the phy_device to represent it. + * @bus, stores it in @phy_id and returns zero on success. */ -struct phy_device * get_phy_device(struct mii_bus *bus, int addr) +int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id) { int phy_reg; - u32 phy_id; - struct phy_device *dev = NULL; /* Grab the bits from PHYIR1, and put them * in the upper half */ phy_reg = bus->read(bus, addr, MII_PHYSID1); if (phy_reg < 0) - return ERR_PTR(phy_reg); + return -EIO; - phy_id = (phy_reg & 0xffff) << 16; + *phy_id = (phy_reg & 0xffff) << 16; /* Grab the bits from PHYIR2, and put them in the lower half */ phy_reg = bus->read(bus, addr, MII_PHYSID2); if (phy_reg < 0) - return ERR_PTR(phy_reg); + return -EIO; + + *phy_id |= (phy_reg & 0xffff); + + return 0; +} + +/** + * get_phy_device - reads the specified PHY device and returns its @phy_device struct + * @bus: the target MII bus + * @addr: PHY address on the MII bus + * + * Description: Reads the ID registers of the PHY at @addr on the + * @bus, then allocates and returns the phy_device to represent it. + */ +struct phy_device * get_phy_device(struct mii_bus *bus, int addr) +{ + struct phy_device *dev = NULL; + u32 phy_id; + int r; - phy_id |= (phy_reg & 0xffff); + r = get_phy_id(bus, addr, &phy_id); + if (r) + return ERR_PTR(r); /* If the phy_id is all Fs, there is no device there */ if (0xffffffff == phy_id) diff --git a/trunk/include/linux/phy.h b/trunk/include/linux/phy.h index 2d838448415c..779cbcd65f62 100644 --- a/trunk/include/linux/phy.h +++ b/trunk/include/linux/phy.h @@ -381,6 +381,7 @@ struct phy_driver { int phy_read(struct phy_device *phydev, u16 regnum); int phy_write(struct phy_device *phydev, u16 regnum, u16 val); +int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id); struct phy_device* get_phy_device(struct mii_bus *bus, int addr); int phy_clear_interrupt(struct phy_device *phydev); int phy_config_interrupt(struct phy_device *phydev, u32 interrupts);