1b9f221588859482fdc76df9e2c2ba143d5a578b
[openwrt/staging/chunkeey.git] / target / linux / mediatek / patches-4.4 / 0072-net-mediatek-move-the-pending_work-struct-to-the-dev.patch
1 From 147dab4408adcccf702f8c5143e9c6b91f746790 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Tue, 29 Mar 2016 17:24:24 +0200
4 Subject: [PATCH 72/78] net: mediatek: move the pending_work struct to the
5 device generic struct
6
7 The worker always touches both netdevs. It is ethernet core and not MAC
8 specific. We only need one worker, which belongs into the ethernets core struct.
9
10 Signed-off-by: John Crispin <blogic@openwrt.org>
11 ---
12 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 10 ++++------
13 drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 ++--
14 2 files changed, 6 insertions(+), 8 deletions(-)
15
16 diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
17 index 67b18f9..bbcd607 100644
18 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
19 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
20 @@ -1193,7 +1193,7 @@ static void mtk_tx_timeout(struct net_device *dev)
21 eth->netdev[mac->id]->stats.tx_errors++;
22 netif_err(eth, tx_err, dev,
23 "transmit timed out\n");
24 - schedule_work(&mac->pending_work);
25 + schedule_work(&eth->pending_work);
26 }
27
28 static irqreturn_t mtk_handle_irq(int irq, void *_eth)
29 @@ -1438,7 +1438,7 @@ static void mtk_pending_work(struct work_struct *work)
30
31 /* stop all devices to make sure that dma is properly shut down */
32 for (i = 0; i < MTK_MAC_COUNT; i++) {
33 - if (!netif_oper_up(eth->netdev[i]))
34 + if (!eth->netdev[i])
35 continue;
36 mtk_stop(eth->netdev[i]);
37 __set_bit(i, &restart);
38 @@ -1464,15 +1464,13 @@ static int mtk_cleanup(struct mtk_eth *eth)
39 int i;
40
41 for (i = 0; i < MTK_MAC_COUNT; i++) {
42 - struct mtk_mac *mac = netdev_priv(eth->netdev[i]);
43 -
44 if (!eth->netdev[i])
45 continue;
46
47 unregister_netdev(eth->netdev[i]);
48 free_netdev(eth->netdev[i]);
49 - cancel_work_sync(&mac->pending_work);
50 }
51 + cancel_work_sync(&eth->pending_work);
52
53 return 0;
54 }
55 @@ -1660,7 +1658,6 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
56 mac->id = id;
57 mac->hw = eth;
58 mac->of_node = np;
59 - INIT_WORK(&mac->pending_work, mtk_pending_work);
60
61 mac->hw_stats = devm_kzalloc(eth->dev,
62 sizeof(*mac->hw_stats),
63 @@ -1762,6 +1759,7 @@ static int mtk_probe(struct platform_device *pdev)
64
65 eth->dev = &pdev->dev;
66 eth->msg_enable = netif_msg_init(mtk_msg_level, MTK_DEFAULT_MSG_ENABLE);
67 + INIT_WORK(&eth->pending_work, mtk_pending_work);
68
69 err = mtk_hw_init(eth);
70 if (err)
71 diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
72 index 48a5292..eed626d 100644
73 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
74 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
75 @@ -363,6 +363,7 @@ struct mtk_rx_ring {
76 * @clk_gp1: The gmac1 clock
77 * @clk_gp2: The gmac2 clock
78 * @mii_bus: If there is a bus we need to create an instance for it
79 + * @pending_work: The workqueue used to reset the dma ring
80 */
81
82 struct mtk_eth {
83 @@ -389,6 +390,7 @@ struct mtk_eth {
84 struct clk *clk_gp1;
85 struct clk *clk_gp2;
86 struct mii_bus *mii_bus;
87 + struct work_struct pending_work;
88 };
89
90 /* struct mtk_mac - the structure that holds the info about the MACs of the
91 @@ -398,7 +400,6 @@ struct mtk_eth {
92 * @hw: Backpointer to our main datastruture
93 * @hw_stats: Packet statistics counter
94 * @phy_dev: The attached PHY if available
95 - * @pending_work: The workqueue used to reset the dma ring
96 */
97 struct mtk_mac {
98 int id;
99 @@ -406,7 +407,6 @@ struct mtk_mac {
100 struct mtk_eth *hw;
101 struct mtk_hw_stats *hw_stats;
102 struct phy_device *phy_dev;
103 - struct work_struct pending_work;
104 };
105
106 /* the struct describing the SoC. these are declared in the soc_xyz.c files */
107 --
108 1.7.10.4
109