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