0068-net-mediatek-move-the-pending_work-struct-to-the-dev.patch 3.2 KB

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