1 --- a/drivers/net/phy/phy.c
2 +++ b/drivers/net/phy/phy.c
3 @@ -348,6 +348,50 @@ int phy_ethtool_gset(struct phy_device *
5 EXPORT_SYMBOL(phy_ethtool_gset);
7 +int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr)
11 + struct ethtool_cmd ecmd = { ETHTOOL_GSET };
12 + struct ethtool_value edata = { ETHTOOL_GLINK };
14 + if (get_user(cmd, (u32 *) useraddr))
19 + phy_ethtool_gset(phydev, &ecmd);
20 + if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
25 + if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
27 + return phy_ethtool_sset(phydev, &ecmd);
29 + case ETHTOOL_NWAY_RST:
30 + /* if autoneg is off, it's an error */
31 + tmp = phy_read(phydev, MII_BMCR);
32 + if (tmp & BMCR_ANENABLE) {
33 + tmp |= (BMCR_ANRESTART);
34 + phy_write(phydev, MII_BMCR, tmp);
40 + edata.data = (phy_read(phydev,
41 + MII_BMSR) & BMSR_LSTATUS) ? 1 : 0;
42 + if (copy_to_user(useraddr, &edata, sizeof(edata)))
49 +EXPORT_SYMBOL(phy_ethtool_ioctl);
52 * phy_mii_ioctl - generic PHY MII ioctl interface
53 * @phydev: the phy_device struct
54 @@ -403,8 +447,8 @@ int phy_mii_ioctl(struct phy_device *phy
57 phy_write(phydev, mii_data->reg_num, val);
59 - if (mii_data->reg_num == MII_BMCR
61 + if (mii_data->reg_num == MII_BMCR
63 && phydev->drv->config_init) {
64 phy_scan_fixups(phydev);
65 @@ -524,7 +568,7 @@ static void phy_force_reduction(struct p
68 idx = phy_find_setting(phydev->speed, phydev->duplex);
73 idx = phy_find_valid(idx, phydev->supported);
74 --- a/include/linux/phy.h
75 +++ b/include/linux/phy.h
76 @@ -434,6 +434,7 @@ void phy_start_machine(struct phy_device
77 void phy_stop_machine(struct phy_device *phydev);
78 int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd);
79 int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd);
80 +int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr);
81 int phy_mii_ioctl(struct phy_device *phydev,
82 struct mii_ioctl_data *mii_data, int cmd);
83 int phy_start_interrupts(struct phy_device *phydev);