f69078cb4c5c63dccbb7946d12afacaf36073add
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.9 / 0093-dsa-compat.patch
1 --- a/drivers/net/dsa/mt7530.c
2 +++ b/drivers/net/dsa/mt7530.c
3 @@ -834,6 +834,7 @@ mt7530_port_bridge_join(struct dsa_switc
4 int i;
5
6 mutex_lock(&priv->reg_mutex);
7 + priv->bridge_dev[port] = bridge;
8
9 for (i = 0; i < MT7530_NUM_PORTS; i++) {
10 /* Add this port to the port matrix of the other ports in the
11 @@ -841,7 +842,7 @@ mt7530_port_bridge_join(struct dsa_switc
12 * and not being setup until the port becomes enabled.
13 */
14 if (ds->enabled_port_mask & BIT(i) && i != port) {
15 - if (ds->ports[i].bridge_dev != bridge)
16 + if (priv->bridge_dev[i] != bridge)
17 continue;
18 if (priv->ports[i].enable)
19 mt7530_set(priv, MT7530_PCR_P(i),
20 @@ -864,8 +865,7 @@ mt7530_port_bridge_join(struct dsa_switc
21 }
22
23 static void
24 -mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
25 - struct net_device *bridge)
26 +mt7530_port_bridge_leave(struct dsa_switch *ds, int port)
27 {
28 struct mt7530_priv *priv = ds->priv;
29 int i;
30 @@ -878,7 +878,7 @@ mt7530_port_bridge_leave(struct dsa_swit
31 * is kept and not being setup until the port becomes enabled.
32 */
33 if (ds->enabled_port_mask & BIT(i) && i != port) {
34 - if (ds->ports[i].bridge_dev != bridge)
35 + if (priv->bridge_dev[i] != priv->bridge_dev[port])
36 continue;
37 if (priv->ports[i].enable)
38 mt7530_clear(priv, MT7530_PCR_P(i),
39 @@ -890,6 +890,7 @@ mt7530_port_bridge_leave(struct dsa_swit
40 /* Set the cpu port to be the only one in the port matrix of
41 * this port.
42 */
43 + priv->bridge_dev[port] = NULL;
44 if (priv->ports[port].enable)
45 mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
46 PCR_MATRIX(BIT(MT7530_CPU_PORT)));
47 @@ -1033,7 +1034,7 @@ mt7530_probe(struct mdio_device *mdiodev
48 if (!priv)
49 return -ENOMEM;
50
51 - priv->ds = dsa_switch_alloc(&mdiodev->dev, DSA_MAX_PORTS);
52 + priv->ds = devm_kzalloc(&mdiodev->dev, sizeof(*priv->ds), GFP_KERNEL);
53 if (!priv->ds)
54 return -ENOMEM;
55
56 @@ -1076,12 +1077,13 @@ mt7530_probe(struct mdio_device *mdiodev
57 priv->bus = mdiodev->bus;
58 priv->dev = &mdiodev->dev;
59 priv->ds->priv = priv;
60 + priv->ds->dev = &mdiodev->dev;
61 priv->ds->ops = &mt7530_switch_ops;
62 mutex_init(&priv->reg_mutex);
63 lpriv = priv;
64 dev_set_drvdata(&mdiodev->dev, priv);
65
66 - return dsa_register_switch(priv->ds, &mdiodev->dev);
67 + return dsa_register_switch(priv->ds, priv->ds->dev->of_node);
68 }
69
70 static void
71 --- a/drivers/net/dsa/mt7530.h
72 +++ b/drivers/net/dsa/mt7530.h
73 @@ -379,6 +379,8 @@ struct mt7530_priv {
74 struct mt7530_port ports[MT7530_NUM_PORTS];
75 /* protect among processes for registers access*/
76 struct mutex reg_mutex;
77 +
78 + struct net_device *bridge_dev[MT7530_NUM_PORTS];
79 };
80
81 struct mt7530_hw_stats {
82 --- a/net/dsa/tag_mtk.c
83 +++ b/net/dsa/tag_mtk.c
84 @@ -35,7 +35,7 @@ static struct sk_buff *mtk_tag_xmit(stru
85 /* Build the tag after the MAC Source Address */
86 mtk_tag = skb->data + 2 * ETH_ALEN;
87 mtk_tag[0] = 0;
88 - mtk_tag[1] = (1 << p->dp->index) & MTK_HDR_XMIT_DP_BIT_MASK;
89 + mtk_tag[1] = (1 << p->port) & MTK_HDR_XMIT_DP_BIT_MASK;
90 mtk_tag[2] = 0;
91 mtk_tag[3] = 0;
92