|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | +/* |
| 3 | + * Stubs for the Network PHY library |
| 4 | + */ |
| 5 | + |
| 6 | +#include <linux/rtnetlink.h> |
| 7 | + |
| 8 | +struct kernel_hwtstamp_config; |
| 9 | +struct netlink_ext_ack; |
| 10 | +struct phy_device; |
| 11 | + |
| 12 | +#if IS_ENABLED(CONFIG_PHYLIB) |
| 13 | + |
| 14 | +extern const struct phylib_stubs *phylib_stubs; |
| 15 | + |
| 16 | +struct phylib_stubs { |
| 17 | + int (*hwtstamp_get)(struct phy_device *phydev, |
| 18 | + struct kernel_hwtstamp_config *config); |
| 19 | + int (*hwtstamp_set)(struct phy_device *phydev, |
| 20 | + struct kernel_hwtstamp_config *config, |
| 21 | + struct netlink_ext_ack *extack); |
| 22 | +}; |
| 23 | + |
| 24 | +static inline int phy_hwtstamp_get(struct phy_device *phydev, |
| 25 | + struct kernel_hwtstamp_config *config) |
| 26 | +{ |
| 27 | + /* phylib_register_stubs() and phylib_unregister_stubs() |
| 28 | + * also run under rtnl_lock(). |
| 29 | + */ |
| 30 | + ASSERT_RTNL(); |
| 31 | + |
| 32 | + if (!phylib_stubs) |
| 33 | + return -EOPNOTSUPP; |
| 34 | + |
| 35 | + return phylib_stubs->hwtstamp_get(phydev, config); |
| 36 | +} |
| 37 | + |
| 38 | +static inline int phy_hwtstamp_set(struct phy_device *phydev, |
| 39 | + struct kernel_hwtstamp_config *config, |
| 40 | + struct netlink_ext_ack *extack) |
| 41 | +{ |
| 42 | + /* phylib_register_stubs() and phylib_unregister_stubs() |
| 43 | + * also run under rtnl_lock(). |
| 44 | + */ |
| 45 | + ASSERT_RTNL(); |
| 46 | + |
| 47 | + if (!phylib_stubs) |
| 48 | + return -EOPNOTSUPP; |
| 49 | + |
| 50 | + return phylib_stubs->hwtstamp_set(phydev, config, extack); |
| 51 | +} |
| 52 | + |
| 53 | +#else |
| 54 | + |
| 55 | +static inline int phy_hwtstamp_get(struct phy_device *phydev, |
| 56 | + struct kernel_hwtstamp_config *config) |
| 57 | +{ |
| 58 | + return -EOPNOTSUPP; |
| 59 | +} |
| 60 | + |
| 61 | +static inline int phy_hwtstamp_set(struct phy_device *phydev, |
| 62 | + struct kernel_hwtstamp_config *config, |
| 63 | + struct netlink_ext_ack *extack) |
| 64 | +{ |
| 65 | + return -EOPNOTSUPP; |
| 66 | +} |
| 67 | + |
| 68 | +#endif |
0 commit comments