071-v4.8-0002-net-ethernet-bgmac-add-dma_dev-pointer.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. From a0b68486f6f680c7c0352a47c60042d7d95ffd87 Mon Sep 17 00:00:00 2001
  2. From: Jon Mason <jon.mason@broadcom.com>
  3. Date: Thu, 7 Jul 2016 19:08:54 -0400
  4. Subject: [PATCH 2/5] net: ethernet: bgmac: add dma_dev pointer
  5. The dma buffer allocation, etc references a dma_dev device pointer from
  6. the bcma core. In anticipation of removing the bcma requirement for
  7. this driver, these must be changed to not reference that struct. Add a
  8. dma_dev device pointer to the bgmac stuct and reference that instead.
  9. Signed-off-by: Jon Mason <jon.mason@broadcom.com>
  10. Acked-by: Arnd Bergmann <arnd@arndb.de>
  11. Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
  12. Tested-by: Florian Fainelli <f.fainelli@gmail.com>
  13. Signed-off-by: David S. Miller <davem@davemloft.net>
  14. ---
  15. drivers/net/ethernet/broadcom/bgmac.c | 17 +++++++++--------
  16. drivers/net/ethernet/broadcom/bgmac.h | 1 +
  17. 2 files changed, 10 insertions(+), 8 deletions(-)
  18. --- a/drivers/net/ethernet/broadcom/bgmac.c
  19. +++ b/drivers/net/ethernet/broadcom/bgmac.c
  20. @@ -152,7 +152,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
  21. struct bgmac_dma_ring *ring,
  22. struct sk_buff *skb)
  23. {
  24. - struct device *dma_dev = bgmac->core->dma_dev;
  25. + struct device *dma_dev = bgmac->dma_dev;
  26. struct net_device *net_dev = bgmac->net_dev;
  27. int index = ring->end % BGMAC_TX_RING_SLOTS;
  28. struct bgmac_slot_info *slot = &ring->slots[index];
  29. @@ -254,7 +254,7 @@ err_drop:
  30. /* Free transmitted packets */
  31. static void bgmac_dma_tx_free(struct bgmac *bgmac, struct bgmac_dma_ring *ring)
  32. {
  33. - struct device *dma_dev = bgmac->core->dma_dev;
  34. + struct device *dma_dev = bgmac->dma_dev;
  35. int empty_slot;
  36. bool freed = false;
  37. unsigned bytes_compl = 0, pkts_compl = 0;
  38. @@ -355,7 +355,7 @@ static void bgmac_dma_rx_enable(struct b
  39. static int bgmac_dma_rx_skb_for_slot(struct bgmac *bgmac,
  40. struct bgmac_slot_info *slot)
  41. {
  42. - struct device *dma_dev = bgmac->core->dma_dev;
  43. + struct device *dma_dev = bgmac->dma_dev;
  44. dma_addr_t dma_addr;
  45. struct bgmac_rx_header *rx;
  46. void *buf;
  47. @@ -444,7 +444,7 @@ static int bgmac_dma_rx_read(struct bgma
  48. end_slot /= sizeof(struct bgmac_dma_desc);
  49. while (ring->start != end_slot) {
  50. - struct device *dma_dev = bgmac->core->dma_dev;
  51. + struct device *dma_dev = bgmac->dma_dev;
  52. struct bgmac_slot_info *slot = &ring->slots[ring->start];
  53. struct bgmac_rx_header *rx = slot->buf + BGMAC_RX_BUF_OFFSET;
  54. struct sk_buff *skb;
  55. @@ -547,7 +547,7 @@ static bool bgmac_dma_unaligned(struct b
  56. static void bgmac_dma_tx_ring_free(struct bgmac *bgmac,
  57. struct bgmac_dma_ring *ring)
  58. {
  59. - struct device *dma_dev = bgmac->core->dma_dev;
  60. + struct device *dma_dev = bgmac->dma_dev;
  61. struct bgmac_dma_desc *dma_desc = ring->cpu_base;
  62. struct bgmac_slot_info *slot;
  63. int i;
  64. @@ -574,7 +574,7 @@ static void bgmac_dma_tx_ring_free(struc
  65. static void bgmac_dma_rx_ring_free(struct bgmac *bgmac,
  66. struct bgmac_dma_ring *ring)
  67. {
  68. - struct device *dma_dev = bgmac->core->dma_dev;
  69. + struct device *dma_dev = bgmac->dma_dev;
  70. struct bgmac_slot_info *slot;
  71. int i;
  72. @@ -595,7 +595,7 @@ static void bgmac_dma_ring_desc_free(str
  73. struct bgmac_dma_ring *ring,
  74. int num_slots)
  75. {
  76. - struct device *dma_dev = bgmac->core->dma_dev;
  77. + struct device *dma_dev = bgmac->dma_dev;
  78. int size;
  79. if (!ring->cpu_base)
  80. @@ -633,7 +633,7 @@ static void bgmac_dma_free(struct bgmac
  81. static int bgmac_dma_alloc(struct bgmac *bgmac)
  82. {
  83. - struct device *dma_dev = bgmac->core->dma_dev;
  84. + struct device *dma_dev = bgmac->dma_dev;
  85. struct bgmac_dma_ring *ring;
  86. static const u16 ring_base[] = { BGMAC_DMA_BASE0, BGMAC_DMA_BASE1,
  87. BGMAC_DMA_BASE2, BGMAC_DMA_BASE3, };
  88. @@ -1734,6 +1734,7 @@ static int bgmac_probe(struct bcma_devic
  89. net_dev->ethtool_ops = &bgmac_ethtool_ops;
  90. bgmac = netdev_priv(net_dev);
  91. bgmac->dev = &core->dev;
  92. + bgmac->dma_dev = core->dma_dev;
  93. bgmac->net_dev = net_dev;
  94. bgmac->core = core;
  95. bcma_set_drvdata(core, bgmac);
  96. --- a/drivers/net/ethernet/broadcom/bgmac.h
  97. +++ b/drivers/net/ethernet/broadcom/bgmac.h
  98. @@ -429,6 +429,7 @@ struct bgmac {
  99. struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
  100. struct device *dev;
  101. + struct device *dma_dev;
  102. struct net_device *net_dev;
  103. struct napi_struct napi;
  104. struct mii_bus *mii_bus;