Commit 9f9e772d authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

net: dsa: Initialize ds->cpu_port_mask earlier

The mt7530 driver has its dsa_switch_ops::get_tag_protocol function
check ds->cpu_port_mask to issue a warning in case the configured CPU
port is not capable of supporting tags.

After commit 14be36c2 ("net: dsa: Initialize all CPU and enabled
ports masks in dsa_ds_parse()") we slightly re-arranged the
initialization such that this was no longer working. Just make sure that
ds->cpu_port_mask is set prior to the first call to get_tag_protocol,
thus restoring the expected contract. In case of error, the CPU port bit
is cleared.

Fixes: 14be36c2 ("net: dsa: Initialize all CPU and enabled ports masks in dsa_ds_parse()")
Reported-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c800aaf8
...@@ -509,21 +509,22 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index, ...@@ -509,21 +509,22 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
dst->cpu_dp->netdev = ethernet_dev; dst->cpu_dp->netdev = ethernet_dev;
} }
/* Initialize cpu_port_mask now for drv->setup()
* to have access to a correct value, just like what
* net/dsa/dsa.c::dsa_switch_setup_one does.
*/
ds->cpu_port_mask |= BIT(index);
tag_protocol = ds->ops->get_tag_protocol(ds); tag_protocol = ds->ops->get_tag_protocol(ds);
dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol); dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol);
if (IS_ERR(dst->tag_ops)) { if (IS_ERR(dst->tag_ops)) {
dev_warn(ds->dev, "No tagger for this switch\n"); dev_warn(ds->dev, "No tagger for this switch\n");
ds->cpu_port_mask &= ~BIT(index);
return PTR_ERR(dst->tag_ops); return PTR_ERR(dst->tag_ops);
} }
dst->rcv = dst->tag_ops->rcv; dst->rcv = dst->tag_ops->rcv;
/* Initialize cpu_port_mask now for drv->setup()
* to have access to a correct value, just like what
* net/dsa/dsa.c::dsa_switch_setup_one does.
*/
ds->cpu_port_mask |= BIT(index);
return 0; return 0;
} }
......
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