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 {
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 platform_device *pdev)
* 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 platform_device *pdev)
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)
......
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