Commit 9b717075 authored by Francois Romieu's avatar Francois Romieu

ipw2100: stop using net_device.base_addr.

No net_device.irq removal yet. The driver probe, remove and failure
paths need some care beforehand.
Signed-off-by: default avatarFrancois Romieu <romieu@fr.zoreil.com>
Cc: Stanislav Yakovlev <stas.yakovlev@gmail.com>
parent a3442794
...@@ -343,38 +343,50 @@ static struct iw_handler_def ipw2100_wx_handler_def; ...@@ -343,38 +343,50 @@ static struct iw_handler_def ipw2100_wx_handler_def;
static inline void read_register(struct net_device *dev, u32 reg, u32 * val) static inline void read_register(struct net_device *dev, u32 reg, u32 * val)
{ {
*val = readl((void __iomem *)(dev->base_addr + reg)); struct ipw2100_priv *priv = libipw_priv(dev);
*val = ioread32(priv->ioaddr + reg);
IPW_DEBUG_IO("r: 0x%08X => 0x%08X\n", reg, *val); IPW_DEBUG_IO("r: 0x%08X => 0x%08X\n", reg, *val);
} }
static inline void write_register(struct net_device *dev, u32 reg, u32 val) static inline void write_register(struct net_device *dev, u32 reg, u32 val)
{ {
writel(val, (void __iomem *)(dev->base_addr + reg)); struct ipw2100_priv *priv = libipw_priv(dev);
iowrite32(val, priv->ioaddr + reg);
IPW_DEBUG_IO("w: 0x%08X <= 0x%08X\n", reg, val); IPW_DEBUG_IO("w: 0x%08X <= 0x%08X\n", reg, val);
} }
static inline void read_register_word(struct net_device *dev, u32 reg, static inline void read_register_word(struct net_device *dev, u32 reg,
u16 * val) u16 * val)
{ {
*val = readw((void __iomem *)(dev->base_addr + reg)); struct ipw2100_priv *priv = libipw_priv(dev);
*val = ioread16(priv->ioaddr + reg);
IPW_DEBUG_IO("r: 0x%08X => %04X\n", reg, *val); IPW_DEBUG_IO("r: 0x%08X => %04X\n", reg, *val);
} }
static inline void read_register_byte(struct net_device *dev, u32 reg, u8 * val) static inline void read_register_byte(struct net_device *dev, u32 reg, u8 * val)
{ {
*val = readb((void __iomem *)(dev->base_addr + reg)); struct ipw2100_priv *priv = libipw_priv(dev);
*val = ioread8(priv->ioaddr + reg);
IPW_DEBUG_IO("r: 0x%08X => %02X\n", reg, *val); IPW_DEBUG_IO("r: 0x%08X => %02X\n", reg, *val);
} }
static inline void write_register_word(struct net_device *dev, u32 reg, u16 val) static inline void write_register_word(struct net_device *dev, u32 reg, u16 val)
{ {
writew(val, (void __iomem *)(dev->base_addr + reg)); struct ipw2100_priv *priv = libipw_priv(dev);
iowrite16(val, priv->ioaddr + reg);
IPW_DEBUG_IO("w: 0x%08X <= %04X\n", reg, val); IPW_DEBUG_IO("w: 0x%08X <= %04X\n", reg, val);
} }
static inline void write_register_byte(struct net_device *dev, u32 reg, u8 val) static inline void write_register_byte(struct net_device *dev, u32 reg, u8 val)
{ {
writeb(val, (void __iomem *)(dev->base_addr + reg)); struct ipw2100_priv *priv = libipw_priv(dev);
iowrite8(val, priv->ioaddr + reg);
IPW_DEBUG_IO("w: 0x%08X =< %02X\n", reg, val); IPW_DEBUG_IO("w: 0x%08X =< %02X\n", reg, val);
} }
...@@ -506,13 +518,13 @@ static void read_nic_memory(struct net_device *dev, u32 addr, u32 len, ...@@ -506,13 +518,13 @@ static void read_nic_memory(struct net_device *dev, u32 addr, u32 len,
read_register_byte(dev, IPW_REG_INDIRECT_ACCESS_DATA + i, buf); read_register_byte(dev, IPW_REG_INDIRECT_ACCESS_DATA + i, buf);
} }
static inline int ipw2100_hw_is_adapter_in_system(struct net_device *dev) static bool ipw2100_hw_is_adapter_in_system(struct net_device *dev)
{ {
return (dev->base_addr && u32 dbg;
(readl
((void __iomem *)(dev->base_addr + read_register(dev, IPW_REG_DOA_DEBUG_AREA_START, &dbg);
IPW_REG_DOA_DEBUG_AREA_START))
== IPW_DATA_DOA_DEBUG_VALUE)); return dbg == IPW_DATA_DOA_DEBUG_VALUE;
} }
static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord, static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord,
...@@ -6082,9 +6094,7 @@ static const struct net_device_ops ipw2100_netdev_ops = { ...@@ -6082,9 +6094,7 @@ static const struct net_device_ops ipw2100_netdev_ops = {
/* Look into using netdev destructor to shutdown libipw? */ /* Look into using netdev destructor to shutdown libipw? */
static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev, static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
void __iomem * base_addr, void __iomem * ioaddr)
unsigned long mem_start,
unsigned long mem_len)
{ {
struct ipw2100_priv *priv; struct ipw2100_priv *priv;
struct net_device *dev; struct net_device *dev;
...@@ -6096,6 +6106,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev, ...@@ -6096,6 +6106,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
priv->ieee = netdev_priv(dev); priv->ieee = netdev_priv(dev);
priv->pci_dev = pci_dev; priv->pci_dev = pci_dev;
priv->net_dev = dev; priv->net_dev = dev;
priv->ioaddr = ioaddr;
priv->ieee->hard_start_xmit = ipw2100_tx; priv->ieee->hard_start_xmit = ipw2100_tx;
priv->ieee->set_security = shim__set_security; priv->ieee->set_security = shim__set_security;
...@@ -6111,10 +6122,6 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev, ...@@ -6111,10 +6122,6 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
dev->watchdog_timeo = 3 * HZ; dev->watchdog_timeo = 3 * HZ;
dev->irq = 0; dev->irq = 0;
dev->base_addr = (unsigned long)base_addr;
dev->mem_start = mem_start;
dev->mem_end = dev->mem_start + mem_len - 1;
/* NOTE: We don't use the wireless_handlers hook /* NOTE: We don't use the wireless_handlers hook
* in dev as the system will start throwing WX requests * in dev as the system will start throwing WX requests
* to us before we're actually initialized and it just * to us before we're actually initialized and it just
...@@ -6215,8 +6222,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev, ...@@ -6215,8 +6222,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
static int ipw2100_pci_init_one(struct pci_dev *pci_dev, static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
unsigned long mem_start, mem_len, mem_flags; void __iomem *ioaddr;
void __iomem *base_addr = NULL;
struct net_device *dev = NULL; struct net_device *dev = NULL;
struct ipw2100_priv *priv = NULL; struct ipw2100_priv *priv = NULL;
int err = 0; int err = 0;
...@@ -6225,18 +6231,14 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, ...@@ -6225,18 +6231,14 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
IPW_DEBUG_INFO("enter\n"); IPW_DEBUG_INFO("enter\n");
mem_start = pci_resource_start(pci_dev, 0); if (!(pci_resource_flags(pci_dev, 0) & IORESOURCE_MEM)) {
mem_len = pci_resource_len(pci_dev, 0);
mem_flags = pci_resource_flags(pci_dev, 0);
if ((mem_flags & IORESOURCE_MEM) != IORESOURCE_MEM) {
IPW_DEBUG_INFO("weird - resource type is not memory\n"); IPW_DEBUG_INFO("weird - resource type is not memory\n");
err = -ENODEV; err = -ENODEV;
goto fail; goto out;
} }
base_addr = ioremap_nocache(mem_start, mem_len); ioaddr = pci_iomap(pci_dev, 0, 0);
if (!base_addr) { if (!ioaddr) {
printk(KERN_WARNING DRV_NAME printk(KERN_WARNING DRV_NAME
"Error calling ioremap_nocache.\n"); "Error calling ioremap_nocache.\n");
err = -EIO; err = -EIO;
...@@ -6244,7 +6246,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, ...@@ -6244,7 +6246,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
} }
/* allocate and initialize our net_device */ /* allocate and initialize our net_device */
dev = ipw2100_alloc_device(pci_dev, base_addr, mem_start, mem_len); dev = ipw2100_alloc_device(pci_dev, ioaddr);
if (!dev) { if (!dev) {
printk(KERN_WARNING DRV_NAME printk(KERN_WARNING DRV_NAME
"Error calling ipw2100_alloc_device.\n"); "Error calling ipw2100_alloc_device.\n");
...@@ -6379,8 +6381,8 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, ...@@ -6379,8 +6381,8 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
priv->status |= STATUS_INITIALIZED; priv->status |= STATUS_INITIALIZED;
mutex_unlock(&priv->action_mutex); mutex_unlock(&priv->action_mutex);
out:
return 0; return err;
fail_unlock: fail_unlock:
mutex_unlock(&priv->action_mutex); mutex_unlock(&priv->action_mutex);
...@@ -6409,13 +6411,11 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, ...@@ -6409,13 +6411,11 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
pci_set_drvdata(pci_dev, NULL); pci_set_drvdata(pci_dev, NULL);
} }
if (base_addr) pci_iounmap(pci_dev, ioaddr);
iounmap(base_addr);
pci_release_regions(pci_dev); pci_release_regions(pci_dev);
pci_disable_device(pci_dev); pci_disable_device(pci_dev);
goto out;
return err;
} }
static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev) static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev)
...@@ -6458,8 +6458,7 @@ static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev) ...@@ -6458,8 +6458,7 @@ static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev)
if (dev->irq) if (dev->irq)
free_irq(dev->irq, priv); free_irq(dev->irq, priv);
if (dev->base_addr) pci_iounmap(pci_dev, priv->ioaddr);
iounmap((void __iomem *)dev->base_addr);
/* wiphy_unregister needs to be here, before free_libipw */ /* wiphy_unregister needs to be here, before free_libipw */
wiphy_unregister(priv->ieee->wdev.wiphy); wiphy_unregister(priv->ieee->wdev.wiphy);
...@@ -8609,7 +8608,7 @@ static int ipw2100_ucode_download(struct ipw2100_priv *priv, ...@@ -8609,7 +8608,7 @@ static int ipw2100_ucode_download(struct ipw2100_priv *priv,
struct net_device *dev = priv->net_dev; struct net_device *dev = priv->net_dev;
const unsigned char *microcode_data = fw->uc.data; const unsigned char *microcode_data = fw->uc.data;
unsigned int microcode_data_left = fw->uc.size; unsigned int microcode_data_left = fw->uc.size;
void __iomem *reg = (void __iomem *)dev->base_addr; void __iomem *reg = priv->ioaddr;
struct symbol_alive_response response; struct symbol_alive_response response;
int i, j; int i, j;
......
...@@ -488,6 +488,7 @@ enum { ...@@ -488,6 +488,7 @@ enum {
#define CAP_PRIVACY_ON (1<<1) /* Off = No privacy */ #define CAP_PRIVACY_ON (1<<1) /* Off = No privacy */
struct ipw2100_priv { struct ipw2100_priv {
void __iomem *ioaddr;
int stop_hang_check; /* Set 1 when shutting down to kill hang_check */ int stop_hang_check; /* Set 1 when shutting down to kill hang_check */
int stop_rf_kill; /* Set 1 when shutting down to kill rf_kill */ int stop_rf_kill; /* Set 1 when shutting down to kill rf_kill */
......
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