diff options
-rw-r--r-- | drivers/net/mac8390.c | 229 |
1 files changed, 122 insertions, 107 deletions
diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c index 8bd09e280c9e..8f168893caa9 100644 --- a/drivers/net/mac8390.c +++ b/drivers/net/mac8390.c | |||
@@ -36,9 +36,9 @@ | |||
36 | #include <linux/etherdevice.h> | 36 | #include <linux/etherdevice.h> |
37 | #include <linux/skbuff.h> | 37 | #include <linux/skbuff.h> |
38 | #include <linux/bitops.h> | 38 | #include <linux/bitops.h> |
39 | #include <linux/io.h> | ||
39 | 40 | ||
40 | #include <asm/system.h> | 41 | #include <asm/system.h> |
41 | #include <asm/io.h> | ||
42 | #include <asm/dma.h> | 42 | #include <asm/dma.h> |
43 | #include <asm/hwtest.h> | 43 | #include <asm/hwtest.h> |
44 | #include <asm/macints.h> | 44 | #include <asm/macints.h> |
@@ -47,20 +47,25 @@ static char version[] = | |||
47 | "v0.4 2001-05-15 David Huggins-Daines <dhd@debian.org> and others\n"; | 47 | "v0.4 2001-05-15 David Huggins-Daines <dhd@debian.org> and others\n"; |
48 | 48 | ||
49 | #define EI_SHIFT(x) (ei_local->reg_offset[x]) | 49 | #define EI_SHIFT(x) (ei_local->reg_offset[x]) |
50 | #define ei_inb(port) in_8(port) | 50 | #define ei_inb(port) in_8(port) |
51 | #define ei_outb(val,port) out_8(port,val) | 51 | #define ei_outb(val, port) out_8(port, val) |
52 | #define ei_inb_p(port) in_8(port) | 52 | #define ei_inb_p(port) in_8(port) |
53 | #define ei_outb_p(val,port) out_8(port,val) | 53 | #define ei_outb_p(val, port) out_8(port, val) |
54 | 54 | ||
55 | #include "lib8390.c" | 55 | #include "lib8390.c" |
56 | 56 | ||
57 | #define WD_START_PG 0x00 /* First page of TX buffer */ | 57 | #define WD_START_PG 0x00 /* First page of TX buffer */ |
58 | #define CABLETRON_RX_START_PG 0x00 /* First page of RX buffer */ | 58 | #define CABLETRON_RX_START_PG 0x00 /* First page of RX buffer */ |
59 | #define CABLETRON_RX_STOP_PG 0x30 /* Last page +1 of RX ring */ | 59 | #define CABLETRON_RX_STOP_PG 0x30 /* Last page +1 of RX ring */ |
60 | #define CABLETRON_TX_START_PG CABLETRON_RX_STOP_PG /* First page of TX buffer */ | 60 | #define CABLETRON_TX_START_PG CABLETRON_RX_STOP_PG |
61 | /* First page of TX buffer */ | ||
61 | 62 | ||
62 | /* Unfortunately it seems we have to hardcode these for the moment */ | 63 | /* |
63 | /* Shouldn't the card know about this? Does anyone know where to read it off the card? Do we trust the data provided by the card? */ | 64 | * Unfortunately it seems we have to hardcode these for the moment |
65 | * Shouldn't the card know about this? | ||
66 | * Does anyone know where to read it off the card? | ||
67 | * Do we trust the data provided by the card? | ||
68 | */ | ||
64 | 69 | ||
65 | #define DAYNA_8390_BASE 0x80000 | 70 | #define DAYNA_8390_BASE 0x80000 |
66 | #define DAYNA_8390_MEM 0x00000 | 71 | #define DAYNA_8390_MEM 0x00000 |
@@ -82,7 +87,7 @@ enum mac8390_type { | |||
82 | MAC8390_KINETICS, | 87 | MAC8390_KINETICS, |
83 | }; | 88 | }; |
84 | 89 | ||
85 | static const char * cardname[] = { | 90 | static const char *cardname[] = { |
86 | "apple", | 91 | "apple", |
87 | "asante", | 92 | "asante", |
88 | "farallon", | 93 | "farallon", |
@@ -92,7 +97,7 @@ static const char * cardname[] = { | |||
92 | "kinetics", | 97 | "kinetics", |
93 | }; | 98 | }; |
94 | 99 | ||
95 | static int word16[] = { | 100 | static const int word16[] = { |
96 | 1, /* apple */ | 101 | 1, /* apple */ |
97 | 1, /* asante */ | 102 | 1, /* asante */ |
98 | 1, /* farallon */ | 103 | 1, /* farallon */ |
@@ -103,7 +108,7 @@ static int word16[] = { | |||
103 | }; | 108 | }; |
104 | 109 | ||
105 | /* on which cards do we use NuBus resources? */ | 110 | /* on which cards do we use NuBus resources? */ |
106 | static int useresources[] = { | 111 | static const int useresources[] = { |
107 | 1, /* apple */ | 112 | 1, /* apple */ |
108 | 1, /* asante */ | 113 | 1, /* asante */ |
109 | 1, /* farallon */ | 114 | 1, /* farallon */ |
@@ -119,22 +124,22 @@ enum mac8390_access { | |||
119 | ACCESS_16, | 124 | ACCESS_16, |
120 | }; | 125 | }; |
121 | 126 | ||
122 | extern int mac8390_memtest(struct net_device * dev); | 127 | extern int mac8390_memtest(struct net_device *dev); |
123 | static int mac8390_initdev(struct net_device * dev, struct nubus_dev * ndev, | 128 | static int mac8390_initdev(struct net_device *dev, struct nubus_dev *ndev, |
124 | enum mac8390_type type); | 129 | enum mac8390_type type); |
125 | 130 | ||
126 | static int mac8390_open(struct net_device * dev); | 131 | static int mac8390_open(struct net_device *dev); |
127 | static int mac8390_close(struct net_device * dev); | 132 | static int mac8390_close(struct net_device *dev); |
128 | static void mac8390_no_reset(struct net_device *dev); | 133 | static void mac8390_no_reset(struct net_device *dev); |
129 | static void interlan_reset(struct net_device *dev); | 134 | static void interlan_reset(struct net_device *dev); |
130 | 135 | ||
131 | /* Sane (32-bit chunk memory read/write) - Some Farallon and Apple do this*/ | 136 | /* Sane (32-bit chunk memory read/write) - Some Farallon and Apple do this*/ |
132 | static void sane_get_8390_hdr(struct net_device *dev, | 137 | static void sane_get_8390_hdr(struct net_device *dev, |
133 | struct e8390_pkt_hdr *hdr, int ring_page); | 138 | struct e8390_pkt_hdr *hdr, int ring_page); |
134 | static void sane_block_input(struct net_device * dev, int count, | 139 | static void sane_block_input(struct net_device *dev, int count, |
135 | struct sk_buff * skb, int ring_offset); | 140 | struct sk_buff *skb, int ring_offset); |
136 | static void sane_block_output(struct net_device * dev, int count, | 141 | static void sane_block_output(struct net_device *dev, int count, |
137 | const unsigned char * buf, const int start_page); | 142 | const unsigned char *buf, const int start_page); |
138 | 143 | ||
139 | /* dayna_memcpy to and from card */ | 144 | /* dayna_memcpy to and from card */ |
140 | static void dayna_memcpy_fromcard(struct net_device *dev, void *to, | 145 | static void dayna_memcpy_fromcard(struct net_device *dev, void *to, |
@@ -150,8 +155,8 @@ static void dayna_block_input(struct net_device *dev, int count, | |||
150 | static void dayna_block_output(struct net_device *dev, int count, | 155 | static void dayna_block_output(struct net_device *dev, int count, |
151 | const unsigned char *buf, int start_page); | 156 | const unsigned char *buf, int start_page); |
152 | 157 | ||
153 | #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c)) | 158 | #define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c)) |
154 | #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c)) | 159 | #define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c)) |
155 | 160 | ||
156 | /* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */ | 161 | /* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */ |
157 | static void slow_sane_get_8390_hdr(struct net_device *dev, | 162 | static void slow_sane_get_8390_hdr(struct net_device *dev, |
@@ -222,10 +227,12 @@ static enum mac8390_type __init mac8390_ident(struct nubus_dev *dev) | |||
222 | break; | 227 | break; |
223 | 228 | ||
224 | case NUBUS_DRSW_DAYNA: | 229 | case NUBUS_DRSW_DAYNA: |
225 | // These correspond to Dayna Sonic cards | 230 | /* |
226 | // which use the macsonic driver | 231 | * These correspond to Dayna Sonic cards |
232 | * which use the macsonic driver | ||
233 | */ | ||
227 | if (dev->dr_hw == NUBUS_DRHW_SMC9194 || | 234 | if (dev->dr_hw == NUBUS_DRHW_SMC9194 || |
228 | dev->dr_hw == NUBUS_DRHW_INTERLAN ) | 235 | dev->dr_hw == NUBUS_DRHW_INTERLAN) |
229 | return MAC8390_NONE; | 236 | return MAC8390_NONE; |
230 | else | 237 | else |
231 | return MAC8390_DAYNA; | 238 | return MAC8390_DAYNA; |
@@ -260,7 +267,7 @@ static int __init mac8390_memsize(unsigned long membase) | |||
260 | local_irq_save(flags); | 267 | local_irq_save(flags); |
261 | /* Check up to 32K in 4K increments */ | 268 | /* Check up to 32K in 4K increments */ |
262 | for (i = 0; i < 8; i++) { | 269 | for (i = 0; i < 8; i++) { |
263 | volatile unsigned short *m = (unsigned short *) (membase + (i * 0x1000)); | 270 | volatile unsigned short *m = (unsigned short *)(membase + (i * 0x1000)); |
264 | 271 | ||
265 | /* Unwriteable - we have a fully decoded card and the | 272 | /* Unwriteable - we have a fully decoded card and the |
266 | RAM end located */ | 273 | RAM end located */ |
@@ -275,22 +282,24 @@ static int __init mac8390_memsize(unsigned long membase) | |||
275 | 282 | ||
276 | /* check for partial decode and wrap */ | 283 | /* check for partial decode and wrap */ |
277 | for (j = 0; j < i; j++) { | 284 | for (j = 0; j < i; j++) { |
278 | volatile unsigned short *p = (unsigned short *) (membase + (j * 0x1000)); | 285 | volatile unsigned short *p = (unsigned short *)(membase + (j * 0x1000)); |
279 | if (*p != (0xA5A0 | j)) | 286 | if (*p != (0xA5A0 | j)) |
280 | break; | 287 | break; |
281 | } | 288 | } |
282 | } | 289 | } |
283 | local_irq_restore(flags); | 290 | local_irq_restore(flags); |
284 | /* in any case, we stopped once we tried one block too many, | 291 | /* |
285 | or once we reached 32K */ | 292 | * in any case, we stopped once we tried one block too many, |
286 | return i * 0x1000; | 293 | * or once we reached 32K |
294 | */ | ||
295 | return i * 0x1000; | ||
287 | } | 296 | } |
288 | 297 | ||
289 | struct net_device * __init mac8390_probe(int unit) | 298 | struct net_device * __init mac8390_probe(int unit) |
290 | { | 299 | { |
291 | struct net_device *dev; | 300 | struct net_device *dev; |
292 | volatile unsigned short *i; | 301 | volatile unsigned short *i; |
293 | struct nubus_dev * ndev = NULL; | 302 | struct nubus_dev *ndev = NULL; |
294 | int err = -ENODEV; | 303 | int err = -ENODEV; |
295 | 304 | ||
296 | struct nubus_dir dir; | 305 | struct nubus_dir dir; |
@@ -312,20 +321,23 @@ struct net_device * __init mac8390_probe(int unit) | |||
312 | if (unit >= 0) | 321 | if (unit >= 0) |
313 | sprintf(dev->name, "eth%d", unit); | 322 | sprintf(dev->name, "eth%d", unit); |
314 | 323 | ||
315 | while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK, NUBUS_TYPE_ETHERNET, ndev))) { | 324 | while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK, NUBUS_TYPE_ETHERNET, |
325 | ndev))) { | ||
316 | /* Have we seen it already? */ | 326 | /* Have we seen it already? */ |
317 | if (slots & (1<<ndev->board->slot)) | 327 | if (slots & (1<<ndev->board->slot)) |
318 | continue; | 328 | continue; |
319 | slots |= 1<<ndev->board->slot; | 329 | slots |= 1<<ndev->board->slot; |
320 | 330 | ||
321 | if ((cardtype = mac8390_ident(ndev)) == MAC8390_NONE) | 331 | cardtype = mac8390_ident(ndev); |
332 | if (cardtype == MAC8390_NONE) | ||
322 | continue; | 333 | continue; |
323 | 334 | ||
324 | printk_once(KERN_INFO pr_fmt(version)); | 335 | printk_once(KERN_INFO pr_fmt(version)); |
325 | 336 | ||
326 | dev->irq = SLOT2IRQ(ndev->board->slot); | 337 | dev->irq = SLOT2IRQ(ndev->board->slot); |
327 | /* This is getting to be a habit */ | 338 | /* This is getting to be a habit */ |
328 | dev->base_addr = ndev->board->slot_addr | ((ndev->board->slot&0xf) << 20); | 339 | dev->base_addr = (ndev->board->slot_addr | |
340 | ((ndev->board->slot & 0xf) << 20)); | ||
329 | 341 | ||
330 | /* Get some Nubus info - we will trust the card's idea | 342 | /* Get some Nubus info - we will trust the card's idea |
331 | of where its memory and registers are. */ | 343 | of where its memory and registers are. */ |
@@ -337,7 +349,7 @@ struct net_device * __init mac8390_probe(int unit) | |||
337 | } | 349 | } |
338 | 350 | ||
339 | /* Get the MAC address */ | 351 | /* Get the MAC address */ |
340 | if ((nubus_find_rsrc(&dir, NUBUS_RESID_MAC_ADDRESS, &ent)) == -1) { | 352 | if (nubus_find_rsrc(&dir, NUBUS_RESID_MAC_ADDRESS, &ent) == -1) { |
341 | pr_info("%s: Couldn't get MAC address!\n", dev->name); | 353 | pr_info("%s: Couldn't get MAC address!\n", dev->name); |
342 | continue; | 354 | continue; |
343 | } else { | 355 | } else { |
@@ -346,7 +358,8 @@ struct net_device * __init mac8390_probe(int unit) | |||
346 | 358 | ||
347 | if (useresources[cardtype] == 1) { | 359 | if (useresources[cardtype] == 1) { |
348 | nubus_rewinddir(&dir); | 360 | nubus_rewinddir(&dir); |
349 | if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_BASEOS, &ent) == -1) { | 361 | if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_BASEOS, |
362 | &ent) == -1) { | ||
350 | pr_err("%s: Memory offset resource for slot %X not found!\n", | 363 | pr_err("%s: Memory offset resource for slot %X not found!\n", |
351 | dev->name, ndev->board->slot); | 364 | dev->name, ndev->board->slot); |
352 | continue; | 365 | continue; |
@@ -356,7 +369,8 @@ struct net_device * __init mac8390_probe(int unit) | |||
356 | /* yes, this is how the Apple driver does it */ | 369 | /* yes, this is how the Apple driver does it */ |
357 | dev->base_addr = dev->mem_start + 0x10000; | 370 | dev->base_addr = dev->mem_start + 0x10000; |
358 | nubus_rewinddir(&dir); | 371 | nubus_rewinddir(&dir); |
359 | if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_LENGTH, &ent) == -1) { | 372 | if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_LENGTH, |
373 | &ent) == -1) { | ||
360 | pr_info("%s: Memory length resource for slot %X not found, probing\n", | 374 | pr_info("%s: Memory length resource for slot %X not found, probing\n", |
361 | dev->name, ndev->board->slot); | 375 | dev->name, ndev->board->slot); |
362 | offset = mac8390_memsize(dev->mem_start); | 376 | offset = mac8390_memsize(dev->mem_start); |
@@ -485,22 +499,23 @@ static const struct net_device_ops mac8390_netdev_ops = { | |||
485 | #endif | 499 | #endif |
486 | }; | 500 | }; |
487 | 501 | ||
488 | static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * ndev, | 502 | static int __init mac8390_initdev(struct net_device *dev, |
489 | enum mac8390_type type) | 503 | struct nubus_dev *ndev, |
504 | enum mac8390_type type) | ||
490 | { | 505 | { |
491 | static u32 fwrd4_offsets[16]={ | 506 | static u32 fwrd4_offsets[16] = { |
492 | 0, 4, 8, 12, | 507 | 0, 4, 8, 12, |
493 | 16, 20, 24, 28, | 508 | 16, 20, 24, 28, |
494 | 32, 36, 40, 44, | 509 | 32, 36, 40, 44, |
495 | 48, 52, 56, 60 | 510 | 48, 52, 56, 60 |
496 | }; | 511 | }; |
497 | static u32 back4_offsets[16]={ | 512 | static u32 back4_offsets[16] = { |
498 | 60, 56, 52, 48, | 513 | 60, 56, 52, 48, |
499 | 44, 40, 36, 32, | 514 | 44, 40, 36, 32, |
500 | 28, 24, 20, 16, | 515 | 28, 24, 20, 16, |
501 | 12, 8, 4, 0 | 516 | 12, 8, 4, 0 |
502 | }; | 517 | }; |
503 | static u32 fwrd2_offsets[16]={ | 518 | static u32 fwrd2_offsets[16] = { |
504 | 0, 2, 4, 6, | 519 | 0, 2, 4, 6, |
505 | 8, 10, 12, 14, | 520 | 8, 10, 12, 14, |
506 | 16, 18, 20, 22, | 521 | 16, 18, 20, 22, |
@@ -518,17 +533,17 @@ static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * nd | |||
518 | 533 | ||
519 | /* Cabletron's TX/RX buffers are backwards */ | 534 | /* Cabletron's TX/RX buffers are backwards */ |
520 | if (type == MAC8390_CABLETRON) { | 535 | if (type == MAC8390_CABLETRON) { |
521 | ei_status.tx_start_page = CABLETRON_TX_START_PG; | 536 | ei_status.tx_start_page = CABLETRON_TX_START_PG; |
522 | ei_status.rx_start_page = CABLETRON_RX_START_PG; | 537 | ei_status.rx_start_page = CABLETRON_RX_START_PG; |
523 | ei_status.stop_page = CABLETRON_RX_STOP_PG; | 538 | ei_status.stop_page = CABLETRON_RX_STOP_PG; |
524 | ei_status.rmem_start = dev->mem_start; | 539 | ei_status.rmem_start = dev->mem_start; |
525 | ei_status.rmem_end = dev->mem_start + CABLETRON_RX_STOP_PG*256; | 540 | ei_status.rmem_end = dev->mem_start + CABLETRON_RX_STOP_PG*256; |
526 | } else { | 541 | } else { |
527 | ei_status.tx_start_page = WD_START_PG; | 542 | ei_status.tx_start_page = WD_START_PG; |
528 | ei_status.rx_start_page = WD_START_PG + TX_PAGES; | 543 | ei_status.rx_start_page = WD_START_PG + TX_PAGES; |
529 | ei_status.stop_page = (dev->mem_end - dev->mem_start)/256; | 544 | ei_status.stop_page = (dev->mem_end - dev->mem_start)/256; |
530 | ei_status.rmem_start = dev->mem_start + TX_PAGES*256; | 545 | ei_status.rmem_start = dev->mem_start + TX_PAGES*256; |
531 | ei_status.rmem_end = dev->mem_end; | 546 | ei_status.rmem_end = dev->mem_end; |
532 | } | 547 | } |
533 | 548 | ||
534 | /* Fill in model-specific information and functions */ | 549 | /* Fill in model-specific information and functions */ |
@@ -600,8 +615,8 @@ static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * nd | |||
600 | ei_status.block_input = &slow_sane_block_input; | 615 | ei_status.block_input = &slow_sane_block_input; |
601 | ei_status.block_output = &slow_sane_block_output; | 616 | ei_status.block_output = &slow_sane_block_output; |
602 | ei_status.get_8390_hdr = &slow_sane_get_8390_hdr; | 617 | ei_status.get_8390_hdr = &slow_sane_get_8390_hdr; |
603 | ei_status.reg_offset = fwrd4_offsets; | 618 | ei_status.reg_offset = fwrd4_offsets; |
604 | break; | 619 | break; |
605 | 620 | ||
606 | default: | 621 | default: |
607 | pr_err("Card type %s is unsupported, sorry\n", | 622 | pr_err("Card type %s is unsupported, sorry\n", |
@@ -649,7 +664,7 @@ static void mac8390_no_reset(struct net_device *dev) | |||
649 | 664 | ||
650 | static void interlan_reset(struct net_device *dev) | 665 | static void interlan_reset(struct net_device *dev) |
651 | { | 666 | { |
652 | unsigned char *target=nubus_slot_addr(IRQ2SLOT(dev->irq)); | 667 | unsigned char *target = nubus_slot_addr(IRQ2SLOT(dev->irq)); |
653 | if (ei_debug > 1) | 668 | if (ei_debug > 1) |
654 | pr_info("Need to reset the NS8390 t=%lu...", jiffies); | 669 | pr_info("Need to reset the NS8390 t=%lu...", jiffies); |
655 | ei_status.txing = 0; | 670 | ei_status.txing = 0; |
@@ -661,54 +676,53 @@ static void interlan_reset(struct net_device *dev) | |||
661 | 676 | ||
662 | /* dayna_memcpy_fromio/dayna_memcpy_toio */ | 677 | /* dayna_memcpy_fromio/dayna_memcpy_toio */ |
663 | /* directly from daynaport.c by Alan Cox */ | 678 | /* directly from daynaport.c by Alan Cox */ |
664 | static void dayna_memcpy_fromcard(struct net_device *dev, void *to, int from, int count) | 679 | static void dayna_memcpy_fromcard(struct net_device *dev, void *to, int from, |
680 | int count) | ||
665 | { | 681 | { |
666 | volatile unsigned char *ptr; | 682 | volatile unsigned char *ptr; |
667 | unsigned char *target=to; | 683 | unsigned char *target = to; |
668 | from<<=1; /* word, skip overhead */ | 684 | from <<= 1; /* word, skip overhead */ |
669 | ptr=(unsigned char *)(dev->mem_start+from); | 685 | ptr = (unsigned char *)(dev->mem_start+from); |
670 | /* Leading byte? */ | 686 | /* Leading byte? */ |
671 | if (from&2) { | 687 | if (from & 2) { |
672 | *target++ = ptr[-1]; | 688 | *target++ = ptr[-1]; |
673 | ptr += 2; | 689 | ptr += 2; |
674 | count--; | 690 | count--; |
675 | } | 691 | } |
676 | while(count>=2) | 692 | while (count >= 2) { |
677 | { | ||
678 | *(unsigned short *)target = *(unsigned short volatile *)ptr; | 693 | *(unsigned short *)target = *(unsigned short volatile *)ptr; |
679 | ptr += 4; /* skip cruft */ | 694 | ptr += 4; /* skip cruft */ |
680 | target += 2; | 695 | target += 2; |
681 | count-=2; | 696 | count -= 2; |
682 | } | 697 | } |
683 | /* Trailing byte? */ | 698 | /* Trailing byte? */ |
684 | if(count) | 699 | if (count) |
685 | *target = *ptr; | 700 | *target = *ptr; |
686 | } | 701 | } |
687 | 702 | ||
688 | static void dayna_memcpy_tocard(struct net_device *dev, int to, const void *from, int count) | 703 | static void dayna_memcpy_tocard(struct net_device *dev, int to, |
704 | const void *from, int count) | ||
689 | { | 705 | { |
690 | volatile unsigned short *ptr; | 706 | volatile unsigned short *ptr; |
691 | const unsigned char *src=from; | 707 | const unsigned char *src = from; |
692 | to<<=1; /* word, skip overhead */ | 708 | to <<= 1; /* word, skip overhead */ |
693 | ptr=(unsigned short *)(dev->mem_start+to); | 709 | ptr = (unsigned short *)(dev->mem_start+to); |
694 | /* Leading byte? */ | 710 | /* Leading byte? */ |
695 | if (to&2) { /* avoid a byte write (stomps on other data) */ | 711 | if (to & 2) { /* avoid a byte write (stomps on other data) */ |
696 | ptr[-1] = (ptr[-1]&0xFF00)|*src++; | 712 | ptr[-1] = (ptr[-1]&0xFF00)|*src++; |
697 | ptr++; | 713 | ptr++; |
698 | count--; | 714 | count--; |
699 | } | 715 | } |
700 | while(count>=2) | 716 | while (count >= 2) { |
701 | { | 717 | *ptr++ = *(unsigned short *)src; /* Copy and */ |
702 | *ptr++=*(unsigned short *)src; /* Copy and */ | ||
703 | ptr++; /* skip cruft */ | 718 | ptr++; /* skip cruft */ |
704 | src += 2; | 719 | src += 2; |
705 | count-=2; | 720 | count -= 2; |
706 | } | 721 | } |
707 | /* Trailing byte? */ | 722 | /* Trailing byte? */ |
708 | if(count) | 723 | if (count) { |
709 | { | ||
710 | /* card doesn't like byte writes */ | 724 | /* card doesn't like byte writes */ |
711 | *ptr=(*ptr&0x00FF)|(*src << 8); | 725 | *ptr = (*ptr & 0x00FF) | (*src << 8); |
712 | } | 726 | } |
713 | } | 727 | } |
714 | 728 | ||
@@ -731,11 +745,14 @@ static void sane_block_input(struct net_device *dev, int count, | |||
731 | if (xfer_start + count > ei_status.rmem_end) { | 745 | if (xfer_start + count > ei_status.rmem_end) { |
732 | /* We must wrap the input move. */ | 746 | /* We must wrap the input move. */ |
733 | int semi_count = ei_status.rmem_end - xfer_start; | 747 | int semi_count = ei_status.rmem_end - xfer_start; |
734 | memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base, semi_count); | 748 | memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base, |
749 | semi_count); | ||
735 | count -= semi_count; | 750 | count -= semi_count; |
736 | memcpy_toio(skb->data + semi_count, (char *)ei_status.rmem_start, count); | 751 | memcpy_toio(skb->data + semi_count, |
752 | (char *)ei_status.rmem_start, count); | ||
737 | } else { | 753 | } else { |
738 | memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base, count); | 754 | memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base, |
755 | count); | ||
739 | } | 756 | } |
740 | } | 757 | } |
741 | 758 | ||
@@ -748,16 +765,18 @@ static void sane_block_output(struct net_device *dev, int count, | |||
748 | } | 765 | } |
749 | 766 | ||
750 | /* dayna block input/output */ | 767 | /* dayna block input/output */ |
751 | static void dayna_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page) | 768 | static void dayna_get_8390_hdr(struct net_device *dev, |
769 | struct e8390_pkt_hdr *hdr, int ring_page) | ||
752 | { | 770 | { |
753 | unsigned long hdr_start = (ring_page - WD_START_PG)<<8; | 771 | unsigned long hdr_start = (ring_page - WD_START_PG)<<8; |
754 | 772 | ||
755 | dayna_memcpy_fromcard(dev, hdr, hdr_start, 4); | 773 | dayna_memcpy_fromcard(dev, hdr, hdr_start, 4); |
756 | /* Fix endianness */ | 774 | /* Fix endianness */ |
757 | hdr->count=(hdr->count&0xFF)<<8|(hdr->count>>8); | 775 | hdr->count = (hdr->count & 0xFF) << 8 | (hdr->count >> 8); |
758 | } | 776 | } |
759 | 777 | ||
760 | static void dayna_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset) | 778 | static void dayna_block_input(struct net_device *dev, int count, |
779 | struct sk_buff *skb, int ring_offset) | ||
761 | { | 780 | { |
762 | unsigned long xfer_base = ring_offset - (WD_START_PG<<8); | 781 | unsigned long xfer_base = ring_offset - (WD_START_PG<<8); |
763 | unsigned long xfer_start = xfer_base+dev->mem_start; | 782 | unsigned long xfer_start = xfer_base+dev->mem_start; |
@@ -765,8 +784,7 @@ static void dayna_block_input(struct net_device *dev, int count, struct sk_buff | |||
765 | /* Note the offset math is done in card memory space which is word | 784 | /* Note the offset math is done in card memory space which is word |
766 | per long onto our space. */ | 785 | per long onto our space. */ |
767 | 786 | ||
768 | if (xfer_start + count > ei_status.rmem_end) | 787 | if (xfer_start + count > ei_status.rmem_end) { |
769 | { | ||
770 | /* We must wrap the input move. */ | 788 | /* We must wrap the input move. */ |
771 | int semi_count = ei_status.rmem_end - xfer_start; | 789 | int semi_count = ei_status.rmem_end - xfer_start; |
772 | dayna_memcpy_fromcard(dev, skb->data, xfer_base, semi_count); | 790 | dayna_memcpy_fromcard(dev, skb->data, xfer_base, semi_count); |
@@ -774,15 +792,14 @@ static void dayna_block_input(struct net_device *dev, int count, struct sk_buff | |||
774 | dayna_memcpy_fromcard(dev, skb->data + semi_count, | 792 | dayna_memcpy_fromcard(dev, skb->data + semi_count, |
775 | ei_status.rmem_start - dev->mem_start, | 793 | ei_status.rmem_start - dev->mem_start, |
776 | count); | 794 | count); |
777 | } | 795 | } else { |
778 | else | ||
779 | { | ||
780 | dayna_memcpy_fromcard(dev, skb->data, xfer_base, count); | 796 | dayna_memcpy_fromcard(dev, skb->data, xfer_base, count); |
781 | } | 797 | } |
782 | } | 798 | } |
783 | 799 | ||
784 | static void dayna_block_output(struct net_device *dev, int count, const unsigned char *buf, | 800 | static void dayna_block_output(struct net_device *dev, int count, |
785 | int start_page) | 801 | const unsigned char *buf, |
802 | int start_page) | ||
786 | { | 803 | { |
787 | long shmem = (start_page - WD_START_PG)<<8; | 804 | long shmem = (start_page - WD_START_PG)<<8; |
788 | 805 | ||
@@ -790,8 +807,9 @@ static void dayna_block_output(struct net_device *dev, int count, const unsigned | |||
790 | } | 807 | } |
791 | 808 | ||
792 | /* Cabletron block I/O */ | 809 | /* Cabletron block I/O */ |
793 | static void slow_sane_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, | 810 | static void slow_sane_get_8390_hdr(struct net_device *dev, |
794 | int ring_page) | 811 | struct e8390_pkt_hdr *hdr, |
812 | int ring_page) | ||
795 | { | 813 | { |
796 | unsigned long hdr_start = (ring_page - WD_START_PG)<<8; | 814 | unsigned long hdr_start = (ring_page - WD_START_PG)<<8; |
797 | word_memcpy_fromcard(hdr, (char *)dev->mem_start + hdr_start, 4); | 815 | word_memcpy_fromcard(hdr, (char *)dev->mem_start + hdr_start, 4); |
@@ -799,14 +817,13 @@ static void slow_sane_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr | |||
799 | hdr->count = (hdr->count&0xFF)<<8|(hdr->count>>8); | 817 | hdr->count = (hdr->count&0xFF)<<8|(hdr->count>>8); |
800 | } | 818 | } |
801 | 819 | ||
802 | static void slow_sane_block_input(struct net_device *dev, int count, struct sk_buff *skb, | 820 | static void slow_sane_block_input(struct net_device *dev, int count, |
803 | int ring_offset) | 821 | struct sk_buff *skb, int ring_offset) |
804 | { | 822 | { |
805 | unsigned long xfer_base = ring_offset - (WD_START_PG<<8); | 823 | unsigned long xfer_base = ring_offset - (WD_START_PG<<8); |
806 | unsigned long xfer_start = xfer_base+dev->mem_start; | 824 | unsigned long xfer_start = xfer_base+dev->mem_start; |
807 | 825 | ||
808 | if (xfer_start + count > ei_status.rmem_end) | 826 | if (xfer_start + count > ei_status.rmem_end) { |
809 | { | ||
810 | /* We must wrap the input move. */ | 827 | /* We must wrap the input move. */ |
811 | int semi_count = ei_status.rmem_end - xfer_start; | 828 | int semi_count = ei_status.rmem_end - xfer_start; |
812 | word_memcpy_fromcard(skb->data, | 829 | word_memcpy_fromcard(skb->data, |
@@ -815,16 +832,14 @@ static void slow_sane_block_input(struct net_device *dev, int count, struct sk_b | |||
815 | count -= semi_count; | 832 | count -= semi_count; |
816 | word_memcpy_fromcard(skb->data + semi_count, | 833 | word_memcpy_fromcard(skb->data + semi_count, |
817 | (char *)ei_status.rmem_start, count); | 834 | (char *)ei_status.rmem_start, count); |
818 | } | 835 | } else { |
819 | else | ||
820 | { | ||
821 | word_memcpy_fromcard(skb->data, | 836 | word_memcpy_fromcard(skb->data, |
822 | (char *)dev->mem_start + xfer_base, count); | 837 | (char *)dev->mem_start + xfer_base, count); |
823 | } | 838 | } |
824 | } | 839 | } |
825 | 840 | ||
826 | static void slow_sane_block_output(struct net_device *dev, int count, const unsigned char *buf, | 841 | static void slow_sane_block_output(struct net_device *dev, int count, |
827 | int start_page) | 842 | const unsigned char *buf, int start_page) |
828 | { | 843 | { |
829 | long shmem = (start_page - WD_START_PG)<<8; | 844 | long shmem = (start_page - WD_START_PG)<<8; |
830 | 845 | ||
@@ -837,10 +852,10 @@ static void word_memcpy_tocard(void *tp, const void *fp, int count) | |||
837 | const unsigned short *from = fp; | 852 | const unsigned short *from = fp; |
838 | 853 | ||
839 | count++; | 854 | count++; |
840 | count/=2; | 855 | count /= 2; |
841 | 856 | ||
842 | while(count--) | 857 | while (count--) |
843 | *to++=*from++; | 858 | *to++ = *from++; |
844 | } | 859 | } |
845 | 860 | ||
846 | static void word_memcpy_fromcard(void *tp, const void *fp, int count) | 861 | static void word_memcpy_fromcard(void *tp, const void *fp, int count) |
@@ -849,10 +864,10 @@ static void word_memcpy_fromcard(void *tp, const void *fp, int count) | |||
849 | const volatile unsigned short *from = fp; | 864 | const volatile unsigned short *from = fp; |
850 | 865 | ||
851 | count++; | 866 | count++; |
852 | count/=2; | 867 | count /= 2; |
853 | 868 | ||
854 | while(count--) | 869 | while (count--) |
855 | *to++=*from++; | 870 | *to++ = *from++; |
856 | } | 871 | } |
857 | 872 | ||
858 | 873 | ||