aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/cirrus
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-05-18 08:56:29 -0400
committerDavid S. Miller <davem@davemloft.net>2012-05-18 23:48:07 -0400
commitca034bcdb1786b0bfbe949c1575f8175d05325ce (patch)
treef37c2bdc2403cf350fb753dbda4ded471f1c8d3b /drivers/net/ethernet/cirrus
parentdd92b9ade4390783fdb64eec92dc5150a918e9a6 (diff)
cirrus: cs89x0: Code neatening
Just some stylings. Use #include <linux... not #include <asm... Convert a test and print to a printk_once. Combine an "if (foo) { if (bar) {" to single "if (foo && bar) {" to save an indent level. Convert single line "if (foo) bar;" to multiple lines. Move some braces. Align some long lines a bit better. Long lines and printks with KERN_ checkpatch complaints still exist. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/cirrus')
-rw-r--r--drivers/net/ethernet/cirrus/cs89x0.c452
1 files changed, 272 insertions, 180 deletions
diff --git a/drivers/net/ethernet/cirrus/cs89x0.c b/drivers/net/ethernet/cirrus/cs89x0.c
index b6120400d080..6e5b2c79340f 100644
--- a/drivers/net/ethernet/cirrus/cs89x0.c
+++ b/drivers/net/ethernet/cirrus/cs89x0.c
@@ -67,8 +67,8 @@
67#include <linux/bitops.h> 67#include <linux/bitops.h>
68#include <linux/delay.h> 68#include <linux/delay.h>
69#include <linux/gfp.h> 69#include <linux/gfp.h>
70#include <linux/io.h>
70 71
71#include <asm/io.h>
72#include <asm/irq.h> 72#include <asm/irq.h>
73#include <linux/atomic.h> 73#include <linux/atomic.h>
74#if ALLOW_DMA 74#if ALLOW_DMA
@@ -78,7 +78,7 @@
78#include "cs89x0.h" 78#include "cs89x0.h"
79 79
80static char version[] __initdata = 80static char version[] __initdata =
81 "cs89x0.c: v2.4.3-pre1 Russell Nelson <nelson@crynwr.com>, Andrew Morton\n"; 81 "v2.4.3-pre1 Russell Nelson <nelson@crynwr.com>, Andrew Morton\n";
82 82
83#define DRV_NAME "cs89x0" 83#define DRV_NAME "cs89x0"
84 84
@@ -97,17 +97,29 @@ static char version[] __initdata =
97 */ 97 */
98#if defined(CONFIG_MACH_IXDP2351) 98#if defined(CONFIG_MACH_IXDP2351)
99#define CS89x0_NONISA_IRQ 99#define CS89x0_NONISA_IRQ
100static unsigned int netcard_portlist[] __used __initdata = {IXDP2351_VIRT_CS8900_BASE, 0}; 100static unsigned int netcard_portlist[] __used __initdata = {
101static unsigned int cs8900_irq_map[] = {IRQ_IXDP2351_CS8900, 0, 0, 0}; 101 IXDP2351_VIRT_CS8900_BASE, 0
102};
103static unsigned int cs8900_irq_map[] = {
104 IRQ_IXDP2351_CS8900, 0, 0, 0
105};
102#elif defined(CONFIG_ARCH_IXDP2X01) 106#elif defined(CONFIG_ARCH_IXDP2X01)
103#define CS89x0_NONISA_IRQ 107#define CS89x0_NONISA_IRQ
104static unsigned int netcard_portlist[] __used __initdata = {IXDP2X01_CS8900_VIRT_BASE, 0}; 108static unsigned int netcard_portlist[] __used __initdata = {
105static unsigned int cs8900_irq_map[] = {IRQ_IXDP2X01_CS8900, 0, 0, 0}; 109 IXDP2X01_CS8900_VIRT_BASE, 0
110};
111static unsigned int cs8900_irq_map[] = {
112 IRQ_IXDP2X01_CS8900, 0, 0, 0
113};
106#else 114#else
107#ifndef CONFIG_CS89x0_PLATFORM 115#ifndef CONFIG_CS89x0_PLATFORM
108static unsigned int netcard_portlist[] __used __initdata = 116static unsigned int netcard_portlist[] __used __initdata = {
109{ 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0}; 117 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240,
110static unsigned int cs8900_irq_map[] = {10, 11, 12, 5}; 118 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0
119};
120static unsigned int cs8900_irq_map[] = {
121 10, 11, 12, 5
122};
111#endif 123#endif
112#endif 124#endif
113 125
@@ -201,9 +213,13 @@ static int g_cs89x0_media__force;
201 213
202static int __init media_fn(char *str) 214static int __init media_fn(char *str)
203{ 215{
204 if (!strcmp(str, "rj45")) g_cs89x0_media__force = FORCE_RJ45; 216 if (!strcmp(str, "rj45"))
205 else if (!strcmp(str, "aui")) g_cs89x0_media__force = FORCE_AUI; 217 g_cs89x0_media__force = FORCE_RJ45;
206 else if (!strcmp(str, "bnc")) g_cs89x0_media__force = FORCE_BNC; 218 else if (!strcmp(str, "aui"))
219 g_cs89x0_media__force = FORCE_AUI;
220 else if (!strcmp(str, "bnc"))
221 g_cs89x0_media__force = FORCE_BNC;
222
207 return 1; 223 return 1;
208} 224}
209 225
@@ -299,16 +315,21 @@ get_eeprom_data(struct net_device *dev, int off, int len, int *buffer)
299{ 315{
300 int i; 316 int i;
301 317
302 if (net_debug > 3) printk("EEPROM data from %x for %x:\n", off, len); 318 if (net_debug > 3)
319 printk("EEPROM data from %x for %x:\n", off, len);
303 for (i = 0; i < len; i++) { 320 for (i = 0; i < len; i++) {
304 if (wait_eeprom_ready(dev) < 0) return -1; 321 if (wait_eeprom_ready(dev) < 0)
322 return -1;
305 /* Now send the EEPROM read command and EEPROM location to read */ 323 /* Now send the EEPROM read command and EEPROM location to read */
306 writereg(dev, PP_EECMD, (off + i) | EEPROM_READ_CMD); 324 writereg(dev, PP_EECMD, (off + i) | EEPROM_READ_CMD);
307 if (wait_eeprom_ready(dev) < 0) return -1; 325 if (wait_eeprom_ready(dev) < 0)
326 return -1;
308 buffer[i] = readreg(dev, PP_EEData); 327 buffer[i] = readreg(dev, PP_EEData);
309 if (net_debug > 3) printk("%04x ", buffer[i]); 328 if (net_debug > 3)
329 printk("%04x ", buffer[i]);
310 } 330 }
311 if (net_debug > 3) printk("\n"); 331 if (net_debug > 3)
332 printk("\n");
312 return 0; 333 return 0;
313} 334}
314 335
@@ -364,7 +385,6 @@ static int __init
364cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular) 385cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
365{ 386{
366 struct net_local *lp = netdev_priv(dev); 387 struct net_local *lp = netdev_priv(dev);
367 static unsigned version_printed;
368 int i; 388 int i;
369 int tmp; 389 int tmp;
370 unsigned rev_type = 0; 390 unsigned rev_type = 0;
@@ -415,8 +435,8 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
415 if (lp->chip_type != CS8900 && lp->chip_revision >= 'C') 435 if (lp->chip_type != CS8900 && lp->chip_revision >= 'C')
416 lp->send_cmd = TX_NOW; 436 lp->send_cmd = TX_NOW;
417 437
418 if (net_debug && version_printed++ == 0) 438 if (net_debug)
419 printk(version); 439 printk_once(version);
420 440
421 pr_info("%s: cs89%c0%s rev %c found at %p ", 441 pr_info("%s: cs89%c0%s rev %c found at %p ",
422 dev->name, 442 dev->name,
@@ -436,7 +456,7 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
436 */ 456 */
437 457
438 if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) == 458 if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) ==
439 (EEPROM_OK|EEPROM_PRESENT)) { 459 (EEPROM_OK | EEPROM_PRESENT)) {
440 /* Load the MAC. */ 460 /* Load the MAC. */
441 for (i = 0; i < ETH_ALEN / 2; i++) { 461 for (i = 0; i < ETH_ALEN / 2; i++) {
442 unsigned int Addr; 462 unsigned int Addr;
@@ -507,12 +527,14 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
507 */ 527 */
508 528
509 /* get transmission control word but keep the autonegotiation bits */ 529 /* get transmission control word but keep the autonegotiation bits */
510 if (!lp->auto_neg_cnf) lp->auto_neg_cnf = eeprom_buff[AUTO_NEG_CNF_OFFSET/2]; 530 if (!lp->auto_neg_cnf)
531 lp->auto_neg_cnf = eeprom_buff[AUTO_NEG_CNF_OFFSET / 2];
511 /* Store adapter configuration */ 532 /* Store adapter configuration */
512 if (!lp->adapter_cnf) lp->adapter_cnf = eeprom_buff[ADAPTER_CNF_OFFSET/2]; 533 if (!lp->adapter_cnf)
534 lp->adapter_cnf = eeprom_buff[ADAPTER_CNF_OFFSET / 2];
513 /* Store ISA configuration */ 535 /* Store ISA configuration */
514 lp->isa_config = eeprom_buff[ISA_CNF_OFFSET/2]; 536 lp->isa_config = eeprom_buff[ISA_CNF_OFFSET / 2];
515 dev->mem_start = eeprom_buff[PACKET_PAGE_OFFSET/2] << 8; 537 dev->mem_start = eeprom_buff[PACKET_PAGE_OFFSET / 2] << 8;
516 538
517 /* eeprom_buff has 32-bit ints, so we can't just memcpy it */ 539 /* eeprom_buff has 32-bit ints, so we can't just memcpy it */
518 /* store the initial memory base address */ 540 /* store the initial memory base address */
@@ -528,13 +550,26 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
528 /* allow them to force multiple transceivers. If they force multiple, autosense */ 550 /* allow them to force multiple transceivers. If they force multiple, autosense */
529 { 551 {
530 int count = 0; 552 int count = 0;
531 if (lp->force & FORCE_RJ45) {lp->adapter_cnf |= A_CNF_10B_T; count++; } 553 if (lp->force & FORCE_RJ45) {
532 if (lp->force & FORCE_AUI) {lp->adapter_cnf |= A_CNF_AUI; count++; } 554 lp->adapter_cnf |= A_CNF_10B_T;
533 if (lp->force & FORCE_BNC) {lp->adapter_cnf |= A_CNF_10B_2; count++; } 555 count++;
534 if (count > 1) {lp->adapter_cnf |= A_CNF_MEDIA_AUTO; } 556 }
535 else if (lp->force & FORCE_RJ45){lp->adapter_cnf |= A_CNF_MEDIA_10B_T; } 557 if (lp->force & FORCE_AUI) {
536 else if (lp->force & FORCE_AUI) {lp->adapter_cnf |= A_CNF_MEDIA_AUI; } 558 lp->adapter_cnf |= A_CNF_AUI;
537 else if (lp->force & FORCE_BNC) {lp->adapter_cnf |= A_CNF_MEDIA_10B_2; } 559 count++;
560 }
561 if (lp->force & FORCE_BNC) {
562 lp->adapter_cnf |= A_CNF_10B_2;
563 count++;
564 }
565 if (count > 1)
566 lp->adapter_cnf |= A_CNF_MEDIA_AUTO;
567 else if (lp->force & FORCE_RJ45)
568 lp->adapter_cnf |= A_CNF_MEDIA_10B_T;
569 else if (lp->force & FORCE_AUI)
570 lp->adapter_cnf |= A_CNF_MEDIA_AUI;
571 else if (lp->force & FORCE_BNC)
572 lp->adapter_cnf |= A_CNF_MEDIA_10B_2;
538 } 573 }
539 574
540 if (net_debug > 1) 575 if (net_debug > 1)
@@ -584,7 +619,8 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
584 IRQ_MAP_LEN / 2, 619 IRQ_MAP_LEN / 2,
585 irq_map_buff) >= 0) { 620 irq_map_buff) >= 0) {
586 if ((irq_map_buff[0] & 0xff) == PNP_IRQ_FRMT) 621 if ((irq_map_buff[0] & 0xff) == PNP_IRQ_FRMT)
587 lp->irq_map = (irq_map_buff[0] >> 8) | (irq_map_buff[1] << 8); 622 lp->irq_map = ((irq_map_buff[0] >> 8) |
623 (irq_map_buff[1] << 8));
588 } 624 }
589#endif 625#endif
590 } 626 }
@@ -599,20 +635,16 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
599 if (lp->use_dma) { 635 if (lp->use_dma) {
600 get_dma_channel(dev); 636 get_dma_channel(dev);
601 printk(", DMA %d", dev->dma); 637 printk(", DMA %d", dev->dma);
602 } 638 } else
603 else
604#endif 639#endif
605 {
606 printk(", programmed I/O"); 640 printk(", programmed I/O");
607 }
608 641
609 /* print the ethernet address. */ 642 /* print the ethernet address. */
610 printk(", MAC %pM", dev->dev_addr); 643 printk(", MAC %pM\n", dev->dev_addr);
611 644
612 dev->netdev_ops = &net_ops; 645 dev->netdev_ops = &net_ops;
613 dev->watchdog_timeo = HZ; 646 dev->watchdog_timeo = HZ;
614 647
615 printk("\n");
616 if (net_debug) 648 if (net_debug)
617 printk("cs89x0_probe1() successful\n"); 649 printk("cs89x0_probe1() successful\n");
618 650
@@ -663,7 +695,7 @@ cs89x0_ioport_probe(struct net_device *dev, unsigned long ioport, int modular)
663 if (ioport & 1) { 695 if (ioport & 1) {
664 if (net_debug > 1) 696 if (net_debug > 1)
665 pr_info("%s: odd ioaddr 0x%lx\n", dev->name, ioport); 697 pr_info("%s: odd ioaddr 0x%lx\n", dev->name, ioport);
666 if ((ioport & 2) != 2) 698 if ((ioport & 2) != 2) {
667 if ((ioread16(io_mem + ADD_PORT) & ADD_MASK) != 699 if ((ioread16(io_mem + ADD_PORT) & ADD_MASK) !=
668 ADD_SIG) { 700 ADD_SIG) {
669 pr_err("%s: bad signature 0x%x\n", 701 pr_err("%s: bad signature 0x%x\n",
@@ -671,6 +703,7 @@ cs89x0_ioport_probe(struct net_device *dev, unsigned long ioport, int modular)
671 ret = -ENODEV; 703 ret = -ENODEV;
672 goto unmap; 704 goto unmap;
673 } 705 }
706 }
674 } 707 }
675 708
676 ret = cs89x0_probe1(dev, io_mem, modular); 709 ret = cs89x0_probe1(dev, io_mem, modular);
@@ -742,7 +775,7 @@ out:
742 775
743#if ALLOW_DMA 776#if ALLOW_DMA
744 777
745#define dma_page_eq(ptr1, ptr2) ((long)(ptr1)>>17 == (long)(ptr2)>>17) 778#define dma_page_eq(ptr1, ptr2) ((long)(ptr1) >> 17 == (long)(ptr2) >> 17)
746 779
747static void 780static void
748get_dma_channel(struct net_device *dev) 781get_dma_channel(struct net_device *dev)
@@ -771,11 +804,10 @@ write_dma(struct net_device *dev, int chip_type, int dma)
771 struct net_local *lp = netdev_priv(dev); 804 struct net_local *lp = netdev_priv(dev);
772 if ((lp->isa_config & ANY_ISA_DMA) == 0) 805 if ((lp->isa_config & ANY_ISA_DMA) == 0)
773 return; 806 return;
774 if (chip_type == CS8900) { 807 if (chip_type == CS8900)
775 writereg(dev, PP_CS8900_ISADMA, dma-5); 808 writereg(dev, PP_CS8900_ISADMA, dma - 5);
776 } else { 809 else
777 writereg(dev, PP_CS8920_ISADMA, dma); 810 writereg(dev, PP_CS8920_ISADMA, dma);
778 }
779} 811}
780 812
781static void 813static void
@@ -836,8 +868,8 @@ dma_rx(struct net_device *dev)
836 int status, length; 868 int status, length;
837 unsigned char *bp = lp->rx_dma_ptr; 869 unsigned char *bp = lp->rx_dma_ptr;
838 870
839 status = bp[0] + (bp[1]<<8); 871 status = bp[0] + (bp[1] << 8);
840 length = bp[2] + (bp[3]<<8); 872 length = bp[2] + (bp[3] << 8);
841 bp += 4; 873 bp += 4;
842 if (net_debug > 5) { 874 if (net_debug > 5) {
843 printk("%s: receiving DMA packet at %lx, status %x, length %x\n", 875 printk("%s: receiving DMA packet at %lx, status %x, length %x\n",
@@ -852,13 +884,15 @@ dma_rx(struct net_device *dev)
852 skb = netdev_alloc_skb(dev, length + 2); 884 skb = netdev_alloc_skb(dev, length + 2);
853 if (skb == NULL) { 885 if (skb == NULL) {
854 if (net_debug) /* I don't think we want to do this to a stressed system */ 886 if (net_debug) /* I don't think we want to do this to a stressed system */
855 printk("%s: Memory squeeze, dropping packet.\n", dev->name); 887 printk("%s: Memory squeeze, dropping packet\n",
888 dev->name);
856 dev->stats.rx_dropped++; 889 dev->stats.rx_dropped++;
857 890
858 /* AKPM: advance bp to the next frame */ 891 /* AKPM: advance bp to the next frame */
859skip_this_frame: 892skip_this_frame:
860 bp += (length + 3) & ~3; 893 bp += (length + 3) & ~3;
861 if (bp >= lp->end_dma_buff) bp -= lp->dmasize*1024; 894 if (bp >= lp->end_dma_buff)
895 bp -= lp->dmasize * 1024;
862 lp->rx_dma_ptr = bp; 896 lp->rx_dma_ptr = bp;
863 return; 897 return;
864 } 898 }
@@ -873,13 +907,15 @@ skip_this_frame:
873 memcpy(skb_put(skb, length), bp, length); 907 memcpy(skb_put(skb, length), bp, length);
874 } 908 }
875 bp += (length + 3) & ~3; 909 bp += (length + 3) & ~3;
876 if (bp >= lp->end_dma_buff) bp -= lp->dmasize*1024; 910 if (bp >= lp->end_dma_buff)
911 bp -= lp->dmasize*1024;
877 lp->rx_dma_ptr = bp; 912 lp->rx_dma_ptr = bp;
878 913
879 if (net_debug > 3) { 914 if (net_debug > 3) {
880 printk("%s: received %d byte DMA packet of type %x\n", 915 printk("%s: received %d byte DMA packet of type %x\n",
881 dev->name, length, 916 dev->name, length,
882 (skb->data[ETH_ALEN + ETH_ALEN] << 8) | skb->data[ETH_ALEN + ETH_ALEN + 1]); 917 ((skb->data[ETH_ALEN + ETH_ALEN] << 8) |
918 skb->data[ETH_ALEN + ETH_ALEN + 1]));
883 } 919 }
884 skb->protocol = eth_type_trans(skb, dev); 920 skb->protocol = eth_type_trans(skb, dev);
885 netif_rx(skb); 921 netif_rx(skb);
@@ -919,7 +955,8 @@ static void __init reset_chip(struct net_device *dev)
919 955
920 /* Wait until the chip is reset */ 956 /* Wait until the chip is reset */
921 reset_start_time = jiffies; 957 reset_start_time = jiffies;
922 while ((readreg(dev, PP_SelfST) & INIT_DONE) == 0 && jiffies - reset_start_time < 2) 958 while ((readreg(dev, PP_SelfST) & INIT_DONE) == 0 &&
959 jiffies - reset_start_time < 2)
923 ; 960 ;
924#endif /* !CONFIG_MACH_MX31ADS */ 961#endif /* !CONFIG_MACH_MX31ADS */
925} 962}
@@ -932,8 +969,9 @@ control_dc_dc(struct net_device *dev, int on_not_off)
932 unsigned int selfcontrol; 969 unsigned int selfcontrol;
933 int timenow = jiffies; 970 int timenow = jiffies;
934 /* control the DC to DC convertor in the SelfControl register. 971 /* control the DC to DC convertor in the SelfControl register.
935 Note: This is hooked up to a general purpose pin, might not 972 * Note: This is hooked up to a general purpose pin, might not
936 always be a DC to DC convertor. */ 973 * always be a DC to DC convertor.
974 */
937 975
938 selfcontrol = HCB1_ENBL; /* Enable the HCB1 bit as an output */ 976 selfcontrol = HCB1_ENBL; /* Enable the HCB1 bit as an output */
939 if (((lp->adapter_cnf & A_CNF_DC_DC_POLARITY) != 0) ^ on_not_off) 977 if (((lp->adapter_cnf & A_CNF_DC_DC_POLARITY) != 0) ^ on_not_off)
@@ -960,18 +998,23 @@ detect_tp(struct net_device *dev)
960 int timenow = jiffies; 998 int timenow = jiffies;
961 int fdx; 999 int fdx;
962 1000
963 if (net_debug > 1) printk("%s: Attempting TP\n", dev->name); 1001 if (net_debug > 1)
964 1002 printk("%s: Attempting TP\n", dev->name);
965 /* If connected to another full duplex capable 10-Base-T card the link pulses 1003
966 seem to be lost when the auto detect bit in the LineCTL is set. 1004 /* If connected to another full duplex capable 10-Base-T card
967 To overcome this the auto detect bit will be cleared whilst testing the 1005 * the link pulses seem to be lost when the auto detect bit in
968 10-Base-T interface. This would not be necessary for the sparrow chip but 1006 * the LineCTL is set. To overcome this the auto detect bit will
969 is simpler to do it anyway. */ 1007 * be cleared whilst testing the 10-Base-T interface. This would
1008 * not be necessary for the sparrow chip but is simpler to do it
1009 * anyway.
1010 */
970 writereg(dev, PP_LineCTL, lp->linectl & ~AUI_ONLY); 1011 writereg(dev, PP_LineCTL, lp->linectl & ~AUI_ONLY);
971 control_dc_dc(dev, 0); 1012 control_dc_dc(dev, 0);
972 1013
973 /* Delay for the hardware to work out if the TP cable is present - 150ms */ 1014 /* Delay for the hardware to work out if the TP cable is present
974 for (timenow = jiffies; jiffies - timenow < 15; ) 1015 * - 150ms
1016 */
1017 for (timenow = jiffies; jiffies - timenow < 15;)
975 ; 1018 ;
976 if ((readreg(dev, PP_LineST) & LINK_OK) == 0) 1019 if ((readreg(dev, PP_LineST) & LINK_OK) == 0)
977 return DETECTED_NONE; 1020 return DETECTED_NONE;
@@ -991,7 +1034,8 @@ detect_tp(struct net_device *dev)
991 case FORCE_HALF: 1034 case FORCE_HALF:
992 break; 1035 break;
993 case FORCE_FULL: 1036 case FORCE_FULL:
994 writereg(dev, PP_TestCTL, readreg(dev, PP_TestCTL) | FDX_8900); 1037 writereg(dev, PP_TestCTL,
1038 readreg(dev, PP_TestCTL) | FDX_8900);
995 break; 1039 break;
996 } 1040 }
997 fdx = readreg(dev, PP_TestCTL) & FDX_8900; 1041 fdx = readreg(dev, PP_TestCTL) & FDX_8900;
@@ -1032,10 +1076,12 @@ static int
1032send_test_pkt(struct net_device *dev) 1076send_test_pkt(struct net_device *dev)
1033{ 1077{
1034 struct net_local *lp = netdev_priv(dev); 1078 struct net_local *lp = netdev_priv(dev);
1035 char test_packet[] = { 0,0,0,0,0,0, 0,0,0,0,0,0, 1079 char test_packet[] = {
1036 0, 46, /* A 46 in network order */ 1080 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1037 0, 0, /* DSAP=0 & SSAP=0 fields */ 1081 0, 46, /* A 46 in network order */
1038 0xf3, 0 /* Control (Test Req + P bit set) */ }; 1082 0, 0, /* DSAP=0 & SSAP=0 fields */
1083 0xf3, 0 /* Control (Test Req + P bit set) */
1084 };
1039 long timenow = jiffies; 1085 long timenow = jiffies;
1040 1086
1041 writereg(dev, PP_LineCTL, readreg(dev, PP_LineCTL) | SERIAL_TX_ON); 1087 writereg(dev, PP_LineCTL, readreg(dev, PP_LineCTL) | SERIAL_TX_ON);
@@ -1054,17 +1100,20 @@ send_test_pkt(struct net_device *dev)
1054 return 0; /* this shouldn't happen */ 1100 return 0; /* this shouldn't happen */
1055 1101
1056 /* Write the contents of the packet */ 1102 /* Write the contents of the packet */
1057 writewords(lp, TX_FRAME_PORT, test_packet, (ETH_ZLEN+1) >> 1); 1103 writewords(lp, TX_FRAME_PORT, test_packet, (ETH_ZLEN + 1) >> 1);
1058 1104
1059 if (net_debug > 1) printk("Sending test packet "); 1105 if (net_debug > 1)
1106 printk("Sending test packet ");
1060 /* wait a couple of jiffies for packet to be received */ 1107 /* wait a couple of jiffies for packet to be received */
1061 for (timenow = jiffies; jiffies - timenow < 3; ) 1108 for (timenow = jiffies; jiffies - timenow < 3;)
1062 ; 1109 ;
1063 if ((readreg(dev, PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK) { 1110 if ((readreg(dev, PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK) {
1064 if (net_debug > 1) printk("succeeded\n"); 1111 if (net_debug > 1)
1112 printk("succeeded\n");
1065 return 1; 1113 return 1;
1066 } 1114 }
1067 if (net_debug > 1) printk("failed\n"); 1115 if (net_debug > 1)
1116 printk("failed\n");
1068 return 0; 1117 return 0;
1069} 1118}
1070 1119
@@ -1074,7 +1123,8 @@ detect_aui(struct net_device *dev)
1074{ 1123{
1075 struct net_local *lp = netdev_priv(dev); 1124 struct net_local *lp = netdev_priv(dev);
1076 1125
1077 if (net_debug > 1) printk("%s: Attempting AUI\n", dev->name); 1126 if (net_debug > 1)
1127 printk("%s: Attempting AUI\n", dev->name);
1078 control_dc_dc(dev, 0); 1128 control_dc_dc(dev, 0);
1079 1129
1080 writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY); 1130 writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
@@ -1090,7 +1140,8 @@ detect_bnc(struct net_device *dev)
1090{ 1140{
1091 struct net_local *lp = netdev_priv(dev); 1141 struct net_local *lp = netdev_priv(dev);
1092 1142
1093 if (net_debug > 1) printk("%s: Attempting BNC\n", dev->name); 1143 if (net_debug > 1)
1144 printk("%s: Attempting BNC\n", dev->name);
1094 control_dc_dc(dev, 1); 1145 control_dc_dc(dev, 1);
1095 1146
1096 writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY); 1147 writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
@@ -1155,7 +1206,8 @@ net_open(struct net_device *dev)
1155 1206
1156 for (i = 2; i < CS8920_NO_INTS; i++) { 1207 for (i = 2; i < CS8920_NO_INTS; i++) {
1157 if ((1 << i) & lp->irq_map) { 1208 if ((1 << i) & lp->irq_map) {
1158 if (request_irq(i, net_interrupt, 0, dev->name, dev) == 0) { 1209 if (request_irq(i, net_interrupt, 0, dev->name,
1210 dev) == 0) {
1159 dev->irq = i; 1211 dev->irq = i;
1160 write_irq(dev, lp->chip_type, i); 1212 write_irq(dev, lp->chip_type, i);
1161 /* writereg(dev, PP_BufCFG, GENERATE_SW_INTERRUPT); */ 1213 /* writereg(dev, PP_BufCFG, GENERATE_SW_INTERRUPT); */
@@ -1170,9 +1222,7 @@ net_open(struct net_device *dev)
1170 ret = -EAGAIN; 1222 ret = -EAGAIN;
1171 goto bad_out; 1223 goto bad_out;
1172 } 1224 }
1173 } 1225 } else {
1174 else
1175 {
1176#if !defined(CS89x0_NONISA_IRQ) && !defined(CONFIG_CS89x0_PLATFORM) 1226#if !defined(CS89x0_NONISA_IRQ) && !defined(CONFIG_CS89x0_PLATFORM)
1177 if (((1 << dev->irq) & lp->irq_map) == 0) { 1227 if (((1 << dev->irq) & lp->irq_map) == 0) {
1178 pr_err("%s: IRQ %d is not in our map of allowable IRQs, which is %x\n", 1228 pr_err("%s: IRQ %d is not in our map of allowable IRQs, which is %x\n",
@@ -1196,69 +1246,78 @@ net_open(struct net_device *dev)
1196 } 1246 }
1197 1247
1198#if ALLOW_DMA 1248#if ALLOW_DMA
1199 if (lp->use_dma) { 1249 if (lp->use_dma && (lp->isa_config & ANY_ISA_DMA)) {
1200 if (lp->isa_config & ANY_ISA_DMA) { 1250 unsigned long flags;
1201 unsigned long flags; 1251 lp->dma_buff = (unsigned char *)__get_dma_pages(GFP_KERNEL,
1202 lp->dma_buff = (unsigned char *)__get_dma_pages(GFP_KERNEL, 1252 get_order(lp->dmasize * 1024));
1203 get_order(lp->dmasize * 1024)); 1253 if (!lp->dma_buff) {
1204 1254 pr_err("%s: cannot get %dK memory for DMA\n",
1205 if (!lp->dma_buff) { 1255 dev->name, lp->dmasize);
1206 pr_err("%s: cannot get %dK memory for DMA\n", 1256 goto release_irq;
1207 dev->name, lp->dmasize); 1257 }
1208 goto release_irq; 1258 if (net_debug > 1) {
1209 } 1259 printk("%s: dma %lx %lx\n",
1210 if (net_debug > 1) { 1260 dev->name,
1211 printk("%s: dma %lx %lx\n", 1261 (unsigned long)lp->dma_buff,
1212 dev->name, 1262 (unsigned long)isa_virt_to_bus(lp->dma_buff));
1213 (unsigned long)lp->dma_buff, 1263 }
1214 (unsigned long)isa_virt_to_bus(lp->dma_buff)); 1264 if ((unsigned long)lp->dma_buff >= MAX_DMA_ADDRESS ||
1215 } 1265 !dma_page_eq(lp->dma_buff,
1216 if ((unsigned long) lp->dma_buff >= MAX_DMA_ADDRESS || 1266 lp->dma_buff + lp->dmasize * 1024 - 1)) {
1217 !dma_page_eq(lp->dma_buff, lp->dma_buff+lp->dmasize*1024-1)) { 1267 pr_err("%s: not usable as DMA buffer\n", dev->name);
1218 pr_err("%s: not usable as DMA buffer\n", 1268 goto release_irq;
1219 dev->name);
1220 goto release_irq;
1221 }
1222 memset(lp->dma_buff, 0, lp->dmasize * 1024); /* Why? */
1223 if (request_dma(dev->dma, dev->name)) {
1224 pr_err("%s: cannot get dma channel %d\n",
1225 dev->name, dev->dma);
1226 goto release_irq;
1227 }
1228 write_dma(dev, lp->chip_type, dev->dma);
1229 lp->rx_dma_ptr = lp->dma_buff;
1230 lp->end_dma_buff = lp->dma_buff + lp->dmasize*1024;
1231 spin_lock_irqsave(&lp->lock, flags);
1232 disable_dma(dev->dma);
1233 clear_dma_ff(dev->dma);
1234 set_dma_mode(dev->dma, DMA_RX_MODE); /* auto_init as well */
1235 set_dma_addr(dev->dma, isa_virt_to_bus(lp->dma_buff));
1236 set_dma_count(dev->dma, lp->dmasize*1024);
1237 enable_dma(dev->dma);
1238 spin_unlock_irqrestore(&lp->lock, flags);
1239 } 1269 }
1270 memset(lp->dma_buff, 0, lp->dmasize * 1024); /* Why? */
1271 if (request_dma(dev->dma, dev->name)) {
1272 pr_err("%s: cannot get dma channel %d\n",
1273 dev->name, dev->dma);
1274 goto release_irq;
1275 }
1276 write_dma(dev, lp->chip_type, dev->dma);
1277 lp->rx_dma_ptr = lp->dma_buff;
1278 lp->end_dma_buff = lp->dma_buff + lp->dmasize * 1024;
1279 spin_lock_irqsave(&lp->lock, flags);
1280 disable_dma(dev->dma);
1281 clear_dma_ff(dev->dma);
1282 set_dma_mode(dev->dma, DMA_RX_MODE); /* auto_init as well */
1283 set_dma_addr(dev->dma, isa_virt_to_bus(lp->dma_buff));
1284 set_dma_count(dev->dma, lp->dmasize * 1024);
1285 enable_dma(dev->dma);
1286 spin_unlock_irqrestore(&lp->lock, flags);
1240 } 1287 }
1241#endif /* ALLOW_DMA */ 1288#endif /* ALLOW_DMA */
1242 1289
1243 /* set the Ethernet address */ 1290 /* set the Ethernet address */
1244 for (i = 0; i < ETH_ALEN / 2; i++) 1291 for (i = 0; i < ETH_ALEN / 2; i++)
1245 writereg(dev, PP_IA + i * 2, dev->dev_addr[i * 2] | (dev->dev_addr[i * 2 + 1] << 8)); 1292 writereg(dev, PP_IA + i * 2,
1293 (dev->dev_addr[i * 2] |
1294 (dev->dev_addr[i * 2 + 1] << 8)));
1246 1295
1247 /* while we're testing the interface, leave interrupts disabled */ 1296 /* while we're testing the interface, leave interrupts disabled */
1248 writereg(dev, PP_BusCTL, MEMORY_ON); 1297 writereg(dev, PP_BusCTL, MEMORY_ON);
1249 1298
1250 /* Set the LineCTL quintuplet based on adapter configuration read from EEPROM */ 1299 /* Set the LineCTL quintuplet based on adapter configuration read from EEPROM */
1251 if ((lp->adapter_cnf & A_CNF_EXTND_10B_2) && (lp->adapter_cnf & A_CNF_LOW_RX_SQUELCH)) 1300 if ((lp->adapter_cnf & A_CNF_EXTND_10B_2) &&
1301 (lp->adapter_cnf & A_CNF_LOW_RX_SQUELCH))
1252 lp->linectl = LOW_RX_SQUELCH; 1302 lp->linectl = LOW_RX_SQUELCH;
1253 else 1303 else
1254 lp->linectl = 0; 1304 lp->linectl = 0;
1255 1305
1256 /* check to make sure that they have the "right" hardware available */ 1306 /* check to make sure that they have the "right" hardware available */
1257 switch (lp->adapter_cnf & A_CNF_MEDIA_TYPE) { 1307 switch (lp->adapter_cnf & A_CNF_MEDIA_TYPE) {
1258 case A_CNF_MEDIA_10B_T: result = lp->adapter_cnf & A_CNF_10B_T; break; 1308 case A_CNF_MEDIA_10B_T:
1259 case A_CNF_MEDIA_AUI: result = lp->adapter_cnf & A_CNF_AUI; break; 1309 result = lp->adapter_cnf & A_CNF_10B_T;
1260 case A_CNF_MEDIA_10B_2: result = lp->adapter_cnf & A_CNF_10B_2; break; 1310 break;
1261 default: result = lp->adapter_cnf & (A_CNF_10B_T | A_CNF_AUI | A_CNF_10B_2); 1311 case A_CNF_MEDIA_AUI:
1312 result = lp->adapter_cnf & A_CNF_AUI;
1313 break;
1314 case A_CNF_MEDIA_10B_2:
1315 result = lp->adapter_cnf & A_CNF_10B_2;
1316 break;
1317 default:
1318 result = lp->adapter_cnf & (A_CNF_10B_T |
1319 A_CNF_AUI |
1320 A_CNF_10B_2);
1262 } 1321 }
1263 if (!result) { 1322 if (!result) {
1264 pr_err("%s: EEPROM is configured for unavailable media\n", 1323 pr_err("%s: EEPROM is configured for unavailable media\n",
@@ -1269,7 +1328,8 @@ release_dma:
1269release_irq: 1328release_irq:
1270 release_dma_buff(lp); 1329 release_dma_buff(lp);
1271#endif 1330#endif
1272 writereg(dev, PP_LineCTL, readreg(dev, PP_LineCTL) & ~(SERIAL_TX_ON | SERIAL_RX_ON)); 1331 writereg(dev, PP_LineCTL,
1332 readreg(dev, PP_LineCTL) & ~(SERIAL_TX_ON | SERIAL_RX_ON));
1273 free_irq(dev->irq, dev); 1333 free_irq(dev->irq, dev);
1274 ret = -EAGAIN; 1334 ret = -EAGAIN;
1275 goto bad_out; 1335 goto bad_out;
@@ -1304,15 +1364,21 @@ release_irq:
1304 break; 1364 break;
1305 case A_CNF_MEDIA_AUTO: 1365 case A_CNF_MEDIA_AUTO:
1306 writereg(dev, PP_LineCTL, lp->linectl | AUTO_AUI_10BASET); 1366 writereg(dev, PP_LineCTL, lp->linectl | AUTO_AUI_10BASET);
1307 if (lp->adapter_cnf & A_CNF_10B_T) 1367 if (lp->adapter_cnf & A_CNF_10B_T) {
1308 if ((result = detect_tp(dev)) != DETECTED_NONE) 1368 result = detect_tp(dev);
1369 if (result != DETECTED_NONE)
1309 break; 1370 break;
1310 if (lp->adapter_cnf & A_CNF_AUI) 1371 }
1311 if ((result = detect_aui(dev)) != DETECTED_NONE) 1372 if (lp->adapter_cnf & A_CNF_AUI) {
1373 result = detect_aui(dev);
1374 if (result != DETECTED_NONE)
1312 break; 1375 break;
1313 if (lp->adapter_cnf & A_CNF_10B_2) 1376 }
1314 if ((result = detect_bnc(dev)) != DETECTED_NONE) 1377 if (lp->adapter_cnf & A_CNF_10B_2) {
1378 result = detect_bnc(dev);
1379 if (result != DETECTED_NONE)
1315 break; 1380 break;
1381 }
1316 pr_err("%s: no media detected\n", dev->name); 1382 pr_err("%s: no media detected\n", dev->name);
1317 goto release_dma; 1383 goto release_dma;
1318 } 1384 }
@@ -1336,7 +1402,8 @@ release_irq:
1336 } 1402 }
1337 1403
1338 /* Turn on both receive and transmit operations */ 1404 /* Turn on both receive and transmit operations */
1339 writereg(dev, PP_LineCTL, readreg(dev, PP_LineCTL) | SERIAL_RX_ON | SERIAL_TX_ON); 1405 writereg(dev, PP_LineCTL,
1406 readreg(dev, PP_LineCTL) | SERIAL_RX_ON | SERIAL_TX_ON);
1340 1407
1341 /* Receive only error free packets addressed to this card */ 1408 /* Receive only error free packets addressed to this card */
1342 lp->rx_mode = 0; 1409 lp->rx_mode = 0;
@@ -1351,22 +1418,29 @@ release_irq:
1351#endif 1418#endif
1352 writereg(dev, PP_RxCFG, lp->curr_rx_cfg); 1419 writereg(dev, PP_RxCFG, lp->curr_rx_cfg);
1353 1420
1354 writereg(dev, PP_TxCFG, TX_LOST_CRS_ENBL | TX_SQE_ERROR_ENBL | TX_OK_ENBL | 1421 writereg(dev, PP_TxCFG, (TX_LOST_CRS_ENBL |
1355 TX_LATE_COL_ENBL | TX_JBR_ENBL | TX_ANY_COL_ENBL | TX_16_COL_ENBL); 1422 TX_SQE_ERROR_ENBL |
1423 TX_OK_ENBL |
1424 TX_LATE_COL_ENBL |
1425 TX_JBR_ENBL |
1426 TX_ANY_COL_ENBL |
1427 TX_16_COL_ENBL));
1356 1428
1357 writereg(dev, PP_BufCFG, READY_FOR_TX_ENBL | RX_MISS_COUNT_OVRFLOW_ENBL | 1429 writereg(dev, PP_BufCFG, (READY_FOR_TX_ENBL |
1430 RX_MISS_COUNT_OVRFLOW_ENBL |
1358#if ALLOW_DMA 1431#if ALLOW_DMA
1359 dma_bufcfg(dev) | 1432 dma_bufcfg(dev) |
1360#endif 1433#endif
1361 TX_COL_COUNT_OVRFLOW_ENBL | TX_UNDERRUN_ENBL); 1434 TX_COL_COUNT_OVRFLOW_ENBL |
1435 TX_UNDERRUN_ENBL));
1362 1436
1363 /* now that we've got our act together, enable everything */ 1437 /* now that we've got our act together, enable everything */
1364 writereg(dev, PP_BusCTL, ENABLE_IRQ 1438 writereg(dev, PP_BusCTL, (ENABLE_IRQ
1365 | (dev->mem_start ? MEMORY_ON : 0) /* turn memory on */ 1439 | (dev->mem_start ? MEMORY_ON : 0) /* turn memory on */
1366#if ALLOW_DMA 1440#if ALLOW_DMA
1367 | dma_busctl(dev) 1441 | dma_busctl(dev)
1368#endif 1442#endif
1369 ); 1443 ));
1370 netif_start_queue(dev); 1444 netif_start_queue(dev);
1371 if (net_debug > 1) 1445 if (net_debug > 1)
1372 printk("cs89x0: net_open() succeeded\n"); 1446 printk("cs89x0: net_open() succeeded\n");
@@ -1379,8 +1453,10 @@ static void net_timeout(struct net_device *dev)
1379{ 1453{
1380 /* If we get here, some higher level has decided we are broken. 1454 /* If we get here, some higher level has decided we are broken.
1381 There should really be a "kick me" function call instead. */ 1455 There should really be a "kick me" function call instead. */
1382 if (net_debug > 0) printk("%s: transmit timed out, %s?\n", dev->name, 1456 if (net_debug > 0)
1383 tx_done(dev) ? "IRQ conflict ?" : "network cable problem"); 1457 printk("%s: transmit timed out, %s?\n",
1458 dev->name,
1459 tx_done(dev) ? "IRQ conflict" : "network cable problem");
1384 /* Try to restart the adaptor. */ 1460 /* Try to restart the adaptor. */
1385 netif_wake_queue(dev); 1461 netif_wake_queue(dev);
1386} 1462}
@@ -1393,12 +1469,14 @@ static netdev_tx_t net_send_packet(struct sk_buff *skb, struct net_device *dev)
1393 if (net_debug > 3) { 1469 if (net_debug > 3) {
1394 printk("%s: sent %d byte packet of type %x\n", 1470 printk("%s: sent %d byte packet of type %x\n",
1395 dev->name, skb->len, 1471 dev->name, skb->len,
1396 (skb->data[ETH_ALEN + ETH_ALEN] << 8) | skb->data[ETH_ALEN + ETH_ALEN + 1]); 1472 ((skb->data[ETH_ALEN + ETH_ALEN] << 8) |
1473 skb->data[ETH_ALEN + ETH_ALEN + 1]));
1397 } 1474 }
1398 1475
1399 /* keep the upload from being interrupted, since we 1476 /* keep the upload from being interrupted, since we
1400 ask the chip to start transmitting before the 1477 * ask the chip to start transmitting before the
1401 whole packet has been completely uploaded. */ 1478 * whole packet has been completely uploaded.
1479 */
1402 1480
1403 spin_lock_irqsave(&lp->lock, flags); 1481 spin_lock_irqsave(&lp->lock, flags);
1404 netif_stop_queue(dev); 1482 netif_stop_queue(dev);
@@ -1414,11 +1492,12 @@ static netdev_tx_t net_send_packet(struct sk_buff *skb, struct net_device *dev)
1414 */ 1492 */
1415 1493
1416 spin_unlock_irqrestore(&lp->lock, flags); 1494 spin_unlock_irqrestore(&lp->lock, flags);
1417 if (net_debug) printk("cs89x0: Tx buffer not free!\n"); 1495 if (net_debug)
1496 printk("cs89x0: Tx buffer not free!\n");
1418 return NETDEV_TX_BUSY; 1497 return NETDEV_TX_BUSY;
1419 } 1498 }
1420 /* Write the contents of the packet */ 1499 /* Write the contents of the packet */
1421 writewords(lp, TX_FRAME_PORT, skb->data, (skb->len+1) >> 1); 1500 writewords(lp, TX_FRAME_PORT, skb->data, (skb->len + 1) >> 1);
1422 spin_unlock_irqrestore(&lp->lock, flags); 1501 spin_unlock_irqrestore(&lp->lock, flags);
1423 dev->stats.tx_bytes += skb->len; 1502 dev->stats.tx_bytes += skb->len;
1424 dev_kfree_skb(skb); 1503 dev_kfree_skb(skb);
@@ -1427,10 +1506,10 @@ static netdev_tx_t net_send_packet(struct sk_buff *skb, struct net_device *dev)
1427 * We also DO NOT call netif_start_queue(). 1506 * We also DO NOT call netif_start_queue().
1428 * 1507 *
1429 * Either of these would cause another bottom half run through 1508 * Either of these would cause another bottom half run through
1430 * net_send_packet() before this packet has fully gone out. That causes 1509 * net_send_packet() before this packet has fully gone out.
1431 * us to hit the "Gasp!" above and the send is rescheduled. it runs like 1510 * That causes us to hit the "Gasp!" above and the send is rescheduled.
1432 * a dog. We just return and wait for the Tx completion interrupt handler 1511 * it runs like a dog. We just return and wait for the Tx completion
1433 * to restart the netdevice layer 1512 * interrupt handler to restart the netdevice layer
1434 */ 1513 */
1435 1514
1436 return NETDEV_TX_OK; 1515 return NETDEV_TX_OK;
@@ -1458,7 +1537,8 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
1458 * vista, baby! 1537 * vista, baby!
1459 */ 1538 */
1460 while ((status = ioread16(lp->virt_addr + ISQ_PORT))) { 1539 while ((status = ioread16(lp->virt_addr + ISQ_PORT))) {
1461 if (net_debug > 4)printk("%s: event=%04x\n", dev->name, status); 1540 if (net_debug > 4)
1541 printk("%s: event=%04x\n", dev->name, status);
1462 handled = 1; 1542 handled = 1;
1463 switch (status & ISQ_EVENT_MASK) { 1543 switch (status & ISQ_EVENT_MASK) {
1464 case ISQ_RECEIVER_EVENT: 1544 case ISQ_RECEIVER_EVENT:
@@ -1496,10 +1576,14 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
1496 netif_wake_queue(dev); /* Inform upper layers. */ 1576 netif_wake_queue(dev); /* Inform upper layers. */
1497 } 1577 }
1498 if (status & TX_UNDERRUN) { 1578 if (status & TX_UNDERRUN) {
1499 if (net_debug > 0) printk("%s: transmit underrun\n", dev->name); 1579 if (net_debug > 0)
1580 printk("%s: transmit underrun\n",
1581 dev->name);
1500 lp->send_underrun++; 1582 lp->send_underrun++;
1501 if (lp->send_underrun == 3) lp->send_cmd = TX_AFTER_381; 1583 if (lp->send_underrun == 3)
1502 else if (lp->send_underrun == 6) lp->send_cmd = TX_AFTER_ALL; 1584 lp->send_cmd = TX_AFTER_381;
1585 else if (lp->send_underrun == 6)
1586 lp->send_cmd = TX_AFTER_ALL;
1503 /* transmit cycle is done, although 1587 /* transmit cycle is done, although
1504 * frame wasn't transmitted - this 1588 * frame wasn't transmitted - this
1505 * avoids having to wait for the upper 1589 * avoids having to wait for the upper
@@ -1513,14 +1597,17 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
1513 int count = readreg(dev, PP_DmaFrameCnt); 1597 int count = readreg(dev, PP_DmaFrameCnt);
1514 while (count) { 1598 while (count) {
1515 if (net_debug > 5) 1599 if (net_debug > 5)
1516 printk("%s: receiving %d DMA frames\n", dev->name, count); 1600 printk("%s: receiving %d DMA frames\n",
1601 dev->name, count);
1517 if (net_debug > 2 && count > 1) 1602 if (net_debug > 2 && count > 1)
1518 printk("%s: receiving %d DMA frames\n", dev->name, count); 1603 printk("%s: receiving %d DMA frames\n",
1604 dev->name, count);
1519 dma_rx(dev); 1605 dma_rx(dev);
1520 if (--count == 0) 1606 if (--count == 0)
1521 count = readreg(dev, PP_DmaFrameCnt); 1607 count = readreg(dev, PP_DmaFrameCnt);
1522 if (net_debug > 2 && count > 0) 1608 if (net_debug > 2 && count > 0)
1523 printk("%s: continuing with %d DMA frames\n", dev->name, count); 1609 printk("%s: continuing with %d DMA frames\n",
1610 dev->name, count);
1524 } 1611 }
1525 } 1612 }
1526#endif 1613#endif
@@ -1544,7 +1631,7 @@ count_rx_errors(int status, struct net_device *dev)
1544 dev->stats.rx_length_errors++; 1631 dev->stats.rx_length_errors++;
1545 if (status & RX_EXTRA_DATA) 1632 if (status & RX_EXTRA_DATA)
1546 dev->stats.rx_length_errors++; 1633 dev->stats.rx_length_errors++;
1547 if ((status & RX_CRC_ERROR) && !(status & (RX_EXTRA_DATA|RX_RUNT))) 1634 if ((status & RX_CRC_ERROR) && !(status & (RX_EXTRA_DATA | RX_RUNT)))
1548 /* per str 172 */ 1635 /* per str 172 */
1549 dev->stats.rx_crc_errors++; 1636 dev->stats.rx_crc_errors++;
1550 if (status & RX_DRIBBLE) 1637 if (status & RX_DRIBBLE)
@@ -1585,7 +1672,8 @@ net_rx(struct net_device *dev)
1585 if (net_debug > 3) { 1672 if (net_debug > 3) {
1586 printk("%s: received %d byte packet of type %x\n", 1673 printk("%s: received %d byte packet of type %x\n",
1587 dev->name, length, 1674 dev->name, length,
1588 (skb->data[ETH_ALEN + ETH_ALEN] << 8) | skb->data[ETH_ALEN + ETH_ALEN + 1]); 1675 (skb->data[ETH_ALEN + ETH_ALEN] << 8) |
1676 skb->data[ETH_ALEN + ETH_ALEN + 1]);
1589 } 1677 }
1590 1678
1591 skb->protocol = eth_type_trans(skb, dev); 1679 skb->protocol = eth_type_trans(skb, dev);
@@ -1598,7 +1686,8 @@ net_rx(struct net_device *dev)
1598static void release_dma_buff(struct net_local *lp) 1686static void release_dma_buff(struct net_local *lp)
1599{ 1687{
1600 if (lp->dma_buff) { 1688 if (lp->dma_buff) {
1601 free_pages((unsigned long)(lp->dma_buff), get_order(lp->dmasize * 1024)); 1689 free_pages((unsigned long)(lp->dma_buff),
1690 get_order(lp->dmasize * 1024));
1602 lp->dma_buff = NULL; 1691 lp->dma_buff = NULL;
1603 } 1692 }
1604} 1693}
@@ -1656,28 +1745,29 @@ static void set_multicast_list(struct net_device *dev)
1656 unsigned long flags; 1745 unsigned long flags;
1657 1746
1658 spin_lock_irqsave(&lp->lock, flags); 1747 spin_lock_irqsave(&lp->lock, flags);
1659 if (dev->flags&IFF_PROMISC) 1748 if (dev->flags & IFF_PROMISC)
1660 {
1661 lp->rx_mode = RX_ALL_ACCEPT; 1749 lp->rx_mode = RX_ALL_ACCEPT;
1662 }
1663 else if ((dev->flags & IFF_ALLMULTI) || !netdev_mc_empty(dev)) 1750 else if ((dev->flags & IFF_ALLMULTI) || !netdev_mc_empty(dev))
1664 { 1751 /* The multicast-accept list is initialized to accept-all,
1665 /* The multicast-accept list is initialized to accept-all, and we 1752 * and we rely on higher-level filtering for now.
1666 rely on higher-level filtering for now. */ 1753 */
1667 lp->rx_mode = RX_MULTCAST_ACCEPT; 1754 lp->rx_mode = RX_MULTCAST_ACCEPT;
1668 }
1669 else 1755 else
1670 lp->rx_mode = 0; 1756 lp->rx_mode = 0;
1671 1757
1672 writereg(dev, PP_RxCTL, DEF_RX_ACCEPT | lp->rx_mode); 1758 writereg(dev, PP_RxCTL, DEF_RX_ACCEPT | lp->rx_mode);
1673 1759
1674 /* in promiscuous mode, we accept errored packets, so we have to enable interrupts on them also */ 1760 /* in promiscuous mode, we accept errored packets,
1675 writereg(dev, PP_RxCFG, lp->curr_rx_cfg | 1761 * so we have to enable interrupts on them also
1676 (lp->rx_mode == RX_ALL_ACCEPT ? (RX_CRC_ERROR_ENBL|RX_RUNT_ENBL|RX_EXTRA_DATA_ENBL) : 0)); 1762 */
1763 writereg(dev, PP_RxCFG,
1764 (lp->curr_rx_cfg |
1765 (lp->rx_mode == RX_ALL_ACCEPT)
1766 ? (RX_CRC_ERROR_ENBL | RX_RUNT_ENBL | RX_EXTRA_DATA_ENBL)
1767 : 0));
1677 spin_unlock_irqrestore(&lp->lock, flags); 1768 spin_unlock_irqrestore(&lp->lock, flags);
1678} 1769}
1679 1770
1680
1681static int set_mac_address(struct net_device *dev, void *p) 1771static int set_mac_address(struct net_device *dev, void *p)
1682{ 1772{
1683 int i; 1773 int i;
@@ -1689,12 +1779,14 @@ static int set_mac_address(struct net_device *dev, void *p)
1689 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); 1779 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
1690 1780
1691 if (net_debug) 1781 if (net_debug)
1692 printk("%s: Setting MAC address to %pM.\n", 1782 printk("%s: Setting MAC address to %pM\n",
1693 dev->name, dev->dev_addr); 1783 dev->name, dev->dev_addr);
1694 1784
1695 /* set the Ethernet address */ 1785 /* set the Ethernet address */
1696 for (i = 0; i < ETH_ALEN / 2; i++) 1786 for (i = 0; i < ETH_ALEN / 2; i++)
1697 writereg(dev, PP_IA + i * 2, dev->dev_addr[i * 2] | (dev->dev_addr[i * 2 + 1] << 8)); 1787 writereg(dev, PP_IA + i * 2,
1788 (dev->dev_addr[i * 2] |
1789 (dev->dev_addr[i * 2 + 1] << 8)));
1698 1790
1699 return 0; 1791 return 0;
1700} 1792}
@@ -1871,28 +1963,28 @@ static int __init cs89x0_platform_probe(struct platform_device *pdev)
1871 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1963 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1872 dev->irq = platform_get_irq(pdev, 0); 1964 dev->irq = platform_get_irq(pdev, 0);
1873 if (mem_res == NULL || dev->irq <= 0) { 1965 if (mem_res == NULL || dev->irq <= 0) {
1874 dev_warn(&dev->dev, "memory/interrupt resource missing.\n"); 1966 dev_warn(&dev->dev, "memory/interrupt resource missing\n");
1875 err = -ENXIO; 1967 err = -ENXIO;
1876 goto free; 1968 goto free;
1877 } 1969 }
1878 1970
1879 lp->size = resource_size(mem_res); 1971 lp->size = resource_size(mem_res);
1880 if (!request_mem_region(mem_res->start, lp->size, DRV_NAME)) { 1972 if (!request_mem_region(mem_res->start, lp->size, DRV_NAME)) {
1881 dev_warn(&dev->dev, "request_mem_region() failed.\n"); 1973 dev_warn(&dev->dev, "request_mem_region() failed\n");
1882 err = -EBUSY; 1974 err = -EBUSY;
1883 goto free; 1975 goto free;
1884 } 1976 }
1885 1977
1886 virt_addr = ioremap(mem_res->start, lp->size); 1978 virt_addr = ioremap(mem_res->start, lp->size);
1887 if (!virt_addr) { 1979 if (!virt_addr) {
1888 dev_warn(&dev->dev, "ioremap() failed.\n"); 1980 dev_warn(&dev->dev, "ioremap() failed\n");
1889 err = -ENOMEM; 1981 err = -ENOMEM;
1890 goto release; 1982 goto release;
1891 } 1983 }
1892 1984
1893 err = cs89x0_probe1(dev, virt_addr, 0); 1985 err = cs89x0_probe1(dev, virt_addr, 0);
1894 if (err) { 1986 if (err) {
1895 dev_warn(&dev->dev, "no cs8900 or cs8920 detected.\n"); 1987 dev_warn(&dev->dev, "no cs8900 or cs8920 detected\n");
1896 goto unmap; 1988 goto unmap;
1897 } 1989 }
1898 1990