diff options
author | Alexander Kurz <linux@kbdbabel.org> | 2010-03-30 22:42:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-04-01 22:53:13 -0400 |
commit | f64e96973a1fa885ce6e4f7e3fdbae83de98fcab (patch) | |
tree | a71e26ab65b5a43b8dfdade00cd3903544c92243 /drivers/net/pcmcia/3c589_cs.c | |
parent | e6b043d512fa8d9a3801bf5d72bfa3b8fc3b3cc8 (diff) |
net/pcmcia/3c589_cs: using netdev_info and friends where appropriate
Signed-off-by: Alexander Kurz <linux@kbdbabel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/pcmcia/3c589_cs.c')
-rw-r--r-- | drivers/net/pcmcia/3c589_cs.c | 286 |
1 files changed, 147 insertions, 139 deletions
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index 091e0b00043e..580977f56ad0 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c | |||
@@ -1,20 +1,20 @@ | |||
1 | /*====================================================================== | 1 | /*====================================================================== |
2 | 2 | ||
3 | A PCMCIA ethernet driver for the 3com 3c589 card. | 3 | A PCMCIA ethernet driver for the 3com 3c589 card. |
4 | 4 | ||
5 | Copyright (C) 1999 David A. Hinds -- dahinds@users.sourceforge.net | 5 | Copyright (C) 1999 David A. Hinds -- dahinds@users.sourceforge.net |
6 | 6 | ||
7 | 3c589_cs.c 1.162 2001/10/13 00:08:50 | 7 | 3c589_cs.c 1.162 2001/10/13 00:08:50 |
8 | 8 | ||
9 | The network driver code is based on Donald Becker's 3c589 code: | 9 | The network driver code is based on Donald Becker's 3c589 code: |
10 | 10 | ||
11 | Written 1994 by Donald Becker. | 11 | Written 1994 by Donald Becker. |
12 | Copyright 1993 United States Government as represented by the | 12 | Copyright 1993 United States Government as represented by the |
13 | Director, National Security Agency. This software may be used and | 13 | Director, National Security Agency. This software may be used and |
14 | distributed according to the terms of the GNU General Public License, | 14 | distributed according to the terms of the GNU General Public License, |
15 | incorporated herein by reference. | 15 | incorporated herein by reference. |
16 | Donald Becker may be reached at becker@scyld.com | 16 | Donald Becker may be reached at becker@scyld.com |
17 | 17 | ||
18 | Updated for 2.5.x by Alan Cox <alan@lxorguk.ukuu.org.uk> | 18 | Updated for 2.5.x by Alan Cox <alan@lxorguk.ukuu.org.uk> |
19 | 19 | ||
20 | ======================================================================*/ | 20 | ======================================================================*/ |
@@ -69,31 +69,54 @@ | |||
69 | /* The top five bits written to EL3_CMD are a command, the lower | 69 | /* The top five bits written to EL3_CMD are a command, the lower |
70 | 11 bits are the parameter, if applicable. */ | 70 | 11 bits are the parameter, if applicable. */ |
71 | enum c509cmd { | 71 | enum c509cmd { |
72 | TotalReset = 0<<11, SelectWindow = 1<<11, StartCoax = 2<<11, | 72 | TotalReset = 0<<11, |
73 | RxDisable = 3<<11, RxEnable = 4<<11, RxReset = 5<<11, RxDiscard = 8<<11, | 73 | SelectWindow = 1<<11, |
74 | TxEnable = 9<<11, TxDisable = 10<<11, TxReset = 11<<11, | 74 | StartCoax = 2<<11, |
75 | FakeIntr = 12<<11, AckIntr = 13<<11, SetIntrEnb = 14<<11, | 75 | RxDisable = 3<<11, |
76 | SetStatusEnb = 15<<11, SetRxFilter = 16<<11, SetRxThreshold = 17<<11, | 76 | RxEnable = 4<<11, |
77 | SetTxThreshold = 18<<11, SetTxStart = 19<<11, StatsEnable = 21<<11, | 77 | RxReset = 5<<11, |
78 | StatsDisable = 22<<11, StopCoax = 23<<11, | 78 | RxDiscard = 8<<11, |
79 | TxEnable = 9<<11, | ||
80 | TxDisable = 10<<11, | ||
81 | TxReset = 11<<11, | ||
82 | FakeIntr = 12<<11, | ||
83 | AckIntr = 13<<11, | ||
84 | SetIntrEnb = 14<<11, | ||
85 | SetStatusEnb = 15<<11, | ||
86 | SetRxFilter = 16<<11, | ||
87 | SetRxThreshold = 17<<11, | ||
88 | SetTxThreshold = 18<<11, | ||
89 | SetTxStart = 19<<11, | ||
90 | StatsEnable = 21<<11, | ||
91 | StatsDisable = 22<<11, | ||
92 | StopCoax = 23<<11 | ||
79 | }; | 93 | }; |
80 | 94 | ||
81 | enum c509status { | 95 | enum c509status { |
82 | IntLatch = 0x0001, AdapterFailure = 0x0002, TxComplete = 0x0004, | 96 | IntLatch = 0x0001, |
83 | TxAvailable = 0x0008, RxComplete = 0x0010, RxEarly = 0x0020, | 97 | AdapterFailure = 0x0002, |
84 | IntReq = 0x0040, StatsFull = 0x0080, CmdBusy = 0x1000 | 98 | TxComplete = 0x0004, |
99 | TxAvailable = 0x0008, | ||
100 | RxComplete = 0x0010, | ||
101 | RxEarly = 0x0020, | ||
102 | IntReq = 0x0040, | ||
103 | StatsFull = 0x0080, | ||
104 | CmdBusy = 0x1000 | ||
85 | }; | 105 | }; |
86 | 106 | ||
87 | /* The SetRxFilter command accepts the following classes: */ | 107 | /* The SetRxFilter command accepts the following classes: */ |
88 | enum RxFilter { | 108 | enum RxFilter { |
89 | RxStation = 1, RxMulticast = 2, RxBroadcast = 4, RxProm = 8 | 109 | RxStation = 1, |
110 | RxMulticast = 2, | ||
111 | RxBroadcast = 4, | ||
112 | RxProm = 8 | ||
90 | }; | 113 | }; |
91 | 114 | ||
92 | /* Register window 1 offsets, the window used in normal operation. */ | 115 | /* Register window 1 offsets, the window used in normal operation. */ |
93 | #define TX_FIFO 0x00 | 116 | #define TX_FIFO 0x00 |
94 | #define RX_FIFO 0x00 | 117 | #define RX_FIFO 0x00 |
95 | #define RX_STATUS 0x08 | 118 | #define RX_STATUS 0x08 |
96 | #define TX_STATUS 0x0B | 119 | #define TX_STATUS 0x0B |
97 | #define TX_FREE 0x0C /* Remaining free bytes in Tx buffer. */ | 120 | #define TX_FREE 0x0C /* Remaining free bytes in Tx buffer. */ |
98 | 121 | ||
99 | #define WN0_IRQ 0x08 /* Window 0: Set IRQ line in bits 12-15. */ | 122 | #define WN0_IRQ 0x08 /* Window 0: Set IRQ line in bits 12-15. */ |
@@ -106,13 +129,13 @@ enum RxFilter { | |||
106 | 129 | ||
107 | struct el3_private { | 130 | struct el3_private { |
108 | struct pcmcia_device *p_dev; | 131 | struct pcmcia_device *p_dev; |
109 | dev_node_t node; | 132 | dev_node_t node; |
110 | /* For transceiver monitoring */ | 133 | /* For transceiver monitoring */ |
111 | struct timer_list media; | 134 | struct timer_list media; |
112 | u16 media_status; | 135 | u16 media_status; |
113 | u16 fast_poll; | 136 | u16 fast_poll; |
114 | unsigned long last_irq; | 137 | unsigned long last_irq; |
115 | spinlock_t lock; | 138 | spinlock_t lock; |
116 | }; | 139 | }; |
117 | 140 | ||
118 | static const char *if_names[] = { "auto", "10baseT", "10base2", "AUI" }; | 141 | static const char *if_names[] = { "auto", "10baseT", "10base2", "AUI" }; |
@@ -164,15 +187,15 @@ static void tc589_detach(struct pcmcia_device *p_dev); | |||
164 | ======================================================================*/ | 187 | ======================================================================*/ |
165 | 188 | ||
166 | static const struct net_device_ops el3_netdev_ops = { | 189 | static const struct net_device_ops el3_netdev_ops = { |
167 | .ndo_open = el3_open, | 190 | .ndo_open = el3_open, |
168 | .ndo_stop = el3_close, | 191 | .ndo_stop = el3_close, |
169 | .ndo_start_xmit = el3_start_xmit, | 192 | .ndo_start_xmit = el3_start_xmit, |
170 | .ndo_tx_timeout = el3_tx_timeout, | 193 | .ndo_tx_timeout = el3_tx_timeout, |
171 | .ndo_set_config = el3_config, | 194 | .ndo_set_config = el3_config, |
172 | .ndo_get_stats = el3_get_stats, | 195 | .ndo_get_stats = el3_get_stats, |
173 | .ndo_set_multicast_list = set_multicast_list, | 196 | .ndo_set_multicast_list = set_multicast_list, |
174 | .ndo_change_mtu = eth_change_mtu, | 197 | .ndo_change_mtu = eth_change_mtu, |
175 | .ndo_set_mac_address = eth_mac_addr, | 198 | .ndo_set_mac_address = eth_mac_addr, |
176 | .ndo_validate_addr = eth_validate_addr, | 199 | .ndo_validate_addr = eth_validate_addr, |
177 | }; | 200 | }; |
178 | 201 | ||
@@ -236,7 +259,7 @@ static void tc589_detach(struct pcmcia_device *link) | |||
236 | tc589_config() is scheduled to run after a CARD_INSERTION event | 259 | tc589_config() is scheduled to run after a CARD_INSERTION event |
237 | is received, to configure the PCMCIA socket, and to make the | 260 | is received, to configure the PCMCIA socket, and to make the |
238 | ethernet device available to the system. | 261 | ethernet device available to the system. |
239 | 262 | ||
240 | ======================================================================*/ | 263 | ======================================================================*/ |
241 | 264 | ||
242 | static int tc589_config(struct pcmcia_device *link) | 265 | static int tc589_config(struct pcmcia_device *link) |
@@ -249,7 +272,7 @@ static int tc589_config(struct pcmcia_device *link) | |||
249 | char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; | 272 | char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; |
250 | u8 *buf; | 273 | u8 *buf; |
251 | size_t len; | 274 | size_t len; |
252 | 275 | ||
253 | dev_dbg(&link->dev, "3c589_config\n"); | 276 | dev_dbg(&link->dev, "3c589_config\n"); |
254 | 277 | ||
255 | phys_addr = (__be16 *)dev->dev_addr; | 278 | phys_addr = (__be16 *)dev->dev_addr; |
@@ -278,7 +301,7 @@ static int tc589_config(struct pcmcia_device *link) | |||
278 | ret = pcmcia_request_configuration(link, &link->conf); | 301 | ret = pcmcia_request_configuration(link, &link->conf); |
279 | if (ret) | 302 | if (ret) |
280 | goto failed; | 303 | goto failed; |
281 | 304 | ||
282 | dev->irq = link->irq.AssignedIRQ; | 305 | dev->irq = link->irq.AssignedIRQ; |
283 | dev->base_addr = link->io.BasePort1; | 306 | dev->base_addr = link->io.BasePort1; |
284 | ioaddr = dev->base_addr; | 307 | ioaddr = dev->base_addr; |
@@ -312,7 +335,7 @@ static int tc589_config(struct pcmcia_device *link) | |||
312 | dev->if_port = if_port; | 335 | dev->if_port = if_port; |
313 | else | 336 | else |
314 | printk(KERN_ERR "3c589_cs: invalid if_port requested\n"); | 337 | printk(KERN_ERR "3c589_cs: invalid if_port requested\n"); |
315 | 338 | ||
316 | link->dev_node = &lp->node; | 339 | link->dev_node = &lp->node; |
317 | SET_NETDEV_DEV(dev, &link->dev); | 340 | SET_NETDEV_DEV(dev, &link->dev); |
318 | 341 | ||
@@ -324,13 +347,12 @@ static int tc589_config(struct pcmcia_device *link) | |||
324 | 347 | ||
325 | strcpy(lp->node.dev_name, dev->name); | 348 | strcpy(lp->node.dev_name, dev->name); |
326 | 349 | ||
327 | printk(KERN_INFO "%s: 3Com 3c%s, io %#3lx, irq %d, " | 350 | netdev_info(dev, "3Com 3c%s, io %#3lx, irq %d, hw_addr %pM\n", |
328 | "hw_addr %pM\n", | 351 | (multi ? "562" : "589"), dev->base_addr, dev->irq, |
329 | dev->name, (multi ? "562" : "589"), dev->base_addr, dev->irq, | 352 | dev->dev_addr); |
330 | dev->dev_addr); | 353 | netdev_info(dev, " %dK FIFO split %s Rx:Tx, %s xcvr\n", |
331 | printk(KERN_INFO " %dK FIFO split %s Rx:Tx, %s xcvr\n", | 354 | (fifo & 7) ? 32 : 8, ram_split[(fifo >> 16) & 3], |
332 | (fifo & 7) ? 32 : 8, ram_split[(fifo >> 16) & 3], | 355 | if_names[dev->if_port]); |
333 | if_names[dev->if_port]); | ||
334 | return 0; | 356 | return 0; |
335 | 357 | ||
336 | failed: | 358 | failed: |
@@ -343,7 +365,7 @@ failed: | |||
343 | After a card is removed, tc589_release() will unregister the net | 365 | After a card is removed, tc589_release() will unregister the net |
344 | device, and release the PCMCIA configuration. If the device is | 366 | device, and release the PCMCIA configuration. If the device is |
345 | still open, this will be postponed until it is closed. | 367 | still open, this will be postponed until it is closed. |
346 | 368 | ||
347 | ======================================================================*/ | 369 | ======================================================================*/ |
348 | 370 | ||
349 | static void tc589_release(struct pcmcia_device *link) | 371 | static void tc589_release(struct pcmcia_device *link) |
@@ -365,7 +387,7 @@ static int tc589_resume(struct pcmcia_device *link) | |||
365 | { | 387 | { |
366 | struct net_device *dev = link->priv; | 388 | struct net_device *dev = link->priv; |
367 | 389 | ||
368 | if (link->open) { | 390 | if (link->open) { |
369 | tc589_reset(dev); | 391 | tc589_reset(dev); |
370 | netif_device_attach(dev); | 392 | netif_device_attach(dev); |
371 | } | 393 | } |
@@ -385,8 +407,7 @@ static void tc589_wait_for_completion(struct net_device *dev, int cmd) | |||
385 | while (--i > 0) | 407 | while (--i > 0) |
386 | if (!(inw(dev->base_addr + EL3_STATUS) & 0x1000)) break; | 408 | if (!(inw(dev->base_addr + EL3_STATUS) & 0x1000)) break; |
387 | if (i == 0) | 409 | if (i == 0) |
388 | printk(KERN_WARNING "%s: command 0x%04x did not complete!\n", | 410 | netdev_warn(dev, "command 0x%04x did not complete!\n", cmd); |
389 | dev->name, cmd); | ||
390 | } | 411 | } |
391 | 412 | ||
392 | /* | 413 | /* |
@@ -412,7 +433,7 @@ static void tc589_set_xcvr(struct net_device *dev, int if_port) | |||
412 | { | 433 | { |
413 | struct el3_private *lp = netdev_priv(dev); | 434 | struct el3_private *lp = netdev_priv(dev); |
414 | unsigned int ioaddr = dev->base_addr; | 435 | unsigned int ioaddr = dev->base_addr; |
415 | 436 | ||
416 | EL3WINDOW(0); | 437 | EL3WINDOW(0); |
417 | switch (if_port) { | 438 | switch (if_port) { |
418 | case 0: case 1: outw(0, ioaddr + 6); break; | 439 | case 0: case 1: outw(0, ioaddr + 6); break; |
@@ -435,14 +456,13 @@ static void dump_status(struct net_device *dev) | |||
435 | { | 456 | { |
436 | unsigned int ioaddr = dev->base_addr; | 457 | unsigned int ioaddr = dev->base_addr; |
437 | EL3WINDOW(1); | 458 | EL3WINDOW(1); |
438 | printk(KERN_INFO " irq status %04x, rx status %04x, tx status " | 459 | netdev_info(dev, " irq status %04x, rx status %04x, tx status %02x tx free %04x\n", |
439 | "%02x tx free %04x\n", inw(ioaddr+EL3_STATUS), | 460 | inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS), |
440 | inw(ioaddr+RX_STATUS), inb(ioaddr+TX_STATUS), | 461 | inb(ioaddr+TX_STATUS), inw(ioaddr+TX_FREE)); |
441 | inw(ioaddr+TX_FREE)); | ||
442 | EL3WINDOW(4); | 462 | EL3WINDOW(4); |
443 | printk(KERN_INFO " diagnostics: fifo %04x net %04x ethernet %04x" | 463 | netdev_info(dev, " diagnostics: fifo %04x net %04x ethernet %04x media %04x\n", |
444 | " media %04x\n", inw(ioaddr+0x04), inw(ioaddr+0x06), | 464 | inw(ioaddr+0x04), inw(ioaddr+0x06), inw(ioaddr+0x08), |
445 | inw(ioaddr+0x08), inw(ioaddr+0x0a)); | 465 | inw(ioaddr+0x0a)); |
446 | EL3WINDOW(1); | 466 | EL3WINDOW(1); |
447 | } | 467 | } |
448 | 468 | ||
@@ -451,18 +471,18 @@ static void tc589_reset(struct net_device *dev) | |||
451 | { | 471 | { |
452 | unsigned int ioaddr = dev->base_addr; | 472 | unsigned int ioaddr = dev->base_addr; |
453 | int i; | 473 | int i; |
454 | 474 | ||
455 | EL3WINDOW(0); | 475 | EL3WINDOW(0); |
456 | outw(0x0001, ioaddr + 4); /* Activate board. */ | 476 | outw(0x0001, ioaddr + 4); /* Activate board. */ |
457 | outw(0x3f00, ioaddr + 8); /* Set the IRQ line. */ | 477 | outw(0x3f00, ioaddr + 8); /* Set the IRQ line. */ |
458 | 478 | ||
459 | /* Set the station address in window 2. */ | 479 | /* Set the station address in window 2. */ |
460 | EL3WINDOW(2); | 480 | EL3WINDOW(2); |
461 | for (i = 0; i < 6; i++) | 481 | for (i = 0; i < 6; i++) |
462 | outb(dev->dev_addr[i], ioaddr + i); | 482 | outb(dev->dev_addr[i], ioaddr + i); |
463 | 483 | ||
464 | tc589_set_xcvr(dev, dev->if_port); | 484 | tc589_set_xcvr(dev, dev->if_port); |
465 | 485 | ||
466 | /* Switch to the stats window, and clear all stats by reading. */ | 486 | /* Switch to the stats window, and clear all stats by reading. */ |
467 | outw(StatsDisable, ioaddr + EL3_CMD); | 487 | outw(StatsDisable, ioaddr + EL3_CMD); |
468 | EL3WINDOW(6); | 488 | EL3WINDOW(6); |
@@ -470,7 +490,7 @@ static void tc589_reset(struct net_device *dev) | |||
470 | inb(ioaddr+i); | 490 | inb(ioaddr+i); |
471 | inw(ioaddr + 10); | 491 | inw(ioaddr + 10); |
472 | inw(ioaddr + 12); | 492 | inw(ioaddr + 12); |
473 | 493 | ||
474 | /* Switch to register set 1 for normal use. */ | 494 | /* Switch to register set 1 for normal use. */ |
475 | EL3WINDOW(1); | 495 | EL3WINDOW(1); |
476 | 496 | ||
@@ -504,8 +524,7 @@ static int el3_config(struct net_device *dev, struct ifmap *map) | |||
504 | if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) { | 524 | if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) { |
505 | if (map->port <= 3) { | 525 | if (map->port <= 3) { |
506 | dev->if_port = map->port; | 526 | dev->if_port = map->port; |
507 | printk(KERN_INFO "%s: switched to %s port\n", | 527 | netdev_info(dev, "switched to %s port\n", if_names[dev->if_port]); |
508 | dev->name, if_names[dev->if_port]); | ||
509 | tc589_set_xcvr(dev, dev->if_port); | 528 | tc589_set_xcvr(dev, dev->if_port); |
510 | } else | 529 | } else |
511 | return -EINVAL; | 530 | return -EINVAL; |
@@ -517,13 +536,13 @@ static int el3_open(struct net_device *dev) | |||
517 | { | 536 | { |
518 | struct el3_private *lp = netdev_priv(dev); | 537 | struct el3_private *lp = netdev_priv(dev); |
519 | struct pcmcia_device *link = lp->p_dev; | 538 | struct pcmcia_device *link = lp->p_dev; |
520 | 539 | ||
521 | if (!pcmcia_dev_present(link)) | 540 | if (!pcmcia_dev_present(link)) |
522 | return -ENODEV; | 541 | return -ENODEV; |
523 | 542 | ||
524 | link->open++; | 543 | link->open++; |
525 | netif_start_queue(dev); | 544 | netif_start_queue(dev); |
526 | 545 | ||
527 | tc589_reset(dev); | 546 | tc589_reset(dev); |
528 | init_timer(&lp->media); | 547 | init_timer(&lp->media); |
529 | lp->media.function = &media_check; | 548 | lp->media.function = &media_check; |
@@ -533,15 +552,15 @@ static int el3_open(struct net_device *dev) | |||
533 | 552 | ||
534 | dev_dbg(&link->dev, "%s: opened, status %4.4x.\n", | 553 | dev_dbg(&link->dev, "%s: opened, status %4.4x.\n", |
535 | dev->name, inw(dev->base_addr + EL3_STATUS)); | 554 | dev->name, inw(dev->base_addr + EL3_STATUS)); |
536 | 555 | ||
537 | return 0; | 556 | return 0; |
538 | } | 557 | } |
539 | 558 | ||
540 | static void el3_tx_timeout(struct net_device *dev) | 559 | static void el3_tx_timeout(struct net_device *dev) |
541 | { | 560 | { |
542 | unsigned int ioaddr = dev->base_addr; | 561 | unsigned int ioaddr = dev->base_addr; |
543 | 562 | ||
544 | printk(KERN_WARNING "%s: Transmit timed out!\n", dev->name); | 563 | netdev_warn(dev, "Transmit timed out!\n"); |
545 | dump_status(dev); | 564 | dump_status(dev); |
546 | dev->stats.tx_errors++; | 565 | dev->stats.tx_errors++; |
547 | dev->trans_start = jiffies; | 566 | dev->trans_start = jiffies; |
@@ -555,19 +574,18 @@ static void pop_tx_status(struct net_device *dev) | |||
555 | { | 574 | { |
556 | unsigned int ioaddr = dev->base_addr; | 575 | unsigned int ioaddr = dev->base_addr; |
557 | int i; | 576 | int i; |
558 | 577 | ||
559 | /* Clear the Tx status stack. */ | 578 | /* Clear the Tx status stack. */ |
560 | for (i = 32; i > 0; i--) { | 579 | for (i = 32; i > 0; i--) { |
561 | u_char tx_status = inb(ioaddr + TX_STATUS); | 580 | u_char tx_status = inb(ioaddr + TX_STATUS); |
562 | if (!(tx_status & 0x84)) break; | 581 | if (!(tx_status & 0x84)) break; |
563 | /* reset transmitter on jabber error or underrun */ | 582 | /* reset transmitter on jabber error or underrun */ |
564 | if (tx_status & 0x30) | 583 | if (tx_status & 0x30) |
565 | tc589_wait_for_completion(dev, TxReset); | 584 | tc589_wait_for_completion(dev, TxReset); |
566 | if (tx_status & 0x38) { | 585 | if (tx_status & 0x38) { |
567 | pr_debug("%s: transmit error: status 0x%02x\n", | 586 | netdev_dbg(dev, "transmit error: status 0x%02x\n", tx_status); |
568 | dev->name, tx_status); | 587 | outw(TxEnable, ioaddr + EL3_CMD); |
569 | outw(TxEnable, ioaddr + EL3_CMD); | 588 | dev->stats.tx_aborted_errors++; |
570 | dev->stats.tx_aborted_errors++; | ||
571 | } | 589 | } |
572 | outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ | 590 | outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ |
573 | } | 591 | } |
@@ -580,11 +598,10 @@ static netdev_tx_t el3_start_xmit(struct sk_buff *skb, | |||
580 | struct el3_private *priv = netdev_priv(dev); | 598 | struct el3_private *priv = netdev_priv(dev); |
581 | unsigned long flags; | 599 | unsigned long flags; |
582 | 600 | ||
583 | pr_debug("%s: el3_start_xmit(length = %ld) called, " | 601 | netdev_dbg(dev, "el3_start_xmit(length = %ld) called, status %4.4x.\n", |
584 | "status %4.4x.\n", dev->name, (long)skb->len, | 602 | (long)skb->len, inw(ioaddr + EL3_STATUS)); |
585 | inw(ioaddr + EL3_STATUS)); | ||
586 | 603 | ||
587 | spin_lock_irqsave(&priv->lock, flags); | 604 | spin_lock_irqsave(&priv->lock, flags); |
588 | 605 | ||
589 | dev->stats.tx_bytes += skb->len; | 606 | dev->stats.tx_bytes += skb->len; |
590 | 607 | ||
@@ -602,9 +619,9 @@ static netdev_tx_t el3_start_xmit(struct sk_buff *skb, | |||
602 | } | 619 | } |
603 | 620 | ||
604 | pop_tx_status(dev); | 621 | pop_tx_status(dev); |
605 | spin_unlock_irqrestore(&priv->lock, flags); | 622 | spin_unlock_irqrestore(&priv->lock, flags); |
606 | dev_kfree_skb(skb); | 623 | dev_kfree_skb(skb); |
607 | 624 | ||
608 | return NETDEV_TX_OK; | 625 | return NETDEV_TX_OK; |
609 | } | 626 | } |
610 | 627 | ||
@@ -616,37 +633,32 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id) | |||
616 | unsigned int ioaddr; | 633 | unsigned int ioaddr; |
617 | __u16 status; | 634 | __u16 status; |
618 | int i = 0, handled = 1; | 635 | int i = 0, handled = 1; |
619 | 636 | ||
620 | if (!netif_device_present(dev)) | 637 | if (!netif_device_present(dev)) |
621 | return IRQ_NONE; | 638 | return IRQ_NONE; |
622 | 639 | ||
623 | ioaddr = dev->base_addr; | 640 | ioaddr = dev->base_addr; |
624 | 641 | ||
625 | pr_debug("%s: interrupt, status %4.4x.\n", | 642 | netdev_dbg(dev, "interrupt, status %4.4x.\n", inw(ioaddr + EL3_STATUS)); |
626 | dev->name, inw(ioaddr + EL3_STATUS)); | ||
627 | 643 | ||
628 | spin_lock(&lp->lock); | 644 | spin_lock(&lp->lock); |
629 | while ((status = inw(ioaddr + EL3_STATUS)) & | 645 | while ((status = inw(ioaddr + EL3_STATUS)) & |
630 | (IntLatch | RxComplete | StatsFull)) { | 646 | (IntLatch | RxComplete | StatsFull)) { |
631 | if ((status & 0xe000) != 0x2000) { | 647 | if ((status & 0xe000) != 0x2000) { |
632 | pr_debug("%s: interrupt from dead card\n", dev->name); | 648 | netdev_dbg(dev, "interrupt from dead card\n"); |
633 | handled = 0; | 649 | handled = 0; |
634 | break; | 650 | break; |
635 | } | 651 | } |
636 | |||
637 | if (status & RxComplete) | 652 | if (status & RxComplete) |
638 | el3_rx(dev); | 653 | el3_rx(dev); |
639 | |||
640 | if (status & TxAvailable) { | 654 | if (status & TxAvailable) { |
641 | pr_debug(" TX room bit was handled.\n"); | 655 | netdev_dbg(dev, " TX room bit was handled.\n"); |
642 | /* There's room in the FIFO for a full-sized packet. */ | 656 | /* There's room in the FIFO for a full-sized packet. */ |
643 | outw(AckIntr | TxAvailable, ioaddr + EL3_CMD); | 657 | outw(AckIntr | TxAvailable, ioaddr + EL3_CMD); |
644 | netif_wake_queue(dev); | 658 | netif_wake_queue(dev); |
645 | } | 659 | } |
646 | |||
647 | if (status & TxComplete) | 660 | if (status & TxComplete) |
648 | pop_tx_status(dev); | 661 | pop_tx_status(dev); |
649 | |||
650 | if (status & (AdapterFailure | RxEarly | StatsFull)) { | 662 | if (status & (AdapterFailure | RxEarly | StatsFull)) { |
651 | /* Handle all uncommon interrupts. */ | 663 | /* Handle all uncommon interrupts. */ |
652 | if (status & StatsFull) /* Empty statistics. */ | 664 | if (status & StatsFull) /* Empty statistics. */ |
@@ -660,8 +672,8 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id) | |||
660 | EL3WINDOW(4); | 672 | EL3WINDOW(4); |
661 | fifo_diag = inw(ioaddr + 4); | 673 | fifo_diag = inw(ioaddr + 4); |
662 | EL3WINDOW(1); | 674 | EL3WINDOW(1); |
663 | printk(KERN_WARNING "%s: adapter failure, FIFO diagnostic" | 675 | netdev_warn(dev, "adapter failure, FIFO diagnostic register %04x.\n", |
664 | " register %04x.\n", dev->name, fifo_diag); | 676 | fifo_diag); |
665 | if (fifo_diag & 0x0400) { | 677 | if (fifo_diag & 0x0400) { |
666 | /* Tx overrun */ | 678 | /* Tx overrun */ |
667 | tc589_wait_for_completion(dev, TxReset); | 679 | tc589_wait_for_completion(dev, TxReset); |
@@ -676,22 +688,20 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id) | |||
676 | outw(AckIntr | AdapterFailure, ioaddr + EL3_CMD); | 688 | outw(AckIntr | AdapterFailure, ioaddr + EL3_CMD); |
677 | } | 689 | } |
678 | } | 690 | } |
679 | |||
680 | if (++i > 10) { | 691 | if (++i > 10) { |
681 | printk(KERN_ERR "%s: infinite loop in interrupt, " | 692 | netdev_err(dev, "infinite loop in interrupt, status %4.4x.\n", |
682 | "status %4.4x.\n", dev->name, status); | 693 | status); |
683 | /* Clear all interrupts */ | 694 | /* Clear all interrupts */ |
684 | outw(AckIntr | 0xFF, ioaddr + EL3_CMD); | 695 | outw(AckIntr | 0xFF, ioaddr + EL3_CMD); |
685 | break; | 696 | break; |
686 | } | 697 | } |
687 | /* Acknowledge the IRQ. */ | 698 | /* Acknowledge the IRQ. */ |
688 | outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD); | 699 | outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD); |
689 | } | 700 | } |
690 | |||
691 | lp->last_irq = jiffies; | 701 | lp->last_irq = jiffies; |
692 | spin_unlock(&lp->lock); | 702 | spin_unlock(&lp->lock); |
693 | pr_debug("%s: exiting interrupt, status %4.4x.\n", | 703 | netdev_dbg(dev, "exiting interrupt, status %4.4x.\n", |
694 | dev->name, inw(ioaddr + EL3_STATUS)); | 704 | inw(ioaddr + EL3_STATUS)); |
695 | return IRQ_RETVAL(handled); | 705 | return IRQ_RETVAL(handled); |
696 | } | 706 | } |
697 | 707 | ||
@@ -710,7 +720,7 @@ static void media_check(unsigned long arg) | |||
710 | if ((inw(ioaddr + EL3_STATUS) & IntLatch) && | 720 | if ((inw(ioaddr + EL3_STATUS) & IntLatch) && |
711 | (inb(ioaddr + EL3_TIMER) == 0xff)) { | 721 | (inb(ioaddr + EL3_TIMER) == 0xff)) { |
712 | if (!lp->fast_poll) | 722 | if (!lp->fast_poll) |
713 | printk(KERN_WARNING "%s: interrupt(s) dropped!\n", dev->name); | 723 | netdev_warn(dev, "interrupt(s) dropped!\n"); |
714 | 724 | ||
715 | local_irq_save(flags); | 725 | local_irq_save(flags); |
716 | el3_interrupt(dev->irq, dev); | 726 | el3_interrupt(dev->irq, dev); |
@@ -727,7 +737,7 @@ static void media_check(unsigned long arg) | |||
727 | 737 | ||
728 | /* lp->lock guards the EL3 window. Window should always be 1 except | 738 | /* lp->lock guards the EL3 window. Window should always be 1 except |
729 | when the lock is held */ | 739 | when the lock is held */ |
730 | spin_lock_irqsave(&lp->lock, flags); | 740 | spin_lock_irqsave(&lp->lock, flags); |
731 | EL3WINDOW(4); | 741 | EL3WINDOW(4); |
732 | media = inw(ioaddr+WN4_MEDIA) & 0xc810; | 742 | media = inw(ioaddr+WN4_MEDIA) & 0xc810; |
733 | 743 | ||
@@ -747,32 +757,30 @@ static void media_check(unsigned long arg) | |||
747 | if (media != lp->media_status) { | 757 | if (media != lp->media_status) { |
748 | if ((media & lp->media_status & 0x8000) && | 758 | if ((media & lp->media_status & 0x8000) && |
749 | ((lp->media_status ^ media) & 0x0800)) | 759 | ((lp->media_status ^ media) & 0x0800)) |
750 | printk(KERN_INFO "%s: %s link beat\n", dev->name, | 760 | netdev_info(dev, "%s link beat\n", |
751 | (lp->media_status & 0x0800 ? "lost" : "found")); | 761 | (lp->media_status & 0x0800 ? "lost" : "found")); |
752 | else if ((media & lp->media_status & 0x4000) && | 762 | else if ((media & lp->media_status & 0x4000) && |
753 | ((lp->media_status ^ media) & 0x0010)) | 763 | ((lp->media_status ^ media) & 0x0010)) |
754 | printk(KERN_INFO "%s: coax cable %s\n", dev->name, | 764 | netdev_info(dev, "coax cable %s\n", |
755 | (lp->media_status & 0x0010 ? "ok" : "problem")); | 765 | (lp->media_status & 0x0010 ? "ok" : "problem")); |
756 | if (dev->if_port == 0) { | 766 | if (dev->if_port == 0) { |
757 | if (media & 0x8000) { | 767 | if (media & 0x8000) { |
758 | if (media & 0x0800) | 768 | if (media & 0x0800) |
759 | printk(KERN_INFO "%s: flipped to 10baseT\n", | 769 | netdev_info(dev, "flipped to 10baseT\n"); |
760 | dev->name); | ||
761 | else | 770 | else |
762 | tc589_set_xcvr(dev, 2); | 771 | tc589_set_xcvr(dev, 2); |
763 | } else if (media & 0x4000) { | 772 | } else if (media & 0x4000) { |
764 | if (media & 0x0010) | 773 | if (media & 0x0010) |
765 | tc589_set_xcvr(dev, 1); | 774 | tc589_set_xcvr(dev, 1); |
766 | else | 775 | else |
767 | printk(KERN_INFO "%s: flipped to 10base2\n", | 776 | netdev_info(dev, "flipped to 10base2\n"); |
768 | dev->name); | ||
769 | } | 777 | } |
770 | } | 778 | } |
771 | lp->media_status = media; | 779 | lp->media_status = media; |
772 | } | 780 | } |
773 | 781 | ||
774 | EL3WINDOW(1); | 782 | EL3WINDOW(1); |
775 | spin_unlock_irqrestore(&lp->lock, flags); | 783 | spin_unlock_irqrestore(&lp->lock, flags); |
776 | 784 | ||
777 | reschedule: | 785 | reschedule: |
778 | lp->media.expires = jiffies + HZ; | 786 | lp->media.expires = jiffies + HZ; |
@@ -786,7 +794,7 @@ static struct net_device_stats *el3_get_stats(struct net_device *dev) | |||
786 | struct pcmcia_device *link = lp->p_dev; | 794 | struct pcmcia_device *link = lp->p_dev; |
787 | 795 | ||
788 | if (pcmcia_dev_present(link)) { | 796 | if (pcmcia_dev_present(link)) { |
789 | spin_lock_irqsave(&lp->lock, flags); | 797 | spin_lock_irqsave(&lp->lock, flags); |
790 | update_stats(dev); | 798 | update_stats(dev); |
791 | spin_unlock_irqrestore(&lp->lock, flags); | 799 | spin_unlock_irqrestore(&lp->lock, flags); |
792 | } | 800 | } |
@@ -798,21 +806,21 @@ static struct net_device_stats *el3_get_stats(struct net_device *dev) | |||
798 | single-threaded if the device is active. This is expected to be a rare | 806 | single-threaded if the device is active. This is expected to be a rare |
799 | operation, and it's simpler for the rest of the driver to assume that | 807 | operation, and it's simpler for the rest of the driver to assume that |
800 | window 1 is always valid rather than use a special window-state variable. | 808 | window 1 is always valid rather than use a special window-state variable. |
801 | 809 | ||
802 | Caller must hold the lock for this | 810 | Caller must hold the lock for this |
803 | */ | 811 | */ |
804 | static void update_stats(struct net_device *dev) | 812 | static void update_stats(struct net_device *dev) |
805 | { | 813 | { |
806 | unsigned int ioaddr = dev->base_addr; | 814 | unsigned int ioaddr = dev->base_addr; |
807 | 815 | ||
808 | pr_debug("%s: updating the statistics.\n", dev->name); | 816 | netdev_dbg(dev, "updating the statistics.\n"); |
809 | /* Turn off statistics updates while reading. */ | 817 | /* Turn off statistics updates while reading. */ |
810 | outw(StatsDisable, ioaddr + EL3_CMD); | 818 | outw(StatsDisable, ioaddr + EL3_CMD); |
811 | /* Switch to the stats window, and read everything. */ | 819 | /* Switch to the stats window, and read everything. */ |
812 | EL3WINDOW(6); | 820 | EL3WINDOW(6); |
813 | dev->stats.tx_carrier_errors += inb(ioaddr + 0); | 821 | dev->stats.tx_carrier_errors += inb(ioaddr + 0); |
814 | dev->stats.tx_heartbeat_errors += inb(ioaddr + 1); | 822 | dev->stats.tx_heartbeat_errors += inb(ioaddr + 1); |
815 | /* Multiple collisions. */ inb(ioaddr + 2); | 823 | /* Multiple collisions. */ inb(ioaddr + 2); |
816 | dev->stats.collisions += inb(ioaddr + 3); | 824 | dev->stats.collisions += inb(ioaddr + 3); |
817 | dev->stats.tx_window_errors += inb(ioaddr + 4); | 825 | dev->stats.tx_window_errors += inb(ioaddr + 4); |
818 | dev->stats.rx_fifo_errors += inb(ioaddr + 5); | 826 | dev->stats.rx_fifo_errors += inb(ioaddr + 5); |
@@ -821,7 +829,7 @@ static void update_stats(struct net_device *dev) | |||
821 | /* Tx deferrals */ inb(ioaddr + 8); | 829 | /* Tx deferrals */ inb(ioaddr + 8); |
822 | /* Rx octets */ inw(ioaddr + 10); | 830 | /* Rx octets */ inw(ioaddr + 10); |
823 | /* Tx octets */ inw(ioaddr + 12); | 831 | /* Tx octets */ inw(ioaddr + 12); |
824 | 832 | ||
825 | /* Back to window 1, and turn statistics back on. */ | 833 | /* Back to window 1, and turn statistics back on. */ |
826 | EL3WINDOW(1); | 834 | EL3WINDOW(1); |
827 | outw(StatsEnable, ioaddr + EL3_CMD); | 835 | outw(StatsEnable, ioaddr + EL3_CMD); |
@@ -832,9 +840,9 @@ static int el3_rx(struct net_device *dev) | |||
832 | unsigned int ioaddr = dev->base_addr; | 840 | unsigned int ioaddr = dev->base_addr; |
833 | int worklimit = 32; | 841 | int worklimit = 32; |
834 | short rx_status; | 842 | short rx_status; |
835 | 843 | ||
836 | pr_debug("%s: in rx_packet(), status %4.4x, rx_status %4.4x.\n", | 844 | netdev_dbg(dev, "in rx_packet(), status %4.4x, rx_status %4.4x.\n", |
837 | dev->name, inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS)); | 845 | inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS)); |
838 | while (!((rx_status = inw(ioaddr + RX_STATUS)) & 0x8000) && | 846 | while (!((rx_status = inw(ioaddr + RX_STATUS)) & 0x8000) && |
839 | worklimit > 0) { | 847 | worklimit > 0) { |
840 | worklimit--; | 848 | worklimit--; |
@@ -852,11 +860,11 @@ static int el3_rx(struct net_device *dev) | |||
852 | } else { | 860 | } else { |
853 | short pkt_len = rx_status & 0x7ff; | 861 | short pkt_len = rx_status & 0x7ff; |
854 | struct sk_buff *skb; | 862 | struct sk_buff *skb; |
855 | 863 | ||
856 | skb = dev_alloc_skb(pkt_len+5); | 864 | skb = dev_alloc_skb(pkt_len+5); |
857 | 865 | ||
858 | pr_debug(" Receiving packet size %d status %4.4x.\n", | 866 | netdev_dbg(dev, " Receiving packet size %d status %4.4x.\n", |
859 | pkt_len, rx_status); | 867 | pkt_len, rx_status); |
860 | if (skb != NULL) { | 868 | if (skb != NULL) { |
861 | skb_reserve(skb, 2); | 869 | skb_reserve(skb, 2); |
862 | insl(ioaddr+RX_FIFO, skb_put(skb, pkt_len), | 870 | insl(ioaddr+RX_FIFO, skb_put(skb, pkt_len), |
@@ -866,8 +874,8 @@ static int el3_rx(struct net_device *dev) | |||
866 | dev->stats.rx_packets++; | 874 | dev->stats.rx_packets++; |
867 | dev->stats.rx_bytes += pkt_len; | 875 | dev->stats.rx_bytes += pkt_len; |
868 | } else { | 876 | } else { |
869 | pr_debug("%s: couldn't allocate a sk_buff of" | 877 | netdev_dbg(dev, "couldn't allocate a sk_buff of size %d.\n", |
870 | " size %d.\n", dev->name, pkt_len); | 878 | pkt_len); |
871 | dev->stats.rx_dropped++; | 879 | dev->stats.rx_dropped++; |
872 | } | 880 | } |
873 | } | 881 | } |
@@ -875,7 +883,7 @@ static int el3_rx(struct net_device *dev) | |||
875 | tc589_wait_for_completion(dev, RxDiscard); | 883 | tc589_wait_for_completion(dev, RxDiscard); |
876 | } | 884 | } |
877 | if (worklimit == 0) | 885 | if (worklimit == 0) |
878 | printk(KERN_WARNING "%s: too much work in el3_rx!\n", dev->name); | 886 | netdev_warn(dev, "too much work in el3_rx!\n"); |
879 | return 0; | 887 | return 0; |
880 | } | 888 | } |
881 | 889 | ||
@@ -906,17 +914,17 @@ static int el3_close(struct net_device *dev) | |||
906 | struct el3_private *lp = netdev_priv(dev); | 914 | struct el3_private *lp = netdev_priv(dev); |
907 | struct pcmcia_device *link = lp->p_dev; | 915 | struct pcmcia_device *link = lp->p_dev; |
908 | unsigned int ioaddr = dev->base_addr; | 916 | unsigned int ioaddr = dev->base_addr; |
909 | 917 | ||
910 | dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name); | 918 | dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name); |
911 | 919 | ||
912 | if (pcmcia_dev_present(link)) { | 920 | if (pcmcia_dev_present(link)) { |
913 | /* Turn off statistics ASAP. We update dev->stats below. */ | 921 | /* Turn off statistics ASAP. We update dev->stats below. */ |
914 | outw(StatsDisable, ioaddr + EL3_CMD); | 922 | outw(StatsDisable, ioaddr + EL3_CMD); |
915 | 923 | ||
916 | /* Disable the receiver and transmitter. */ | 924 | /* Disable the receiver and transmitter. */ |
917 | outw(RxDisable, ioaddr + EL3_CMD); | 925 | outw(RxDisable, ioaddr + EL3_CMD); |
918 | outw(TxDisable, ioaddr + EL3_CMD); | 926 | outw(TxDisable, ioaddr + EL3_CMD); |
919 | 927 | ||
920 | if (dev->if_port == 2) | 928 | if (dev->if_port == 2) |
921 | /* Turn off thinnet power. Green! */ | 929 | /* Turn off thinnet power. Green! */ |
922 | outw(StopCoax, ioaddr + EL3_CMD); | 930 | outw(StopCoax, ioaddr + EL3_CMD); |
@@ -925,12 +933,12 @@ static int el3_close(struct net_device *dev) | |||
925 | EL3WINDOW(4); | 933 | EL3WINDOW(4); |
926 | outw(0, ioaddr + WN4_MEDIA); | 934 | outw(0, ioaddr + WN4_MEDIA); |
927 | } | 935 | } |
928 | 936 | ||
929 | /* Switching back to window 0 disables the IRQ. */ | 937 | /* Switching back to window 0 disables the IRQ. */ |
930 | EL3WINDOW(0); | 938 | EL3WINDOW(0); |
931 | /* But we explicitly zero the IRQ line select anyway. */ | 939 | /* But we explicitly zero the IRQ line select anyway. */ |
932 | outw(0x0f00, ioaddr + WN0_IRQ); | 940 | outw(0x0f00, ioaddr + WN0_IRQ); |
933 | 941 | ||
934 | /* Check if the card still exists */ | 942 | /* Check if the card still exists */ |
935 | if ((inw(ioaddr+EL3_STATUS) & 0xe000) == 0x2000) | 943 | if ((inw(ioaddr+EL3_STATUS) & 0xe000) == 0x2000) |
936 | update_stats(dev); | 944 | update_stats(dev); |
@@ -939,7 +947,7 @@ static int el3_close(struct net_device *dev) | |||
939 | link->open--; | 947 | link->open--; |
940 | netif_stop_queue(dev); | 948 | netif_stop_queue(dev); |
941 | del_timer_sync(&lp->media); | 949 | del_timer_sync(&lp->media); |
942 | 950 | ||
943 | return 0; | 951 | return 0; |
944 | } | 952 | } |
945 | 953 | ||
@@ -961,7 +969,7 @@ static struct pcmcia_driver tc589_driver = { | |||
961 | }, | 969 | }, |
962 | .probe = tc589_probe, | 970 | .probe = tc589_probe, |
963 | .remove = tc589_detach, | 971 | .remove = tc589_detach, |
964 | .id_table = tc589_ids, | 972 | .id_table = tc589_ids, |
965 | .suspend = tc589_suspend, | 973 | .suspend = tc589_suspend, |
966 | .resume = tc589_resume, | 974 | .resume = tc589_resume, |
967 | }; | 975 | }; |