Subject: [PATCH] smc911x

From: Pierre TARDY <[email-masked]>
Date: Tue, 19 Dec 2006 18:02:57 +0100

Attached a patch on smc911x driver, which corrects obvious errors in the 
16bit chips support of this driver.

Please note that this driver still do NOT support 16bit chips (9115 and 
9117), as it claims to, there may be mistakes in the data fifo 
managment, this patch enable the driver to init the chip, but the data 
is then corrupted.

I managed to make my chip work with the driver smsc911x (out of the 
box), from smsc, which has been refused to be included in the kernel tree.
http://thread.gmane.org/gmane.linux.network.general/10498/focus=40384

I think it my be a good idea to reconsider this choice
- smsc911x has more chance to be supported as it has originally been 
made by the manufacturer of the chip.
- smc911x is mono chip (do not work with 9117 at least), mono arch and 
mono plateform (restricted to PXA), while smsc911x has been tested on 
various chips by smsc

The only thing that is missing in smsc911x is dma support, which is very 
architecture dependant ( There is one way to do dma with the pxa, 
another on the freescale mxc plateforms, another on the x86..)

-- 
Pierre Tardy

--- linux-2.6.18.1.orig/drivers/net/smc911x.h	2006-10-14 05:34:03.000000000 +0200
+++ linux-2.6.18.1/drivers/net/smc911x.h	2006-12-19 11:22:39.000000000 +0100
@@ -46,13 +46,13 @@
 #if	SMC_USE_16BIT
 #define SMC_inb(a, r)			 readb((a) + (r))
 #define SMC_inw(a, r)			 readw((a) + (r))
-#define SMC_inl(a, r)			 ((SMC_inw(a, r) & 0xFFFF)+(SMC_inw(a+2, r)<<16))
+#define SMC_inl(a, r)			 ((SMC_inw(a, r) & 0xFFFF)|(SMC_inw(a+2, r)<<16))
 #define SMC_outb(v, a, r)		 writeb(v, (a) + (r))
 #define SMC_outw(v, a, r)		 writew(v, (a) + (r))
 #define SMC_outl(v, a, r) 			 \
 	do{					 \
-		 writel(v & 0xFFFF, (a) + (r));	 \
-		 writel(v >> 16, (a) + (r) + 2); \
+		 writew((v) & 0xFFFF, (a) + (r));	 \
+		 writew((v) >> 16, (a) + (r) + 2); \
 	 } while (0)
 #define SMC_insl(a, r, p, l)	 readsw((short*)((a) + (r)), p, l*2)
 #define SMC_outsl(a, r, p, l)	 writesw((short*)((a) + (r)), p, l*2)