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_*
7 The bgmac_* print wrappers call dev_* prints with the dev pointer from
8 the bcma core. In anticipation of removing the bcma requirement for
9 this driver, these must be changed to not reference that struct. So,
10 simply change all of the bgmac_* prints to their dev_* counterparts. In
11 some cases netdev_* prints are more appropriate, so change those as
14 Signed-off-by: Jon Mason <jon.mason@broadcom.com>
15 Acked-by: Arnd Bergmann <arnd@arndb.de>
16 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
17 Tested-by: Florian Fainelli <f.fainelli@gmail.com>
18 Signed-off-by: David S. Miller <davem@davemloft.net>
20 drivers/net/ethernet/broadcom/bgmac.c | 103 +++++++++++++++++-----------------
21 drivers/net/ethernet/broadcom/bgmac.h | 14 +----
22 2 files changed, 55 insertions(+), 62 deletions(-)
24 --- a/drivers/net/ethernet/broadcom/bgmac.c
25 +++ b/drivers/net/ethernet/broadcom/bgmac.c
26 @@ -50,7 +50,7 @@ static bool bgmac_wait_value(struct bcma
30 - pr_err("Timeout waiting for reg 0x%X\n", reg);
31 + dev_err(&core->dev, "Timeout waiting for reg 0x%X\n", reg);
35 @@ -84,8 +84,8 @@ static void bgmac_dma_tx_reset(struct bg
39 - bgmac_err(bgmac, "Timeout suspending DMA TX ring 0x%X (BGMAC_DMA_TX_STAT: 0x%08X)\n",
40 - ring->mmio_base, val);
41 + dev_err(bgmac->dev, "Timeout suspending DMA TX ring 0x%X (BGMAC_DMA_TX_STAT: 0x%08X)\n",
42 + ring->mmio_base, val);
44 /* Remove SUSPEND bit */
45 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_CTL, 0);
46 @@ -93,13 +93,13 @@ static void bgmac_dma_tx_reset(struct bg
47 ring->mmio_base + BGMAC_DMA_TX_STATUS,
48 BGMAC_DMA_TX_STAT, BGMAC_DMA_TX_STAT_DISABLED,
50 - bgmac_warn(bgmac, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
52 + dev_warn(bgmac->dev, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
55 val = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_TX_STATUS);
56 if ((val & BGMAC_DMA_TX_STAT) != BGMAC_DMA_TX_STAT_DISABLED)
57 - bgmac_err(bgmac, "Reset of DMA TX ring 0x%X failed\n",
59 + dev_err(bgmac->dev, "Reset of DMA TX ring 0x%X failed\n",
64 @@ -161,7 +161,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
67 if (skb->len > BGMAC_DESC_CTL1_LEN) {
68 - bgmac_err(bgmac, "Too long skb (%d)\n", skb->len);
69 + netdev_err(bgmac->net_dev, "Too long skb (%d)\n", skb->len);
73 @@ -174,7 +174,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
74 * even when ring->end overflows
76 if (ring->end - ring->start + nr_frags + 1 >= BGMAC_TX_RING_SLOTS) {
77 - bgmac_err(bgmac, "TX ring is full, queue should be stopped!\n");
78 + netdev_err(bgmac->net_dev, "TX ring is full, queue should be stopped!\n");
79 netif_stop_queue(net_dev);
80 return NETDEV_TX_BUSY;
82 @@ -241,8 +241,8 @@ err_dma:
86 - bgmac_err(bgmac, "Mapping error of skb on ring 0x%X\n",
88 + netdev_err(bgmac->net_dev, "Mapping error of skb on ring 0x%X\n",
93 @@ -321,8 +321,8 @@ static void bgmac_dma_rx_reset(struct bg
94 ring->mmio_base + BGMAC_DMA_RX_STATUS,
95 BGMAC_DMA_RX_STAT, BGMAC_DMA_RX_STAT_DISABLED,
97 - bgmac_err(bgmac, "Reset of ring 0x%X RX failed\n",
99 + dev_err(bgmac->dev, "Reset of ring 0x%X RX failed\n",
103 static void bgmac_dma_rx_enable(struct bgmac *bgmac,
104 @@ -371,7 +371,7 @@ static int bgmac_dma_rx_skb_for_slot(str
105 dma_addr = dma_map_single(dma_dev, buf + BGMAC_RX_BUF_OFFSET,
106 BGMAC_RX_BUF_SIZE, DMA_FROM_DEVICE);
107 if (dma_mapping_error(dma_dev, dma_addr)) {
108 - bgmac_err(bgmac, "DMA mapping error\n");
109 + netdev_err(bgmac->net_dev, "DMA mapping error\n");
110 put_page(virt_to_head_page(buf));
113 @@ -466,16 +466,16 @@ static int bgmac_dma_rx_read(struct bgma
115 /* Check for poison and drop or pass the packet */
116 if (len == 0xdead && flags == 0xbeef) {
117 - bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n",
119 + netdev_err(bgmac->net_dev, "Found poisoned packet at slot %d, DMA issue!\n",
121 put_page(virt_to_head_page(buf));
122 bgmac->net_dev->stats.rx_errors++;
126 if (len > BGMAC_RX_ALLOC_SIZE) {
127 - bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n",
129 + netdev_err(bgmac->net_dev, "Found oversized packet at slot %d, DMA issue!\n",
131 put_page(virt_to_head_page(buf));
132 bgmac->net_dev->stats.rx_length_errors++;
133 bgmac->net_dev->stats.rx_errors++;
134 @@ -487,7 +487,7 @@ static int bgmac_dma_rx_read(struct bgma
136 skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
137 if (unlikely(!skb)) {
138 - bgmac_err(bgmac, "build_skb failed\n");
139 + netdev_err(bgmac->net_dev, "build_skb failed\n");
140 put_page(virt_to_head_page(buf));
141 bgmac->net_dev->stats.rx_errors++;
143 @@ -641,7 +641,7 @@ static int bgmac_dma_alloc(struct bgmac
144 BUILD_BUG_ON(BGMAC_MAX_RX_RINGS > ARRAY_SIZE(ring_base));
146 if (!(bcma_aread32(bgmac->core, BCMA_IOST) & BCMA_IOST_DMA64)) {
147 - bgmac_err(bgmac, "Core does not report 64-bit DMA\n");
148 + dev_err(bgmac->dev, "Core does not report 64-bit DMA\n");
152 @@ -655,8 +655,8 @@ static int bgmac_dma_alloc(struct bgmac
155 if (!ring->cpu_base) {
156 - bgmac_err(bgmac, "Allocation of TX ring 0x%X failed\n",
158 + dev_err(bgmac->dev, "Allocation of TX ring 0x%X failed\n",
163 @@ -680,8 +680,8 @@ static int bgmac_dma_alloc(struct bgmac
166 if (!ring->cpu_base) {
167 - bgmac_err(bgmac, "Allocation of RX ring 0x%X failed\n",
169 + dev_err(bgmac->dev, "Allocation of RX ring 0x%X failed\n",
174 @@ -800,8 +800,8 @@ static u16 bgmac_phy_read(struct bgmac *
175 bcma_write32(core, phy_access_addr, tmp);
177 if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
178 - bgmac_err(bgmac, "Reading PHY %d register 0x%X failed\n",
180 + dev_err(bgmac->dev, "Reading PHY %d register 0x%X failed\n",
185 @@ -833,7 +833,7 @@ static int bgmac_phy_write(struct bgmac
187 bgmac_write(bgmac, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
188 if (bgmac_read(bgmac, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
189 - bgmac_warn(bgmac, "Error setting MDIO int\n");
190 + dev_warn(bgmac->dev, "Error setting MDIO int\n");
192 tmp = BGMAC_PA_START;
193 tmp |= BGMAC_PA_WRITE;
194 @@ -843,8 +843,8 @@ static int bgmac_phy_write(struct bgmac
195 bcma_write32(core, phy_access_addr, tmp);
197 if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
198 - bgmac_err(bgmac, "Writing to PHY %d register 0x%X failed\n",
200 + dev_err(bgmac->dev, "Writing to PHY %d register 0x%X failed\n",
205 @@ -897,7 +897,7 @@ static void bgmac_phy_reset(struct bgmac
206 bgmac_phy_write(bgmac, bgmac->phyaddr, MII_BMCR, BMCR_RESET);
208 if (bgmac_phy_read(bgmac, bgmac->phyaddr, MII_BMCR) & BMCR_RESET)
209 - bgmac_err(bgmac, "PHY reset failed\n");
210 + dev_err(bgmac->dev, "PHY reset failed\n");
211 bgmac_phy_init(bgmac);
214 @@ -998,7 +998,8 @@ static void bgmac_mac_speed(struct bgmac
215 set |= BGMAC_CMDCFG_ES_2500;
218 - bgmac_err(bgmac, "Unsupported speed: %d\n", bgmac->mac_speed);
219 + dev_err(bgmac->dev, "Unsupported speed: %d\n",
223 if (bgmac->mac_duplex == DUPLEX_HALF)
224 @@ -1097,8 +1098,8 @@ static void bgmac_chip_reset(struct bgma
226 if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
227 if (kstrtou8(buf, 0, &et_swtype))
228 - bgmac_err(bgmac, "Failed to parse et_swtype (%s)\n",
230 + dev_err(bgmac->dev, "Failed to parse et_swtype (%s)\n",
235 @@ -1261,7 +1262,7 @@ static irqreturn_t bgmac_interrupt(int i
237 int_status &= ~(BGMAC_IS_TX0 | BGMAC_IS_RX);
239 - bgmac_err(bgmac, "Unknown IRQs: 0x%08X\n", int_status);
240 + dev_err(bgmac->dev, "Unknown IRQs: 0x%08X\n", int_status);
242 /* Disable new interrupts until handling existing ones */
243 bgmac_chip_intrs_off(bgmac);
244 @@ -1315,7 +1316,7 @@ static int bgmac_open(struct net_device
245 err = request_irq(bgmac->core->irq, bgmac_interrupt, IRQF_SHARED,
246 KBUILD_MODNAME, net_dev);
248 - bgmac_err(bgmac, "IRQ request error: %d!\n", err);
249 + dev_err(bgmac->dev, "IRQ request error: %d!\n", err);
250 bgmac_dma_cleanup(bgmac);
253 @@ -1596,14 +1597,14 @@ static int bgmac_fixed_phy_register(stru
255 phy_dev = fixed_phy_register(PHY_POLL, &fphy_status, -1, NULL);
256 if (!phy_dev || IS_ERR(phy_dev)) {
257 - bgmac_err(bgmac, "Failed to register fixed PHY device\n");
258 + dev_err(bgmac->dev, "Failed to register fixed PHY device\n");
262 err = phy_connect_direct(bgmac->net_dev, phy_dev, bgmac_adjust_link,
263 PHY_INTERFACE_MODE_MII);
265 - bgmac_err(bgmac, "Connecting PHY failed\n");
266 + dev_err(bgmac->dev, "Connecting PHY failed\n");
270 @@ -1643,7 +1644,7 @@ static int bgmac_mii_register(struct bgm
272 err = mdiobus_register(mii_bus);
274 - bgmac_err(bgmac, "Registration of mii bus failed\n");
275 + dev_err(bgmac->dev, "Registration of mii bus failed\n");
279 @@ -1655,7 +1656,7 @@ static int bgmac_mii_register(struct bgm
280 phy_dev = phy_connect(bgmac->net_dev, bus_id, &bgmac_adjust_link,
281 PHY_INTERFACE_MODE_MII);
282 if (IS_ERR(phy_dev)) {
283 - bgmac_err(bgmac, "PHY connecton failed\n");
284 + dev_err(bgmac->dev, "PHY connecton failed\n");
285 err = PTR_ERR(phy_dev);
286 goto err_unregister_bus;
288 @@ -1704,7 +1705,8 @@ static int bgmac_probe(struct bcma_devic
292 - pr_err("Unsupported core_unit %d\n", core->core_unit);
293 + dev_err(&core->dev, "Unsupported core_unit %d\n",
298 @@ -1727,6 +1729,7 @@ static int bgmac_probe(struct bcma_devic
299 net_dev->irq = core->irq;
300 net_dev->ethtool_ops = &bgmac_ethtool_ops;
301 bgmac = netdev_priv(net_dev);
302 + bgmac->dev = &core->dev;
303 bgmac->net_dev = net_dev;
305 bcma_set_drvdata(core, bgmac);
306 @@ -1738,7 +1741,7 @@ static int bgmac_probe(struct bcma_devic
307 /* On BCM4706 we need common core to access PHY */
308 if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
309 !core->bus->drv_gmac_cmn.core) {
310 - bgmac_err(bgmac, "GMAC CMN core not found (required for BCM4706)\n");
311 + dev_err(bgmac->dev, "GMAC CMN core not found (required for BCM4706)\n");
313 goto err_netdev_free;
315 @@ -1757,15 +1760,15 @@ static int bgmac_probe(struct bcma_devic
317 bgmac->phyaddr &= BGMAC_PHY_MASK;
318 if (bgmac->phyaddr == BGMAC_PHY_MASK) {
319 - bgmac_err(bgmac, "No PHY found\n");
320 + dev_err(bgmac->dev, "No PHY found\n");
322 goto err_netdev_free;
324 - bgmac_info(bgmac, "Found PHY addr: %d%s\n", bgmac->phyaddr,
325 - bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
326 + dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
327 + bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
329 if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) {
330 - bgmac_err(bgmac, "PCI setup not implemented\n");
331 + dev_err(bgmac->dev, "PCI setup not implemented\n");
333 goto err_netdev_free;
335 @@ -1794,7 +1797,7 @@ static int bgmac_probe(struct bcma_devic
337 err = bgmac_dma_alloc(bgmac);
339 - bgmac_err(bgmac, "Unable to alloc memory for DMA\n");
340 + dev_err(bgmac->dev, "Unable to alloc memory for DMA\n");
341 goto err_netdev_free;
344 @@ -1808,16 +1811,16 @@ static int bgmac_probe(struct bcma_devic
345 bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo &
347 if (bgmac->has_robosw)
348 - bgmac_warn(bgmac, "Support for Roboswitch not implemented\n");
349 + dev_warn(bgmac->dev, "Support for Roboswitch not implemented\n");
351 if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
352 - bgmac_warn(bgmac, "Support for ADMtek ethernet switch not implemented\n");
353 + dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
355 netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
357 err = bgmac_mii_register(bgmac);
359 - bgmac_err(bgmac, "Cannot register MDIO\n");
360 + dev_err(bgmac->dev, "Cannot connect to phy\n");
364 @@ -1827,7 +1830,7 @@ static int bgmac_probe(struct bcma_devic
366 err = register_netdev(bgmac->net_dev);
368 - bgmac_err(bgmac, "Cannot register net device\n");
369 + dev_err(bgmac->dev, "Cannot register net device\n");
370 goto err_mii_unregister;
373 --- a/drivers/net/ethernet/broadcom/bgmac.h
374 +++ b/drivers/net/ethernet/broadcom/bgmac.h
379 -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
381 -#define bgmac_err(bgmac, fmt, ...) \
382 - dev_err(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
383 -#define bgmac_warn(bgmac, fmt, ...) \
384 - dev_warn(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
385 -#define bgmac_info(bgmac, fmt, ...) \
386 - dev_info(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
387 -#define bgmac_dbg(bgmac, fmt, ...) \
388 - dev_dbg(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
390 #include <linux/bcma/bcma.h>
391 #include <linux/brcmphy.h>
392 #include <linux/netdevice.h>
393 @@ -438,6 +427,8 @@ struct bgmac_rx_header {
395 struct bcma_device *core;
396 struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
398 + struct device *dev;
399 struct net_device *net_dev;
400 struct napi_struct napi;
401 struct mii_bus *mii_bus;
402 @@ -489,5 +480,4 @@ static inline void bgmac_set(struct bgma
404 bgmac_maskset(bgmac, offset, ~0, set);
407 #endif /* _BGMAC_H */