1 From: Russell King <rmk+kernel@arm.linux.org.uk>
2 Date: Thu, 1 Oct 2015 23:10:05 +0100
3 Subject: [PATCH] phylink: add module EEPROM support
5 Add support for reading module EEPROMs through phylink.
7 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
8 Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
11 --- a/drivers/net/phy/phylink.c
12 +++ b/drivers/net/phy/phylink.c
13 @@ -930,6 +930,36 @@ int phylink_ethtool_set_pauseparam(struc
15 EXPORT_SYMBOL_GPL(phylink_ethtool_set_pauseparam);
17 +int phylink_ethtool_get_module_info(struct phylink *pl,
18 + struct ethtool_modinfo *modinfo)
20 + int ret = -EOPNOTSUPP;
22 + mutex_lock(&pl->config_mutex);
24 + ret = pl->module_ops->get_module_info(pl->module_data,
26 + mutex_unlock(&pl->config_mutex);
30 +EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_info);
32 +int phylink_ethtool_get_module_eeprom(struct phylink *pl,
33 + struct ethtool_eeprom *ee, u8 *buf)
35 + int ret = -EOPNOTSUPP;
37 + mutex_lock(&pl->config_mutex);
39 + ret = pl->module_ops->get_module_eeprom(pl->module_data, ee,
41 + mutex_unlock(&pl->config_mutex);
45 +EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_eeprom);
47 int phylink_init_eee(struct phylink *pl, bool clk_stop_enable)
49 int ret = -EPROTONOSUPPORT;
50 @@ -1115,6 +1145,39 @@ EXPORT_SYMBOL_GPL(phylink_mii_ioctl);
54 +int phylink_register_module(struct phylink *pl, void *data,
55 + const struct phylink_module_ops *ops)
59 + mutex_lock(&pl->config_mutex);
60 + if (!pl->module_ops) {
61 + pl->module_ops = ops;
62 + pl->module_data = data;
65 + mutex_unlock(&pl->config_mutex);
69 +EXPORT_SYMBOL_GPL(phylink_register_module);
71 +int phylink_unregister_module(struct phylink *pl, void *data)
75 + mutex_lock(&pl->config_mutex);
76 + if (pl->module_data == data) {
77 + pl->module_ops = NULL;
78 + pl->module_data = NULL;
81 + mutex_unlock(&pl->config_mutex);
85 +EXPORT_SYMBOL_GPL(phylink_unregister_module);
87 void phylink_disable(struct phylink *pl)
89 set_bit(PHYLINK_DISABLE_LINK, &pl->phylink_disable_state);
90 --- a/include/linux/phylink.h
91 +++ b/include/linux/phylink.h
92 @@ -74,6 +74,11 @@ struct phylink_mac_ops {
96 +struct phylink_module_ops {
97 + int (*get_module_info)(void *, struct ethtool_modinfo *);
98 + int (*get_module_eeprom)(void *, struct ethtool_eeprom *, u8 *);
101 struct phylink *phylink_create(struct net_device *, struct device_node *,
102 phy_interface_t iface, const struct phylink_mac_ops *ops);
103 void phylink_destroy(struct phylink *);
104 @@ -96,12 +101,19 @@ void phylink_ethtool_get_pauseparam(stru
105 struct ethtool_pauseparam *);
106 int phylink_ethtool_set_pauseparam(struct phylink *,
107 struct ethtool_pauseparam *);
108 +int phylink_ethtool_get_module_info(struct phylink *, struct ethtool_modinfo *);
109 +int phylink_ethtool_get_module_eeprom(struct phylink *,
110 + struct ethtool_eeprom *, u8 *);
111 int phylink_init_eee(struct phylink *, bool);
112 int phylink_get_eee_err(struct phylink *);
113 int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *);
114 int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *);
115 int phylink_mii_ioctl(struct phylink *, struct ifreq *, int);
117 +int phylink_register_module(struct phylink *, void *,
118 + const struct phylink_module_ops *);
119 +int phylink_unregister_module(struct phylink *, void *);
121 int phylink_set_link(struct phylink *pl, unsigned int mode, u8 port,
122 const unsigned long *support);
123 void phylink_disable(struct phylink *pl);