Commit 65c563a6 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: dsa: do not open-code dsa_switch_for_each_port

Find the remaining iterators over dst->ports that only filter for the
ports belonging to a certain switch, and replace those with the
dsa_switch_for_each_port helper that we have now.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d0004a02
...@@ -399,11 +399,8 @@ static int dsa_tree_setup_cpu_ports(struct dsa_switch_tree *dst) ...@@ -399,11 +399,8 @@ static int dsa_tree_setup_cpu_ports(struct dsa_switch_tree *dst)
if (!dsa_port_is_cpu(cpu_dp)) if (!dsa_port_is_cpu(cpu_dp))
continue; continue;
list_for_each_entry(dp, &dst->ports, list) { /* Prefer a local CPU port */
/* Prefer a local CPU port */ dsa_switch_for_each_port(dp, cpu_dp->ds) {
if (dp->ds != cpu_dp->ds)
continue;
/* Prefer the first local CPU port found */ /* Prefer the first local CPU port found */
if (dp->cpu_dp) if (dp->cpu_dp)
continue; continue;
...@@ -852,12 +849,10 @@ static int dsa_switch_setup(struct dsa_switch *ds) ...@@ -852,12 +849,10 @@ static int dsa_switch_setup(struct dsa_switch *ds)
/* Setup devlink port instances now, so that the switch /* Setup devlink port instances now, so that the switch
* setup() can register regions etc, against the ports * setup() can register regions etc, against the ports
*/ */
list_for_each_entry(dp, &ds->dst->ports, list) { dsa_switch_for_each_port(dp, ds) {
if (dp->ds == ds) { err = dsa_port_devlink_setup(dp);
err = dsa_port_devlink_setup(dp); if (err)
if (err) goto unregister_devlink_ports;
goto unregister_devlink_ports;
}
} }
err = dsa_switch_register_notifier(ds); err = dsa_switch_register_notifier(ds);
...@@ -901,9 +896,8 @@ static int dsa_switch_setup(struct dsa_switch *ds) ...@@ -901,9 +896,8 @@ static int dsa_switch_setup(struct dsa_switch *ds)
unregister_notifier: unregister_notifier:
dsa_switch_unregister_notifier(ds); dsa_switch_unregister_notifier(ds);
unregister_devlink_ports: unregister_devlink_ports:
list_for_each_entry(dp, &ds->dst->ports, list) dsa_switch_for_each_port(dp, ds)
if (dp->ds == ds) dsa_port_devlink_teardown(dp);
dsa_port_devlink_teardown(dp);
devlink_free(ds->devlink); devlink_free(ds->devlink);
ds->devlink = NULL; ds->devlink = NULL;
return err; return err;
...@@ -931,9 +925,8 @@ static void dsa_switch_teardown(struct dsa_switch *ds) ...@@ -931,9 +925,8 @@ static void dsa_switch_teardown(struct dsa_switch *ds)
dsa_switch_unregister_notifier(ds); dsa_switch_unregister_notifier(ds);
if (ds->devlink) { if (ds->devlink) {
list_for_each_entry(dp, &ds->dst->ports, list) dsa_switch_for_each_port(dp, ds)
if (dp->ds == ds) dsa_port_devlink_teardown(dp);
dsa_port_devlink_teardown(dp);
devlink_free(ds->devlink); devlink_free(ds->devlink);
ds->devlink = NULL; ds->devlink = NULL;
} }
...@@ -1180,8 +1173,8 @@ static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index) ...@@ -1180,8 +1173,8 @@ static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index)
struct dsa_switch_tree *dst = ds->dst; struct dsa_switch_tree *dst = ds->dst;
struct dsa_port *dp; struct dsa_port *dp;
list_for_each_entry(dp, &dst->ports, list) dsa_switch_for_each_port(dp, ds)
if (dp->ds == ds && dp->index == index) if (dp->index == index)
return dp; return dp;
dp = kzalloc(sizeof(*dp), GFP_KERNEL); dp = kzalloc(sizeof(*dp), GFP_KERNEL);
...@@ -1522,12 +1515,9 @@ static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd) ...@@ -1522,12 +1515,9 @@ static int dsa_switch_parse(struct dsa_switch *ds, struct dsa_chip_data *cd)
static void dsa_switch_release_ports(struct dsa_switch *ds) static void dsa_switch_release_ports(struct dsa_switch *ds)
{ {
struct dsa_switch_tree *dst = ds->dst;
struct dsa_port *dp, *next; struct dsa_port *dp, *next;
list_for_each_entry_safe(dp, next, &dst->ports, list) { dsa_switch_for_each_port_safe(dp, next, ds) {
if (dp->ds != ds)
continue;
list_del(&dp->list); list_del(&dp->list);
kfree(dp); kfree(dp);
} }
...@@ -1619,13 +1609,7 @@ void dsa_switch_shutdown(struct dsa_switch *ds) ...@@ -1619,13 +1609,7 @@ void dsa_switch_shutdown(struct dsa_switch *ds)
mutex_lock(&dsa2_mutex); mutex_lock(&dsa2_mutex);
rtnl_lock(); rtnl_lock();
list_for_each_entry(dp, &ds->dst->ports, list) { dsa_switch_for_each_user_port(dp, ds) {
if (dp->ds != ds)
continue;
if (!dsa_port_is_user(dp))
continue;
master = dp->cpu_dp->master; master = dp->cpu_dp->master;
slave_dev = dp->slave; slave_dev = dp->slave;
......
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