Re: [PATCH] smc91x: allow for dynamic bus access configs

2006-03-21 Thread Jeff Garzik

Nicolas Pitre wrote:

All accessor's different methods are now selected with C code and unused
ones statically optimized away at compile time instead of being selected
with #if's and #ifdef's.  This has many advantages such as allowing the
compiler to validate the syntax of the whole code, making it cleaner and
easier to understand, and ultimately allowing people to define
configuration symbols in terms of variables if they really want to
dynamically support multiple bus configurations at the same time (with
the unavoidable performance cost).

Signed-off-by: Nicolas Pitre [EMAIL PROTECTED]


applied


-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html



Re: [PATCH] smc91x: allow for dynamic bus access configs

2006-01-09 Thread Jeff Garzik

Nicolas Pitre wrote:
All accessor's different methods are now selected with C code and unused 
ones statically optimized away at compile time instead of being selected 
with #if's and #ifdef's.  This has many advantages such as allowing the 
compiler to validate the syntax of the whole code, making it cleaner and 
easier to understand, and ultimately allowing people to define 
configuration symbols in terms of variables if they really want to 
dynamically support multiple bus configurations at the same time (with 
the unavoidable performance cost).


Signed-off-by: Nicolas Pitre [EMAIL PROTECTED]


OK, but patch doesn't apply:


Applying 'smc91x: allow for dynamic bus access configs'

error: patch failed: drivers/net/smc91x.h:342
error: drivers/net/smc91x.h: patch does not apply

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] smc91x: allow for dynamic bus access configs

2006-01-09 Thread Nicolas Pitre
On Mon, 9 Jan 2006, Jeff Garzik wrote:

 Nicolas Pitre wrote:
  All accessor's different methods are now selected with C code and unused
  ones statically optimized away at compile time instead of being selected
  with #if's and #ifdef's.  This has many advantages such as allowing the
  compiler to validate the syntax of the whole code, making it cleaner and
  easier to understand, and ultimately allowing people to define configuration
  symbols in terms of variables if they really want to dynamically support
  multiple bus configurations at the same time (with the unavoidable
  performance cost).
  
  Signed-off-by: Nicolas Pitre [EMAIL PROTECTED]
 
 OK, but patch doesn't apply:
 
 
 Applying 'smc91x: allow for dynamic bus access configs'
 
 error: patch failed: drivers/net/smc91x.h:342
 error: drivers/net/smc91x.h: patch does not apply

Gah...  Resynched patch follows.


Nicolas
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] smc91x: allow for dynamic bus access configs

2006-01-09 Thread Nicolas Pitre
All accessor's different methods are now selected with C code and unused 
ones statically optimized away at compile time instead of being selected 
with #if's and #ifdef's.  This has many advantages such as allowing the 
compiler to validate the syntax of the whole code, making it cleaner and 
easier to understand, and ultimately allowing people to define 
configuration symbols in terms of variables if they really want to 
dynamically support multiple bus configurations at the same time (with 
the unavoidable performance cost).

Signed-off-by: Nicolas Pitre [EMAIL PROTECTED]

---

Index: linux-2.6/drivers/net/smc91x.c
===
--- linux-2.6.orig/drivers/net/smc91x.c
+++ linux-2.6/drivers/net/smc91x.c
@@ -215,15 +215,12 @@ struct smc_local {
 
spinlock_t lock;
 
-#ifdef SMC_CAN_USE_DATACS
-   u32 __iomem *datacs;
-#endif
-
 #ifdef SMC_USE_PXA_DMA
/* DMA needs the physical address of the chip */
u_long physaddr;
 #endif
void __iomem *base;
+   void __iomem *datacs;
 };
 
 #if SMC_DEBUG  0
@@ -2104,9 +2101,8 @@ static int smc_enable_device(struct plat
 * Set the appropriate byte/word mode.
 */
ecsr = readb(addr + (ECSR  SMC_IO_SHIFT))  ~ECSR_IOIS8;
-#ifndef SMC_CAN_USE_16BIT
-   ecsr |= ECSR_IOIS8;
-#endif
+   if (SMC_CAN_USE_16BIT)
+   ecsr |= ECSR_IOIS8;
writeb(ecsr, addr + (ECSR  SMC_IO_SHIFT));
local_irq_restore(flags);
 
@@ -2143,40 +2139,39 @@ static void smc_release_attrib(struct pl
release_mem_region(res-start, ATTRIB_SIZE);
 }
 
-#ifdef SMC_CAN_USE_DATACS
-static void smc_request_datacs(struct platform_device *pdev, struct net_device 
*ndev)
+static inline void smc_request_datacs(struct platform_device *pdev, struct 
net_device *ndev)
 {
-   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
-   struct smc_local *lp = netdev_priv(ndev);
+   if (SMC_CAN_USE_DATACS) {
+   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
+   struct smc_local *lp = netdev_priv(ndev);
 
-   if (!res)
-   return;
+   if (!res)
+   return;
 
-   if(!request_mem_region(res-start, SMC_DATA_EXTENT, CARDNAME)) {
-   printk(KERN_INFO %s: failed to request datacs memory 
region.\n, CARDNAME);
-   return;
-   }
+   if(!request_mem_region(res-start, SMC_DATA_EXTENT, CARDNAME)) {
+   printk(KERN_INFO %s: failed to request datacs memory 
region.\n, CARDNAME);
+   return;
+   }
 
-   lp-datacs = ioremap(res-start, SMC_DATA_EXTENT);
+   lp-datacs = ioremap(res-start, SMC_DATA_EXTENT);
+   }
 }
 
 static void smc_release_datacs(struct platform_device *pdev, struct net_device 
*ndev)
 {
-   struct smc_local *lp = netdev_priv(ndev);
-   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
+   if (SMC_CAN_USE_DATACS) {
+   struct smc_local *lp = netdev_priv(ndev);
+   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
 
-   if (lp-datacs)
-   iounmap(lp-datacs);
+   if (lp-datacs)
+   iounmap(lp-datacs);
 
-   lp-datacs = NULL;
+   lp-datacs = NULL;
 
-   if (res)
-   release_mem_region(res-start, SMC_DATA_EXTENT);
+   if (res)
+   release_mem_region(res-start, SMC_DATA_EXTENT);
+   }
 }
-#else
-static void smc_request_datacs(struct platform_device *pdev, struct net_device 
*ndev) {}
-static void smc_release_datacs(struct platform_device *pdev, struct net_device 
*ndev) {}
-#endif
 
 /*
  * smc_init(void)
Index: linux-2.6/drivers/net/smc91x.h
===
--- linux-2.6.orig/drivers/net/smc91x.h
+++ linux-2.6/drivers/net/smc91x.h
@@ -275,7 +275,10 @@ SMC_outw(u16 val, void __iomem *ioaddr, 
 #define SMC_insw(a,r,p,l)  readsw ((void*) ((a) + (r)), p, l)
 #define SMC_outw(v,a,r) ({ writew ((v), (a) + (r)); 
LPD7A40X_IOBARRIER; })
 
-static inline void SMC_outsw (unsigned long a, int r, unsigned char* p, int l)
+#define SMC_outsw  LPD7A40X_SMC_outsw
+
+static inline void LPD7A40X_SMC_outsw(unsigned long a, int r,
+unsigned char* p, int l)
 {
unsigned short* ps = (unsigned short*) p;
while (l--  0) {
@@ -342,10 +345,6 @@ static inline void SMC_outsw (unsigned l
 
 #endif
 
-#ifndefSMC_IRQ_FLAGS
-#defineSMC_IRQ_FLAGS   SA_TRIGGER_RISING
-#endif
-
 #ifdef SMC_USE_PXA_DMA
 /*
  * Let's use the DMA engine on the XScale PXA2xx for RX packets. This is
@@ -441,10 +440,85 @@ smc_pxa_dma_irq(int dma, void *dummy, 

[PATCH] smc91x: allow for dynamic bus access configs

2006-01-08 Thread Nicolas Pitre
All accessor's different methods are now selected with C code and unused 
ones statically optimized away at compile time instead of being selected 
with #if's and #ifdef's.  This has many advantages such as allowing the 
compiler to validate the syntax of the whole code, making it cleaner and 
easier to understand, and ultimately allowing people to define 
configuration symbols in terms of variables if they really want to 
dynamically support multiple bus configurations at the same time (with 
the unavoidable performance cost).

Signed-off-by: Nicolas Pitre [EMAIL PROTECTED]

---

Index: linux-2.6/drivers/net/smc91x.c
===
--- linux-2.6.orig/drivers/net/smc91x.c
+++ linux-2.6/drivers/net/smc91x.c
@@ -216,15 +216,12 @@ struct smc_local {
 
spinlock_t lock;
 
-#ifdef SMC_CAN_USE_DATACS
-   u32 __iomem *datacs;
-#endif
-
 #ifdef SMC_USE_PXA_DMA
/* DMA needs the physical address of the chip */
u_long physaddr;
 #endif
void __iomem *base;
+   void __iomem *datacs;
 };
 
 #if SMC_DEBUG  0
@@ -2107,9 +2104,8 @@ static int smc_enable_device(struct plat
 * Set the appropriate byte/word mode.
 */
ecsr = readb(addr + (ECSR  SMC_IO_SHIFT))  ~ECSR_IOIS8;
-#ifndef SMC_CAN_USE_16BIT
-   ecsr |= ECSR_IOIS8;
-#endif
+   if (SMC_CAN_USE_16BIT)
+   ecsr |= ECSR_IOIS8;
writeb(ecsr, addr + (ECSR  SMC_IO_SHIFT));
local_irq_restore(flags);
 
@@ -2146,40 +2142,39 @@ static void smc_release_attrib(struct pl
release_mem_region(res-start, ATTRIB_SIZE);
 }
 
-#ifdef SMC_CAN_USE_DATACS
-static void smc_request_datacs(struct platform_device *pdev, struct net_device 
*ndev)
+static inline void smc_request_datacs(struct platform_device *pdev, struct 
net_device *ndev)
 {
-   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
-   struct smc_local *lp = netdev_priv(ndev);
+   if (SMC_CAN_USE_DATACS) {
+   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
+   struct smc_local *lp = netdev_priv(ndev);
 
-   if (!res)
-   return;
+   if (!res)
+   return;
 
-   if(!request_mem_region(res-start, SMC_DATA_EXTENT, CARDNAME)) {
-   printk(KERN_INFO %s: failed to request datacs memory 
region.\n, CARDNAME);
-   return;
-   }
+   if(!request_mem_region(res-start, SMC_DATA_EXTENT, CARDNAME)) {
+   printk(KERN_INFO %s: failed to request datacs memory 
region.\n, CARDNAME);
+   return;
+   }
 
-   lp-datacs = ioremap(res-start, SMC_DATA_EXTENT);
+   lp-datacs = ioremap(res-start, SMC_DATA_EXTENT);
+   }
 }
 
 static void smc_release_datacs(struct platform_device *pdev, struct net_device 
*ndev)
 {
-   struct smc_local *lp = netdev_priv(ndev);
-   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
+   if (SMC_CAN_USE_DATACS) {
+   struct smc_local *lp = netdev_priv(ndev);
+   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
 
-   if (lp-datacs)
-   iounmap(lp-datacs);
+   if (lp-datacs)
+   iounmap(lp-datacs);
 
-   lp-datacs = NULL;
+   lp-datacs = NULL;
 
-   if (res)
-   release_mem_region(res-start, SMC_DATA_EXTENT);
+   if (res)
+   release_mem_region(res-start, SMC_DATA_EXTENT);
+   }
 }
-#else
-static void smc_request_datacs(struct platform_device *pdev, struct net_device 
*ndev) {}
-static void smc_release_datacs(struct platform_device *pdev, struct net_device 
*ndev) {}
-#endif
 
 /*
  * smc_init(void)
Index: linux-2.6/drivers/net/smc91x.h
===
--- linux-2.6.orig/drivers/net/smc91x.h
+++ linux-2.6/drivers/net/smc91x.h
@@ -275,7 +275,10 @@ SMC_outw(u16 val, void __iomem *ioaddr, 
 #define SMC_insw(a,r,p,l)  readsw ((void*) ((a) + (r)), p, l)
 #define SMC_outw(v,a,r) ({ writew ((v), (a) + (r)); 
LPD7A40X_IOBARRIER; })
 
-static inline void SMC_outsw (unsigned long a, int r, unsigned char* p, int l)
+#define SMC_outsw  LPD7A40X_SMC_outsw
+
+static inline void LPD7A40X_SMC_outsw(unsigned long a, int r,
+unsigned char* p, int l)
 {
unsigned short* ps = (unsigned short*) p;
while (l--  0) {
@@ -342,10 +345,6 @@ static inline void SMC_outsw (unsigned l
 
 #endif
 
-#ifndefSMC_IRQ_TRIGGER_TYPE
-#defineSMC_IRQ_TRIGGER_TYPEIRQT_RISING
-#endif
-
 #ifdef SMC_USE_PXA_DMA
 /*
  * Let's use the DMA engine on the XScale PXA2xx for RX packets. This is
@@ -441,10 +440,85 @@ smc_pxa_dma_irq(int dma, void *dummy,