1 From: John Crispin <john@phrozen.org>
2 Subject: net: phy: add phy_ethtool_ioctl()
4 Signed-off-by: John Crispin <john@phrozen.org>
6 drivers/net/phy/phy.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
7 include/linux/phy.h | 1 +
8 2 files changed, 45 insertions(+)
10 diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
11 index a9be26f1f677..d0a5ac1d6445 100644
12 --- a/drivers/net/phy/phy.c
13 +++ b/drivers/net/phy/phy.c
14 @@ -466,6 +466,50 @@ int phy_ethtool_ksettings_get(struct phy_device *phydev,
16 EXPORT_SYMBOL(phy_ethtool_ksettings_get);
18 +int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr)
22 + struct ethtool_cmd ecmd = { ETHTOOL_GSET };
23 + struct ethtool_value edata = { ETHTOOL_GLINK };
25 + if (get_user(cmd, (u32 *) useraddr))
30 + phy_ethtool_gset(phydev, &ecmd);
31 + if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
36 + if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
38 + return phy_ethtool_sset(phydev, &ecmd);
40 + case ETHTOOL_NWAY_RST:
41 + /* if autoneg is off, it's an error */
42 + tmp = phy_read(phydev, MII_BMCR);
43 + if (tmp & BMCR_ANENABLE) {
44 + tmp |= (BMCR_ANRESTART);
45 + phy_write(phydev, MII_BMCR, tmp);
51 + edata.data = (phy_read(phydev,
52 + MII_BMSR) & BMSR_LSTATUS) ? 1 : 0;
53 + if (copy_to_user(useraddr, &edata, sizeof(edata)))
60 +EXPORT_SYMBOL(phy_ethtool_ioctl);
63 * phy_mii_ioctl - generic PHY MII ioctl interface
64 * @phydev: the phy_device struct
65 diff --git a/include/linux/phy.h b/include/linux/phy.h
66 index bd22670e2182..93c1e74afc44 100644
67 --- a/include/linux/phy.h
68 +++ b/include/linux/phy.h
69 @@ -813,6 +813,7 @@ int phy_ethtool_ksettings_get(struct phy_device *phydev,
70 struct ethtool_link_ksettings *cmd);
71 int phy_ethtool_ksettings_set(struct phy_device *phydev,
72 const struct ethtool_link_ksettings *cmd);
73 +int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr);
74 int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd);
75 int phy_start_interrupts(struct phy_device *phydev);
76 void phy_print_status(struct phy_device *phydev);