aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/can/sja1000/ems_pci.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/ems_pci.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/ems_pci.c')
-rw-r--r--drivers/net/can/sja1000/ems_pci.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
index 88a4649c2ced..121b64101d72 100644
--- a/drivers/net/can/sja1000/ems_pci.c
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -99,25 +99,21 @@ MODULE_DEVICE_TABLE(pci, ems_pci_tbl);
*/
static u8 ems_pci_readb(struct ems_pci_card *card, unsigned int port)
{
- return readb((void __iomem *)card->base_addr
- + (port * EMS_PCI_PORT_BYTES));
+ return readb(card->base_addr + (port * EMS_PCI_PORT_BYTES));
}
-static u8 ems_pci_read_reg(const struct net_device *dev, int port)
+static u8 ems_pci_read_reg(const struct sja1000_priv *priv, int port)
{
- return readb((void __iomem *)dev->base_addr
- + (port * EMS_PCI_PORT_BYTES));
+ return readb(priv->reg_base + (port * EMS_PCI_PORT_BYTES));
}
-static void ems_pci_write_reg(const struct net_device *dev, int port, u8 val)
+static void ems_pci_write_reg(const struct sja1000_priv *priv, int port, u8 val)
{
- writeb(val, (void __iomem *)dev->base_addr
- + (port * EMS_PCI_PORT_BYTES));
+ writeb(val, priv->reg_base + (port * EMS_PCI_PORT_BYTES));
}
-static void ems_pci_post_irq(const struct net_device *dev)
+static void ems_pci_post_irq(const struct sja1000_priv *priv)
{
- struct sja1000_priv *priv = netdev_priv(dev);
struct ems_pci_card *card = (struct ems_pci_card *)priv->priv;
/* reset int flag of pita */
@@ -129,17 +125,17 @@ static void ems_pci_post_irq(const struct net_device *dev)
* Check if a CAN controller is present at the specified location
* by trying to set 'em into the PeliCAN mode
*/
-static inline int ems_pci_check_chan(struct net_device *dev)
+static inline int ems_pci_check_chan(const struct sja1000_priv *priv)
{
unsigned char res;
/* Make sure SJA1000 is in reset mode */
- ems_pci_write_reg(dev, REG_MOD, 1);
+ ems_pci_write_reg(priv, REG_MOD, 1);
- ems_pci_write_reg(dev, REG_CDR, CDR_PELICAN);
+ ems_pci_write_reg(priv, REG_CDR, CDR_PELICAN);
/* read reset-values */
- res = ems_pci_read_reg(dev, REG_CDR);
+ res = ems_pci_read_reg(priv, REG_CDR);
if (res == CDR_PELICAN)
return 1;
@@ -257,12 +253,11 @@ static int __devinit ems_pci_add_card(struct pci_dev *pdev,
priv->irq_flags = IRQF_SHARED;
dev->irq = pdev->irq;
- dev->base_addr = (unsigned long)(card->base_addr
- + EMS_PCI_CAN_BASE_OFFSET
- + (i * EMS_PCI_CAN_CTRL_SIZE));
+ priv->reg_base = card->base_addr + EMS_PCI_CAN_BASE_OFFSET
+ + (i * EMS_PCI_CAN_CTRL_SIZE);
/* Check if channel is present */
- if (ems_pci_check_chan(dev)) {
+ if (ems_pci_check_chan(priv)) {
priv->read_reg = ems_pci_read_reg;
priv->write_reg = ems_pci_write_reg;
priv->post_irq = ems_pci_post_irq;
@@ -286,9 +281,8 @@ static int __devinit ems_pci_add_card(struct pci_dev *pdev,
card->channels++;
- dev_info(&pdev->dev, "Channel #%d at %#lX, irq %d\n",
- i + 1, dev->base_addr,
- dev->irq);
+ dev_info(&pdev->dev, "Channel #%d at 0x%p, irq %d\n",
+ i + 1, priv->reg_base, dev->irq);
} else {
free_sja1000dev(dev);
}