.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
---|
1 | 2 | /* |
---|
2 | 3 | * Microchip ENC28J60 ethernet driver (MAC + PHY) |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2007 Eurek srl |
---|
5 | 6 | * Author: Claudio Lanconelli <lanconelli.claudio@eptar.com> |
---|
6 | 7 | * based on enc28j60.c written by David Anders for 2.4 kernel version |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify |
---|
9 | | - * it under the terms of the GNU General Public License as published by |
---|
10 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
11 | | - * (at your option) any later version. |
---|
12 | 8 | * |
---|
13 | 9 | * $Id: enc28j60.c,v 1.22 2007/12/20 10:47:01 claudio Exp $ |
---|
14 | 10 | */ |
---|
.. | .. |
---|
18 | 14 | #include <linux/types.h> |
---|
19 | 15 | #include <linux/fcntl.h> |
---|
20 | 16 | #include <linux/interrupt.h> |
---|
| 17 | +#include <linux/property.h> |
---|
21 | 18 | #include <linux/string.h> |
---|
22 | 19 | #include <linux/errno.h> |
---|
23 | | -#include <linux/init.h> |
---|
24 | 20 | #include <linux/netdevice.h> |
---|
25 | 21 | #include <linux/etherdevice.h> |
---|
26 | 22 | #include <linux/ethtool.h> |
---|
.. | .. |
---|
28 | 24 | #include <linux/skbuff.h> |
---|
29 | 25 | #include <linux/delay.h> |
---|
30 | 26 | #include <linux/spi/spi.h> |
---|
31 | | -#include <linux/of_net.h> |
---|
32 | 27 | |
---|
33 | 28 | #include "enc28j60_hw.h" |
---|
34 | 29 | |
---|
.. | .. |
---|
41 | 36 | (NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN | NETIF_MSG_LINK) |
---|
42 | 37 | |
---|
43 | 38 | /* Buffer size required for the largest SPI transfer (i.e., reading a |
---|
44 | | - * frame). */ |
---|
| 39 | + * frame). |
---|
| 40 | + */ |
---|
45 | 41 | #define SPI_TRANSFER_BUF_LEN (4 + MAX_FRAMELEN) |
---|
46 | 42 | |
---|
47 | | -#define TX_TIMEOUT (4 * HZ) |
---|
| 43 | +#define TX_TIMEOUT (4 * HZ) |
---|
48 | 44 | |
---|
49 | 45 | /* Max TX retries in case of collision as suggested by errata datasheet */ |
---|
50 | 46 | #define MAX_TX_RETRYCOUNT 16 |
---|
.. | .. |
---|
83 | 79 | |
---|
84 | 80 | /* |
---|
85 | 81 | * SPI read buffer |
---|
86 | | - * wait for the SPI transfer and copy received data to destination |
---|
| 82 | + * Wait for the SPI transfer and copy received data to destination. |
---|
87 | 83 | */ |
---|
88 | 84 | static int |
---|
89 | 85 | spi_read_buf(struct enc28j60_net *priv, int len, u8 *data) |
---|
90 | 86 | { |
---|
| 87 | + struct device *dev = &priv->spi->dev; |
---|
91 | 88 | u8 *rx_buf = priv->spi_transfer_buf + 4; |
---|
92 | 89 | u8 *tx_buf = priv->spi_transfer_buf; |
---|
93 | 90 | struct spi_transfer tx = { |
---|
.. | .. |
---|
113 | 110 | ret = msg.status; |
---|
114 | 111 | } |
---|
115 | 112 | if (ret && netif_msg_drv(priv)) |
---|
116 | | - printk(KERN_DEBUG DRV_NAME ": %s() failed: ret = %d\n", |
---|
117 | | - __func__, ret); |
---|
| 113 | + dev_printk(KERN_DEBUG, dev, "%s() failed: ret = %d\n", |
---|
| 114 | + __func__, ret); |
---|
118 | 115 | |
---|
119 | 116 | return ret; |
---|
120 | 117 | } |
---|
.. | .. |
---|
122 | 119 | /* |
---|
123 | 120 | * SPI write buffer |
---|
124 | 121 | */ |
---|
125 | | -static int spi_write_buf(struct enc28j60_net *priv, int len, |
---|
126 | | - const u8 *data) |
---|
| 122 | +static int spi_write_buf(struct enc28j60_net *priv, int len, const u8 *data) |
---|
127 | 123 | { |
---|
| 124 | + struct device *dev = &priv->spi->dev; |
---|
128 | 125 | int ret; |
---|
129 | 126 | |
---|
130 | 127 | if (len > SPI_TRANSFER_BUF_LEN - 1 || len <= 0) |
---|
.. | .. |
---|
134 | 131 | memcpy(&priv->spi_transfer_buf[1], data, len); |
---|
135 | 132 | ret = spi_write(priv->spi, priv->spi_transfer_buf, len + 1); |
---|
136 | 133 | if (ret && netif_msg_drv(priv)) |
---|
137 | | - printk(KERN_DEBUG DRV_NAME ": %s() failed: ret = %d\n", |
---|
138 | | - __func__, ret); |
---|
| 134 | + dev_printk(KERN_DEBUG, dev, "%s() failed: ret = %d\n", |
---|
| 135 | + __func__, ret); |
---|
139 | 136 | } |
---|
140 | 137 | return ret; |
---|
141 | 138 | } |
---|
.. | .. |
---|
143 | 140 | /* |
---|
144 | 141 | * basic SPI read operation |
---|
145 | 142 | */ |
---|
146 | | -static u8 spi_read_op(struct enc28j60_net *priv, u8 op, |
---|
147 | | - u8 addr) |
---|
| 143 | +static u8 spi_read_op(struct enc28j60_net *priv, u8 op, u8 addr) |
---|
148 | 144 | { |
---|
| 145 | + struct device *dev = &priv->spi->dev; |
---|
149 | 146 | u8 tx_buf[2]; |
---|
150 | 147 | u8 rx_buf[4]; |
---|
151 | 148 | u8 val = 0; |
---|
.. | .. |
---|
159 | 156 | tx_buf[0] = op | (addr & ADDR_MASK); |
---|
160 | 157 | ret = spi_write_then_read(priv->spi, tx_buf, 1, rx_buf, slen); |
---|
161 | 158 | if (ret) |
---|
162 | | - printk(KERN_DEBUG DRV_NAME ": %s() failed: ret = %d\n", |
---|
163 | | - __func__, ret); |
---|
| 159 | + dev_printk(KERN_DEBUG, dev, "%s() failed: ret = %d\n", |
---|
| 160 | + __func__, ret); |
---|
164 | 161 | else |
---|
165 | 162 | val = rx_buf[slen - 1]; |
---|
166 | 163 | |
---|
.. | .. |
---|
170 | 167 | /* |
---|
171 | 168 | * basic SPI write operation |
---|
172 | 169 | */ |
---|
173 | | -static int spi_write_op(struct enc28j60_net *priv, u8 op, |
---|
174 | | - u8 addr, u8 val) |
---|
| 170 | +static int spi_write_op(struct enc28j60_net *priv, u8 op, u8 addr, u8 val) |
---|
175 | 171 | { |
---|
| 172 | + struct device *dev = &priv->spi->dev; |
---|
176 | 173 | int ret; |
---|
177 | 174 | |
---|
178 | 175 | priv->spi_transfer_buf[0] = op | (addr & ADDR_MASK); |
---|
179 | 176 | priv->spi_transfer_buf[1] = val; |
---|
180 | 177 | ret = spi_write(priv->spi, priv->spi_transfer_buf, 2); |
---|
181 | 178 | if (ret && netif_msg_drv(priv)) |
---|
182 | | - printk(KERN_DEBUG DRV_NAME ": %s() failed: ret = %d\n", |
---|
183 | | - __func__, ret); |
---|
| 179 | + dev_printk(KERN_DEBUG, dev, "%s() failed: ret = %d\n", |
---|
| 180 | + __func__, ret); |
---|
184 | 181 | return ret; |
---|
185 | 182 | } |
---|
186 | 183 | |
---|
187 | 184 | static void enc28j60_soft_reset(struct enc28j60_net *priv) |
---|
188 | 185 | { |
---|
189 | | - if (netif_msg_hw(priv)) |
---|
190 | | - printk(KERN_DEBUG DRV_NAME ": %s() enter\n", __func__); |
---|
191 | | - |
---|
192 | 186 | spi_write_op(priv, ENC28J60_SOFT_RESET, 0, ENC28J60_SOFT_RESET); |
---|
193 | 187 | /* Errata workaround #1, CLKRDY check is unreliable, |
---|
194 | | - * delay at least 1 mS instead */ |
---|
| 188 | + * delay at least 1 ms instead */ |
---|
195 | 189 | udelay(2000); |
---|
196 | 190 | } |
---|
197 | 191 | |
---|
.. | .. |
---|
203 | 197 | u8 b = (addr & BANK_MASK) >> 5; |
---|
204 | 198 | |
---|
205 | 199 | /* These registers (EIE, EIR, ESTAT, ECON2, ECON1) |
---|
206 | | - * are present in all banks, no need to switch bank |
---|
| 200 | + * are present in all banks, no need to switch bank. |
---|
207 | 201 | */ |
---|
208 | 202 | if (addr >= EIE && addr <= ECON1) |
---|
209 | 203 | return; |
---|
.. | .. |
---|
242 | 236 | /* |
---|
243 | 237 | * Register bit field Set |
---|
244 | 238 | */ |
---|
245 | | -static void nolock_reg_bfset(struct enc28j60_net *priv, |
---|
246 | | - u8 addr, u8 mask) |
---|
| 239 | +static void nolock_reg_bfset(struct enc28j60_net *priv, u8 addr, u8 mask) |
---|
247 | 240 | { |
---|
248 | 241 | enc28j60_set_bank(priv, addr); |
---|
249 | 242 | spi_write_op(priv, ENC28J60_BIT_FIELD_SET, addr, mask); |
---|
250 | 243 | } |
---|
251 | 244 | |
---|
252 | | -static void locked_reg_bfset(struct enc28j60_net *priv, |
---|
253 | | - u8 addr, u8 mask) |
---|
| 245 | +static void locked_reg_bfset(struct enc28j60_net *priv, u8 addr, u8 mask) |
---|
254 | 246 | { |
---|
255 | 247 | mutex_lock(&priv->lock); |
---|
256 | 248 | nolock_reg_bfset(priv, addr, mask); |
---|
.. | .. |
---|
260 | 252 | /* |
---|
261 | 253 | * Register bit field Clear |
---|
262 | 254 | */ |
---|
263 | | -static void nolock_reg_bfclr(struct enc28j60_net *priv, |
---|
264 | | - u8 addr, u8 mask) |
---|
| 255 | +static void nolock_reg_bfclr(struct enc28j60_net *priv, u8 addr, u8 mask) |
---|
265 | 256 | { |
---|
266 | 257 | enc28j60_set_bank(priv, addr); |
---|
267 | 258 | spi_write_op(priv, ENC28J60_BIT_FIELD_CLR, addr, mask); |
---|
268 | 259 | } |
---|
269 | 260 | |
---|
270 | | -static void locked_reg_bfclr(struct enc28j60_net *priv, |
---|
271 | | - u8 addr, u8 mask) |
---|
| 261 | +static void locked_reg_bfclr(struct enc28j60_net *priv, u8 addr, u8 mask) |
---|
272 | 262 | { |
---|
273 | 263 | mutex_lock(&priv->lock); |
---|
274 | 264 | nolock_reg_bfclr(priv, addr, mask); |
---|
.. | .. |
---|
278 | 268 | /* |
---|
279 | 269 | * Register byte read |
---|
280 | 270 | */ |
---|
281 | | -static int nolock_regb_read(struct enc28j60_net *priv, |
---|
282 | | - u8 address) |
---|
| 271 | +static int nolock_regb_read(struct enc28j60_net *priv, u8 address) |
---|
283 | 272 | { |
---|
284 | 273 | enc28j60_set_bank(priv, address); |
---|
285 | 274 | return spi_read_op(priv, ENC28J60_READ_CTRL_REG, address); |
---|
286 | 275 | } |
---|
287 | 276 | |
---|
288 | | -static int locked_regb_read(struct enc28j60_net *priv, |
---|
289 | | - u8 address) |
---|
| 277 | +static int locked_regb_read(struct enc28j60_net *priv, u8 address) |
---|
290 | 278 | { |
---|
291 | 279 | int ret; |
---|
292 | 280 | |
---|
.. | .. |
---|
300 | 288 | /* |
---|
301 | 289 | * Register word read |
---|
302 | 290 | */ |
---|
303 | | -static int nolock_regw_read(struct enc28j60_net *priv, |
---|
304 | | - u8 address) |
---|
| 291 | +static int nolock_regw_read(struct enc28j60_net *priv, u8 address) |
---|
305 | 292 | { |
---|
306 | 293 | int rl, rh; |
---|
307 | 294 | |
---|
.. | .. |
---|
312 | 299 | return (rh << 8) | rl; |
---|
313 | 300 | } |
---|
314 | 301 | |
---|
315 | | -static int locked_regw_read(struct enc28j60_net *priv, |
---|
316 | | - u8 address) |
---|
| 302 | +static int locked_regw_read(struct enc28j60_net *priv, u8 address) |
---|
317 | 303 | { |
---|
318 | 304 | int ret; |
---|
319 | 305 | |
---|
.. | .. |
---|
327 | 313 | /* |
---|
328 | 314 | * Register byte write |
---|
329 | 315 | */ |
---|
330 | | -static void nolock_regb_write(struct enc28j60_net *priv, |
---|
331 | | - u8 address, u8 data) |
---|
| 316 | +static void nolock_regb_write(struct enc28j60_net *priv, u8 address, u8 data) |
---|
332 | 317 | { |
---|
333 | 318 | enc28j60_set_bank(priv, address); |
---|
334 | 319 | spi_write_op(priv, ENC28J60_WRITE_CTRL_REG, address, data); |
---|
335 | 320 | } |
---|
336 | 321 | |
---|
337 | | -static void locked_regb_write(struct enc28j60_net *priv, |
---|
338 | | - u8 address, u8 data) |
---|
| 322 | +static void locked_regb_write(struct enc28j60_net *priv, u8 address, u8 data) |
---|
339 | 323 | { |
---|
340 | 324 | mutex_lock(&priv->lock); |
---|
341 | 325 | nolock_regb_write(priv, address, data); |
---|
.. | .. |
---|
345 | 329 | /* |
---|
346 | 330 | * Register word write |
---|
347 | 331 | */ |
---|
348 | | -static void nolock_regw_write(struct enc28j60_net *priv, |
---|
349 | | - u8 address, u16 data) |
---|
| 332 | +static void nolock_regw_write(struct enc28j60_net *priv, u8 address, u16 data) |
---|
350 | 333 | { |
---|
351 | 334 | enc28j60_set_bank(priv, address); |
---|
352 | 335 | spi_write_op(priv, ENC28J60_WRITE_CTRL_REG, address, (u8) data); |
---|
.. | .. |
---|
354 | 337 | (u8) (data >> 8)); |
---|
355 | 338 | } |
---|
356 | 339 | |
---|
357 | | -static void locked_regw_write(struct enc28j60_net *priv, |
---|
358 | | - u8 address, u16 data) |
---|
| 340 | +static void locked_regw_write(struct enc28j60_net *priv, u8 address, u16 data) |
---|
359 | 341 | { |
---|
360 | 342 | mutex_lock(&priv->lock); |
---|
361 | 343 | nolock_regw_write(priv, address, data); |
---|
.. | .. |
---|
364 | 346 | |
---|
365 | 347 | /* |
---|
366 | 348 | * Buffer memory read |
---|
367 | | - * Select the starting address and execute a SPI buffer read |
---|
| 349 | + * Select the starting address and execute a SPI buffer read. |
---|
368 | 350 | */ |
---|
369 | | -static void enc28j60_mem_read(struct enc28j60_net *priv, |
---|
370 | | - u16 addr, int len, u8 *data) |
---|
| 351 | +static void enc28j60_mem_read(struct enc28j60_net *priv, u16 addr, int len, |
---|
| 352 | + u8 *data) |
---|
371 | 353 | { |
---|
372 | 354 | mutex_lock(&priv->lock); |
---|
373 | 355 | nolock_regw_write(priv, ERDPTL, addr); |
---|
374 | 356 | #ifdef CONFIG_ENC28J60_WRITEVERIFY |
---|
375 | 357 | if (netif_msg_drv(priv)) { |
---|
| 358 | + struct device *dev = &priv->spi->dev; |
---|
376 | 359 | u16 reg; |
---|
| 360 | + |
---|
377 | 361 | reg = nolock_regw_read(priv, ERDPTL); |
---|
378 | 362 | if (reg != addr) |
---|
379 | | - printk(KERN_DEBUG DRV_NAME ": %s() error writing ERDPT " |
---|
380 | | - "(0x%04x - 0x%04x)\n", __func__, reg, addr); |
---|
| 363 | + dev_printk(KERN_DEBUG, dev, |
---|
| 364 | + "%s() error writing ERDPT (0x%04x - 0x%04x)\n", |
---|
| 365 | + __func__, reg, addr); |
---|
381 | 366 | } |
---|
382 | 367 | #endif |
---|
383 | 368 | spi_read_buf(priv, len, data); |
---|
.. | .. |
---|
390 | 375 | static void |
---|
391 | 376 | enc28j60_packet_write(struct enc28j60_net *priv, int len, const u8 *data) |
---|
392 | 377 | { |
---|
| 378 | + struct device *dev = &priv->spi->dev; |
---|
| 379 | + |
---|
393 | 380 | mutex_lock(&priv->lock); |
---|
394 | 381 | /* Set the write pointer to start of transmit buffer area */ |
---|
395 | 382 | nolock_regw_write(priv, EWRPTL, TXSTART_INIT); |
---|
.. | .. |
---|
398 | 385 | u16 reg; |
---|
399 | 386 | reg = nolock_regw_read(priv, EWRPTL); |
---|
400 | 387 | if (reg != TXSTART_INIT) |
---|
401 | | - printk(KERN_DEBUG DRV_NAME |
---|
402 | | - ": %s() ERWPT:0x%04x != 0x%04x\n", |
---|
403 | | - __func__, reg, TXSTART_INIT); |
---|
| 388 | + dev_printk(KERN_DEBUG, dev, |
---|
| 389 | + "%s() ERWPT:0x%04x != 0x%04x\n", |
---|
| 390 | + __func__, reg, TXSTART_INIT); |
---|
404 | 391 | } |
---|
405 | 392 | #endif |
---|
406 | 393 | /* Set the TXND pointer to correspond to the packet size given */ |
---|
.. | .. |
---|
408 | 395 | /* write per-packet control byte */ |
---|
409 | 396 | spi_write_op(priv, ENC28J60_WRITE_BUF_MEM, 0, 0x00); |
---|
410 | 397 | if (netif_msg_hw(priv)) |
---|
411 | | - printk(KERN_DEBUG DRV_NAME |
---|
412 | | - ": %s() after control byte ERWPT:0x%04x\n", |
---|
413 | | - __func__, nolock_regw_read(priv, EWRPTL)); |
---|
| 398 | + dev_printk(KERN_DEBUG, dev, |
---|
| 399 | + "%s() after control byte ERWPT:0x%04x\n", |
---|
| 400 | + __func__, nolock_regw_read(priv, EWRPTL)); |
---|
414 | 401 | /* copy the packet into the transmit buffer */ |
---|
415 | 402 | spi_write_buf(priv, len, data); |
---|
416 | 403 | if (netif_msg_hw(priv)) |
---|
417 | | - printk(KERN_DEBUG DRV_NAME |
---|
418 | | - ": %s() after write packet ERWPT:0x%04x, len=%d\n", |
---|
419 | | - __func__, nolock_regw_read(priv, EWRPTL), len); |
---|
| 404 | + dev_printk(KERN_DEBUG, dev, |
---|
| 405 | + "%s() after write packet ERWPT:0x%04x, len=%d\n", |
---|
| 406 | + __func__, nolock_regw_read(priv, EWRPTL), len); |
---|
420 | 407 | mutex_unlock(&priv->lock); |
---|
421 | 408 | } |
---|
422 | 409 | |
---|
423 | | -static unsigned long msec20_to_jiffies; |
---|
424 | | - |
---|
425 | 410 | static int poll_ready(struct enc28j60_net *priv, u8 reg, u8 mask, u8 val) |
---|
426 | 411 | { |
---|
427 | | - unsigned long timeout = jiffies + msec20_to_jiffies; |
---|
| 412 | + struct device *dev = &priv->spi->dev; |
---|
| 413 | + unsigned long timeout = jiffies + msecs_to_jiffies(20); |
---|
428 | 414 | |
---|
429 | 415 | /* 20 msec timeout read */ |
---|
430 | 416 | while ((nolock_regb_read(priv, reg) & mask) != val) { |
---|
431 | 417 | if (time_after(jiffies, timeout)) { |
---|
432 | 418 | if (netif_msg_drv(priv)) |
---|
433 | | - dev_dbg(&priv->spi->dev, |
---|
434 | | - "reg %02x ready timeout!\n", reg); |
---|
| 419 | + dev_dbg(dev, "reg %02x ready timeout!\n", reg); |
---|
435 | 420 | return -ETIMEDOUT; |
---|
436 | 421 | } |
---|
437 | 422 | cpu_relax(); |
---|
.. | .. |
---|
449 | 434 | |
---|
450 | 435 | /* |
---|
451 | 436 | * PHY register read |
---|
452 | | - * PHY registers are not accessed directly, but through the MII |
---|
| 437 | + * PHY registers are not accessed directly, but through the MII. |
---|
453 | 438 | */ |
---|
454 | 439 | static u16 enc28j60_phy_read(struct enc28j60_net *priv, u8 address) |
---|
455 | 440 | { |
---|
.. | .. |
---|
465 | 450 | /* quit reading */ |
---|
466 | 451 | nolock_regb_write(priv, MICMD, 0x00); |
---|
467 | 452 | /* return the data */ |
---|
468 | | - ret = nolock_regw_read(priv, MIRDL); |
---|
| 453 | + ret = nolock_regw_read(priv, MIRDL); |
---|
469 | 454 | mutex_unlock(&priv->lock); |
---|
470 | 455 | |
---|
471 | 456 | return ret; |
---|
.. | .. |
---|
494 | 479 | { |
---|
495 | 480 | int ret; |
---|
496 | 481 | struct enc28j60_net *priv = netdev_priv(ndev); |
---|
| 482 | + struct device *dev = &priv->spi->dev; |
---|
497 | 483 | |
---|
498 | 484 | mutex_lock(&priv->lock); |
---|
499 | 485 | if (!priv->hw_enable) { |
---|
500 | 486 | if (netif_msg_drv(priv)) |
---|
501 | | - printk(KERN_INFO DRV_NAME |
---|
502 | | - ": %s: Setting MAC address to %pM\n", |
---|
503 | | - ndev->name, ndev->dev_addr); |
---|
| 487 | + dev_info(dev, "%s: Setting MAC address to %pM\n", |
---|
| 488 | + ndev->name, ndev->dev_addr); |
---|
504 | 489 | /* NOTE: MAC address in ENC28J60 is byte-backward */ |
---|
505 | 490 | nolock_regb_write(priv, MAADR5, ndev->dev_addr[0]); |
---|
506 | 491 | nolock_regb_write(priv, MAADR4, ndev->dev_addr[1]); |
---|
.. | .. |
---|
511 | 496 | ret = 0; |
---|
512 | 497 | } else { |
---|
513 | 498 | if (netif_msg_drv(priv)) |
---|
514 | | - printk(KERN_DEBUG DRV_NAME |
---|
515 | | - ": %s() Hardware must be disabled to set " |
---|
516 | | - "Mac address\n", __func__); |
---|
| 499 | + dev_printk(KERN_DEBUG, dev, |
---|
| 500 | + "%s() Hardware must be disabled to set Mac address\n", |
---|
| 501 | + __func__); |
---|
517 | 502 | ret = -EBUSY; |
---|
518 | 503 | } |
---|
519 | 504 | mutex_unlock(&priv->lock); |
---|
.. | .. |
---|
532 | 517 | if (!is_valid_ether_addr(address->sa_data)) |
---|
533 | 518 | return -EADDRNOTAVAIL; |
---|
534 | 519 | |
---|
535 | | - memcpy(dev->dev_addr, address->sa_data, dev->addr_len); |
---|
| 520 | + ether_addr_copy(dev->dev_addr, address->sa_data); |
---|
536 | 521 | return enc28j60_set_hw_macaddr(dev); |
---|
537 | 522 | } |
---|
538 | 523 | |
---|
.. | .. |
---|
541 | 526 | */ |
---|
542 | 527 | static void enc28j60_dump_regs(struct enc28j60_net *priv, const char *msg) |
---|
543 | 528 | { |
---|
| 529 | + struct device *dev = &priv->spi->dev; |
---|
| 530 | + |
---|
544 | 531 | mutex_lock(&priv->lock); |
---|
545 | | - printk(KERN_DEBUG DRV_NAME " %s\n" |
---|
546 | | - "HwRevID: 0x%02x\n" |
---|
547 | | - "Cntrl: ECON1 ECON2 ESTAT EIR EIE\n" |
---|
548 | | - " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n" |
---|
549 | | - "MAC : MACON1 MACON3 MACON4\n" |
---|
550 | | - " 0x%02x 0x%02x 0x%02x\n" |
---|
551 | | - "Rx : ERXST ERXND ERXWRPT ERXRDPT ERXFCON EPKTCNT MAMXFL\n" |
---|
552 | | - " 0x%04x 0x%04x 0x%04x 0x%04x " |
---|
553 | | - "0x%02x 0x%02x 0x%04x\n" |
---|
554 | | - "Tx : ETXST ETXND MACLCON1 MACLCON2 MAPHSUP\n" |
---|
555 | | - " 0x%04x 0x%04x 0x%02x 0x%02x 0x%02x\n", |
---|
556 | | - msg, nolock_regb_read(priv, EREVID), |
---|
557 | | - nolock_regb_read(priv, ECON1), nolock_regb_read(priv, ECON2), |
---|
558 | | - nolock_regb_read(priv, ESTAT), nolock_regb_read(priv, EIR), |
---|
559 | | - nolock_regb_read(priv, EIE), nolock_regb_read(priv, MACON1), |
---|
560 | | - nolock_regb_read(priv, MACON3), nolock_regb_read(priv, MACON4), |
---|
561 | | - nolock_regw_read(priv, ERXSTL), nolock_regw_read(priv, ERXNDL), |
---|
562 | | - nolock_regw_read(priv, ERXWRPTL), |
---|
563 | | - nolock_regw_read(priv, ERXRDPTL), |
---|
564 | | - nolock_regb_read(priv, ERXFCON), |
---|
565 | | - nolock_regb_read(priv, EPKTCNT), |
---|
566 | | - nolock_regw_read(priv, MAMXFLL), nolock_regw_read(priv, ETXSTL), |
---|
567 | | - nolock_regw_read(priv, ETXNDL), |
---|
568 | | - nolock_regb_read(priv, MACLCON1), |
---|
569 | | - nolock_regb_read(priv, MACLCON2), |
---|
570 | | - nolock_regb_read(priv, MAPHSUP)); |
---|
| 532 | + dev_printk(KERN_DEBUG, dev, |
---|
| 533 | + " %s\n" |
---|
| 534 | + "HwRevID: 0x%02x\n" |
---|
| 535 | + "Cntrl: ECON1 ECON2 ESTAT EIR EIE\n" |
---|
| 536 | + " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n" |
---|
| 537 | + "MAC : MACON1 MACON3 MACON4\n" |
---|
| 538 | + " 0x%02x 0x%02x 0x%02x\n" |
---|
| 539 | + "Rx : ERXST ERXND ERXWRPT ERXRDPT ERXFCON EPKTCNT MAMXFL\n" |
---|
| 540 | + " 0x%04x 0x%04x 0x%04x 0x%04x " |
---|
| 541 | + "0x%02x 0x%02x 0x%04x\n" |
---|
| 542 | + "Tx : ETXST ETXND MACLCON1 MACLCON2 MAPHSUP\n" |
---|
| 543 | + " 0x%04x 0x%04x 0x%02x 0x%02x 0x%02x\n", |
---|
| 544 | + msg, nolock_regb_read(priv, EREVID), |
---|
| 545 | + nolock_regb_read(priv, ECON1), nolock_regb_read(priv, ECON2), |
---|
| 546 | + nolock_regb_read(priv, ESTAT), nolock_regb_read(priv, EIR), |
---|
| 547 | + nolock_regb_read(priv, EIE), nolock_regb_read(priv, MACON1), |
---|
| 548 | + nolock_regb_read(priv, MACON3), nolock_regb_read(priv, MACON4), |
---|
| 549 | + nolock_regw_read(priv, ERXSTL), nolock_regw_read(priv, ERXNDL), |
---|
| 550 | + nolock_regw_read(priv, ERXWRPTL), |
---|
| 551 | + nolock_regw_read(priv, ERXRDPTL), |
---|
| 552 | + nolock_regb_read(priv, ERXFCON), |
---|
| 553 | + nolock_regb_read(priv, EPKTCNT), |
---|
| 554 | + nolock_regw_read(priv, MAMXFLL), nolock_regw_read(priv, ETXSTL), |
---|
| 555 | + nolock_regw_read(priv, ETXNDL), |
---|
| 556 | + nolock_regb_read(priv, MACLCON1), |
---|
| 557 | + nolock_regb_read(priv, MACLCON2), |
---|
| 558 | + nolock_regb_read(priv, MAPHSUP)); |
---|
571 | 559 | mutex_unlock(&priv->lock); |
---|
572 | 560 | } |
---|
573 | 561 | |
---|
.. | .. |
---|
599 | 587 | |
---|
600 | 588 | static void nolock_rxfifo_init(struct enc28j60_net *priv, u16 start, u16 end) |
---|
601 | 589 | { |
---|
| 590 | + struct device *dev = &priv->spi->dev; |
---|
602 | 591 | u16 erxrdpt; |
---|
603 | 592 | |
---|
604 | 593 | if (start > 0x1FFF || end > 0x1FFF || start > end) { |
---|
605 | 594 | if (netif_msg_drv(priv)) |
---|
606 | | - printk(KERN_ERR DRV_NAME ": %s(%d, %d) RXFIFO " |
---|
607 | | - "bad parameters!\n", __func__, start, end); |
---|
| 595 | + dev_err(dev, "%s(%d, %d) RXFIFO bad parameters!\n", |
---|
| 596 | + __func__, start, end); |
---|
608 | 597 | return; |
---|
609 | 598 | } |
---|
610 | 599 | /* set receive buffer start + end */ |
---|
.. | .. |
---|
617 | 606 | |
---|
618 | 607 | static void nolock_txfifo_init(struct enc28j60_net *priv, u16 start, u16 end) |
---|
619 | 608 | { |
---|
| 609 | + struct device *dev = &priv->spi->dev; |
---|
| 610 | + |
---|
620 | 611 | if (start > 0x1FFF || end > 0x1FFF || start > end) { |
---|
621 | 612 | if (netif_msg_drv(priv)) |
---|
622 | | - printk(KERN_ERR DRV_NAME ": %s(%d, %d) TXFIFO " |
---|
623 | | - "bad parameters!\n", __func__, start, end); |
---|
| 613 | + dev_err(dev, "%s(%d, %d) TXFIFO bad parameters!\n", |
---|
| 614 | + __func__, start, end); |
---|
624 | 615 | return; |
---|
625 | 616 | } |
---|
626 | 617 | /* set transmit buffer start + end */ |
---|
.. | .. |
---|
630 | 621 | |
---|
631 | 622 | /* |
---|
632 | 623 | * Low power mode shrinks power consumption about 100x, so we'd like |
---|
633 | | - * the chip to be in that mode whenever it's inactive. (However, we |
---|
634 | | - * can't stay in lowpower mode during suspend with WOL active.) |
---|
| 624 | + * the chip to be in that mode whenever it's inactive. (However, we |
---|
| 625 | + * can't stay in low power mode during suspend with WOL active.) |
---|
635 | 626 | */ |
---|
636 | 627 | static void enc28j60_lowpower(struct enc28j60_net *priv, bool is_low) |
---|
637 | 628 | { |
---|
| 629 | + struct device *dev = &priv->spi->dev; |
---|
| 630 | + |
---|
638 | 631 | if (netif_msg_drv(priv)) |
---|
639 | | - dev_dbg(&priv->spi->dev, "%s power...\n", |
---|
640 | | - is_low ? "low" : "high"); |
---|
| 632 | + dev_dbg(dev, "%s power...\n", is_low ? "low" : "high"); |
---|
641 | 633 | |
---|
642 | 634 | mutex_lock(&priv->lock); |
---|
643 | 635 | if (is_low) { |
---|
.. | .. |
---|
656 | 648 | |
---|
657 | 649 | static int enc28j60_hw_init(struct enc28j60_net *priv) |
---|
658 | 650 | { |
---|
| 651 | + struct device *dev = &priv->spi->dev; |
---|
659 | 652 | u8 reg; |
---|
660 | 653 | |
---|
661 | 654 | if (netif_msg_drv(priv)) |
---|
662 | | - printk(KERN_DEBUG DRV_NAME ": %s() - %s\n", __func__, |
---|
663 | | - priv->full_duplex ? "FullDuplex" : "HalfDuplex"); |
---|
| 655 | + dev_printk(KERN_DEBUG, dev, "%s() - %s\n", __func__, |
---|
| 656 | + priv->full_duplex ? "FullDuplex" : "HalfDuplex"); |
---|
664 | 657 | |
---|
665 | 658 | mutex_lock(&priv->lock); |
---|
666 | 659 | /* first reset the chip */ |
---|
.. | .. |
---|
682 | 675 | /* |
---|
683 | 676 | * Check the RevID. |
---|
684 | 677 | * If it's 0x00 or 0xFF probably the enc28j60 is not mounted or |
---|
685 | | - * damaged |
---|
| 678 | + * damaged. |
---|
686 | 679 | */ |
---|
687 | 680 | reg = locked_regb_read(priv, EREVID); |
---|
688 | 681 | if (netif_msg_drv(priv)) |
---|
689 | | - printk(KERN_INFO DRV_NAME ": chip RevID: 0x%02x\n", reg); |
---|
| 682 | + dev_info(dev, "chip RevID: 0x%02x\n", reg); |
---|
690 | 683 | if (reg == 0x00 || reg == 0xff) { |
---|
691 | 684 | if (netif_msg_drv(priv)) |
---|
692 | | - printk(KERN_DEBUG DRV_NAME ": %s() Invalid RevId %d\n", |
---|
693 | | - __func__, reg); |
---|
| 685 | + dev_printk(KERN_DEBUG, dev, "%s() Invalid RevId %d\n", |
---|
| 686 | + __func__, reg); |
---|
694 | 687 | return 0; |
---|
695 | 688 | } |
---|
696 | 689 | |
---|
.. | .. |
---|
723 | 716 | /* |
---|
724 | 717 | * MACLCON1 (default) |
---|
725 | 718 | * MACLCON2 (default) |
---|
726 | | - * Set the maximum packet size which the controller will accept |
---|
| 719 | + * Set the maximum packet size which the controller will accept. |
---|
727 | 720 | */ |
---|
728 | 721 | locked_regw_write(priv, MAMXFLL, MAX_FRAMELEN); |
---|
729 | 722 | |
---|
.. | .. |
---|
750 | 743 | |
---|
751 | 744 | static void enc28j60_hw_enable(struct enc28j60_net *priv) |
---|
752 | 745 | { |
---|
| 746 | + struct device *dev = &priv->spi->dev; |
---|
| 747 | + |
---|
753 | 748 | /* enable interrupts */ |
---|
754 | 749 | if (netif_msg_hw(priv)) |
---|
755 | | - printk(KERN_DEBUG DRV_NAME ": %s() enabling interrupts.\n", |
---|
756 | | - __func__); |
---|
| 750 | + dev_printk(KERN_DEBUG, dev, "%s() enabling interrupts.\n", |
---|
| 751 | + __func__); |
---|
757 | 752 | |
---|
758 | 753 | enc28j60_phy_write(priv, PHIE, PHIE_PGEIE | PHIE_PLNKIE); |
---|
759 | 754 | |
---|
.. | .. |
---|
772 | 767 | static void enc28j60_hw_disable(struct enc28j60_net *priv) |
---|
773 | 768 | { |
---|
774 | 769 | mutex_lock(&priv->lock); |
---|
775 | | - /* disable interrutps and packet reception */ |
---|
| 770 | + /* disable interrupts and packet reception */ |
---|
776 | 771 | nolock_regb_write(priv, EIE, 0x00); |
---|
777 | 772 | nolock_reg_bfclr(priv, ECON1, ECON1_RXEN); |
---|
778 | 773 | priv->hw_enable = false; |
---|
.. | .. |
---|
793 | 788 | priv->full_duplex = (duplex == DUPLEX_FULL); |
---|
794 | 789 | else { |
---|
795 | 790 | if (netif_msg_link(priv)) |
---|
796 | | - dev_warn(&ndev->dev, |
---|
797 | | - "unsupported link setting\n"); |
---|
| 791 | + netdev_warn(ndev, "unsupported link setting\n"); |
---|
798 | 792 | ret = -EOPNOTSUPP; |
---|
799 | 793 | } |
---|
800 | 794 | } else { |
---|
801 | 795 | if (netif_msg_link(priv)) |
---|
802 | | - dev_warn(&ndev->dev, "Warning: hw must be disabled " |
---|
803 | | - "to set link mode\n"); |
---|
| 796 | + netdev_warn(ndev, "Warning: hw must be disabled to set link mode\n"); |
---|
804 | 797 | ret = -EBUSY; |
---|
805 | 798 | } |
---|
806 | 799 | return ret; |
---|
.. | .. |
---|
811 | 804 | */ |
---|
812 | 805 | static void enc28j60_read_tsv(struct enc28j60_net *priv, u8 tsv[TSV_SIZE]) |
---|
813 | 806 | { |
---|
| 807 | + struct device *dev = &priv->spi->dev; |
---|
814 | 808 | int endptr; |
---|
815 | 809 | |
---|
816 | 810 | endptr = locked_regw_read(priv, ETXNDL); |
---|
817 | 811 | if (netif_msg_hw(priv)) |
---|
818 | | - printk(KERN_DEBUG DRV_NAME ": reading TSV at addr:0x%04x\n", |
---|
819 | | - endptr + 1); |
---|
| 812 | + dev_printk(KERN_DEBUG, dev, "reading TSV at addr:0x%04x\n", |
---|
| 813 | + endptr + 1); |
---|
820 | 814 | enc28j60_mem_read(priv, endptr + 1, TSV_SIZE, tsv); |
---|
821 | 815 | } |
---|
822 | 816 | |
---|
823 | 817 | static void enc28j60_dump_tsv(struct enc28j60_net *priv, const char *msg, |
---|
824 | | - u8 tsv[TSV_SIZE]) |
---|
| 818 | + u8 tsv[TSV_SIZE]) |
---|
825 | 819 | { |
---|
| 820 | + struct device *dev = &priv->spi->dev; |
---|
826 | 821 | u16 tmp1, tmp2; |
---|
827 | 822 | |
---|
828 | | - printk(KERN_DEBUG DRV_NAME ": %s - TSV:\n", msg); |
---|
| 823 | + dev_printk(KERN_DEBUG, dev, "%s - TSV:\n", msg); |
---|
829 | 824 | tmp1 = tsv[1]; |
---|
830 | 825 | tmp1 <<= 8; |
---|
831 | 826 | tmp1 |= tsv[0]; |
---|
.. | .. |
---|
834 | 829 | tmp2 <<= 8; |
---|
835 | 830 | tmp2 |= tsv[4]; |
---|
836 | 831 | |
---|
837 | | - printk(KERN_DEBUG DRV_NAME ": ByteCount: %d, CollisionCount: %d," |
---|
838 | | - " TotByteOnWire: %d\n", tmp1, tsv[2] & 0x0f, tmp2); |
---|
839 | | - printk(KERN_DEBUG DRV_NAME ": TxDone: %d, CRCErr:%d, LenChkErr: %d," |
---|
840 | | - " LenOutOfRange: %d\n", TSV_GETBIT(tsv, TSV_TXDONE), |
---|
841 | | - TSV_GETBIT(tsv, TSV_TXCRCERROR), |
---|
842 | | - TSV_GETBIT(tsv, TSV_TXLENCHKERROR), |
---|
843 | | - TSV_GETBIT(tsv, TSV_TXLENOUTOFRANGE)); |
---|
844 | | - printk(KERN_DEBUG DRV_NAME ": Multicast: %d, Broadcast: %d, " |
---|
845 | | - "PacketDefer: %d, ExDefer: %d\n", |
---|
846 | | - TSV_GETBIT(tsv, TSV_TXMULTICAST), |
---|
847 | | - TSV_GETBIT(tsv, TSV_TXBROADCAST), |
---|
848 | | - TSV_GETBIT(tsv, TSV_TXPACKETDEFER), |
---|
849 | | - TSV_GETBIT(tsv, TSV_TXEXDEFER)); |
---|
850 | | - printk(KERN_DEBUG DRV_NAME ": ExCollision: %d, LateCollision: %d, " |
---|
851 | | - "Giant: %d, Underrun: %d\n", |
---|
852 | | - TSV_GETBIT(tsv, TSV_TXEXCOLLISION), |
---|
853 | | - TSV_GETBIT(tsv, TSV_TXLATECOLLISION), |
---|
854 | | - TSV_GETBIT(tsv, TSV_TXGIANT), TSV_GETBIT(tsv, TSV_TXUNDERRUN)); |
---|
855 | | - printk(KERN_DEBUG DRV_NAME ": ControlFrame: %d, PauseFrame: %d, " |
---|
856 | | - "BackPressApp: %d, VLanTagFrame: %d\n", |
---|
857 | | - TSV_GETBIT(tsv, TSV_TXCONTROLFRAME), |
---|
858 | | - TSV_GETBIT(tsv, TSV_TXPAUSEFRAME), |
---|
859 | | - TSV_GETBIT(tsv, TSV_BACKPRESSUREAPP), |
---|
860 | | - TSV_GETBIT(tsv, TSV_TXVLANTAGFRAME)); |
---|
| 832 | + dev_printk(KERN_DEBUG, dev, |
---|
| 833 | + "ByteCount: %d, CollisionCount: %d, TotByteOnWire: %d\n", |
---|
| 834 | + tmp1, tsv[2] & 0x0f, tmp2); |
---|
| 835 | + dev_printk(KERN_DEBUG, dev, |
---|
| 836 | + "TxDone: %d, CRCErr:%d, LenChkErr: %d, LenOutOfRange: %d\n", |
---|
| 837 | + TSV_GETBIT(tsv, TSV_TXDONE), |
---|
| 838 | + TSV_GETBIT(tsv, TSV_TXCRCERROR), |
---|
| 839 | + TSV_GETBIT(tsv, TSV_TXLENCHKERROR), |
---|
| 840 | + TSV_GETBIT(tsv, TSV_TXLENOUTOFRANGE)); |
---|
| 841 | + dev_printk(KERN_DEBUG, dev, |
---|
| 842 | + "Multicast: %d, Broadcast: %d, PacketDefer: %d, ExDefer: %d\n", |
---|
| 843 | + TSV_GETBIT(tsv, TSV_TXMULTICAST), |
---|
| 844 | + TSV_GETBIT(tsv, TSV_TXBROADCAST), |
---|
| 845 | + TSV_GETBIT(tsv, TSV_TXPACKETDEFER), |
---|
| 846 | + TSV_GETBIT(tsv, TSV_TXEXDEFER)); |
---|
| 847 | + dev_printk(KERN_DEBUG, dev, |
---|
| 848 | + "ExCollision: %d, LateCollision: %d, Giant: %d, Underrun: %d\n", |
---|
| 849 | + TSV_GETBIT(tsv, TSV_TXEXCOLLISION), |
---|
| 850 | + TSV_GETBIT(tsv, TSV_TXLATECOLLISION), |
---|
| 851 | + TSV_GETBIT(tsv, TSV_TXGIANT), TSV_GETBIT(tsv, TSV_TXUNDERRUN)); |
---|
| 852 | + dev_printk(KERN_DEBUG, dev, |
---|
| 853 | + "ControlFrame: %d, PauseFrame: %d, BackPressApp: %d, VLanTagFrame: %d\n", |
---|
| 854 | + TSV_GETBIT(tsv, TSV_TXCONTROLFRAME), |
---|
| 855 | + TSV_GETBIT(tsv, TSV_TXPAUSEFRAME), |
---|
| 856 | + TSV_GETBIT(tsv, TSV_BACKPRESSUREAPP), |
---|
| 857 | + TSV_GETBIT(tsv, TSV_TXVLANTAGFRAME)); |
---|
861 | 858 | } |
---|
862 | 859 | |
---|
863 | 860 | /* |
---|
.. | .. |
---|
866 | 863 | static void enc28j60_dump_rsv(struct enc28j60_net *priv, const char *msg, |
---|
867 | 864 | u16 pk_ptr, int len, u16 sts) |
---|
868 | 865 | { |
---|
869 | | - printk(KERN_DEBUG DRV_NAME ": %s - NextPk: 0x%04x - RSV:\n", |
---|
870 | | - msg, pk_ptr); |
---|
871 | | - printk(KERN_DEBUG DRV_NAME ": ByteCount: %d, DribbleNibble: %d\n", len, |
---|
872 | | - RSV_GETBIT(sts, RSV_DRIBBLENIBBLE)); |
---|
873 | | - printk(KERN_DEBUG DRV_NAME ": RxOK: %d, CRCErr:%d, LenChkErr: %d," |
---|
874 | | - " LenOutOfRange: %d\n", RSV_GETBIT(sts, RSV_RXOK), |
---|
875 | | - RSV_GETBIT(sts, RSV_CRCERROR), |
---|
876 | | - RSV_GETBIT(sts, RSV_LENCHECKERR), |
---|
877 | | - RSV_GETBIT(sts, RSV_LENOUTOFRANGE)); |
---|
878 | | - printk(KERN_DEBUG DRV_NAME ": Multicast: %d, Broadcast: %d, " |
---|
879 | | - "LongDropEvent: %d, CarrierEvent: %d\n", |
---|
880 | | - RSV_GETBIT(sts, RSV_RXMULTICAST), |
---|
881 | | - RSV_GETBIT(sts, RSV_RXBROADCAST), |
---|
882 | | - RSV_GETBIT(sts, RSV_RXLONGEVDROPEV), |
---|
883 | | - RSV_GETBIT(sts, RSV_CARRIEREV)); |
---|
884 | | - printk(KERN_DEBUG DRV_NAME ": ControlFrame: %d, PauseFrame: %d," |
---|
885 | | - " UnknownOp: %d, VLanTagFrame: %d\n", |
---|
886 | | - RSV_GETBIT(sts, RSV_RXCONTROLFRAME), |
---|
887 | | - RSV_GETBIT(sts, RSV_RXPAUSEFRAME), |
---|
888 | | - RSV_GETBIT(sts, RSV_RXUNKNOWNOPCODE), |
---|
889 | | - RSV_GETBIT(sts, RSV_RXTYPEVLAN)); |
---|
| 866 | + struct device *dev = &priv->spi->dev; |
---|
| 867 | + |
---|
| 868 | + dev_printk(KERN_DEBUG, dev, "%s - NextPk: 0x%04x - RSV:\n", msg, pk_ptr); |
---|
| 869 | + dev_printk(KERN_DEBUG, dev, "ByteCount: %d, DribbleNibble: %d\n", |
---|
| 870 | + len, RSV_GETBIT(sts, RSV_DRIBBLENIBBLE)); |
---|
| 871 | + dev_printk(KERN_DEBUG, dev, |
---|
| 872 | + "RxOK: %d, CRCErr:%d, LenChkErr: %d, LenOutOfRange: %d\n", |
---|
| 873 | + RSV_GETBIT(sts, RSV_RXOK), |
---|
| 874 | + RSV_GETBIT(sts, RSV_CRCERROR), |
---|
| 875 | + RSV_GETBIT(sts, RSV_LENCHECKERR), |
---|
| 876 | + RSV_GETBIT(sts, RSV_LENOUTOFRANGE)); |
---|
| 877 | + dev_printk(KERN_DEBUG, dev, |
---|
| 878 | + "Multicast: %d, Broadcast: %d, LongDropEvent: %d, CarrierEvent: %d\n", |
---|
| 879 | + RSV_GETBIT(sts, RSV_RXMULTICAST), |
---|
| 880 | + RSV_GETBIT(sts, RSV_RXBROADCAST), |
---|
| 881 | + RSV_GETBIT(sts, RSV_RXLONGEVDROPEV), |
---|
| 882 | + RSV_GETBIT(sts, RSV_CARRIEREV)); |
---|
| 883 | + dev_printk(KERN_DEBUG, dev, |
---|
| 884 | + "ControlFrame: %d, PauseFrame: %d, UnknownOp: %d, VLanTagFrame: %d\n", |
---|
| 885 | + RSV_GETBIT(sts, RSV_RXCONTROLFRAME), |
---|
| 886 | + RSV_GETBIT(sts, RSV_RXPAUSEFRAME), |
---|
| 887 | + RSV_GETBIT(sts, RSV_RXUNKNOWNOPCODE), |
---|
| 888 | + RSV_GETBIT(sts, RSV_RXTYPEVLAN)); |
---|
890 | 889 | } |
---|
891 | 890 | |
---|
892 | 891 | static void dump_packet(const char *msg, int len, const char *data) |
---|
.. | .. |
---|
904 | 903 | static void enc28j60_hw_rx(struct net_device *ndev) |
---|
905 | 904 | { |
---|
906 | 905 | struct enc28j60_net *priv = netdev_priv(ndev); |
---|
| 906 | + struct device *dev = &priv->spi->dev; |
---|
907 | 907 | struct sk_buff *skb = NULL; |
---|
908 | 908 | u16 erxrdpt, next_packet, rxstat; |
---|
909 | 909 | u8 rsv[RSV_SIZE]; |
---|
910 | 910 | int len; |
---|
911 | 911 | |
---|
912 | 912 | if (netif_msg_rx_status(priv)) |
---|
913 | | - printk(KERN_DEBUG DRV_NAME ": RX pk_addr:0x%04x\n", |
---|
914 | | - priv->next_pk_ptr); |
---|
| 913 | + netdev_printk(KERN_DEBUG, ndev, "RX pk_addr:0x%04x\n", |
---|
| 914 | + priv->next_pk_ptr); |
---|
915 | 915 | |
---|
916 | 916 | if (unlikely(priv->next_pk_ptr > RXEND_INIT)) { |
---|
917 | 917 | if (netif_msg_rx_err(priv)) |
---|
918 | | - dev_err(&ndev->dev, |
---|
919 | | - "%s() Invalid packet address!! 0x%04x\n", |
---|
920 | | - __func__, priv->next_pk_ptr); |
---|
| 918 | + netdev_err(ndev, "%s() Invalid packet address!! 0x%04x\n", |
---|
| 919 | + __func__, priv->next_pk_ptr); |
---|
921 | 920 | /* packet address corrupted: reset RX logic */ |
---|
922 | 921 | mutex_lock(&priv->lock); |
---|
923 | 922 | nolock_reg_bfclr(priv, ECON1, ECON1_RXEN); |
---|
.. | .. |
---|
950 | 949 | |
---|
951 | 950 | if (!RSV_GETBIT(rxstat, RSV_RXOK) || len > MAX_FRAMELEN) { |
---|
952 | 951 | if (netif_msg_rx_err(priv)) |
---|
953 | | - dev_err(&ndev->dev, "Rx Error (%04x)\n", rxstat); |
---|
| 952 | + netdev_err(ndev, "Rx Error (%04x)\n", rxstat); |
---|
954 | 953 | ndev->stats.rx_errors++; |
---|
955 | 954 | if (RSV_GETBIT(rxstat, RSV_CRCERROR)) |
---|
956 | 955 | ndev->stats.rx_crc_errors++; |
---|
.. | .. |
---|
962 | 961 | skb = netdev_alloc_skb(ndev, len + NET_IP_ALIGN); |
---|
963 | 962 | if (!skb) { |
---|
964 | 963 | if (netif_msg_rx_err(priv)) |
---|
965 | | - dev_err(&ndev->dev, |
---|
966 | | - "out of memory for Rx'd frame\n"); |
---|
| 964 | + netdev_err(ndev, "out of memory for Rx'd frame\n"); |
---|
967 | 965 | ndev->stats.rx_dropped++; |
---|
968 | 966 | } else { |
---|
969 | 967 | skb_reserve(skb, NET_IP_ALIGN); |
---|
.. | .. |
---|
983 | 981 | /* |
---|
984 | 982 | * Move the RX read pointer to the start of the next |
---|
985 | 983 | * received packet. |
---|
986 | | - * This frees the memory we just read out |
---|
| 984 | + * This frees the memory we just read out. |
---|
987 | 985 | */ |
---|
988 | 986 | erxrdpt = erxrdpt_workaround(next_packet, RXSTART_INIT, RXEND_INIT); |
---|
989 | 987 | if (netif_msg_hw(priv)) |
---|
990 | | - printk(KERN_DEBUG DRV_NAME ": %s() ERXRDPT:0x%04x\n", |
---|
991 | | - __func__, erxrdpt); |
---|
| 988 | + dev_printk(KERN_DEBUG, dev, "%s() ERXRDPT:0x%04x\n", |
---|
| 989 | + __func__, erxrdpt); |
---|
992 | 990 | |
---|
993 | 991 | mutex_lock(&priv->lock); |
---|
994 | 992 | nolock_regw_write(priv, ERXRDPTL, erxrdpt); |
---|
.. | .. |
---|
997 | 995 | u16 reg; |
---|
998 | 996 | reg = nolock_regw_read(priv, ERXRDPTL); |
---|
999 | 997 | if (reg != erxrdpt) |
---|
1000 | | - printk(KERN_DEBUG DRV_NAME ": %s() ERXRDPT verify " |
---|
1001 | | - "error (0x%04x - 0x%04x)\n", __func__, |
---|
1002 | | - reg, erxrdpt); |
---|
| 998 | + dev_printk(KERN_DEBUG, dev, |
---|
| 999 | + "%s() ERXRDPT verify error (0x%04x - 0x%04x)\n", |
---|
| 1000 | + __func__, reg, erxrdpt); |
---|
1003 | 1001 | } |
---|
1004 | 1002 | #endif |
---|
1005 | 1003 | priv->next_pk_ptr = next_packet; |
---|
.. | .. |
---|
1013 | 1011 | */ |
---|
1014 | 1012 | static int enc28j60_get_free_rxfifo(struct enc28j60_net *priv) |
---|
1015 | 1013 | { |
---|
| 1014 | + struct net_device *ndev = priv->netdev; |
---|
1016 | 1015 | int epkcnt, erxst, erxnd, erxwr, erxrd; |
---|
1017 | 1016 | int free_space; |
---|
1018 | 1017 | |
---|
.. | .. |
---|
1035 | 1034 | } |
---|
1036 | 1035 | mutex_unlock(&priv->lock); |
---|
1037 | 1036 | if (netif_msg_rx_status(priv)) |
---|
1038 | | - printk(KERN_DEBUG DRV_NAME ": %s() free_space = %d\n", |
---|
1039 | | - __func__, free_space); |
---|
| 1037 | + netdev_printk(KERN_DEBUG, ndev, "%s() free_space = %d\n", |
---|
| 1038 | + __func__, free_space); |
---|
1040 | 1039 | return free_space; |
---|
1041 | 1040 | } |
---|
1042 | 1041 | |
---|
.. | .. |
---|
1046 | 1045 | static void enc28j60_check_link_status(struct net_device *ndev) |
---|
1047 | 1046 | { |
---|
1048 | 1047 | struct enc28j60_net *priv = netdev_priv(ndev); |
---|
| 1048 | + struct device *dev = &priv->spi->dev; |
---|
1049 | 1049 | u16 reg; |
---|
1050 | 1050 | int duplex; |
---|
1051 | 1051 | |
---|
1052 | 1052 | reg = enc28j60_phy_read(priv, PHSTAT2); |
---|
1053 | 1053 | if (netif_msg_hw(priv)) |
---|
1054 | | - printk(KERN_DEBUG DRV_NAME ": %s() PHSTAT1: %04x, " |
---|
1055 | | - "PHSTAT2: %04x\n", __func__, |
---|
1056 | | - enc28j60_phy_read(priv, PHSTAT1), reg); |
---|
| 1054 | + dev_printk(KERN_DEBUG, dev, |
---|
| 1055 | + "%s() PHSTAT1: %04x, PHSTAT2: %04x\n", __func__, |
---|
| 1056 | + enc28j60_phy_read(priv, PHSTAT1), reg); |
---|
1057 | 1057 | duplex = reg & PHSTAT2_DPXSTAT; |
---|
1058 | 1058 | |
---|
1059 | 1059 | if (reg & PHSTAT2_LSTAT) { |
---|
1060 | 1060 | netif_carrier_on(ndev); |
---|
1061 | 1061 | if (netif_msg_ifup(priv)) |
---|
1062 | | - dev_info(&ndev->dev, "link up - %s\n", |
---|
1063 | | - duplex ? "Full duplex" : "Half duplex"); |
---|
| 1062 | + netdev_info(ndev, "link up - %s\n", |
---|
| 1063 | + duplex ? "Full duplex" : "Half duplex"); |
---|
1064 | 1064 | } else { |
---|
1065 | 1065 | if (netif_msg_ifdown(priv)) |
---|
1066 | | - dev_info(&ndev->dev, "link down\n"); |
---|
| 1066 | + netdev_info(ndev, "link down\n"); |
---|
1067 | 1067 | netif_carrier_off(ndev); |
---|
1068 | 1068 | } |
---|
1069 | 1069 | } |
---|
.. | .. |
---|
1089 | 1089 | |
---|
1090 | 1090 | /* |
---|
1091 | 1091 | * RX handler |
---|
1092 | | - * ignore PKTIF because is unreliable! (look at the errata datasheet) |
---|
1093 | | - * check EPKTCNT is the suggested workaround. |
---|
| 1092 | + * Ignore PKTIF because is unreliable! (Look at the errata datasheet) |
---|
| 1093 | + * Check EPKTCNT is the suggested workaround. |
---|
1094 | 1094 | * We don't need to clear interrupt flag, automatically done when |
---|
1095 | 1095 | * enc28j60_hw_rx() decrements the packet counter. |
---|
1096 | 1096 | * Returns how many packet processed. |
---|
.. | .. |
---|
1102 | 1102 | |
---|
1103 | 1103 | pk_counter = locked_regb_read(priv, EPKTCNT); |
---|
1104 | 1104 | if (pk_counter && netif_msg_intr(priv)) |
---|
1105 | | - printk(KERN_DEBUG DRV_NAME ": intRX, pk_cnt: %d\n", pk_counter); |
---|
| 1105 | + netdev_printk(KERN_DEBUG, ndev, "intRX, pk_cnt: %d\n", |
---|
| 1106 | + pk_counter); |
---|
1106 | 1107 | if (pk_counter > priv->max_pk_counter) { |
---|
1107 | 1108 | /* update statistics */ |
---|
1108 | 1109 | priv->max_pk_counter = pk_counter; |
---|
1109 | 1110 | if (netif_msg_rx_status(priv) && priv->max_pk_counter > 1) |
---|
1110 | | - printk(KERN_DEBUG DRV_NAME ": RX max_pk_cnt: %d\n", |
---|
1111 | | - priv->max_pk_counter); |
---|
| 1111 | + netdev_printk(KERN_DEBUG, ndev, "RX max_pk_cnt: %d\n", |
---|
| 1112 | + priv->max_pk_counter); |
---|
1112 | 1113 | } |
---|
1113 | 1114 | ret = pk_counter; |
---|
1114 | 1115 | while (pk_counter-- > 0) |
---|
.. | .. |
---|
1124 | 1125 | struct net_device *ndev = priv->netdev; |
---|
1125 | 1126 | int intflags, loop; |
---|
1126 | 1127 | |
---|
1127 | | - if (netif_msg_intr(priv)) |
---|
1128 | | - printk(KERN_DEBUG DRV_NAME ": %s() enter\n", __func__); |
---|
1129 | 1128 | /* disable further interrupts */ |
---|
1130 | 1129 | locked_reg_bfclr(priv, EIE, EIE_INTIE); |
---|
1131 | 1130 | |
---|
.. | .. |
---|
1136 | 1135 | if ((intflags & EIR_DMAIF) != 0) { |
---|
1137 | 1136 | loop++; |
---|
1138 | 1137 | if (netif_msg_intr(priv)) |
---|
1139 | | - printk(KERN_DEBUG DRV_NAME |
---|
1140 | | - ": intDMA(%d)\n", loop); |
---|
| 1138 | + netdev_printk(KERN_DEBUG, ndev, "intDMA(%d)\n", |
---|
| 1139 | + loop); |
---|
1141 | 1140 | locked_reg_bfclr(priv, EIR, EIR_DMAIF); |
---|
1142 | 1141 | } |
---|
1143 | 1142 | /* LINK changed handler */ |
---|
1144 | 1143 | if ((intflags & EIR_LINKIF) != 0) { |
---|
1145 | 1144 | loop++; |
---|
1146 | 1145 | if (netif_msg_intr(priv)) |
---|
1147 | | - printk(KERN_DEBUG DRV_NAME |
---|
1148 | | - ": intLINK(%d)\n", loop); |
---|
| 1146 | + netdev_printk(KERN_DEBUG, ndev, "intLINK(%d)\n", |
---|
| 1147 | + loop); |
---|
1149 | 1148 | enc28j60_check_link_status(ndev); |
---|
1150 | 1149 | /* read PHIR to clear the flag */ |
---|
1151 | 1150 | enc28j60_phy_read(priv, PHIR); |
---|
.. | .. |
---|
1156 | 1155 | bool err = false; |
---|
1157 | 1156 | loop++; |
---|
1158 | 1157 | if (netif_msg_intr(priv)) |
---|
1159 | | - printk(KERN_DEBUG DRV_NAME |
---|
1160 | | - ": intTX(%d)\n", loop); |
---|
| 1158 | + netdev_printk(KERN_DEBUG, ndev, "intTX(%d)\n", |
---|
| 1159 | + loop); |
---|
1161 | 1160 | priv->tx_retry_count = 0; |
---|
1162 | 1161 | if (locked_regb_read(priv, ESTAT) & ESTAT_TXABRT) { |
---|
1163 | 1162 | if (netif_msg_tx_err(priv)) |
---|
1164 | | - dev_err(&ndev->dev, |
---|
1165 | | - "Tx Error (aborted)\n"); |
---|
| 1163 | + netdev_err(ndev, "Tx Error (aborted)\n"); |
---|
1166 | 1164 | err = true; |
---|
1167 | 1165 | } |
---|
1168 | 1166 | if (netif_msg_tx_done(priv)) { |
---|
.. | .. |
---|
1179 | 1177 | |
---|
1180 | 1178 | loop++; |
---|
1181 | 1179 | if (netif_msg_intr(priv)) |
---|
1182 | | - printk(KERN_DEBUG DRV_NAME |
---|
1183 | | - ": intTXErr(%d)\n", loop); |
---|
| 1180 | + netdev_printk(KERN_DEBUG, ndev, "intTXErr(%d)\n", |
---|
| 1181 | + loop); |
---|
1184 | 1182 | locked_reg_bfclr(priv, ECON1, ECON1_TXRTS); |
---|
1185 | 1183 | enc28j60_read_tsv(priv, tsv); |
---|
1186 | 1184 | if (netif_msg_tx_err(priv)) |
---|
.. | .. |
---|
1194 | 1192 | /* Transmit Late collision check for retransmit */ |
---|
1195 | 1193 | if (TSV_GETBIT(tsv, TSV_TXLATECOLLISION)) { |
---|
1196 | 1194 | if (netif_msg_tx_err(priv)) |
---|
1197 | | - printk(KERN_DEBUG DRV_NAME |
---|
1198 | | - ": LateCollision TXErr (%d)\n", |
---|
1199 | | - priv->tx_retry_count); |
---|
| 1195 | + netdev_printk(KERN_DEBUG, ndev, |
---|
| 1196 | + "LateCollision TXErr (%d)\n", |
---|
| 1197 | + priv->tx_retry_count); |
---|
1200 | 1198 | if (priv->tx_retry_count++ < MAX_TX_RETRYCOUNT) |
---|
1201 | 1199 | locked_reg_bfset(priv, ECON1, |
---|
1202 | 1200 | ECON1_TXRTS); |
---|
.. | .. |
---|
1210 | 1208 | if ((intflags & EIR_RXERIF) != 0) { |
---|
1211 | 1209 | loop++; |
---|
1212 | 1210 | if (netif_msg_intr(priv)) |
---|
1213 | | - printk(KERN_DEBUG DRV_NAME |
---|
1214 | | - ": intRXErr(%d)\n", loop); |
---|
| 1211 | + netdev_printk(KERN_DEBUG, ndev, "intRXErr(%d)\n", |
---|
| 1212 | + loop); |
---|
1215 | 1213 | /* Check free FIFO space to flag RX overrun */ |
---|
1216 | 1214 | if (enc28j60_get_free_rxfifo(priv) <= 0) { |
---|
1217 | 1215 | if (netif_msg_rx_err(priv)) |
---|
1218 | | - printk(KERN_DEBUG DRV_NAME |
---|
1219 | | - ": RX Overrun\n"); |
---|
| 1216 | + netdev_printk(KERN_DEBUG, ndev, "RX Overrun\n"); |
---|
1220 | 1217 | ndev->stats.rx_dropped++; |
---|
1221 | 1218 | } |
---|
1222 | 1219 | locked_reg_bfclr(priv, EIR, EIR_RXERIF); |
---|
.. | .. |
---|
1228 | 1225 | |
---|
1229 | 1226 | /* re-enable interrupts */ |
---|
1230 | 1227 | locked_reg_bfset(priv, EIE, EIE_INTIE); |
---|
1231 | | - if (netif_msg_intr(priv)) |
---|
1232 | | - printk(KERN_DEBUG DRV_NAME ": %s() exit\n", __func__); |
---|
1233 | 1228 | } |
---|
1234 | 1229 | |
---|
1235 | 1230 | /* |
---|
.. | .. |
---|
1239 | 1234 | */ |
---|
1240 | 1235 | static void enc28j60_hw_tx(struct enc28j60_net *priv) |
---|
1241 | 1236 | { |
---|
| 1237 | + struct net_device *ndev = priv->netdev; |
---|
| 1238 | + |
---|
1242 | 1239 | BUG_ON(!priv->tx_skb); |
---|
1243 | 1240 | |
---|
1244 | 1241 | if (netif_msg_tx_queued(priv)) |
---|
1245 | | - printk(KERN_DEBUG DRV_NAME |
---|
1246 | | - ": Tx Packet Len:%d\n", priv->tx_skb->len); |
---|
| 1242 | + netdev_printk(KERN_DEBUG, ndev, "Tx Packet Len:%d\n", |
---|
| 1243 | + priv->tx_skb->len); |
---|
1247 | 1244 | |
---|
1248 | 1245 | if (netif_msg_pktdata(priv)) |
---|
1249 | 1246 | dump_packet(__func__, |
---|
.. | .. |
---|
1253 | 1250 | #ifdef CONFIG_ENC28J60_WRITEVERIFY |
---|
1254 | 1251 | /* readback and verify written data */ |
---|
1255 | 1252 | if (netif_msg_drv(priv)) { |
---|
| 1253 | + struct device *dev = &priv->spi->dev; |
---|
1256 | 1254 | int test_len, k; |
---|
1257 | 1255 | u8 test_buf[64]; /* limit the test to the first 64 bytes */ |
---|
1258 | 1256 | int okflag; |
---|
.. | .. |
---|
1266 | 1264 | okflag = 1; |
---|
1267 | 1265 | for (k = 0; k < test_len; k++) { |
---|
1268 | 1266 | if (priv->tx_skb->data[k] != test_buf[k]) { |
---|
1269 | | - printk(KERN_DEBUG DRV_NAME |
---|
1270 | | - ": Error, %d location differ: " |
---|
1271 | | - "0x%02x-0x%02x\n", k, |
---|
1272 | | - priv->tx_skb->data[k], test_buf[k]); |
---|
| 1267 | + dev_printk(KERN_DEBUG, dev, |
---|
| 1268 | + "Error, %d location differ: 0x%02x-0x%02x\n", |
---|
| 1269 | + k, priv->tx_skb->data[k], test_buf[k]); |
---|
1273 | 1270 | okflag = 0; |
---|
1274 | 1271 | } |
---|
1275 | 1272 | } |
---|
1276 | 1273 | if (!okflag) |
---|
1277 | | - printk(KERN_DEBUG DRV_NAME ": Tx write buffer, " |
---|
1278 | | - "verify ERROR!\n"); |
---|
| 1274 | + dev_printk(KERN_DEBUG, dev, "Tx write buffer, verify ERROR!\n"); |
---|
1279 | 1275 | } |
---|
1280 | 1276 | #endif |
---|
1281 | 1277 | /* set TX request flag */ |
---|
.. | .. |
---|
1287 | 1283 | { |
---|
1288 | 1284 | struct enc28j60_net *priv = netdev_priv(dev); |
---|
1289 | 1285 | |
---|
1290 | | - if (netif_msg_tx_queued(priv)) |
---|
1291 | | - printk(KERN_DEBUG DRV_NAME ": %s() enter\n", __func__); |
---|
1292 | | - |
---|
1293 | 1286 | /* If some error occurs while trying to transmit this |
---|
1294 | 1287 | * packet, you should return '1' from this function. |
---|
1295 | 1288 | * In such a case you _may not_ do anything to the |
---|
1296 | 1289 | * SKB, it is still owned by the network queueing |
---|
1297 | | - * layer when an error is returned. This means you |
---|
| 1290 | + * layer when an error is returned. This means you |
---|
1298 | 1291 | * may not modify any SKB fields, you may not free |
---|
1299 | 1292 | * the SKB, etc. |
---|
1300 | 1293 | */ |
---|
.. | .. |
---|
1332 | 1325 | return IRQ_HANDLED; |
---|
1333 | 1326 | } |
---|
1334 | 1327 | |
---|
1335 | | -static void enc28j60_tx_timeout(struct net_device *ndev) |
---|
| 1328 | +static void enc28j60_tx_timeout(struct net_device *ndev, unsigned int txqueue) |
---|
1336 | 1329 | { |
---|
1337 | 1330 | struct enc28j60_net *priv = netdev_priv(ndev); |
---|
1338 | 1331 | |
---|
1339 | 1332 | if (netif_msg_timer(priv)) |
---|
1340 | | - dev_err(&ndev->dev, DRV_NAME " tx timeout\n"); |
---|
| 1333 | + netdev_err(ndev, "tx timeout\n"); |
---|
1341 | 1334 | |
---|
1342 | 1335 | ndev->stats.tx_errors++; |
---|
1343 | 1336 | /* can't restart safely under softirq */ |
---|
.. | .. |
---|
1356 | 1349 | { |
---|
1357 | 1350 | struct enc28j60_net *priv = netdev_priv(dev); |
---|
1358 | 1351 | |
---|
1359 | | - if (netif_msg_drv(priv)) |
---|
1360 | | - printk(KERN_DEBUG DRV_NAME ": %s() enter\n", __func__); |
---|
1361 | | - |
---|
1362 | 1352 | if (!is_valid_ether_addr(dev->dev_addr)) { |
---|
1363 | 1353 | if (netif_msg_ifup(priv)) |
---|
1364 | | - dev_err(&dev->dev, "invalid MAC address %pM\n", |
---|
1365 | | - dev->dev_addr); |
---|
| 1354 | + netdev_err(dev, "invalid MAC address %pM\n", dev->dev_addr); |
---|
1366 | 1355 | return -EADDRNOTAVAIL; |
---|
1367 | 1356 | } |
---|
1368 | 1357 | /* Reset the hardware here (and take it out of low power mode) */ |
---|
.. | .. |
---|
1370 | 1359 | enc28j60_hw_disable(priv); |
---|
1371 | 1360 | if (!enc28j60_hw_init(priv)) { |
---|
1372 | 1361 | if (netif_msg_ifup(priv)) |
---|
1373 | | - dev_err(&dev->dev, "hw_reset() failed\n"); |
---|
| 1362 | + netdev_err(dev, "hw_reset() failed\n"); |
---|
1374 | 1363 | return -EINVAL; |
---|
1375 | 1364 | } |
---|
1376 | 1365 | /* Update the MAC address (in case user has changed it) */ |
---|
.. | .. |
---|
1392 | 1381 | { |
---|
1393 | 1382 | struct enc28j60_net *priv = netdev_priv(dev); |
---|
1394 | 1383 | |
---|
1395 | | - if (netif_msg_drv(priv)) |
---|
1396 | | - printk(KERN_DEBUG DRV_NAME ": %s() enter\n", __func__); |
---|
1397 | | - |
---|
1398 | 1384 | enc28j60_hw_disable(priv); |
---|
1399 | 1385 | enc28j60_lowpower(priv, true); |
---|
1400 | 1386 | netif_stop_queue(dev); |
---|
.. | .. |
---|
1415 | 1401 | |
---|
1416 | 1402 | if (dev->flags & IFF_PROMISC) { |
---|
1417 | 1403 | if (netif_msg_link(priv)) |
---|
1418 | | - dev_info(&dev->dev, "promiscuous mode\n"); |
---|
| 1404 | + netdev_info(dev, "promiscuous mode\n"); |
---|
1419 | 1405 | priv->rxfilter = RXFILTER_PROMISC; |
---|
1420 | 1406 | } else if ((dev->flags & IFF_ALLMULTI) || !netdev_mc_empty(dev)) { |
---|
1421 | 1407 | if (netif_msg_link(priv)) |
---|
1422 | | - dev_info(&dev->dev, "%smulticast mode\n", |
---|
1423 | | - (dev->flags & IFF_ALLMULTI) ? "all-" : ""); |
---|
| 1408 | + netdev_info(dev, "%smulticast mode\n", |
---|
| 1409 | + (dev->flags & IFF_ALLMULTI) ? "all-" : ""); |
---|
1424 | 1410 | priv->rxfilter = RXFILTER_MULTI; |
---|
1425 | 1411 | } else { |
---|
1426 | 1412 | if (netif_msg_link(priv)) |
---|
1427 | | - dev_info(&dev->dev, "normal mode\n"); |
---|
| 1413 | + netdev_info(dev, "normal mode\n"); |
---|
1428 | 1414 | priv->rxfilter = RXFILTER_NORMAL; |
---|
1429 | 1415 | } |
---|
1430 | 1416 | |
---|
.. | .. |
---|
1436 | 1422 | { |
---|
1437 | 1423 | struct enc28j60_net *priv = |
---|
1438 | 1424 | container_of(work, struct enc28j60_net, setrx_work); |
---|
| 1425 | + struct device *dev = &priv->spi->dev; |
---|
1439 | 1426 | |
---|
1440 | 1427 | if (priv->rxfilter == RXFILTER_PROMISC) { |
---|
1441 | 1428 | if (netif_msg_drv(priv)) |
---|
1442 | | - printk(KERN_DEBUG DRV_NAME ": promiscuous mode\n"); |
---|
| 1429 | + dev_printk(KERN_DEBUG, dev, "promiscuous mode\n"); |
---|
1443 | 1430 | locked_regb_write(priv, ERXFCON, 0x00); |
---|
1444 | 1431 | } else if (priv->rxfilter == RXFILTER_MULTI) { |
---|
1445 | 1432 | if (netif_msg_drv(priv)) |
---|
1446 | | - printk(KERN_DEBUG DRV_NAME ": multicast mode\n"); |
---|
| 1433 | + dev_printk(KERN_DEBUG, dev, "multicast mode\n"); |
---|
1447 | 1434 | locked_regb_write(priv, ERXFCON, |
---|
1448 | 1435 | ERXFCON_UCEN | ERXFCON_CRCEN | |
---|
1449 | 1436 | ERXFCON_BCEN | ERXFCON_MCEN); |
---|
1450 | 1437 | } else { |
---|
1451 | 1438 | if (netif_msg_drv(priv)) |
---|
1452 | | - printk(KERN_DEBUG DRV_NAME ": normal mode\n"); |
---|
| 1439 | + dev_printk(KERN_DEBUG, dev, "normal mode\n"); |
---|
1453 | 1440 | locked_regb_write(priv, ERXFCON, |
---|
1454 | 1441 | ERXFCON_UCEN | ERXFCON_CRCEN | |
---|
1455 | 1442 | ERXFCON_BCEN); |
---|
.. | .. |
---|
1468 | 1455 | enc28j60_net_close(ndev); |
---|
1469 | 1456 | ret = enc28j60_net_open(ndev); |
---|
1470 | 1457 | if (unlikely(ret)) { |
---|
1471 | | - dev_info(&ndev->dev, " could not restart %d\n", ret); |
---|
| 1458 | + netdev_info(ndev, "could not restart %d\n", ret); |
---|
1472 | 1459 | dev_close(ndev); |
---|
1473 | 1460 | } |
---|
1474 | 1461 | } |
---|
.. | .. |
---|
1552 | 1539 | |
---|
1553 | 1540 | static int enc28j60_probe(struct spi_device *spi) |
---|
1554 | 1541 | { |
---|
| 1542 | + unsigned char macaddr[ETH_ALEN]; |
---|
1555 | 1543 | struct net_device *dev; |
---|
1556 | 1544 | struct enc28j60_net *priv; |
---|
1557 | | - const void *macaddr; |
---|
1558 | 1545 | int ret = 0; |
---|
1559 | 1546 | |
---|
1560 | 1547 | if (netif_msg_drv(&debug)) |
---|
1561 | | - dev_info(&spi->dev, DRV_NAME " Ethernet driver %s loaded\n", |
---|
1562 | | - DRV_VERSION); |
---|
| 1548 | + dev_info(&spi->dev, "Ethernet driver %s loaded\n", DRV_VERSION); |
---|
1563 | 1549 | |
---|
1564 | 1550 | dev = alloc_etherdev(sizeof(struct enc28j60_net)); |
---|
1565 | 1551 | if (!dev) { |
---|
.. | .. |
---|
1570 | 1556 | |
---|
1571 | 1557 | priv->netdev = dev; /* priv to netdev reference */ |
---|
1572 | 1558 | priv->spi = spi; /* priv to spi reference */ |
---|
1573 | | - priv->msg_enable = netif_msg_init(debug.msg_enable, |
---|
1574 | | - ENC28J60_MSG_DEFAULT); |
---|
| 1559 | + priv->msg_enable = netif_msg_init(debug.msg_enable, ENC28J60_MSG_DEFAULT); |
---|
1575 | 1560 | mutex_init(&priv->lock); |
---|
1576 | 1561 | INIT_WORK(&priv->tx_work, enc28j60_tx_work_handler); |
---|
1577 | 1562 | INIT_WORK(&priv->setrx_work, enc28j60_setrx_work_handler); |
---|
.. | .. |
---|
1582 | 1567 | |
---|
1583 | 1568 | if (!enc28j60_chipset_init(dev)) { |
---|
1584 | 1569 | if (netif_msg_probe(priv)) |
---|
1585 | | - dev_info(&spi->dev, DRV_NAME " chip not found\n"); |
---|
| 1570 | + dev_info(&spi->dev, "chip not found\n"); |
---|
1586 | 1571 | ret = -EIO; |
---|
1587 | 1572 | goto error_irq; |
---|
1588 | 1573 | } |
---|
1589 | 1574 | |
---|
1590 | | - macaddr = of_get_mac_address(spi->dev.of_node); |
---|
1591 | | - if (macaddr) |
---|
| 1575 | + if (device_get_mac_address(&spi->dev, macaddr, sizeof(macaddr))) |
---|
1592 | 1576 | ether_addr_copy(dev->dev_addr, macaddr); |
---|
1593 | 1577 | else |
---|
1594 | 1578 | eth_hw_addr_random(dev); |
---|
.. | .. |
---|
1600 | 1584 | ret = request_irq(spi->irq, enc28j60_irq, 0, DRV_NAME, priv); |
---|
1601 | 1585 | if (ret < 0) { |
---|
1602 | 1586 | if (netif_msg_probe(priv)) |
---|
1603 | | - dev_err(&spi->dev, DRV_NAME ": request irq %d failed " |
---|
1604 | | - "(ret = %d)\n", spi->irq, ret); |
---|
| 1587 | + dev_err(&spi->dev, "request irq %d failed (ret = %d)\n", |
---|
| 1588 | + spi->irq, ret); |
---|
1605 | 1589 | goto error_irq; |
---|
1606 | 1590 | } |
---|
1607 | 1591 | |
---|
.. | .. |
---|
1616 | 1600 | ret = register_netdev(dev); |
---|
1617 | 1601 | if (ret) { |
---|
1618 | 1602 | if (netif_msg_probe(priv)) |
---|
1619 | | - dev_err(&spi->dev, "register netdev " DRV_NAME |
---|
1620 | | - " failed (ret = %d)\n", ret); |
---|
| 1603 | + dev_err(&spi->dev, "register netdev failed (ret = %d)\n", |
---|
| 1604 | + ret); |
---|
1621 | 1605 | goto error_register; |
---|
1622 | 1606 | } |
---|
1623 | | - dev_info(&dev->dev, DRV_NAME " driver registered\n"); |
---|
1624 | 1607 | |
---|
1625 | 1608 | return 0; |
---|
1626 | 1609 | |
---|
.. | .. |
---|
1635 | 1618 | static int enc28j60_remove(struct spi_device *spi) |
---|
1636 | 1619 | { |
---|
1637 | 1620 | struct enc28j60_net *priv = spi_get_drvdata(spi); |
---|
1638 | | - |
---|
1639 | | - if (netif_msg_drv(priv)) |
---|
1640 | | - printk(KERN_DEBUG DRV_NAME ": remove\n"); |
---|
1641 | 1621 | |
---|
1642 | 1622 | unregister_netdev(priv->netdev); |
---|
1643 | 1623 | free_irq(spi->irq, priv); |
---|
.. | .. |
---|
1660 | 1640 | .probe = enc28j60_probe, |
---|
1661 | 1641 | .remove = enc28j60_remove, |
---|
1662 | 1642 | }; |
---|
1663 | | - |
---|
1664 | | -static int __init enc28j60_init(void) |
---|
1665 | | -{ |
---|
1666 | | - msec20_to_jiffies = msecs_to_jiffies(20); |
---|
1667 | | - |
---|
1668 | | - return spi_register_driver(&enc28j60_driver); |
---|
1669 | | -} |
---|
1670 | | - |
---|
1671 | | -module_init(enc28j60_init); |
---|
1672 | | - |
---|
1673 | | -static void __exit enc28j60_exit(void) |
---|
1674 | | -{ |
---|
1675 | | - spi_unregister_driver(&enc28j60_driver); |
---|
1676 | | -} |
---|
1677 | | - |
---|
1678 | | -module_exit(enc28j60_exit); |
---|
| 1643 | +module_spi_driver(enc28j60_driver); |
---|
1679 | 1644 | |
---|
1680 | 1645 | MODULE_DESCRIPTION(DRV_NAME " ethernet driver"); |
---|
1681 | 1646 | MODULE_AUTHOR("Claudio Lanconelli <lanconelli.claudio@eptar.com>"); |
---|
1682 | 1647 | MODULE_LICENSE("GPL"); |
---|
1683 | 1648 | module_param_named(debug, debug.msg_enable, int, 0); |
---|
1684 | | -MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., ffff=all)"); |
---|
| 1649 | +MODULE_PARM_DESC(debug, "Debug verbosity level in amount of bits set (0=none, ..., 31=all)"); |
---|
1685 | 1650 | MODULE_ALIAS("spi:" DRV_NAME); |
---|