3837b6094358e1afc24b2088cd3587636473c66d
[librecmc/librecmc.git] /
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
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
12 well.
13
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>
19 ---
20  drivers/net/ethernet/broadcom/bgmac.c | 103 +++++++++++++++++-----------------
21  drivers/net/ethernet/broadcom/bgmac.h |  14 +----
22  2 files changed, 55 insertions(+), 62 deletions(-)
23
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
27                         return true;
28                 udelay(10);
29         }
30 -       pr_err("Timeout waiting for reg 0x%X\n", reg);
31 +       dev_err(&core->dev, "Timeout waiting for reg 0x%X\n", reg);
32         return false;
33  }
34  
35 @@ -84,8 +84,8 @@ static void bgmac_dma_tx_reset(struct bg
36                 udelay(10);
37         }
38         if (i)
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);
43  
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,
49                               10000)) {
50 -               bgmac_warn(bgmac, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
51 -                          ring->mmio_base);
52 +               dev_warn(bgmac->dev, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
53 +                        ring->mmio_base);
54                 udelay(300);
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",
58 -                                 ring->mmio_base);
59 +                       dev_err(bgmac->dev, "Reset of DMA TX ring 0x%X failed\n",
60 +                               ring->mmio_base);
61         }
62  }
63  
64 @@ -161,7 +161,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
65         int i;
66  
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);
70                 goto err_drop;
71         }
72  
73 @@ -174,7 +174,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
74          * even when ring->end overflows
75          */
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;
81         }
82 @@ -241,8 +241,8 @@ err_dma:
83         }
84  
85  err_dma_head:
86 -       bgmac_err(bgmac, "Mapping error of skb on ring 0x%X\n",
87 -                 ring->mmio_base);
88 +       netdev_err(bgmac->net_dev, "Mapping error of skb on ring 0x%X\n",
89 +                  ring->mmio_base);
90  
91  err_drop:
92         dev_kfree_skb(skb);
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,
96                               10000))
97 -               bgmac_err(bgmac, "Reset of ring 0x%X RX failed\n",
98 -                         ring->mmio_base);
99 +               dev_err(bgmac->dev, "Reset of ring 0x%X RX failed\n",
100 +                       ring->mmio_base);
101  }
102  
103  static void bgmac_dma_rx_enable(struct bgmac *bgmac,
104 @@ -374,7 +374,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));
111                 return -ENOMEM;
112         }
113 @@ -469,16 +469,16 @@ static int bgmac_dma_rx_read(struct bgma
114  
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",
118 -                                         ring->start);
119 +                               netdev_err(bgmac->net_dev, "Found poisoned packet at slot %d, DMA issue!\n",
120 +                                          ring->start);
121                                 put_page(virt_to_head_page(buf));
122                                 bgmac->net_dev->stats.rx_errors++;
123                                 break;
124                         }
125  
126                         if (len > BGMAC_RX_ALLOC_SIZE) {
127 -                               bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n",
128 -                                         ring->start);
129 +                               netdev_err(bgmac->net_dev, "Found oversized packet at slot %d, DMA issue!\n",
130 +                                          ring->start);
131                                 put_page(virt_to_head_page(buf));
132                                 bgmac->net_dev->stats.rx_length_errors++;
133                                 bgmac->net_dev->stats.rx_errors++;
134 @@ -490,7 +490,7 @@ static int bgmac_dma_rx_read(struct bgma
135  
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++;
142                                 break;
143 @@ -644,7 +644,7 @@ static int bgmac_dma_alloc(struct bgmac
144         BUILD_BUG_ON(BGMAC_MAX_RX_RINGS > ARRAY_SIZE(ring_base));
145  
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");
149                 return -ENOTSUPP;
150         }
151  
152 @@ -658,8 +658,8 @@ static int bgmac_dma_alloc(struct bgmac
153                                                      &ring->dma_base,
154                                                      GFP_KERNEL);
155                 if (!ring->cpu_base) {
156 -                       bgmac_err(bgmac, "Allocation of TX ring 0x%X failed\n",
157 -                                 ring->mmio_base);
158 +                       dev_err(bgmac->dev, "Allocation of TX ring 0x%X failed\n",
159 +                               ring->mmio_base);
160                         goto err_dma_free;
161                 }
162  
163 @@ -683,8 +683,8 @@ static int bgmac_dma_alloc(struct bgmac
164                                                      &ring->dma_base,
165                                                      GFP_KERNEL);
166                 if (!ring->cpu_base) {
167 -                       bgmac_err(bgmac, "Allocation of RX ring 0x%X failed\n",
168 -                                 ring->mmio_base);
169 +                       dev_err(bgmac->dev, "Allocation of RX ring 0x%X failed\n",
170 +                               ring->mmio_base);
171                         err = -ENOMEM;
172                         goto err_dma_free;
173                 }
174 @@ -803,8 +803,8 @@ static u16 bgmac_phy_read(struct bgmac *
175         bcma_write32(core, phy_access_addr, tmp);
176  
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",
179 -                         phyaddr, reg);
180 +               dev_err(bgmac->dev, "Reading PHY %d register 0x%X failed\n",
181 +                       phyaddr, reg);
182                 return 0xffff;
183         }
184  
185 @@ -836,7 +836,7 @@ static int bgmac_phy_write(struct bgmac
186  
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");
191  
192         tmp = BGMAC_PA_START;
193         tmp |= BGMAC_PA_WRITE;
194 @@ -846,8 +846,8 @@ static int bgmac_phy_write(struct bgmac
195         bcma_write32(core, phy_access_addr, tmp);
196  
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",
199 -                         phyaddr, reg);
200 +               dev_err(bgmac->dev, "Writing to PHY %d register 0x%X failed\n",
201 +                       phyaddr, reg);
202                 return -ETIMEDOUT;
203         }
204  
205 @@ -900,7 +900,7 @@ static void bgmac_phy_reset(struct bgmac
206         bgmac_phy_write(bgmac, bgmac->phyaddr, MII_BMCR, BMCR_RESET);
207         udelay(100);
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);
212  }
213  
214 @@ -1001,7 +1001,8 @@ static void bgmac_mac_speed(struct bgmac
215                 set |= BGMAC_CMDCFG_ES_2500;
216                 break;
217         default:
218 -               bgmac_err(bgmac, "Unsupported speed: %d\n", bgmac->mac_speed);
219 +               dev_err(bgmac->dev, "Unsupported speed: %d\n",
220 +                       bgmac->mac_speed);
221         }
222  
223         if (bgmac->mac_duplex == DUPLEX_HALF)
224 @@ -1100,8 +1101,8 @@ static void bgmac_chip_reset(struct bgma
225  
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",
229 -                                         buf);
230 +                               dev_err(bgmac->dev, "Failed to parse et_swtype (%s)\n",
231 +                                       buf);
232                         et_swtype &= 0x0f;
233                         et_swtype <<= 4;
234                         sw_type = et_swtype;
235 @@ -1264,7 +1265,7 @@ static irqreturn_t bgmac_interrupt(int i
236  
237         int_status &= ~(BGMAC_IS_TX0 | BGMAC_IS_RX);
238         if (int_status)
239 -               bgmac_err(bgmac, "Unknown IRQs: 0x%08X\n", int_status);
240 +               dev_err(bgmac->dev, "Unknown IRQs: 0x%08X\n", int_status);
241  
242         /* Disable new interrupts until handling existing ones */
243         bgmac_chip_intrs_off(bgmac);
244 @@ -1318,7 +1319,7 @@ static int bgmac_open(struct net_device
245         err = request_irq(bgmac->core->irq, bgmac_interrupt, IRQF_SHARED,
246                           KBUILD_MODNAME, net_dev);
247         if (err < 0) {
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);
251                 return err;
252         }
253 @@ -1599,14 +1600,14 @@ static int bgmac_fixed_phy_register(stru
254  
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");
259                 return -ENODEV;
260         }
261  
262         err = phy_connect_direct(bgmac->net_dev, phy_dev, bgmac_adjust_link,
263                                  PHY_INTERFACE_MODE_MII);
264         if (err) {
265 -               bgmac_err(bgmac, "Connecting PHY failed\n");
266 +               dev_err(bgmac->dev, "Connecting PHY failed\n");
267                 return err;
268         }
269  
270 @@ -1646,7 +1647,7 @@ static int bgmac_mii_register(struct bgm
271  
272         err = mdiobus_register(mii_bus);
273         if (err) {
274 -               bgmac_err(bgmac, "Registration of mii bus failed\n");
275 +               dev_err(bgmac->dev, "Registration of mii bus failed\n");
276                 goto err_free_irq;
277         }
278  
279 @@ -1658,7 +1659,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;
287         }
288 @@ -1707,7 +1708,8 @@ static int bgmac_probe(struct bcma_devic
289                 mac = sprom->et2mac;
290                 break;
291         default:
292 -               pr_err("Unsupported core_unit %d\n", core->core_unit);
293 +               dev_err(&core->dev, "Unsupported core_unit %d\n",
294 +                       core->core_unit);
295                 return -ENOTSUPP;
296         }
297  
298 @@ -1730,6 +1732,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;
304         bgmac->core = core;
305         bcma_set_drvdata(core, bgmac);
306 @@ -1741,7 +1744,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");
312                 err = -ENODEV;
313                 goto err_netdev_free;
314         }
315 @@ -1760,15 +1763,15 @@ static int bgmac_probe(struct bcma_devic
316         }
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");
321                 err = -ENODEV;
322                 goto err_netdev_free;
323         }
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)" : "");
328  
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");
332                 err = -ENOTSUPP;
333                 goto err_netdev_free;
334         }
335 @@ -1797,7 +1800,7 @@ static int bgmac_probe(struct bcma_devic
336  
337         err = bgmac_dma_alloc(bgmac);
338         if (err) {
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;
342         }
343  
344 @@ -1811,16 +1814,16 @@ static int bgmac_probe(struct bcma_devic
345         bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo &
346                                BGMAC_BFL_ENETROBO);
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");
350  
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");
354  
355         netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
356  
357         err = bgmac_mii_register(bgmac);
358         if (err) {
359 -               bgmac_err(bgmac, "Cannot register MDIO\n");
360 +               dev_err(bgmac->dev, "Cannot connect to phy\n");
361                 goto err_dma_free;
362         }
363  
364 @@ -1830,7 +1833,7 @@ static int bgmac_probe(struct bcma_devic
365  
366         err = register_netdev(bgmac->net_dev);
367         if (err) {
368 -               bgmac_err(bgmac, "Cannot register net device\n");
369 +               dev_err(bgmac->dev, "Cannot register net device\n");
370                 goto err_mii_unregister;
371         }
372  
373 --- a/drivers/net/ethernet/broadcom/bgmac.h
374 +++ b/drivers/net/ethernet/broadcom/bgmac.h
375 @@ -1,17 +1,6 @@
376  #ifndef _BGMAC_H
377  #define _BGMAC_H
378  
379 -#define pr_fmt(fmt)            KBUILD_MODNAME ": " fmt
380 -
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__)
389 -
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 {
394  struct bgmac {
395         struct bcma_device *core;
396         struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
397 +
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
403  {
404         bgmac_maskset(bgmac, offset, ~0, set);
405  }
406 -
407  #endif /* _BGMAC_H */