9358a18f78a715d7b2935b86742ce1ab16a12bab
[openwrt/svn-archive/archive.git] / target / linux / generic-2.6 / patches-2.6.25 / 600-phy_extension.patch
1 Index: linux-2.6.25.4/drivers/net/phy/phy.c
2 ===================================================================
3 --- linux-2.6.25.4.orig/drivers/net/phy/phy.c
4 +++ linux-2.6.25.4/drivers/net/phy/phy.c
5 @@ -348,6 +348,50 @@ int phy_ethtool_gset(struct phy_device *
6 }
7 EXPORT_SYMBOL(phy_ethtool_gset);
8
9 +int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr)
10 +{
11 + u32 cmd;
12 + int tmp;
13 + struct ethtool_cmd ecmd = { ETHTOOL_GSET };
14 + struct ethtool_value edata = { ETHTOOL_GLINK };
15 +
16 + if (get_user(cmd, (u32 *) useraddr))
17 + return -EFAULT;
18 +
19 + switch (cmd) {
20 + case ETHTOOL_GSET:
21 + phy_ethtool_gset(phydev, &ecmd);
22 + if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
23 + return -EFAULT;
24 + return 0;
25 +
26 + case ETHTOOL_SSET:
27 + if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
28 + return -EFAULT;
29 + return phy_ethtool_sset(phydev, &ecmd);
30 +
31 + case ETHTOOL_NWAY_RST:
32 + /* if autoneg is off, it's an error */
33 + tmp = phy_read(phydev, MII_BMCR);
34 + if (tmp & BMCR_ANENABLE) {
35 + tmp |= (BMCR_ANRESTART);
36 + phy_write(phydev, MII_BMCR, tmp);
37 + return 0;
38 + }
39 + return -EINVAL;
40 +
41 + case ETHTOOL_GLINK:
42 + edata.data = (phy_read(phydev,
43 + MII_BMSR) & BMSR_LSTATUS) ? 1 : 0;
44 + if (copy_to_user(useraddr, &edata, sizeof(edata)))
45 + return -EFAULT;
46 + return 0;
47 + }
48 +
49 + return -EOPNOTSUPP;
50 +}
51 +EXPORT_SYMBOL(phy_ethtool_ioctl);
52 +
53 /**
54 * phy_mii_ioctl - generic PHY MII ioctl interface
55 * @phydev: the phy_device struct
56 Index: linux-2.6.25.4/include/linux/phy.h
57 ===================================================================
58 --- linux-2.6.25.4.orig/include/linux/phy.h
59 +++ linux-2.6.25.4/include/linux/phy.h
60 @@ -399,6 +399,7 @@ void phy_start_machine(struct phy_device
61 void phy_stop_machine(struct phy_device *phydev);
62 int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd);
63 int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd);
64 +int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr);
65 int phy_mii_ioctl(struct phy_device *phydev,
66 struct mii_ioctl_data *mii_data, int cmd);
67 int phy_start_interrupts(struct phy_device *phydev);