summaryrefslogtreecommitdiffstats
path: root/include/linux/phy.h
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2016-01-06 20:11:16 +0100
committerDavid S. Miller <davem@davemloft.net>2016-01-07 14:31:26 -0500
commite5a03bfd873c29eb786655ef2e95e53ed242b404 (patch)
treec860b98c0f61c9fda92a5b44c94068c312835247 /include/linux/phy.h
parente7f4dc3536a40097f95103ddf98dd55b3a980f5b (diff)
downloadop-kernel-dev-e5a03bfd873c29eb786655ef2e95e53ed242b404.zip
op-kernel-dev-e5a03bfd873c29eb786655ef2e95e53ed242b404.tar.gz
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>
Diffstat (limited to 'include/linux/phy.h')
-rw-r--r--include/linux/phy.h26
1 files changed, 11 insertions, 15 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h
index a5473c9..239a0c2 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -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, ...)
OpenPOWER on IntegriCloud