Commit 6158eaa7 authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller

net: dsa: add slave notify helper

Both DSA slave create and destroy functions call call_dsa_notifiers with
respectively DSA_PORT_REGISTER and DSA_PORT_UNREGISTER and the same
dsa_notifier_register_info structure.

Wrap this in a dsa_slave_notify helper so prevent cluttering these
functions.
Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a5b930e0
...@@ -1114,9 +1114,23 @@ int dsa_slave_resume(struct net_device *slave_dev) ...@@ -1114,9 +1114,23 @@ int dsa_slave_resume(struct net_device *slave_dev)
return 0; return 0;
} }
static void dsa_slave_notify(struct net_device *dev, unsigned long val)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct net_device *master = dsa_master_netdev(p);
struct dsa_port *dp = p->dp;
struct dsa_notifier_register_info rinfo = {
.switch_number = dp->ds->index,
.port_number = dp->index,
.master = master,
.info.dev = dev,
};
call_dsa_notifiers(val, dev, &rinfo.info);
}
int dsa_slave_create(struct dsa_port *port, const char *name) int dsa_slave_create(struct dsa_port *port, const char *name)
{ {
struct dsa_notifier_register_info rinfo = { };
struct dsa_port *cpu_dp = port->cpu_dp; struct dsa_port *cpu_dp = port->cpu_dp;
struct net_device *master = cpu_dp->netdev; struct net_device *master = cpu_dp->netdev;
struct dsa_switch *ds = port->ds; struct dsa_switch *ds = port->ds;
...@@ -1175,11 +1189,7 @@ int dsa_slave_create(struct dsa_port *port, const char *name) ...@@ -1175,11 +1189,7 @@ int dsa_slave_create(struct dsa_port *port, const char *name)
goto out_free; goto out_free;
} }
rinfo.info.dev = slave_dev; dsa_slave_notify(slave_dev, DSA_PORT_REGISTER);
rinfo.master = master;
rinfo.port_number = p->dp->index;
rinfo.switch_number = p->dp->ds->index;
call_dsa_notifiers(DSA_PORT_REGISTER, slave_dev, &rinfo.info);
ret = register_netdev(slave_dev); ret = register_netdev(slave_dev);
if (ret) { if (ret) {
...@@ -1204,7 +1214,6 @@ int dsa_slave_create(struct dsa_port *port, const char *name) ...@@ -1204,7 +1214,6 @@ int dsa_slave_create(struct dsa_port *port, const char *name)
void dsa_slave_destroy(struct net_device *slave_dev) void dsa_slave_destroy(struct net_device *slave_dev)
{ {
struct dsa_slave_priv *p = netdev_priv(slave_dev); struct dsa_slave_priv *p = netdev_priv(slave_dev);
struct dsa_notifier_register_info rinfo = { };
struct device_node *port_dn; struct device_node *port_dn;
port_dn = p->dp->dn; port_dn = p->dp->dn;
...@@ -1216,11 +1225,7 @@ void dsa_slave_destroy(struct net_device *slave_dev) ...@@ -1216,11 +1225,7 @@ void dsa_slave_destroy(struct net_device *slave_dev)
if (of_phy_is_fixed_link(port_dn)) if (of_phy_is_fixed_link(port_dn))
of_phy_deregister_fixed_link(port_dn); of_phy_deregister_fixed_link(port_dn);
} }
rinfo.info.dev = slave_dev; dsa_slave_notify(slave_dev, DSA_PORT_UNREGISTER);
rinfo.master = p->dp->cpu_dp->netdev;
rinfo.port_number = p->dp->index;
rinfo.switch_number = p->dp->ds->index;
call_dsa_notifiers(DSA_PORT_UNREGISTER, slave_dev, &rinfo.info);
unregister_netdev(slave_dev); unregister_netdev(slave_dev);
free_percpu(p->stats64); free_percpu(p->stats64);
free_netdev(slave_dev); free_netdev(slave_dev);
......
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