Commit 5447d786 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

net: dsa: Do not register devlink for unused ports

Even if commit 1d27732f ("net: dsa: setup and teardown ports") indicated
that registering a devlink instance for unused ports is not a problem, and this
is true, this can be confusing nonetheless, so let's not do it.

Fixes: 1d27732f ("net: dsa: setup and teardown ports")
Reported-by: default avatarJiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6358d49a
...@@ -258,11 +258,13 @@ static void dsa_tree_teardown_default_cpu(struct dsa_switch_tree *dst) ...@@ -258,11 +258,13 @@ static void dsa_tree_teardown_default_cpu(struct dsa_switch_tree *dst)
static int dsa_port_setup(struct dsa_port *dp) static int dsa_port_setup(struct dsa_port *dp)
{ {
struct dsa_switch *ds = dp->ds; struct dsa_switch *ds = dp->ds;
int err; int err = 0;
memset(&dp->devlink_port, 0, sizeof(dp->devlink_port)); memset(&dp->devlink_port, 0, sizeof(dp->devlink_port));
err = devlink_port_register(ds->devlink, &dp->devlink_port, dp->index); if (dp->type != DSA_PORT_TYPE_UNUSED)
err = devlink_port_register(ds->devlink, &dp->devlink_port,
dp->index);
if (err) if (err)
return err; return err;
...@@ -293,7 +295,8 @@ static int dsa_port_setup(struct dsa_port *dp) ...@@ -293,7 +295,8 @@ static int dsa_port_setup(struct dsa_port *dp)
static void dsa_port_teardown(struct dsa_port *dp) static void dsa_port_teardown(struct dsa_port *dp)
{ {
devlink_port_unregister(&dp->devlink_port); if (dp->type != DSA_PORT_TYPE_UNUSED)
devlink_port_unregister(&dp->devlink_port);
switch (dp->type) { switch (dp->type) {
case DSA_PORT_TYPE_UNUSED: case DSA_PORT_TYPE_UNUSED:
......
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