summaryrefslogtreecommitdiff
path: root/drivers/net/can/sja1000/sja1000_platform.c
diff options
context:
space:
mode:
authorWolfgang Grandegger <wg@grandegger.com>2009-05-30 07:55:49 +0000
committerDavid S. Miller <davem@davemloft.net>2009-06-01 02:53:34 -0700
commit255a9154319d3cf475d527458037758935f6445b (patch)
tree317fd2edb63cfa222000cbfa4c4bed6da15c5420 /drivers/net/can/sja1000/sja1000_platform.c
parent128ced8f9d59bb3e36fbb4df87bd9d881f0a4463 (diff)
can: sja1000: stop misusing member base_addr of struct net_device
As discussed on the netdev mailing list, the member "base_addr" of "struct net_device" should not be (mis)used to store the virtual address to the SJA1000 register area. According to David Miller, it's only use is to allow ISA and similar primitive bus devices to have their I/O ports changed via ifconfig. The virtual address is now stored in the private data structure of the SJA1000 device and the callback functions use "struct sja1000_priv" instead of the unneeded "struct net_device". Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/can/sja1000/sja1000_platform.c')
-rw-r--r--drivers/net/can/sja1000/sja1000_platform.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
index 8017229d6fd6..628374c2a05f 100644
--- a/drivers/net/can/sja1000/sja1000_platform.c
+++ b/drivers/net/can/sja1000/sja1000_platform.c
@@ -37,14 +37,14 @@ MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus");
MODULE_LICENSE("GPL v2");
-static u8 sp_read_reg(const struct net_device *dev, int reg)
+static u8 sp_read_reg(const struct sja1000_priv *priv, int reg)
{
- return ioread8((void __iomem *)(dev->base_addr + reg));
+ return ioread8(priv->reg_base + reg);
}
-static void sp_write_reg(const struct net_device *dev, int reg, u8 val)
+static void sp_write_reg(const struct sja1000_priv *priv, int reg, u8 val)
{
- iowrite8(val, (void __iomem *)(dev->base_addr + reg));
+ iowrite8(val, priv->reg_base + reg);
}
static int sp_probe(struct platform_device *pdev)
@@ -89,9 +89,9 @@ static int sp_probe(struct platform_device *pdev)
}
priv = netdev_priv(dev);
- dev->base_addr = (unsigned long)addr;
dev->irq = res_irq->start;
priv->irq_flags = res_irq->flags & IRQF_TRIGGER_MASK;
+ priv->reg_base = addr;
priv->read_reg = sp_read_reg;
priv->write_reg = sp_write_reg;
priv->can.clock.freq = pdata->clock;
@@ -108,8 +108,8 @@ static int sp_probe(struct platform_device *pdev)
goto exit_free;
}
- dev_info(&pdev->dev, "%s device registered (base_addr=%#lx, irq=%d)\n",
- DRV_NAME, dev->base_addr, dev->irq);
+ dev_info(&pdev->dev, "%s device registered (reg_base=%p, irq=%d)\n",
+ DRV_NAME, priv->reg_base, dev->irq);
return 0;
exit_free:
@@ -125,13 +125,14 @@ static int sp_probe(struct platform_device *pdev)
static int sp_remove(struct platform_device *pdev)
{
struct net_device *dev = dev_get_drvdata(&pdev->dev);
+ struct sja1000_priv *priv = netdev_priv(dev);
struct resource *res;
unregister_sja1000dev(dev);
dev_set_drvdata(&pdev->dev, NULL);
- if (dev->base_addr)
- iounmap((void __iomem *)dev->base_addr);
+ if (priv->reg_base)
+ iounmap(priv->reg_base);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, resource_size(res));