Skip to content

Commit

Permalink
net: dsa: sja1105: register switch before assigning port private data
Browse files Browse the repository at this point in the history
Like the dsa_switch_tree structures, the dsa_port structures will be
allocated on switch registration.

The SJA1105 driver is the only one accessing the dsa_port structure
after the switch allocation and before the switch registration.
For that reason, move switch registration prior to assigning the priv
member of the dsa_port structures.

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
  • Loading branch information
vivien authored and Jakub Kicinski committed Oct 22, 2019
1 parent ef2025e commit d5a619b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions drivers/net/dsa/sja1105/sja1105_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,15 @@ static int sja1105_probe(struct spi_device *spi)

tagger_data = &priv->tagger_data;

mutex_init(&priv->ptp_data.lock);
mutex_init(&priv->mgmt_lock);

sja1105_tas_setup(ds);

rc = dsa_register_switch(priv->ds);
if (rc)
return rc;

/* Connections between dsa_port and sja1105_port */
for (i = 0; i < SJA1105_NUM_PORTS; i++) {
struct sja1105_port *sp = &priv->ports[i];
Expand All @@ -2065,12 +2074,8 @@ static int sja1105_probe(struct spi_device *spi)
sp->dp = dsa_to_port(ds, i);
sp->data = tagger_data;
}
mutex_init(&priv->ptp_data.lock);
mutex_init(&priv->mgmt_lock);

sja1105_tas_setup(ds);

return dsa_register_switch(priv->ds);
return 0;
}

static int sja1105_remove(struct spi_device *spi)
Expand Down

0 comments on commit d5a619b

Please sign in to comment.