phy: Add an mdio_device structure
Not all devices attached to an MDIO bus are phys. So add an mdio_device structure to represent the generic parts of an mdio device, and place this structure into the phy_device. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
e7f4dc3536
commit
e5a03bfd87
@@ -358,14 +358,12 @@ struct phy_c45_device_ids {
|
||||
* handling, as well as handling shifts in PHY hardware state
|
||||
*/
|
||||
struct phy_device {
|
||||
struct mdio_device mdio;
|
||||
|
||||
/* Information about the PHY type */
|
||||
/* And management functions */
|
||||
struct phy_driver *drv;
|
||||
|
||||
struct mii_bus *bus;
|
||||
|
||||
struct device dev;
|
||||
|
||||
u32 phy_id;
|
||||
|
||||
struct phy_c45_device_ids c45_ids;
|
||||
@@ -381,9 +379,6 @@ struct phy_device {
|
||||
|
||||
phy_interface_t interface;
|
||||
|
||||
/* Bus address of the PHY (0-31) */
|
||||
int addr;
|
||||
|
||||
/*
|
||||
* forced speed & duplex (no autoneg)
|
||||
* partner speed & duplex & pause (autoneg)
|
||||
@@ -432,7 +427,8 @@ struct phy_device {
|
||||
|
||||
void (*adjust_link)(struct net_device *dev);
|
||||
};
|
||||
#define to_phy_device(d) container_of(d, struct phy_device, dev)
|
||||
#define to_phy_device(d) container_of(to_mdio_device(d), \
|
||||
struct phy_device, mdio)
|
||||
|
||||
/* struct phy_driver: Driver structure for a particular PHY type
|
||||
*
|
||||
@@ -622,7 +618,7 @@ static inline int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum)
|
||||
if (!phydev->is_c45)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return mdiobus_read(phydev->bus, phydev->addr,
|
||||
return mdiobus_read(phydev->mdio.bus, phydev->mdio.addr,
|
||||
MII_ADDR_C45 | (devad << 16) | (regnum & 0xffff));
|
||||
}
|
||||
|
||||
@@ -648,7 +644,7 @@ int phy_read_mmd_indirect(struct phy_device *phydev, int prtad, int devad);
|
||||
*/
|
||||
static inline int phy_read(struct phy_device *phydev, u32 regnum)
|
||||
{
|
||||
return mdiobus_read(phydev->bus, phydev->addr, regnum);
|
||||
return mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, regnum);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -663,7 +659,7 @@ static inline int phy_read(struct phy_device *phydev, u32 regnum)
|
||||
*/
|
||||
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
|
||||
{
|
||||
return mdiobus_write(phydev->bus, phydev->addr, regnum, val);
|
||||
return mdiobus_write(phydev->mdio.bus, phydev->mdio.addr, regnum, val);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -726,7 +722,7 @@ static inline int phy_write_mmd(struct phy_device *phydev, int devad,
|
||||
|
||||
regnum = MII_ADDR_C45 | ((devad & 0x1f) << 16) | (regnum & 0xffff);
|
||||
|
||||
return mdiobus_write(phydev->bus, phydev->addr, regnum, val);
|
||||
return mdiobus_write(phydev->mdio.bus, phydev->mdio.addr, regnum, val);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -776,14 +772,14 @@ static inline int phy_read_status(struct phy_device *phydev)
|
||||
}
|
||||
|
||||
#define phydev_err(_phydev, format, args...) \
|
||||
dev_err(&_phydev->dev, format, ##args)
|
||||
dev_err(&_phydev->mdio.dev, format, ##args)
|
||||
|
||||
#define phydev_dbg(_phydev, format, args...) \
|
||||
dev_dbg(&_phydev->dev, format, ##args)
|
||||
dev_dbg(&_phydev->mdio.dev, format, ##args);
|
||||
|
||||
static inline const char *phydev_name(const struct phy_device *phydev)
|
||||
{
|
||||
return dev_name(&phydev->dev);
|
||||
return dev_name(&phydev->mdio.dev);
|
||||
}
|
||||
|
||||
void phy_attached_print(struct phy_device *phydev, const char *fmt, ...)
|
||||
|
Reference in New Issue
Block a user