b617fc2575b202a699b4ec7a2cf62d5b2f6dc4b4
[openwrt/openwrt.git] / target / linux / generic / patches-3.14 / 702-phy_add_aneg_done_function.patch
1 --- a/include/linux/phy.h
2 +++ b/include/linux/phy.h
3 @@ -422,9 +422,18 @@ struct phy_driver {
4 */
5 int (*config_aneg)(struct phy_device *phydev);
6
7 + /* Determine if autonegotiation is done */
8 + int (*aneg_done)(struct phy_device *phydev);
9 +
10 /* Determines the negotiated speed and duplex */
11 int (*read_status)(struct phy_device *phydev);
12
13 + /*
14 + * Update the value in phydev->link to reflect the
15 + * current link value
16 + */
17 + int (*update_link)(struct phy_device *phydev);
18 +
19 /* Clears any pending interrupts */
20 int (*ack_interrupt)(struct phy_device *phydev);
21
22 --- a/drivers/net/phy/phy_device.c
23 +++ b/drivers/net/phy/phy_device.c
24 @@ -881,6 +881,9 @@ int genphy_update_link(struct phy_device
25 {
26 int status;
27
28 + if (phydev->drv->update_link)
29 + return phydev->drv->update_link(phydev);
30 +
31 /* Do a fake read */
32 status = phy_read(phydev, MII_BMSR);
33 if (status < 0)
34 --- a/drivers/net/phy/phy.c
35 +++ b/drivers/net/phy/phy.c
36 @@ -99,7 +99,12 @@ static int phy_config_interrupt(struct p
37 */
38 static inline int phy_aneg_done(struct phy_device *phydev)
39 {
40 - int retval = phy_read(phydev, MII_BMSR);
41 + int retval;
42 +
43 + if (phydev->drv->aneg_done)
44 + return phydev->drv->aneg_done(phydev);
45 +
46 + retval = phy_read(phydev, MII_BMSR);
47
48 return (retval < 0) ? retval : (retval & BMSR_ANEGCOMPLETE);
49 }