it is sometimes necessary to poll a phy register by phy_read() function until its value satisfies some condition. introduce phy_read_poll_timeout() macros that do this.
Showing the changes to include/linux (1 of 1 file). Show all
Unified · Split
| @@ -717,6 +717,19 @@ static inline int phy_read(struct phy_device *phydev, u32 regnum) · 716 unmodified lines | |||
| 717 | return mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, regnum); | 717 | return mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, regnum); |
| 718 | } | 718 | } |
| 719 | 719 | ||
| 720 | #define phy_read_poll_timeout(phydev, regnum, val, cond, sleep_us, \ | ||
| 721 | timeout_us, sleep_before_read) \ | ||
| 722 | ({ \ | ||
| 723 | int __ret = read_poll_timeout(phy_read, val, (cond) || val < 0, \ | ||
| 724 | sleep_us, timeout_us, sleep_before_read, phydev, regnum); \ | ||
| 725 | if (val < 0) \ | ||
| 726 | __ret = val; \ | ||
| 727 | if (__ret) \ | ||
| 728 | phydev_err(phydev, "%s failed: %d\n", __func__, __ret); \ | ||
| 729 | __ret; \ | ||
| 730 | }) | ||
| 731 | |||
| 732 | |||
| 720 | /** | 733 | /** |
| 721 | * __phy_read - convenience function for reading a given PHY register | 734 | * __phy_read - convenience function for reading a given PHY register |
| 722 | * @phydev: the phy_device struct | 735 | * @phydev: the phy_device struct |