aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2016-04-07 18:54:10 -0400
committerDavid S. Miller <davem@davemloft.net>2016-04-12 22:41:33 -0400
commit7c78b4ad9bbdbe0bb4fbc98841ad9d904ee116e9 (patch)
tree3ce4c4007249ee3452eca49a2fc350e5b80e2a3f
parente7d425dcea032f1d0b44b6fa4c6735f13882de6e (diff)
net: mediatek: move the pending_work struct to the device generic struct
The worker always touches both netdevs. It is ethernet core and not MAC specific. We only need one worker, which belongs into the ethernets core struct. Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mediatek/mtk_eth_soc.c13
-rw-r--r--drivers/net/ethernet/mediatek/mtk_eth_soc.h4
2 files changed, 7 insertions, 10 deletions
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index cd5d0c97f0ce..eb0d5544787a 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1193,7 +1193,7 @@ static void mtk_tx_timeout(struct net_device *dev)
1193 eth->netdev[mac->id]->stats.tx_errors++; 1193 eth->netdev[mac->id]->stats.tx_errors++;
1194 netif_err(eth, tx_err, dev, 1194 netif_err(eth, tx_err, dev,
1195 "transmit timed out\n"); 1195 "transmit timed out\n");
1196 schedule_work(&mac->pending_work); 1196 schedule_work(&eth->pending_work);
1197} 1197}
1198 1198
1199static irqreturn_t mtk_handle_irq(int irq, void *_eth) 1199static irqreturn_t mtk_handle_irq(int irq, void *_eth)
@@ -1430,8 +1430,7 @@ static int mtk_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1430 1430
1431static void mtk_pending_work(struct work_struct *work) 1431static void mtk_pending_work(struct work_struct *work)
1432{ 1432{
1433 struct mtk_mac *mac = container_of(work, struct mtk_mac, pending_work); 1433 struct mtk_eth *eth = container_of(work, struct mtk_eth, pending_work);
1434 struct mtk_eth *eth = mac->hw;
1435 int err, i; 1434 int err, i;
1436 unsigned long restart = 0; 1435 unsigned long restart = 0;
1437 1436
@@ -1439,7 +1438,7 @@ static void mtk_pending_work(struct work_struct *work)
1439 1438
1440 /* stop all devices to make sure that dma is properly shut down */ 1439 /* stop all devices to make sure that dma is properly shut down */
1441 for (i = 0; i < MTK_MAC_COUNT; i++) { 1440 for (i = 0; i < MTK_MAC_COUNT; i++) {
1442 if (!netif_oper_up(eth->netdev[i])) 1441 if (!eth->netdev[i])
1443 continue; 1442 continue;
1444 mtk_stop(eth->netdev[i]); 1443 mtk_stop(eth->netdev[i]);
1445 __set_bit(i, &restart); 1444 __set_bit(i, &restart);
@@ -1464,15 +1463,13 @@ static int mtk_cleanup(struct mtk_eth *eth)
1464 int i; 1463 int i;
1465 1464
1466 for (i = 0; i < MTK_MAC_COUNT; i++) { 1465 for (i = 0; i < MTK_MAC_COUNT; i++) {
1467 struct mtk_mac *mac = netdev_priv(eth->netdev[i]);
1468
1469 if (!eth->netdev[i]) 1466 if (!eth->netdev[i])
1470 continue; 1467 continue;
1471 1468
1472 unregister_netdev(eth->netdev[i]); 1469 unregister_netdev(eth->netdev[i]);
1473 free_netdev(eth->netdev[i]); 1470 free_netdev(eth->netdev[i]);
1474 cancel_work_sync(&mac->pending_work);
1475 } 1471 }
1472 cancel_work_sync(&eth->pending_work);
1476 1473
1477 return 0; 1474 return 0;
1478} 1475}
@@ -1660,7 +1657,6 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
1660 mac->id = id; 1657 mac->id = id;
1661 mac->hw = eth; 1658 mac->hw = eth;
1662 mac->of_node = np; 1659 mac->of_node = np;
1663 INIT_WORK(&mac->pending_work, mtk_pending_work);
1664 1660
1665 mac->hw_stats = devm_kzalloc(eth->dev, 1661 mac->hw_stats = devm_kzalloc(eth->dev,
1666 sizeof(*mac->hw_stats), 1662 sizeof(*mac->hw_stats),
@@ -1762,6 +1758,7 @@ static int mtk_probe(struct platform_device *pdev)
1762 1758
1763 eth->dev = &pdev->dev; 1759 eth->dev = &pdev->dev;
1764 eth->msg_enable = netif_msg_init(mtk_msg_level, MTK_DEFAULT_MSG_ENABLE); 1760 eth->msg_enable = netif_msg_init(mtk_msg_level, MTK_DEFAULT_MSG_ENABLE);
1761 INIT_WORK(&eth->pending_work, mtk_pending_work);
1765 1762
1766 err = mtk_hw_init(eth); 1763 err = mtk_hw_init(eth);
1767 if (err) 1764 if (err)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index 48a5292c8ed8..eed626d56ea4 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -363,6 +363,7 @@ struct mtk_rx_ring {
363 * @clk_gp1: The gmac1 clock 363 * @clk_gp1: The gmac1 clock
364 * @clk_gp2: The gmac2 clock 364 * @clk_gp2: The gmac2 clock
365 * @mii_bus: If there is a bus we need to create an instance for it 365 * @mii_bus: If there is a bus we need to create an instance for it
366 * @pending_work: The workqueue used to reset the dma ring
366 */ 367 */
367 368
368struct mtk_eth { 369struct mtk_eth {
@@ -389,6 +390,7 @@ struct mtk_eth {
389 struct clk *clk_gp1; 390 struct clk *clk_gp1;
390 struct clk *clk_gp2; 391 struct clk *clk_gp2;
391 struct mii_bus *mii_bus; 392 struct mii_bus *mii_bus;
393 struct work_struct pending_work;
392}; 394};
393 395
394/* struct mtk_mac - the structure that holds the info about the MACs of the 396/* struct mtk_mac - the structure that holds the info about the MACs of the
@@ -398,7 +400,6 @@ struct mtk_eth {
398 * @hw: Backpointer to our main datastruture 400 * @hw: Backpointer to our main datastruture
399 * @hw_stats: Packet statistics counter 401 * @hw_stats: Packet statistics counter
400 * @phy_dev: The attached PHY if available 402 * @phy_dev: The attached PHY if available
401 * @pending_work: The workqueue used to reset the dma ring
402 */ 403 */
403struct mtk_mac { 404struct mtk_mac {
404 int id; 405 int id;
@@ -406,7 +407,6 @@ struct mtk_mac {
406 struct mtk_eth *hw; 407 struct mtk_eth *hw;
407 struct mtk_hw_stats *hw_stats; 408 struct mtk_hw_stats *hw_stats;
408 struct phy_device *phy_dev; 409 struct phy_device *phy_dev;
409 struct work_struct pending_work;
410}; 410};
411 411
412/* the struct describing the SoC. these are declared in the soc_xyz.c files */ 412/* the struct describing the SoC. these are declared in the soc_xyz.c files */