Skip to content

Commit

Permalink
net: dsa: Do not register devlink for unused ports
Browse files Browse the repository at this point in the history
Even if commit 1d27732 ("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: 1d27732 ("net: dsa: setup and teardown ports")
Reported-by: Jiri Pirko <[email protected]>
Signed-off-by: Florian Fainelli <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ffainelli authored and davem330 committed May 18, 2018
1 parent 6358d49 commit 5447d78
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions net/dsa/dsa2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
struct dsa_switch *ds = dp->ds;
int err;
int err = 0;

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)
return err;

Expand Down Expand Up @@ -293,7 +295,8 @@ static int dsa_port_setup(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) {
case DSA_PORT_TYPE_UNUSED:
Expand Down

0 comments on commit 5447d78

Please sign in to comment.