Commit 788abc6d authored by Linus Walleij's avatar Linus Walleij Committed by David S. Miller
Browse files

net: dsa: rtl8366: Fix VLAN set-up



Alter the rtl8366_vlan_add() to call rtl8366_set_vlan()
inside the loop that goes over all VIDs since we now
properly support calling that function more than once.
Augment the loop to postincrement as this is more
intuitive.

The loop moved past the last VID but called
rtl8366_set_vlan() with the port number instead of
the VID, assuming a 1-to-1 correspondence between
ports and VIDs. This was also a bug.

Cc: DENG Qingfang <dqfext@gmail.com>
Cc: Mauri Sandberg <sandberg@mailfence.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Fixes: d8652956 ("net: dsa: realtek-smi: Add Realtek SMI driver")
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 15ab7906
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -397,7 +397,7 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port,
	if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
		dev_err(smi->dev, "port is DSA or CPU port\n");

	for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
	for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
		int pvid_val = 0;

		dev_info(smi->dev, "add VLAN %04x\n", vid);
@@ -420,14 +420,14 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port,
			if (ret < 0)
				return;
		}
	}

	ret = rtl8366_set_vlan(smi, port, member, untag, 0);
		ret = rtl8366_set_vlan(smi, vid, member, untag, 0);
		if (ret)
			dev_err(smi->dev,
				"failed to set up VLAN %04x",
				vid);
	}
}
EXPORT_SYMBOL_GPL(rtl8366_vlan_add);

int rtl8366_vlan_del(struct dsa_switch *ds, int port,