Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Drivers: net: ethernet: 3com: 3c589_cs fixed coding style issues

checkpatch.pl clean-up, from 14 error/ 277 warnings, to 0 errors, 7 warnings

Signed-off-by: Justin van Wijngaarden <justinvanwijngaarden@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Justin van Wijngaarden and committed by
David S. Miller
6df3efcc 82f148e9

+555 -514
+555 -514
drivers/net/ethernet/3com/3c589_cs.c
··· 1 - /*====================================================================== 2 - 3 - A PCMCIA ethernet driver for the 3com 3c589 card. 4 - 5 - Copyright (C) 1999 David A. Hinds -- dahinds@users.sourceforge.net 6 - 7 - 3c589_cs.c 1.162 2001/10/13 00:08:50 8 - 9 - The network driver code is based on Donald Becker's 3c589 code: 10 - 11 - Written 1994 by Donald Becker. 12 - Copyright 1993 United States Government as represented by the 13 - Director, National Security Agency. This software may be used and 14 - distributed according to the terms of the GNU General Public License, 15 - incorporated herein by reference. 16 - Donald Becker may be reached at becker@scyld.com 17 - 18 - Updated for 2.5.x by Alan Cox <alan@lxorguk.ukuu.org.uk> 19 - 20 - ======================================================================*/ 1 + /* ====================================================================== 2 + * 3 + * A PCMCIA ethernet driver for the 3com 3c589 card. 4 + * 5 + * Copyright (C) 1999 David A. Hinds -- dahinds@users.sourceforge.net 6 + * 7 + * 3c589_cs.c 1.162 2001/10/13 00:08:50 8 + * 9 + * The network driver code is based on Donald Becker's 3c589 code: 10 + * 11 + * Written 1994 by Donald Becker. 12 + * Copyright 1993 United States Government as represented by the 13 + * Director, National Security Agency. This software may be used and 14 + * distributed according to the terms of the GNU General Public License, 15 + * incorporated herein by reference. 16 + * Donald Becker may be reached at becker@scyld.com 17 + * 18 + * Updated for 2.5.x by Alan Cox <alan@lxorguk.ukuu.org.uk> 19 + * 20 + * ====================================================================== 21 + */ 21 22 22 23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 23 24 ··· 42 41 #include <linux/ioport.h> 43 42 #include <linux/bitops.h> 44 43 #include <linux/jiffies.h> 44 + #include <linux/uaccess.h> 45 + #include <linux/io.h> 45 46 46 47 #include <pcmcia/cistpl.h> 47 48 #include <pcmcia/cisreg.h> 48 49 #include <pcmcia/ciscode.h> 49 50 #include <pcmcia/ds.h> 50 51 51 - #include <asm/uaccess.h> 52 - #include <asm/io.h> 53 52 54 53 /* To minimize the size of the driver source I only define operating 55 - constants if they are used several times. You'll need the manual 56 - if you want to understand driver details. */ 54 + * constants if they are used several times. You'll need the manual 55 + * if you want to understand driver details. 56 + */ 57 + 57 58 /* Offsets from base I/O address. */ 58 59 #define EL3_DATA 0x00 59 60 #define EL3_TIMER 0x0a ··· 68 65 #define EL3WINDOW(win_num) outw(SelectWindow + (win_num), ioaddr + EL3_CMD) 69 66 70 67 /* The top five bits written to EL3_CMD are a command, the lower 71 - 11 bits are the parameter, if applicable. */ 68 + * 11 bits are the parameter, if applicable. 69 + */ 70 + 72 71 enum c509cmd { 73 72 TotalReset = 0<<11, 74 73 SelectWindow = 1<<11, ··· 195 190 196 191 static int tc589_probe(struct pcmcia_device *link) 197 192 { 198 - struct el3_private *lp; 199 - struct net_device *dev; 193 + struct el3_private *lp; 194 + struct net_device *dev; 200 195 201 - dev_dbg(&link->dev, "3c589_attach()\n"); 196 + dev_dbg(&link->dev, "3c589_attach()\n"); 202 197 203 - /* Create new ethernet device */ 204 - dev = alloc_etherdev(sizeof(struct el3_private)); 205 - if (!dev) 206 - return -ENOMEM; 207 - lp = netdev_priv(dev); 208 - link->priv = dev; 209 - lp->p_dev = link; 198 + /* Create new ethernet device */ 199 + dev = alloc_etherdev(sizeof(struct el3_private)); 200 + if (!dev) 201 + return -ENOMEM; 202 + lp = netdev_priv(dev); 203 + link->priv = dev; 204 + lp->p_dev = link; 210 205 211 - spin_lock_init(&lp->lock); 212 - link->resource[0]->end = 16; 213 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16; 206 + spin_lock_init(&lp->lock); 207 + link->resource[0]->end = 16; 208 + link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16; 214 209 215 - link->config_flags |= CONF_ENABLE_IRQ; 216 - link->config_index = 1; 210 + link->config_flags |= CONF_ENABLE_IRQ; 211 + link->config_index = 1; 217 212 218 - dev->netdev_ops = &el3_netdev_ops; 219 - dev->watchdog_timeo = TX_TIMEOUT; 213 + dev->netdev_ops = &el3_netdev_ops; 214 + dev->watchdog_timeo = TX_TIMEOUT; 220 215 221 - SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 216 + SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 222 217 223 - return tc589_config(link); 218 + return tc589_config(link); 224 219 } 225 220 226 221 static void tc589_detach(struct pcmcia_device *link) 227 222 { 228 - struct net_device *dev = link->priv; 223 + struct net_device *dev = link->priv; 229 224 230 - dev_dbg(&link->dev, "3c589_detach\n"); 225 + dev_dbg(&link->dev, "3c589_detach\n"); 231 226 232 - unregister_netdev(dev); 227 + unregister_netdev(dev); 233 228 234 - tc589_release(link); 229 + tc589_release(link); 235 230 236 - free_netdev(dev); 231 + free_netdev(dev); 237 232 } /* tc589_detach */ 238 233 239 234 static int tc589_config(struct pcmcia_device *link) 240 235 { 241 - struct net_device *dev = link->priv; 242 - __be16 *phys_addr; 243 - int ret, i, j, multi = 0, fifo; 244 - unsigned int ioaddr; 245 - static const char * const ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; 246 - u8 *buf; 247 - size_t len; 236 + struct net_device *dev = link->priv; 237 + __be16 *phys_addr; 238 + int ret, i, j, multi = 0, fifo; 239 + unsigned int ioaddr; 240 + static const char * const ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; 241 + u8 *buf; 242 + size_t len; 248 243 249 - dev_dbg(&link->dev, "3c589_config\n"); 244 + dev_dbg(&link->dev, "3c589_config\n"); 250 245 251 - phys_addr = (__be16 *)dev->dev_addr; 252 - /* Is this a 3c562? */ 253 - if (link->manf_id != MANFID_3COM) 254 - dev_info(&link->dev, "hmmm, is this really a 3Com card??\n"); 255 - multi = (link->card_id == PRODID_3COM_3C562); 246 + phys_addr = (__be16 *)dev->dev_addr; 247 + /* Is this a 3c562? */ 248 + if (link->manf_id != MANFID_3COM) 249 + dev_info(&link->dev, "hmmm, is this really a 3Com card??\n"); 250 + multi = (link->card_id == PRODID_3COM_3C562); 256 251 257 - link->io_lines = 16; 252 + link->io_lines = 16; 258 253 259 - /* For the 3c562, the base address must be xx00-xx7f */ 260 - for (i = j = 0; j < 0x400; j += 0x10) { 261 - if (multi && (j & 0x80)) continue; 262 - link->resource[0]->start = j ^ 0x300; 263 - i = pcmcia_request_io(link); 264 - if (i == 0) 265 - break; 266 - } 267 - if (i != 0) 268 - goto failed; 269 - 270 - ret = pcmcia_request_irq(link, el3_interrupt); 271 - if (ret) 272 - goto failed; 273 - 274 - ret = pcmcia_enable_device(link); 275 - if (ret) 276 - goto failed; 277 - 278 - dev->irq = link->irq; 279 - dev->base_addr = link->resource[0]->start; 280 - ioaddr = dev->base_addr; 281 - EL3WINDOW(0); 282 - 283 - /* The 3c589 has an extra EEPROM for configuration info, including 284 - the hardware address. The 3c562 puts the address in the CIS. */ 285 - len = pcmcia_get_tuple(link, 0x88, &buf); 286 - if (buf && len >= 6) { 287 - for (i = 0; i < 3; i++) 288 - phys_addr[i] = htons(le16_to_cpu(buf[i*2])); 289 - kfree(buf); 290 - } else { 291 - kfree(buf); /* 0 < len < 6 */ 292 - for (i = 0; i < 3; i++) 293 - phys_addr[i] = htons(read_eeprom(ioaddr, i)); 294 - if (phys_addr[0] == htons(0x6060)) { 295 - dev_err(&link->dev, "IO port conflict at 0x%03lx-0x%03lx\n", 296 - dev->base_addr, dev->base_addr+15); 297 - goto failed; 254 + /* For the 3c562, the base address must be xx00-xx7f */ 255 + for (i = j = 0; j < 0x400; j += 0x10) { 256 + if (multi && (j & 0x80)) 257 + continue; 258 + link->resource[0]->start = j ^ 0x300; 259 + i = pcmcia_request_io(link); 260 + if (i == 0) 261 + break; 298 262 } 299 - } 263 + if (i != 0) 264 + goto failed; 300 265 301 - /* The address and resource configuration register aren't loaded from 302 - the EEPROM and *must* be set to 0 and IRQ3 for the PCMCIA version. */ 303 - outw(0x3f00, ioaddr + 8); 304 - fifo = inl(ioaddr); 266 + ret = pcmcia_request_irq(link, el3_interrupt); 267 + if (ret) 268 + goto failed; 305 269 306 - /* The if_port symbol can be set when the module is loaded */ 307 - if ((if_port >= 0) && (if_port <= 3)) 308 - dev->if_port = if_port; 309 - else 310 - dev_err(&link->dev, "invalid if_port requested\n"); 270 + ret = pcmcia_enable_device(link); 271 + if (ret) 272 + goto failed; 311 273 312 - SET_NETDEV_DEV(dev, &link->dev); 274 + dev->irq = link->irq; 275 + dev->base_addr = link->resource[0]->start; 276 + ioaddr = dev->base_addr; 277 + EL3WINDOW(0); 313 278 314 - if (register_netdev(dev) != 0) { 315 - dev_err(&link->dev, "register_netdev() failed\n"); 316 - goto failed; 317 - } 279 + /* The 3c589 has an extra EEPROM for configuration info, including 280 + * the hardware address. The 3c562 puts the address in the CIS. 281 + */ 282 + len = pcmcia_get_tuple(link, 0x88, &buf); 283 + if (buf && len >= 6) { 284 + for (i = 0; i < 3; i++) 285 + phys_addr[i] = htons(le16_to_cpu(buf[i*2])); 286 + kfree(buf); 287 + } else { 288 + kfree(buf); /* 0 < len < 6 */ 289 + for (i = 0; i < 3; i++) 290 + phys_addr[i] = htons(read_eeprom(ioaddr, i)); 291 + if (phys_addr[0] == htons(0x6060)) { 292 + dev_err(&link->dev, "IO port conflict at 0x%03lx-0x%03lx\n", 293 + dev->base_addr, dev->base_addr+15); 294 + goto failed; 295 + } 296 + } 318 297 319 - netdev_info(dev, "3Com 3c%s, io %#3lx, irq %d, hw_addr %pM\n", 320 - (multi ? "562" : "589"), dev->base_addr, dev->irq, 321 - dev->dev_addr); 322 - netdev_info(dev, " %dK FIFO split %s Rx:Tx, %s xcvr\n", 323 - (fifo & 7) ? 32 : 8, ram_split[(fifo >> 16) & 3], 324 - if_names[dev->if_port]); 325 - return 0; 298 + /* The address and resource configuration register aren't loaded from 299 + * the EEPROM and *must* be set to 0 and IRQ3 for the PCMCIA version. 300 + */ 301 + 302 + outw(0x3f00, ioaddr + 8); 303 + fifo = inl(ioaddr); 304 + 305 + /* The if_port symbol can be set when the module is loaded */ 306 + if ((if_port >= 0) && (if_port <= 3)) 307 + dev->if_port = if_port; 308 + else 309 + dev_err(&link->dev, "invalid if_port requested\n"); 310 + 311 + SET_NETDEV_DEV(dev, &link->dev); 312 + 313 + if (register_netdev(dev) != 0) { 314 + dev_err(&link->dev, "register_netdev() failed\n"); 315 + goto failed; 316 + } 317 + 318 + netdev_info(dev, "3Com 3c%s, io %#3lx, irq %d, hw_addr %pM\n", 319 + (multi ? "562" : "589"), dev->base_addr, dev->irq, 320 + dev->dev_addr); 321 + netdev_info(dev, " %dK FIFO split %s Rx:Tx, %s xcvr\n", 322 + (fifo & 7) ? 32 : 8, ram_split[(fifo >> 16) & 3], 323 + if_names[dev->if_port]); 324 + return 0; 326 325 327 326 failed: 328 - tc589_release(link); 329 - return -ENODEV; 327 + tc589_release(link); 328 + return -ENODEV; 330 329 } /* tc589_config */ 331 330 332 331 static void tc589_release(struct pcmcia_device *link) ··· 362 353 363 354 /*====================================================================*/ 364 355 365 - /* 366 - Use this for commands that may take time to finish 367 - */ 356 + /* Use this for commands that may take time to finish */ 357 + 368 358 static void tc589_wait_for_completion(struct net_device *dev, int cmd) 369 359 { 370 - int i = 100; 371 - outw(cmd, dev->base_addr + EL3_CMD); 372 - while (--i > 0) 373 - if (!(inw(dev->base_addr + EL3_STATUS) & 0x1000)) break; 374 - if (i == 0) 375 - netdev_warn(dev, "command 0x%04x did not complete!\n", cmd); 360 + int i = 100; 361 + outw(cmd, dev->base_addr + EL3_CMD); 362 + while (--i > 0) 363 + if (!(inw(dev->base_addr + EL3_STATUS) & 0x1000)) 364 + break; 365 + if (i == 0) 366 + netdev_warn(dev, "command 0x%04x did not complete!\n", cmd); 376 367 } 377 368 378 - /* 379 - Read a word from the EEPROM using the regular EEPROM access register. 380 - Assume that we are in register window zero. 381 - */ 369 + /* Read a word from the EEPROM using the regular EEPROM access register. 370 + * Assume that we are in register window zero. 371 + */ 372 + 382 373 static u16 read_eeprom(unsigned int ioaddr, int index) 383 374 { 384 - int i; 385 - outw(EEPROM_READ + index, ioaddr + 10); 386 - /* Reading the eeprom takes 162 us */ 387 - for (i = 1620; i >= 0; i--) 388 - if ((inw(ioaddr + 10) & EEPROM_BUSY) == 0) 389 - break; 390 - return inw(ioaddr + 12); 375 + int i; 376 + outw(EEPROM_READ + index, ioaddr + 10); 377 + /* Reading the eeprom takes 162 us */ 378 + for (i = 1620; i >= 0; i--) 379 + if ((inw(ioaddr + 10) & EEPROM_BUSY) == 0) 380 + break; 381 + return inw(ioaddr + 12); 391 382 } 392 383 393 - /* 394 - Set transceiver type, perhaps to something other than what the user 395 - specified in dev->if_port. 396 - */ 384 + /* Set transceiver type, perhaps to something other than what the user 385 + * specified in dev->if_port. 386 + */ 387 + 397 388 static void tc589_set_xcvr(struct net_device *dev, int if_port) 398 389 { 399 - struct el3_private *lp = netdev_priv(dev); 400 - unsigned int ioaddr = dev->base_addr; 390 + struct el3_private *lp = netdev_priv(dev); 391 + unsigned int ioaddr = dev->base_addr; 401 392 402 - EL3WINDOW(0); 403 - switch (if_port) { 404 - case 0: case 1: outw(0, ioaddr + 6); break; 405 - case 2: outw(3<<14, ioaddr + 6); break; 406 - case 3: outw(1<<14, ioaddr + 6); break; 407 - } 408 - /* On PCMCIA, this just turns on the LED */ 409 - outw((if_port == 2) ? StartCoax : StopCoax, ioaddr + EL3_CMD); 410 - /* 10baseT interface, enable link beat and jabber check. */ 411 - EL3WINDOW(4); 412 - outw(MEDIA_LED | ((if_port < 2) ? MEDIA_TP : 0), ioaddr + WN4_MEDIA); 413 - EL3WINDOW(1); 414 - if (if_port == 2) 415 - lp->media_status = ((dev->if_port == 0) ? 0x8000 : 0x4000); 416 - else 417 - lp->media_status = ((dev->if_port == 0) ? 0x4010 : 0x8800); 393 + EL3WINDOW(0); 394 + switch (if_port) { 395 + case 0: 396 + case 1: 397 + outw(0, ioaddr + 6); 398 + break; 399 + case 2: 400 + outw(3<<14, ioaddr + 6); 401 + break; 402 + case 3: 403 + outw(1<<14, ioaddr + 6); 404 + break; 405 + } 406 + /* On PCMCIA, this just turns on the LED */ 407 + outw((if_port == 2) ? StartCoax : StopCoax, ioaddr + EL3_CMD); 408 + /* 10baseT interface, enable link beat and jabber check. */ 409 + EL3WINDOW(4); 410 + outw(MEDIA_LED | ((if_port < 2) ? MEDIA_TP : 0), ioaddr + WN4_MEDIA); 411 + EL3WINDOW(1); 412 + if (if_port == 2) 413 + lp->media_status = ((dev->if_port == 0) ? 0x8000 : 0x4000); 414 + else 415 + lp->media_status = ((dev->if_port == 0) ? 0x4010 : 0x8800); 418 416 } 419 417 420 418 static void dump_status(struct net_device *dev) 421 419 { 422 - unsigned int ioaddr = dev->base_addr; 423 - EL3WINDOW(1); 424 - netdev_info(dev, " irq status %04x, rx status %04x, tx status %02x tx free %04x\n", 425 - inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS), 426 - inb(ioaddr+TX_STATUS), inw(ioaddr+TX_FREE)); 427 - EL3WINDOW(4); 428 - netdev_info(dev, " diagnostics: fifo %04x net %04x ethernet %04x media %04x\n", 429 - inw(ioaddr+0x04), inw(ioaddr+0x06), inw(ioaddr+0x08), 430 - inw(ioaddr+0x0a)); 431 - EL3WINDOW(1); 420 + unsigned int ioaddr = dev->base_addr; 421 + EL3WINDOW(1); 422 + netdev_info(dev, " irq status %04x, rx status %04x, tx status %02x tx free %04x\n", 423 + inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS), 424 + inb(ioaddr+TX_STATUS), inw(ioaddr+TX_FREE)); 425 + EL3WINDOW(4); 426 + netdev_info(dev, " diagnostics: fifo %04x net %04x ethernet %04x media %04x\n", 427 + inw(ioaddr+0x04), inw(ioaddr+0x06), inw(ioaddr+0x08), 428 + inw(ioaddr+0x0a)); 429 + EL3WINDOW(1); 432 430 } 433 431 434 432 /* Reset and restore all of the 3c589 registers. */ 435 433 static void tc589_reset(struct net_device *dev) 436 434 { 437 - unsigned int ioaddr = dev->base_addr; 438 - int i; 435 + unsigned int ioaddr = dev->base_addr; 436 + int i; 439 437 440 - EL3WINDOW(0); 441 - outw(0x0001, ioaddr + 4); /* Activate board. */ 442 - outw(0x3f00, ioaddr + 8); /* Set the IRQ line. */ 438 + EL3WINDOW(0); 439 + outw(0x0001, ioaddr + 4); /* Activate board. */ 440 + outw(0x3f00, ioaddr + 8); /* Set the IRQ line. */ 443 441 444 - /* Set the station address in window 2. */ 445 - EL3WINDOW(2); 446 - for (i = 0; i < 6; i++) 447 - outb(dev->dev_addr[i], ioaddr + i); 442 + /* Set the station address in window 2. */ 443 + EL3WINDOW(2); 444 + for (i = 0; i < 6; i++) 445 + outb(dev->dev_addr[i], ioaddr + i); 448 446 449 - tc589_set_xcvr(dev, dev->if_port); 447 + tc589_set_xcvr(dev, dev->if_port); 450 448 451 - /* Switch to the stats window, and clear all stats by reading. */ 452 - outw(StatsDisable, ioaddr + EL3_CMD); 453 - EL3WINDOW(6); 454 - for (i = 0; i < 9; i++) 455 - inb(ioaddr+i); 456 - inw(ioaddr + 10); 457 - inw(ioaddr + 12); 449 + /* Switch to the stats window, and clear all stats by reading. */ 450 + outw(StatsDisable, ioaddr + EL3_CMD); 451 + EL3WINDOW(6); 452 + for (i = 0; i < 9; i++) 453 + inb(ioaddr+i); 454 + inw(ioaddr + 10); 455 + inw(ioaddr + 12); 458 456 459 - /* Switch to register set 1 for normal use. */ 460 - EL3WINDOW(1); 457 + /* Switch to register set 1 for normal use. */ 458 + EL3WINDOW(1); 461 459 462 - set_rx_mode(dev); 463 - outw(StatsEnable, ioaddr + EL3_CMD); /* Turn on statistics. */ 464 - outw(RxEnable, ioaddr + EL3_CMD); /* Enable the receiver. */ 465 - outw(TxEnable, ioaddr + EL3_CMD); /* Enable transmitter. */ 466 - /* Allow status bits to be seen. */ 467 - outw(SetStatusEnb | 0xff, ioaddr + EL3_CMD); 468 - /* Ack all pending events, and set active indicator mask. */ 469 - outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq, 460 + set_rx_mode(dev); 461 + outw(StatsEnable, ioaddr + EL3_CMD); /* Turn on statistics. */ 462 + outw(RxEnable, ioaddr + EL3_CMD); /* Enable the receiver. */ 463 + outw(TxEnable, ioaddr + EL3_CMD); /* Enable transmitter. */ 464 + /* Allow status bits to be seen. */ 465 + outw(SetStatusEnb | 0xff, ioaddr + EL3_CMD); 466 + /* Ack all pending events, and set active indicator mask. */ 467 + outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq, 470 468 ioaddr + EL3_CMD); 471 - outw(SetIntrEnb | IntLatch | TxAvailable | RxComplete | StatsFull 469 + outw(SetIntrEnb | IntLatch | TxAvailable | RxComplete | StatsFull 472 470 | AdapterFailure, ioaddr + EL3_CMD); 473 471 } 474 472 ··· 494 478 495 479 static int el3_config(struct net_device *dev, struct ifmap *map) 496 480 { 497 - if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) { 498 - if (map->port <= 3) { 499 - dev->if_port = map->port; 500 - netdev_info(dev, "switched to %s port\n", if_names[dev->if_port]); 501 - tc589_set_xcvr(dev, dev->if_port); 502 - } else 503 - return -EINVAL; 504 - } 505 - return 0; 481 + if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) { 482 + if (map->port <= 3) { 483 + dev->if_port = map->port; 484 + netdev_info(dev, "switched to %s port\n", if_names[dev->if_port]); 485 + tc589_set_xcvr(dev, dev->if_port); 486 + } else { 487 + return -EINVAL; 488 + } 489 + } 490 + return 0; 506 491 } 507 492 508 493 static int el3_open(struct net_device *dev) 509 494 { 510 - struct el3_private *lp = netdev_priv(dev); 511 - struct pcmcia_device *link = lp->p_dev; 495 + struct el3_private *lp = netdev_priv(dev); 496 + struct pcmcia_device *link = lp->p_dev; 512 497 513 - if (!pcmcia_dev_present(link)) 514 - return -ENODEV; 498 + if (!pcmcia_dev_present(link)) 499 + return -ENODEV; 515 500 516 - link->open++; 517 - netif_start_queue(dev); 501 + link->open++; 502 + netif_start_queue(dev); 518 503 519 - tc589_reset(dev); 520 - init_timer(&lp->media); 521 - lp->media.function = media_check; 522 - lp->media.data = (unsigned long) dev; 523 - lp->media.expires = jiffies + HZ; 524 - add_timer(&lp->media); 504 + tc589_reset(dev); 505 + init_timer(&lp->media); 506 + lp->media.function = media_check; 507 + lp->media.data = (unsigned long) dev; 508 + lp->media.expires = jiffies + HZ; 509 + add_timer(&lp->media); 525 510 526 - dev_dbg(&link->dev, "%s: opened, status %4.4x.\n", 511 + dev_dbg(&link->dev, "%s: opened, status %4.4x.\n", 527 512 dev->name, inw(dev->base_addr + EL3_STATUS)); 528 513 529 - return 0; 514 + return 0; 530 515 } 531 516 532 517 static void el3_tx_timeout(struct net_device *dev) 533 518 { 534 - unsigned int ioaddr = dev->base_addr; 519 + unsigned int ioaddr = dev->base_addr; 535 520 536 - netdev_warn(dev, "Transmit timed out!\n"); 537 - dump_status(dev); 538 - dev->stats.tx_errors++; 539 - dev->trans_start = jiffies; /* prevent tx timeout */ 540 - /* Issue TX_RESET and TX_START commands. */ 541 - tc589_wait_for_completion(dev, TxReset); 542 - outw(TxEnable, ioaddr + EL3_CMD); 543 - netif_wake_queue(dev); 521 + netdev_warn(dev, "Transmit timed out!\n"); 522 + dump_status(dev); 523 + dev->stats.tx_errors++; 524 + dev->trans_start = jiffies; /* prevent tx timeout */ 525 + /* Issue TX_RESET and TX_START commands. */ 526 + tc589_wait_for_completion(dev, TxReset); 527 + outw(TxEnable, ioaddr + EL3_CMD); 528 + netif_wake_queue(dev); 544 529 } 545 530 546 531 static void pop_tx_status(struct net_device *dev) 547 532 { 548 - unsigned int ioaddr = dev->base_addr; 549 - int i; 533 + unsigned int ioaddr = dev->base_addr; 534 + int i; 550 535 551 - /* Clear the Tx status stack. */ 552 - for (i = 32; i > 0; i--) { 553 - u_char tx_status = inb(ioaddr + TX_STATUS); 554 - if (!(tx_status & 0x84)) break; 555 - /* reset transmitter on jabber error or underrun */ 556 - if (tx_status & 0x30) 557 - tc589_wait_for_completion(dev, TxReset); 558 - if (tx_status & 0x38) { 559 - netdev_dbg(dev, "transmit error: status 0x%02x\n", tx_status); 560 - outw(TxEnable, ioaddr + EL3_CMD); 561 - dev->stats.tx_aborted_errors++; 536 + /* Clear the Tx status stack. */ 537 + for (i = 32; i > 0; i--) { 538 + u_char tx_status = inb(ioaddr + TX_STATUS); 539 + if (!(tx_status & 0x84)) 540 + break; 541 + /* reset transmitter on jabber error or underrun */ 542 + if (tx_status & 0x30) 543 + tc589_wait_for_completion(dev, TxReset); 544 + if (tx_status & 0x38) { 545 + netdev_dbg(dev, "transmit error: status 0x%02x\n", tx_status); 546 + outw(TxEnable, ioaddr + EL3_CMD); 547 + dev->stats.tx_aborted_errors++; 548 + } 549 + outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ 562 550 } 563 - outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ 564 - } 565 551 } 566 552 567 553 static netdev_tx_t el3_start_xmit(struct sk_buff *skb, 568 554 struct net_device *dev) 569 555 { 570 - unsigned int ioaddr = dev->base_addr; 571 - struct el3_private *priv = netdev_priv(dev); 572 - unsigned long flags; 556 + unsigned int ioaddr = dev->base_addr; 557 + struct el3_private *priv = netdev_priv(dev); 558 + unsigned long flags; 573 559 574 - netdev_dbg(dev, "el3_start_xmit(length = %ld) called, status %4.4x.\n", 560 + netdev_dbg(dev, "el3_start_xmit(length = %ld) called, status %4.4x.\n", 575 561 (long)skb->len, inw(ioaddr + EL3_STATUS)); 576 562 577 - spin_lock_irqsave(&priv->lock, flags); 563 + spin_lock_irqsave(&priv->lock, flags); 578 564 579 - dev->stats.tx_bytes += skb->len; 565 + dev->stats.tx_bytes += skb->len; 580 566 581 - /* Put out the doubleword header... */ 582 - outw(skb->len, ioaddr + TX_FIFO); 583 - outw(0x00, ioaddr + TX_FIFO); 584 - /* ... and the packet rounded to a doubleword. */ 585 - outsl(ioaddr + TX_FIFO, skb->data, (skb->len + 3) >> 2); 567 + /* Put out the doubleword header... */ 568 + outw(skb->len, ioaddr + TX_FIFO); 569 + outw(0x00, ioaddr + TX_FIFO); 570 + /* ... and the packet rounded to a doubleword. */ 571 + outsl(ioaddr + TX_FIFO, skb->data, (skb->len + 3) >> 2); 586 572 587 - if (inw(ioaddr + TX_FREE) <= 1536) { 588 - netif_stop_queue(dev); 589 - /* Interrupt us when the FIFO has room for max-sized packet. */ 590 - outw(SetTxThreshold + 1536, ioaddr + EL3_CMD); 591 - } 573 + if (inw(ioaddr + TX_FREE) <= 1536) { 574 + netif_stop_queue(dev); 575 + /* Interrupt us when the FIFO has room for max-sized packet. */ 576 + outw(SetTxThreshold + 1536, ioaddr + EL3_CMD); 577 + } 592 578 593 - pop_tx_status(dev); 594 - spin_unlock_irqrestore(&priv->lock, flags); 595 - dev_kfree_skb(skb); 579 + pop_tx_status(dev); 580 + spin_unlock_irqrestore(&priv->lock, flags); 581 + dev_kfree_skb(skb); 596 582 597 - return NETDEV_TX_OK; 583 + return NETDEV_TX_OK; 598 584 } 599 585 600 586 /* The EL3 interrupt handler. */ 601 587 static irqreturn_t el3_interrupt(int irq, void *dev_id) 602 588 { 603 - struct net_device *dev = (struct net_device *) dev_id; 604 - struct el3_private *lp = netdev_priv(dev); 605 - unsigned int ioaddr; 606 - __u16 status; 607 - int i = 0, handled = 1; 589 + struct net_device *dev = (struct net_device *) dev_id; 590 + struct el3_private *lp = netdev_priv(dev); 591 + unsigned int ioaddr; 592 + __u16 status; 593 + int i = 0, handled = 1; 608 594 609 - if (!netif_device_present(dev)) 610 - return IRQ_NONE; 595 + if (!netif_device_present(dev)) 596 + return IRQ_NONE; 611 597 612 - ioaddr = dev->base_addr; 598 + ioaddr = dev->base_addr; 613 599 614 - netdev_dbg(dev, "interrupt, status %4.4x.\n", inw(ioaddr + EL3_STATUS)); 600 + netdev_dbg(dev, "interrupt, status %4.4x.\n", inw(ioaddr + EL3_STATUS)); 615 601 616 - spin_lock(&lp->lock); 617 - while ((status = inw(ioaddr + EL3_STATUS)) & 602 + spin_lock(&lp->lock); 603 + while ((status = inw(ioaddr + EL3_STATUS)) & 618 604 (IntLatch | RxComplete | StatsFull)) { 619 - if ((status & 0xe000) != 0x2000) { 620 - netdev_dbg(dev, "interrupt from dead card\n"); 621 - handled = 0; 622 - break; 623 - } 624 - if (status & RxComplete) 625 - el3_rx(dev); 626 - if (status & TxAvailable) { 627 - netdev_dbg(dev, " TX room bit was handled.\n"); 628 - /* There's room in the FIFO for a full-sized packet. */ 629 - outw(AckIntr | TxAvailable, ioaddr + EL3_CMD); 630 - netif_wake_queue(dev); 631 - } 632 - if (status & TxComplete) 633 - pop_tx_status(dev); 634 - if (status & (AdapterFailure | RxEarly | StatsFull)) { 635 - /* Handle all uncommon interrupts. */ 636 - if (status & StatsFull) /* Empty statistics. */ 637 - update_stats(dev); 638 - if (status & RxEarly) { /* Rx early is unused. */ 639 - el3_rx(dev); 640 - outw(AckIntr | RxEarly, ioaddr + EL3_CMD); 641 - } 642 - if (status & AdapterFailure) { 643 - u16 fifo_diag; 644 - EL3WINDOW(4); 645 - fifo_diag = inw(ioaddr + 4); 646 - EL3WINDOW(1); 647 - netdev_warn(dev, "adapter failure, FIFO diagnostic register %04x.\n", 605 + if ((status & 0xe000) != 0x2000) { 606 + netdev_dbg(dev, "interrupt from dead card\n"); 607 + handled = 0; 608 + break; 609 + } 610 + if (status & RxComplete) 611 + el3_rx(dev); 612 + if (status & TxAvailable) { 613 + netdev_dbg(dev, " TX room bit was handled.\n"); 614 + /* There's room in the FIFO for a full-sized packet. */ 615 + outw(AckIntr | TxAvailable, ioaddr + EL3_CMD); 616 + netif_wake_queue(dev); 617 + } 618 + if (status & TxComplete) 619 + pop_tx_status(dev); 620 + if (status & (AdapterFailure | RxEarly | StatsFull)) { 621 + /* Handle all uncommon interrupts. */ 622 + if (status & StatsFull) /* Empty statistics. */ 623 + update_stats(dev); 624 + if (status & RxEarly) { 625 + /* Rx early is unused. */ 626 + el3_rx(dev); 627 + outw(AckIntr | RxEarly, ioaddr + EL3_CMD); 628 + } 629 + if (status & AdapterFailure) { 630 + u16 fifo_diag; 631 + EL3WINDOW(4); 632 + fifo_diag = inw(ioaddr + 4); 633 + EL3WINDOW(1); 634 + netdev_warn(dev, "adapter failure, FIFO diagnostic register %04x.\n", 648 635 fifo_diag); 649 - if (fifo_diag & 0x0400) { 650 - /* Tx overrun */ 651 - tc589_wait_for_completion(dev, TxReset); 652 - outw(TxEnable, ioaddr + EL3_CMD); 636 + if (fifo_diag & 0x0400) { 637 + /* Tx overrun */ 638 + tc589_wait_for_completion(dev, TxReset); 639 + outw(TxEnable, ioaddr + EL3_CMD); 640 + } 641 + if (fifo_diag & 0x2000) { 642 + /* Rx underrun */ 643 + tc589_wait_for_completion(dev, RxReset); 644 + set_rx_mode(dev); 645 + outw(RxEnable, ioaddr + EL3_CMD); 646 + } 647 + outw(AckIntr | AdapterFailure, ioaddr + EL3_CMD); 648 + } 653 649 } 654 - if (fifo_diag & 0x2000) { 655 - /* Rx underrun */ 656 - tc589_wait_for_completion(dev, RxReset); 657 - set_rx_mode(dev); 658 - outw(RxEnable, ioaddr + EL3_CMD); 650 + if (++i > 10) { 651 + netdev_err(dev, "infinite loop in interrupt, status %4.4x.\n", 652 + status); 653 + /* Clear all interrupts */ 654 + outw(AckIntr | 0xFF, ioaddr + EL3_CMD); 655 + break; 659 656 } 660 - outw(AckIntr | AdapterFailure, ioaddr + EL3_CMD); 661 - } 657 + /* Acknowledge the IRQ. */ 658 + outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD); 662 659 } 663 - if (++i > 10) { 664 - netdev_err(dev, "infinite loop in interrupt, status %4.4x.\n", 665 - status); 666 - /* Clear all interrupts */ 667 - outw(AckIntr | 0xFF, ioaddr + EL3_CMD); 668 - break; 669 - } 670 - /* Acknowledge the IRQ. */ 671 - outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD); 672 - } 673 - lp->last_irq = jiffies; 674 - spin_unlock(&lp->lock); 675 - netdev_dbg(dev, "exiting interrupt, status %4.4x.\n", 676 - inw(ioaddr + EL3_STATUS)); 677 - return IRQ_RETVAL(handled); 660 + lp->last_irq = jiffies; 661 + spin_unlock(&lp->lock); 662 + netdev_dbg(dev, "exiting interrupt, status %4.4x.\n", 663 + inw(ioaddr + EL3_STATUS)); 664 + return IRQ_RETVAL(handled); 678 665 } 679 666 680 667 static void media_check(unsigned long arg) 681 668 { 682 - struct net_device *dev = (struct net_device *)(arg); 683 - struct el3_private *lp = netdev_priv(dev); 684 - unsigned int ioaddr = dev->base_addr; 685 - u16 media, errs; 686 - unsigned long flags; 669 + struct net_device *dev = (struct net_device *)(arg); 670 + struct el3_private *lp = netdev_priv(dev); 671 + unsigned int ioaddr = dev->base_addr; 672 + u16 media, errs; 673 + unsigned long flags; 687 674 688 - if (!netif_device_present(dev)) goto reschedule; 675 + if (!netif_device_present(dev)) 676 + goto reschedule; 689 677 690 - /* Check for pending interrupt with expired latency timer: with 691 - this, we can limp along even if the interrupt is blocked */ 692 - if ((inw(ioaddr + EL3_STATUS) & IntLatch) && 678 + /* Check for pending interrupt with expired latency timer: with 679 + * this, we can limp along even if the interrupt is blocked 680 + */ 681 + if ((inw(ioaddr + EL3_STATUS) & IntLatch) && 693 682 (inb(ioaddr + EL3_TIMER) == 0xff)) { 694 - if (!lp->fast_poll) 695 - netdev_warn(dev, "interrupt(s) dropped!\n"); 683 + if (!lp->fast_poll) 684 + netdev_warn(dev, "interrupt(s) dropped!\n"); 696 685 697 - local_irq_save(flags); 698 - el3_interrupt(dev->irq, dev); 699 - local_irq_restore(flags); 686 + local_irq_save(flags); 687 + el3_interrupt(dev->irq, dev); 688 + local_irq_restore(flags); 700 689 701 - lp->fast_poll = HZ; 702 - } 703 - if (lp->fast_poll) { 704 - lp->fast_poll--; 705 - lp->media.expires = jiffies + HZ/100; 706 - add_timer(&lp->media); 707 - return; 708 - } 690 + lp->fast_poll = HZ; 691 + } 692 + if (lp->fast_poll) { 693 + lp->fast_poll--; 694 + lp->media.expires = jiffies + HZ/100; 695 + add_timer(&lp->media); 696 + return; 697 + } 709 698 710 - /* lp->lock guards the EL3 window. Window should always be 1 except 711 - when the lock is held */ 712 - spin_lock_irqsave(&lp->lock, flags); 713 - EL3WINDOW(4); 714 - media = inw(ioaddr+WN4_MEDIA) & 0xc810; 699 + /* lp->lock guards the EL3 window. Window should always be 1 except 700 + * when the lock is held 701 + */ 715 702 716 - /* Ignore collisions unless we've had no irq's recently */ 717 - if (time_before(jiffies, lp->last_irq + HZ)) { 718 - media &= ~0x0010; 719 - } else { 720 - /* Try harder to detect carrier errors */ 721 - EL3WINDOW(6); 722 - outw(StatsDisable, ioaddr + EL3_CMD); 723 - errs = inb(ioaddr + 0); 724 - outw(StatsEnable, ioaddr + EL3_CMD); 725 - dev->stats.tx_carrier_errors += errs; 726 - if (errs || (lp->media_status & 0x0010)) media |= 0x0010; 727 - } 703 + spin_lock_irqsave(&lp->lock, flags); 704 + EL3WINDOW(4); 705 + media = inw(ioaddr+WN4_MEDIA) & 0xc810; 728 706 729 - if (media != lp->media_status) { 730 - if ((media & lp->media_status & 0x8000) && 731 - ((lp->media_status ^ media) & 0x0800)) 707 + /* Ignore collisions unless we've had no irq's recently */ 708 + if (time_before(jiffies, lp->last_irq + HZ)) { 709 + media &= ~0x0010; 710 + } else { 711 + /* Try harder to detect carrier errors */ 712 + EL3WINDOW(6); 713 + outw(StatsDisable, ioaddr + EL3_CMD); 714 + errs = inb(ioaddr + 0); 715 + outw(StatsEnable, ioaddr + EL3_CMD); 716 + dev->stats.tx_carrier_errors += errs; 717 + if (errs || (lp->media_status & 0x0010)) 718 + media |= 0x0010; 719 + } 720 + 721 + if (media != lp->media_status) { 722 + if ((media & lp->media_status & 0x8000) && 723 + ((lp->media_status ^ media) & 0x0800)) 732 724 netdev_info(dev, "%s link beat\n", 733 - (lp->media_status & 0x0800 ? "lost" : "found")); 734 - else if ((media & lp->media_status & 0x4000) && 725 + (lp->media_status & 0x0800 ? "lost" : "found")); 726 + else if ((media & lp->media_status & 0x4000) && 735 727 ((lp->media_status ^ media) & 0x0010)) 736 728 netdev_info(dev, "coax cable %s\n", 737 - (lp->media_status & 0x0010 ? "ok" : "problem")); 738 - if (dev->if_port == 0) { 739 - if (media & 0x8000) { 740 - if (media & 0x0800) 741 - netdev_info(dev, "flipped to 10baseT\n"); 742 - else 729 + (lp->media_status & 0x0010 ? "ok" : "problem")); 730 + if (dev->if_port == 0) { 731 + if (media & 0x8000) { 732 + if (media & 0x0800) 733 + netdev_info(dev, "flipped to 10baseT\n"); 734 + else 743 735 tc589_set_xcvr(dev, 2); 744 - } else if (media & 0x4000) { 745 - if (media & 0x0010) 746 - tc589_set_xcvr(dev, 1); 747 - else 748 - netdev_info(dev, "flipped to 10base2\n"); 749 - } 736 + } else if (media & 0x4000) { 737 + if (media & 0x0010) 738 + tc589_set_xcvr(dev, 1); 739 + else 740 + netdev_info(dev, "flipped to 10base2\n"); 741 + } 742 + } 743 + lp->media_status = media; 750 744 } 751 - lp->media_status = media; 752 - } 753 745 754 - EL3WINDOW(1); 755 - spin_unlock_irqrestore(&lp->lock, flags); 746 + EL3WINDOW(1); 747 + spin_unlock_irqrestore(&lp->lock, flags); 756 748 757 749 reschedule: 758 - lp->media.expires = jiffies + HZ; 759 - add_timer(&lp->media); 750 + lp->media.expires = jiffies + HZ; 751 + add_timer(&lp->media); 760 752 } 761 753 762 754 static struct net_device_stats *el3_get_stats(struct net_device *dev) 763 755 { 764 - struct el3_private *lp = netdev_priv(dev); 765 - unsigned long flags; 766 - struct pcmcia_device *link = lp->p_dev; 756 + struct el3_private *lp = netdev_priv(dev); 757 + unsigned long flags; 758 + struct pcmcia_device *link = lp->p_dev; 767 759 768 - if (pcmcia_dev_present(link)) { 769 - spin_lock_irqsave(&lp->lock, flags); 770 - update_stats(dev); 771 - spin_unlock_irqrestore(&lp->lock, flags); 772 - } 773 - return &dev->stats; 760 + if (pcmcia_dev_present(link)) { 761 + spin_lock_irqsave(&lp->lock, flags); 762 + update_stats(dev); 763 + spin_unlock_irqrestore(&lp->lock, flags); 764 + } 765 + return &dev->stats; 774 766 } 775 767 776 - /* 777 - Update statistics. We change to register window 6, so this should be run 778 - single-threaded if the device is active. This is expected to be a rare 779 - operation, and it's simpler for the rest of the driver to assume that 780 - window 1 is always valid rather than use a special window-state variable. 781 - 782 - Caller must hold the lock for this 768 + /* Update statistics. We change to register window 6, so this should be run 769 + * single-threaded if the device is active. This is expected to be a rare 770 + * operation, and it's simpler for the rest of the driver to assume that 771 + * window 1 is always valid rather than use a special window-state variable. 772 + * 773 + * Caller must hold the lock for this 783 774 */ 775 + 784 776 static void update_stats(struct net_device *dev) 785 777 { 786 - unsigned int ioaddr = dev->base_addr; 778 + unsigned int ioaddr = dev->base_addr; 787 779 788 - netdev_dbg(dev, "updating the statistics.\n"); 789 - /* Turn off statistics updates while reading. */ 790 - outw(StatsDisable, ioaddr + EL3_CMD); 791 - /* Switch to the stats window, and read everything. */ 792 - EL3WINDOW(6); 793 - dev->stats.tx_carrier_errors += inb(ioaddr + 0); 794 - dev->stats.tx_heartbeat_errors += inb(ioaddr + 1); 795 - /* Multiple collisions. */ inb(ioaddr + 2); 796 - dev->stats.collisions += inb(ioaddr + 3); 797 - dev->stats.tx_window_errors += inb(ioaddr + 4); 798 - dev->stats.rx_fifo_errors += inb(ioaddr + 5); 799 - dev->stats.tx_packets += inb(ioaddr + 6); 800 - /* Rx packets */ inb(ioaddr + 7); 801 - /* Tx deferrals */ inb(ioaddr + 8); 802 - /* Rx octets */ inw(ioaddr + 10); 803 - /* Tx octets */ inw(ioaddr + 12); 780 + netdev_dbg(dev, "updating the statistics.\n"); 781 + /* Turn off statistics updates while reading. */ 782 + outw(StatsDisable, ioaddr + EL3_CMD); 783 + /* Switch to the stats window, and read everything. */ 784 + EL3WINDOW(6); 785 + dev->stats.tx_carrier_errors += inb(ioaddr + 0); 786 + dev->stats.tx_heartbeat_errors += inb(ioaddr + 1); 787 + /* Multiple collisions. */ 788 + inb(ioaddr + 2); 789 + dev->stats.collisions += inb(ioaddr + 3); 790 + dev->stats.tx_window_errors += inb(ioaddr + 4); 791 + dev->stats.rx_fifo_errors += inb(ioaddr + 5); 792 + dev->stats.tx_packets += inb(ioaddr + 6); 793 + /* Rx packets */ 794 + inb(ioaddr + 7); 795 + /* Tx deferrals */ 796 + inb(ioaddr + 8); 797 + /* Rx octets */ 798 + inw(ioaddr + 10); 799 + /* Tx octets */ 800 + inw(ioaddr + 12); 804 801 805 - /* Back to window 1, and turn statistics back on. */ 806 - EL3WINDOW(1); 807 - outw(StatsEnable, ioaddr + EL3_CMD); 802 + /* Back to window 1, and turn statistics back on. */ 803 + EL3WINDOW(1); 804 + outw(StatsEnable, ioaddr + EL3_CMD); 808 805 } 809 806 810 807 static int el3_rx(struct net_device *dev) 811 808 { 812 - unsigned int ioaddr = dev->base_addr; 813 - int worklimit = 32; 814 - short rx_status; 809 + unsigned int ioaddr = dev->base_addr; 810 + int worklimit = 32; 811 + short rx_status; 815 812 816 - netdev_dbg(dev, "in rx_packet(), status %4.4x, rx_status %4.4x.\n", 813 + netdev_dbg(dev, "in rx_packet(), status %4.4x, rx_status %4.4x.\n", 817 814 inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS)); 818 - while (!((rx_status = inw(ioaddr + RX_STATUS)) & 0x8000) && 815 + while (!((rx_status = inw(ioaddr + RX_STATUS)) & 0x8000) && 819 816 worklimit > 0) { 820 - worklimit--; 821 - if (rx_status & 0x4000) { /* Error, update stats. */ 822 - short error = rx_status & 0x3800; 823 - dev->stats.rx_errors++; 824 - switch (error) { 825 - case 0x0000: dev->stats.rx_over_errors++; break; 826 - case 0x0800: dev->stats.rx_length_errors++; break; 827 - case 0x1000: dev->stats.rx_frame_errors++; break; 828 - case 0x1800: dev->stats.rx_length_errors++; break; 829 - case 0x2000: dev->stats.rx_frame_errors++; break; 830 - case 0x2800: dev->stats.rx_crc_errors++; break; 831 - } 832 - } else { 833 - short pkt_len = rx_status & 0x7ff; 834 - struct sk_buff *skb; 817 + worklimit--; 818 + if (rx_status & 0x4000) { /* Error, update stats. */ 819 + short error = rx_status & 0x3800; 820 + dev->stats.rx_errors++; 821 + switch (error) { 822 + case 0x0000: 823 + dev->stats.rx_over_errors++; 824 + break; 825 + case 0x0800: 826 + dev->stats.rx_length_errors++; 827 + break; 828 + case 0x1000: 829 + dev->stats.rx_frame_errors++; 830 + break; 831 + case 0x1800: 832 + dev->stats.rx_length_errors++; 833 + break; 834 + case 0x2000: 835 + dev->stats.rx_frame_errors++; 836 + break; 837 + case 0x2800: 838 + dev->stats.rx_crc_errors++; 839 + break; 840 + } 841 + } else { 842 + short pkt_len = rx_status & 0x7ff; 843 + struct sk_buff *skb; 835 844 836 - skb = netdev_alloc_skb(dev, pkt_len + 5); 845 + skb = netdev_alloc_skb(dev, pkt_len + 5); 837 846 838 - netdev_dbg(dev, " Receiving packet size %d status %4.4x.\n", 847 + netdev_dbg(dev, " Receiving packet size %d status %4.4x.\n", 839 848 pkt_len, rx_status); 840 - if (skb != NULL) { 841 - skb_reserve(skb, 2); 842 - insl(ioaddr+RX_FIFO, skb_put(skb, pkt_len), 849 + if (skb != NULL) { 850 + skb_reserve(skb, 2); 851 + insl(ioaddr+RX_FIFO, skb_put(skb, pkt_len), 843 852 (pkt_len+3)>>2); 844 - skb->protocol = eth_type_trans(skb, dev); 845 - netif_rx(skb); 846 - dev->stats.rx_packets++; 847 - dev->stats.rx_bytes += pkt_len; 848 - } else { 849 - netdev_dbg(dev, "couldn't allocate a sk_buff of size %d.\n", 853 + skb->protocol = eth_type_trans(skb, dev); 854 + netif_rx(skb); 855 + dev->stats.rx_packets++; 856 + dev->stats.rx_bytes += pkt_len; 857 + } else { 858 + netdev_dbg(dev, "couldn't allocate a sk_buff of size %d.\n", 850 859 pkt_len); 851 - dev->stats.rx_dropped++; 852 - } 860 + dev->stats.rx_dropped++; 861 + } 862 + } 863 + /* Pop the top of the Rx FIFO */ 864 + tc589_wait_for_completion(dev, RxDiscard); 853 865 } 854 - /* Pop the top of the Rx FIFO */ 855 - tc589_wait_for_completion(dev, RxDiscard); 856 - } 857 - if (worklimit == 0) 858 - netdev_warn(dev, "too much work in el3_rx!\n"); 859 - return 0; 866 + if (worklimit == 0) 867 + netdev_warn(dev, "too much work in el3_rx!\n"); 868 + return 0; 860 869 } 861 870 862 871 static void set_rx_mode(struct net_device *dev) 863 872 { 864 - unsigned int ioaddr = dev->base_addr; 865 - u16 opts = SetRxFilter | RxStation | RxBroadcast; 873 + unsigned int ioaddr = dev->base_addr; 874 + u16 opts = SetRxFilter | RxStation | RxBroadcast; 866 875 867 - if (dev->flags & IFF_PROMISC) 868 - opts |= RxMulticast | RxProm; 869 - else if (!netdev_mc_empty(dev) || (dev->flags & IFF_ALLMULTI)) 870 - opts |= RxMulticast; 871 - outw(opts, ioaddr + EL3_CMD); 876 + if (dev->flags & IFF_PROMISC) 877 + opts |= RxMulticast | RxProm; 878 + else if (!netdev_mc_empty(dev) || (dev->flags & IFF_ALLMULTI)) 879 + opts |= RxMulticast; 880 + outw(opts, ioaddr + EL3_CMD); 872 881 } 873 882 874 883 static void set_multicast_list(struct net_device *dev) ··· 908 867 909 868 static int el3_close(struct net_device *dev) 910 869 { 911 - struct el3_private *lp = netdev_priv(dev); 912 - struct pcmcia_device *link = lp->p_dev; 913 - unsigned int ioaddr = dev->base_addr; 870 + struct el3_private *lp = netdev_priv(dev); 871 + struct pcmcia_device *link = lp->p_dev; 872 + unsigned int ioaddr = dev->base_addr; 914 873 915 - dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name); 874 + dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name); 916 875 917 - if (pcmcia_dev_present(link)) { 918 - /* Turn off statistics ASAP. We update dev->stats below. */ 919 - outw(StatsDisable, ioaddr + EL3_CMD); 876 + if (pcmcia_dev_present(link)) { 877 + /* Turn off statistics ASAP. We update dev->stats below. */ 878 + outw(StatsDisable, ioaddr + EL3_CMD); 920 879 921 - /* Disable the receiver and transmitter. */ 922 - outw(RxDisable, ioaddr + EL3_CMD); 923 - outw(TxDisable, ioaddr + EL3_CMD); 880 + /* Disable the receiver and transmitter. */ 881 + outw(RxDisable, ioaddr + EL3_CMD); 882 + outw(TxDisable, ioaddr + EL3_CMD); 924 883 925 - if (dev->if_port == 2) 926 - /* Turn off thinnet power. Green! */ 927 - outw(StopCoax, ioaddr + EL3_CMD); 928 - else if (dev->if_port == 1) { 929 - /* Disable link beat and jabber */ 930 - EL3WINDOW(4); 931 - outw(0, ioaddr + WN4_MEDIA); 884 + if (dev->if_port == 2) 885 + /* Turn off thinnet power. Green! */ 886 + outw(StopCoax, ioaddr + EL3_CMD); 887 + else if (dev->if_port == 1) { 888 + /* Disable link beat and jabber */ 889 + EL3WINDOW(4); 890 + outw(0, ioaddr + WN4_MEDIA); 891 + } 892 + 893 + /* Switching back to window 0 disables the IRQ. */ 894 + EL3WINDOW(0); 895 + /* But we explicitly zero the IRQ line select anyway. */ 896 + outw(0x0f00, ioaddr + WN0_IRQ); 897 + 898 + /* Check if the card still exists */ 899 + if ((inw(ioaddr+EL3_STATUS) & 0xe000) == 0x2000) 900 + update_stats(dev); 932 901 } 933 902 934 - /* Switching back to window 0 disables the IRQ. */ 935 - EL3WINDOW(0); 936 - /* But we explicitly zero the IRQ line select anyway. */ 937 - outw(0x0f00, ioaddr + WN0_IRQ); 903 + link->open--; 904 + netif_stop_queue(dev); 905 + del_timer_sync(&lp->media); 938 906 939 - /* Check if the card still exists */ 940 - if ((inw(ioaddr+EL3_STATUS) & 0xe000) == 0x2000) 941 - update_stats(dev); 942 - } 943 - 944 - link->open--; 945 - netif_stop_queue(dev); 946 - del_timer_sync(&lp->media); 947 - 948 - return 0; 907 + return 0; 949 908 } 950 909 951 910 static const struct pcmcia_device_id tc589_ids[] = {