Commit 320587e6 authored by Russell King's avatar Russell King Committed by David S. Miller

net: sfp: add mandatory attach/detach methods for sfp buses

Add attach and detach methods for SFP buses, which will allow us to get
rid of the netdev storage in sfp-bus.
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cdea04c2
...@@ -1650,6 +1650,20 @@ int phylink_mii_ioctl(struct phylink *pl, struct ifreq *ifr, int cmd) ...@@ -1650,6 +1650,20 @@ int phylink_mii_ioctl(struct phylink *pl, struct ifreq *ifr, int cmd)
} }
EXPORT_SYMBOL_GPL(phylink_mii_ioctl); EXPORT_SYMBOL_GPL(phylink_mii_ioctl);
static void phylink_sfp_attach(void *upstream, struct sfp_bus *bus)
{
struct phylink *pl = upstream;
pl->netdev->sfp_bus = bus;
}
static void phylink_sfp_detach(void *upstream, struct sfp_bus *bus)
{
struct phylink *pl = upstream;
pl->netdev->sfp_bus = NULL;
}
static int phylink_sfp_module_insert(void *upstream, static int phylink_sfp_module_insert(void *upstream,
const struct sfp_eeprom_id *id) const struct sfp_eeprom_id *id)
{ {
...@@ -1768,6 +1782,8 @@ static void phylink_sfp_disconnect_phy(void *upstream) ...@@ -1768,6 +1782,8 @@ static void phylink_sfp_disconnect_phy(void *upstream)
} }
static const struct sfp_upstream_ops sfp_phylink_ops = { static const struct sfp_upstream_ops sfp_phylink_ops = {
.attach = phylink_sfp_attach,
.detach = phylink_sfp_detach,
.module_insert = phylink_sfp_module_insert, .module_insert = phylink_sfp_module_insert,
.link_up = phylink_sfp_link_up, .link_up = phylink_sfp_link_up,
.link_down = phylink_sfp_link_down, .link_down = phylink_sfp_link_down,
......
...@@ -351,7 +351,7 @@ static int sfp_register_bus(struct sfp_bus *bus) ...@@ -351,7 +351,7 @@ static int sfp_register_bus(struct sfp_bus *bus)
bus->socket_ops->attach(bus->sfp); bus->socket_ops->attach(bus->sfp);
if (bus->started) if (bus->started)
bus->socket_ops->start(bus->sfp); bus->socket_ops->start(bus->sfp);
bus->netdev->sfp_bus = bus; bus->upstream_ops->attach(bus->upstream, bus);
bus->registered = true; bus->registered = true;
return 0; return 0;
} }
...@@ -360,8 +360,8 @@ static void sfp_unregister_bus(struct sfp_bus *bus) ...@@ -360,8 +360,8 @@ static void sfp_unregister_bus(struct sfp_bus *bus)
{ {
const struct sfp_upstream_ops *ops = bus->upstream_ops; const struct sfp_upstream_ops *ops = bus->upstream_ops;
bus->netdev->sfp_bus = NULL;
if (bus->registered) { if (bus->registered) {
bus->upstream_ops->detach(bus->upstream, bus);
if (bus->started) if (bus->started)
bus->socket_ops->stop(bus->sfp); bus->socket_ops->stop(bus->sfp);
bus->socket_ops->detach(bus->sfp); bus->socket_ops->detach(bus->sfp);
......
...@@ -469,6 +469,10 @@ struct sfp_bus; ...@@ -469,6 +469,10 @@ struct sfp_bus;
/** /**
* struct sfp_upstream_ops - upstream operations structure * struct sfp_upstream_ops - upstream operations structure
* @attach: called when the sfp socket driver is bound to the upstream
* (mandatory).
* @detach: called when the sfp socket driver is unbound from the upstream
* (mandatory).
* @module_insert: called after a module has been detected to determine * @module_insert: called after a module has been detected to determine
* whether the module is supported for the upstream device. * whether the module is supported for the upstream device.
* @module_remove: called after the module has been removed. * @module_remove: called after the module has been removed.
...@@ -481,6 +485,8 @@ struct sfp_bus; ...@@ -481,6 +485,8 @@ struct sfp_bus;
* been removed. * been removed.
*/ */
struct sfp_upstream_ops { struct sfp_upstream_ops {
void (*attach)(void *priv, struct sfp_bus *bus);
void (*detach)(void *priv, struct sfp_bus *bus);
int (*module_insert)(void *priv, const struct sfp_eeprom_id *id); int (*module_insert)(void *priv, const struct sfp_eeprom_id *id);
void (*module_remove)(void *priv); void (*module_remove)(void *priv);
void (*link_down)(void *priv); void (*link_down)(void *priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment