Commit 09779c6d authored by Nicolas Pitre's avatar Nicolas Pitre Committed by Jeff Garzik

[PATCH] smc91x: allow for dynamic bus access configs

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: default avatarNicolas Pitre <nico@cam.org>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent ac62ef04
...@@ -215,15 +215,12 @@ struct smc_local { ...@@ -215,15 +215,12 @@ struct smc_local {
spinlock_t lock; spinlock_t lock;
#ifdef SMC_CAN_USE_DATACS
u32 __iomem *datacs;
#endif
#ifdef SMC_USE_PXA_DMA #ifdef SMC_USE_PXA_DMA
/* DMA needs the physical address of the chip */ /* DMA needs the physical address of the chip */
u_long physaddr; u_long physaddr;
#endif #endif
void __iomem *base; void __iomem *base;
void __iomem *datacs;
}; };
#if SMC_DEBUG > 0 #if SMC_DEBUG > 0
...@@ -2104,9 +2101,8 @@ static int smc_enable_device(struct platform_device *pdev) ...@@ -2104,9 +2101,8 @@ static int smc_enable_device(struct platform_device *pdev)
* Set the appropriate byte/word mode. * Set the appropriate byte/word mode.
*/ */
ecsr = readb(addr + (ECSR << SMC_IO_SHIFT)) & ~ECSR_IOIS8; ecsr = readb(addr + (ECSR << SMC_IO_SHIFT)) & ~ECSR_IOIS8;
#ifndef SMC_CAN_USE_16BIT if (!SMC_CAN_USE_16BIT)
ecsr |= ECSR_IOIS8; ecsr |= ECSR_IOIS8;
#endif
writeb(ecsr, addr + (ECSR << SMC_IO_SHIFT)); writeb(ecsr, addr + (ECSR << SMC_IO_SHIFT));
local_irq_restore(flags); local_irq_restore(flags);
...@@ -2143,9 +2139,9 @@ static void smc_release_attrib(struct platform_device *pdev) ...@@ -2143,9 +2139,9 @@ static void smc_release_attrib(struct platform_device *pdev)
release_mem_region(res->start, ATTRIB_SIZE); release_mem_region(res->start, ATTRIB_SIZE);
} }
#ifdef SMC_CAN_USE_DATACS static inline void smc_request_datacs(struct platform_device *pdev, struct net_device *ndev)
static void smc_request_datacs(struct platform_device *pdev, struct net_device *ndev)
{ {
if (SMC_CAN_USE_DATACS) {
struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-data32"); struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-data32");
struct smc_local *lp = netdev_priv(ndev); struct smc_local *lp = netdev_priv(ndev);
...@@ -2158,10 +2154,12 @@ static void smc_request_datacs(struct platform_device *pdev, struct net_device * ...@@ -2158,10 +2154,12 @@ static void smc_request_datacs(struct platform_device *pdev, struct net_device *
} }
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) static void smc_release_datacs(struct platform_device *pdev, struct net_device *ndev)
{ {
if (SMC_CAN_USE_DATACS) {
struct smc_local *lp = netdev_priv(ndev); struct smc_local *lp = netdev_priv(ndev);
struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-data32"); struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-data32");
...@@ -2172,11 +2170,8 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device * ...@@ -2172,11 +2170,8 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
if (res) if (res)
release_mem_region(res->start, SMC_DATA_EXTENT); 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) * smc_init(void)
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment