2
0

071-v4.8-0001-net-ethernet-bgmac-change-bgmac_-prints-to-dev_-prin.patch 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. From d00a8281bcc962027dfe409c2f3e3f0546be9200 Mon Sep 17 00:00:00 2001
  2. From: Jon Mason <jon.mason@broadcom.com>
  3. Date: Thu, 7 Jul 2016 19:08:53 -0400
  4. Subject: [PATCH 1/5] net: ethernet: bgmac: change bgmac_* prints to dev_*
  5. prints
  6. The bgmac_* print wrappers call dev_* prints with the dev pointer from
  7. the bcma core. In anticipation of removing the bcma requirement for
  8. this driver, these must be changed to not reference that struct. So,
  9. simply change all of the bgmac_* prints to their dev_* counterparts. In
  10. some cases netdev_* prints are more appropriate, so change those as
  11. well.
  12. Signed-off-by: Jon Mason <jon.mason@broadcom.com>
  13. Acked-by: Arnd Bergmann <arnd@arndb.de>
  14. Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
  15. Tested-by: Florian Fainelli <f.fainelli@gmail.com>
  16. Signed-off-by: David S. Miller <davem@davemloft.net>
  17. ---
  18. drivers/net/ethernet/broadcom/bgmac.c | 103 +++++++++++++++++-----------------
  19. drivers/net/ethernet/broadcom/bgmac.h | 14 +----
  20. 2 files changed, 55 insertions(+), 62 deletions(-)
  21. --- a/drivers/net/ethernet/broadcom/bgmac.c
  22. +++ b/drivers/net/ethernet/broadcom/bgmac.c
  23. @@ -50,7 +50,7 @@ static bool bgmac_wait_value(struct bcma
  24. return true;
  25. udelay(10);
  26. }
  27. - pr_err("Timeout waiting for reg 0x%X\n", reg);
  28. + dev_err(&core->dev, "Timeout waiting for reg 0x%X\n", reg);
  29. return false;
  30. }
  31. @@ -84,8 +84,8 @@ static void bgmac_dma_tx_reset(struct bg
  32. udelay(10);
  33. }
  34. if (i)
  35. - bgmac_err(bgmac, "Timeout suspending DMA TX ring 0x%X (BGMAC_DMA_TX_STAT: 0x%08X)\n",
  36. - ring->mmio_base, val);
  37. + dev_err(bgmac->dev, "Timeout suspending DMA TX ring 0x%X (BGMAC_DMA_TX_STAT: 0x%08X)\n",
  38. + ring->mmio_base, val);
  39. /* Remove SUSPEND bit */
  40. bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_CTL, 0);
  41. @@ -93,13 +93,13 @@ static void bgmac_dma_tx_reset(struct bg
  42. ring->mmio_base + BGMAC_DMA_TX_STATUS,
  43. BGMAC_DMA_TX_STAT, BGMAC_DMA_TX_STAT_DISABLED,
  44. 10000)) {
  45. - bgmac_warn(bgmac, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
  46. - ring->mmio_base);
  47. + dev_warn(bgmac->dev, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
  48. + ring->mmio_base);
  49. udelay(300);
  50. val = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_TX_STATUS);
  51. if ((val & BGMAC_DMA_TX_STAT) != BGMAC_DMA_TX_STAT_DISABLED)
  52. - bgmac_err(bgmac, "Reset of DMA TX ring 0x%X failed\n",
  53. - ring->mmio_base);
  54. + dev_err(bgmac->dev, "Reset of DMA TX ring 0x%X failed\n",
  55. + ring->mmio_base);
  56. }
  57. }
  58. @@ -161,7 +161,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
  59. int i;
  60. if (skb->len > BGMAC_DESC_CTL1_LEN) {
  61. - bgmac_err(bgmac, "Too long skb (%d)\n", skb->len);
  62. + netdev_err(bgmac->net_dev, "Too long skb (%d)\n", skb->len);
  63. goto err_drop;
  64. }
  65. @@ -174,7 +174,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
  66. * even when ring->end overflows
  67. */
  68. if (ring->end - ring->start + nr_frags + 1 >= BGMAC_TX_RING_SLOTS) {
  69. - bgmac_err(bgmac, "TX ring is full, queue should be stopped!\n");
  70. + netdev_err(bgmac->net_dev, "TX ring is full, queue should be stopped!\n");
  71. netif_stop_queue(net_dev);
  72. return NETDEV_TX_BUSY;
  73. }
  74. @@ -241,8 +241,8 @@ err_dma:
  75. }
  76. err_dma_head:
  77. - bgmac_err(bgmac, "Mapping error of skb on ring 0x%X\n",
  78. - ring->mmio_base);
  79. + netdev_err(bgmac->net_dev, "Mapping error of skb on ring 0x%X\n",
  80. + ring->mmio_base);
  81. err_drop:
  82. dev_kfree_skb(skb);
  83. @@ -321,8 +321,8 @@ static void bgmac_dma_rx_reset(struct bg
  84. ring->mmio_base + BGMAC_DMA_RX_STATUS,
  85. BGMAC_DMA_RX_STAT, BGMAC_DMA_RX_STAT_DISABLED,
  86. 10000))
  87. - bgmac_err(bgmac, "Reset of ring 0x%X RX failed\n",
  88. - ring->mmio_base);
  89. + dev_err(bgmac->dev, "Reset of ring 0x%X RX failed\n",
  90. + ring->mmio_base);
  91. }
  92. static void bgmac_dma_rx_enable(struct bgmac *bgmac,
  93. @@ -374,7 +374,7 @@ static int bgmac_dma_rx_skb_for_slot(str
  94. dma_addr = dma_map_single(dma_dev, buf + BGMAC_RX_BUF_OFFSET,
  95. BGMAC_RX_BUF_SIZE, DMA_FROM_DEVICE);
  96. if (dma_mapping_error(dma_dev, dma_addr)) {
  97. - bgmac_err(bgmac, "DMA mapping error\n");
  98. + netdev_err(bgmac->net_dev, "DMA mapping error\n");
  99. put_page(virt_to_head_page(buf));
  100. return -ENOMEM;
  101. }
  102. @@ -469,16 +469,16 @@ static int bgmac_dma_rx_read(struct bgma
  103. /* Check for poison and drop or pass the packet */
  104. if (len == 0xdead && flags == 0xbeef) {
  105. - bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n",
  106. - ring->start);
  107. + netdev_err(bgmac->net_dev, "Found poisoned packet at slot %d, DMA issue!\n",
  108. + ring->start);
  109. put_page(virt_to_head_page(buf));
  110. bgmac->net_dev->stats.rx_errors++;
  111. break;
  112. }
  113. if (len > BGMAC_RX_ALLOC_SIZE) {
  114. - bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n",
  115. - ring->start);
  116. + netdev_err(bgmac->net_dev, "Found oversized packet at slot %d, DMA issue!\n",
  117. + ring->start);
  118. put_page(virt_to_head_page(buf));
  119. bgmac->net_dev->stats.rx_length_errors++;
  120. bgmac->net_dev->stats.rx_errors++;
  121. @@ -490,7 +490,7 @@ static int bgmac_dma_rx_read(struct bgma
  122. skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
  123. if (unlikely(!skb)) {
  124. - bgmac_err(bgmac, "build_skb failed\n");
  125. + netdev_err(bgmac->net_dev, "build_skb failed\n");
  126. put_page(virt_to_head_page(buf));
  127. bgmac->net_dev->stats.rx_errors++;
  128. break;
  129. @@ -644,7 +644,7 @@ static int bgmac_dma_alloc(struct bgmac
  130. BUILD_BUG_ON(BGMAC_MAX_RX_RINGS > ARRAY_SIZE(ring_base));
  131. if (!(bcma_aread32(bgmac->core, BCMA_IOST) & BCMA_IOST_DMA64)) {
  132. - bgmac_err(bgmac, "Core does not report 64-bit DMA\n");
  133. + dev_err(bgmac->dev, "Core does not report 64-bit DMA\n");
  134. return -ENOTSUPP;
  135. }
  136. @@ -658,8 +658,8 @@ static int bgmac_dma_alloc(struct bgmac
  137. &ring->dma_base,
  138. GFP_KERNEL);
  139. if (!ring->cpu_base) {
  140. - bgmac_err(bgmac, "Allocation of TX ring 0x%X failed\n",
  141. - ring->mmio_base);
  142. + dev_err(bgmac->dev, "Allocation of TX ring 0x%X failed\n",
  143. + ring->mmio_base);
  144. goto err_dma_free;
  145. }
  146. @@ -683,8 +683,8 @@ static int bgmac_dma_alloc(struct bgmac
  147. &ring->dma_base,
  148. GFP_KERNEL);
  149. if (!ring->cpu_base) {
  150. - bgmac_err(bgmac, "Allocation of RX ring 0x%X failed\n",
  151. - ring->mmio_base);
  152. + dev_err(bgmac->dev, "Allocation of RX ring 0x%X failed\n",
  153. + ring->mmio_base);
  154. err = -ENOMEM;
  155. goto err_dma_free;
  156. }
  157. @@ -803,8 +803,8 @@ static u16 bgmac_phy_read(struct bgmac *
  158. bcma_write32(core, phy_access_addr, tmp);
  159. if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
  160. - bgmac_err(bgmac, "Reading PHY %d register 0x%X failed\n",
  161. - phyaddr, reg);
  162. + dev_err(bgmac->dev, "Reading PHY %d register 0x%X failed\n",
  163. + phyaddr, reg);
  164. return 0xffff;
  165. }
  166. @@ -836,7 +836,7 @@ static int bgmac_phy_write(struct bgmac
  167. bgmac_write(bgmac, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
  168. if (bgmac_read(bgmac, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
  169. - bgmac_warn(bgmac, "Error setting MDIO int\n");
  170. + dev_warn(bgmac->dev, "Error setting MDIO int\n");
  171. tmp = BGMAC_PA_START;
  172. tmp |= BGMAC_PA_WRITE;
  173. @@ -846,8 +846,8 @@ static int bgmac_phy_write(struct bgmac
  174. bcma_write32(core, phy_access_addr, tmp);
  175. if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
  176. - bgmac_err(bgmac, "Writing to PHY %d register 0x%X failed\n",
  177. - phyaddr, reg);
  178. + dev_err(bgmac->dev, "Writing to PHY %d register 0x%X failed\n",
  179. + phyaddr, reg);
  180. return -ETIMEDOUT;
  181. }
  182. @@ -900,7 +900,7 @@ static void bgmac_phy_reset(struct bgmac
  183. bgmac_phy_write(bgmac, bgmac->phyaddr, MII_BMCR, BMCR_RESET);
  184. udelay(100);
  185. if (bgmac_phy_read(bgmac, bgmac->phyaddr, MII_BMCR) & BMCR_RESET)
  186. - bgmac_err(bgmac, "PHY reset failed\n");
  187. + dev_err(bgmac->dev, "PHY reset failed\n");
  188. bgmac_phy_init(bgmac);
  189. }
  190. @@ -1001,7 +1001,8 @@ static void bgmac_mac_speed(struct bgmac
  191. set |= BGMAC_CMDCFG_ES_2500;
  192. break;
  193. default:
  194. - bgmac_err(bgmac, "Unsupported speed: %d\n", bgmac->mac_speed);
  195. + dev_err(bgmac->dev, "Unsupported speed: %d\n",
  196. + bgmac->mac_speed);
  197. }
  198. if (bgmac->mac_duplex == DUPLEX_HALF)
  199. @@ -1100,8 +1101,8 @@ static void bgmac_chip_reset(struct bgma
  200. if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
  201. if (kstrtou8(buf, 0, &et_swtype))
  202. - bgmac_err(bgmac, "Failed to parse et_swtype (%s)\n",
  203. - buf);
  204. + dev_err(bgmac->dev, "Failed to parse et_swtype (%s)\n",
  205. + buf);
  206. et_swtype &= 0x0f;
  207. et_swtype <<= 4;
  208. sw_type = et_swtype;
  209. @@ -1264,7 +1265,7 @@ static irqreturn_t bgmac_interrupt(int i
  210. int_status &= ~(BGMAC_IS_TX0 | BGMAC_IS_RX);
  211. if (int_status)
  212. - bgmac_err(bgmac, "Unknown IRQs: 0x%08X\n", int_status);
  213. + dev_err(bgmac->dev, "Unknown IRQs: 0x%08X\n", int_status);
  214. /* Disable new interrupts until handling existing ones */
  215. bgmac_chip_intrs_off(bgmac);
  216. @@ -1318,7 +1319,7 @@ static int bgmac_open(struct net_device
  217. err = request_irq(bgmac->core->irq, bgmac_interrupt, IRQF_SHARED,
  218. KBUILD_MODNAME, net_dev);
  219. if (err < 0) {
  220. - bgmac_err(bgmac, "IRQ request error: %d!\n", err);
  221. + dev_err(bgmac->dev, "IRQ request error: %d!\n", err);
  222. bgmac_dma_cleanup(bgmac);
  223. return err;
  224. }
  225. @@ -1599,14 +1600,14 @@ static int bgmac_fixed_phy_register(stru
  226. phy_dev = fixed_phy_register(PHY_POLL, &fphy_status, -1, NULL);
  227. if (!phy_dev || IS_ERR(phy_dev)) {
  228. - bgmac_err(bgmac, "Failed to register fixed PHY device\n");
  229. + dev_err(bgmac->dev, "Failed to register fixed PHY device\n");
  230. return -ENODEV;
  231. }
  232. err = phy_connect_direct(bgmac->net_dev, phy_dev, bgmac_adjust_link,
  233. PHY_INTERFACE_MODE_MII);
  234. if (err) {
  235. - bgmac_err(bgmac, "Connecting PHY failed\n");
  236. + dev_err(bgmac->dev, "Connecting PHY failed\n");
  237. return err;
  238. }
  239. @@ -1646,7 +1647,7 @@ static int bgmac_mii_register(struct bgm
  240. err = mdiobus_register(mii_bus);
  241. if (err) {
  242. - bgmac_err(bgmac, "Registration of mii bus failed\n");
  243. + dev_err(bgmac->dev, "Registration of mii bus failed\n");
  244. goto err_free_irq;
  245. }
  246. @@ -1658,7 +1659,7 @@ static int bgmac_mii_register(struct bgm
  247. phy_dev = phy_connect(bgmac->net_dev, bus_id, &bgmac_adjust_link,
  248. PHY_INTERFACE_MODE_MII);
  249. if (IS_ERR(phy_dev)) {
  250. - bgmac_err(bgmac, "PHY connecton failed\n");
  251. + dev_err(bgmac->dev, "PHY connecton failed\n");
  252. err = PTR_ERR(phy_dev);
  253. goto err_unregister_bus;
  254. }
  255. @@ -1707,7 +1708,8 @@ static int bgmac_probe(struct bcma_devic
  256. mac = sprom->et2mac;
  257. break;
  258. default:
  259. - pr_err("Unsupported core_unit %d\n", core->core_unit);
  260. + dev_err(&core->dev, "Unsupported core_unit %d\n",
  261. + core->core_unit);
  262. return -ENOTSUPP;
  263. }
  264. @@ -1730,6 +1732,7 @@ static int bgmac_probe(struct bcma_devic
  265. net_dev->irq = core->irq;
  266. net_dev->ethtool_ops = &bgmac_ethtool_ops;
  267. bgmac = netdev_priv(net_dev);
  268. + bgmac->dev = &core->dev;
  269. bgmac->net_dev = net_dev;
  270. bgmac->core = core;
  271. bcma_set_drvdata(core, bgmac);
  272. @@ -1741,7 +1744,7 @@ static int bgmac_probe(struct bcma_devic
  273. /* On BCM4706 we need common core to access PHY */
  274. if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
  275. !core->bus->drv_gmac_cmn.core) {
  276. - bgmac_err(bgmac, "GMAC CMN core not found (required for BCM4706)\n");
  277. + dev_err(bgmac->dev, "GMAC CMN core not found (required for BCM4706)\n");
  278. err = -ENODEV;
  279. goto err_netdev_free;
  280. }
  281. @@ -1760,15 +1763,15 @@ static int bgmac_probe(struct bcma_devic
  282. }
  283. bgmac->phyaddr &= BGMAC_PHY_MASK;
  284. if (bgmac->phyaddr == BGMAC_PHY_MASK) {
  285. - bgmac_err(bgmac, "No PHY found\n");
  286. + dev_err(bgmac->dev, "No PHY found\n");
  287. err = -ENODEV;
  288. goto err_netdev_free;
  289. }
  290. - bgmac_info(bgmac, "Found PHY addr: %d%s\n", bgmac->phyaddr,
  291. - bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
  292. + dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
  293. + bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
  294. if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) {
  295. - bgmac_err(bgmac, "PCI setup not implemented\n");
  296. + dev_err(bgmac->dev, "PCI setup not implemented\n");
  297. err = -ENOTSUPP;
  298. goto err_netdev_free;
  299. }
  300. @@ -1797,7 +1800,7 @@ static int bgmac_probe(struct bcma_devic
  301. err = bgmac_dma_alloc(bgmac);
  302. if (err) {
  303. - bgmac_err(bgmac, "Unable to alloc memory for DMA\n");
  304. + dev_err(bgmac->dev, "Unable to alloc memory for DMA\n");
  305. goto err_netdev_free;
  306. }
  307. @@ -1811,16 +1814,16 @@ static int bgmac_probe(struct bcma_devic
  308. bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo &
  309. BGMAC_BFL_ENETROBO);
  310. if (bgmac->has_robosw)
  311. - bgmac_warn(bgmac, "Support for Roboswitch not implemented\n");
  312. + dev_warn(bgmac->dev, "Support for Roboswitch not implemented\n");
  313. if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
  314. - bgmac_warn(bgmac, "Support for ADMtek ethernet switch not implemented\n");
  315. + dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
  316. netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
  317. err = bgmac_mii_register(bgmac);
  318. if (err) {
  319. - bgmac_err(bgmac, "Cannot register MDIO\n");
  320. + dev_err(bgmac->dev, "Cannot connect to phy\n");
  321. goto err_dma_free;
  322. }
  323. @@ -1830,7 +1833,7 @@ static int bgmac_probe(struct bcma_devic
  324. err = register_netdev(bgmac->net_dev);
  325. if (err) {
  326. - bgmac_err(bgmac, "Cannot register net device\n");
  327. + dev_err(bgmac->dev, "Cannot register net device\n");
  328. goto err_mii_unregister;
  329. }
  330. --- a/drivers/net/ethernet/broadcom/bgmac.h
  331. +++ b/drivers/net/ethernet/broadcom/bgmac.h
  332. @@ -1,17 +1,6 @@
  333. #ifndef _BGMAC_H
  334. #define _BGMAC_H
  335. -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  336. -
  337. -#define bgmac_err(bgmac, fmt, ...) \
  338. - dev_err(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
  339. -#define bgmac_warn(bgmac, fmt, ...) \
  340. - dev_warn(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
  341. -#define bgmac_info(bgmac, fmt, ...) \
  342. - dev_info(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
  343. -#define bgmac_dbg(bgmac, fmt, ...) \
  344. - dev_dbg(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
  345. -
  346. #include <linux/bcma/bcma.h>
  347. #include <linux/brcmphy.h>
  348. #include <linux/netdevice.h>
  349. @@ -438,6 +427,8 @@ struct bgmac_rx_header {
  350. struct bgmac {
  351. struct bcma_device *core;
  352. struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
  353. +
  354. + struct device *dev;
  355. struct net_device *net_dev;
  356. struct napi_struct napi;
  357. struct mii_bus *mii_bus;
  358. @@ -489,5 +480,4 @@ static inline void bgmac_set(struct bgma
  359. {
  360. bgmac_maskset(bgmac, offset, ~0, set);
  361. }
  362. -
  363. #endif /* _BGMAC_H */