diff options
author | Wolfgang Grandegger <wg@grandegger.com> | 2009-05-30 03:55:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-06-01 05:53:34 -0400 |
commit | 255a9154319d3cf475d527458037758935f6445b (patch) | |
tree | 317fd2edb63cfa222000cbfa4c4bed6da15c5420 /drivers/net/can/sja1000/ems_pci.c | |
parent | 128ced8f9d59bb3e36fbb4df87bd9d881f0a4463 (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.c | 36 |
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); | |||
99 | */ | 99 | */ |
100 | static u8 ems_pci_readb(struct ems_pci_card *card, unsigned int port) | 100 | static u8 ems_pci_readb(struct ems_pci_card *card, unsigned int port) |
101 | { | 101 | { |
102 | return readb((void __iomem *)card->base_addr | 102 | return readb(card->base_addr + (port * EMS_PCI_PORT_BYTES)); |
103 | + (port * EMS_PCI_PORT_BYTES)); | ||
104 | } | 103 | } |
105 | 104 | ||
106 | static u8 ems_pci_read_reg(const struct net_device *dev, int port) | 105 | static u8 ems_pci_read_reg(const struct sja1000_priv *priv, int port) |
107 | { | 106 | { |
108 | return readb((void __iomem *)dev->base_addr | 107 | return readb(priv->reg_base + (port * EMS_PCI_PORT_BYTES)); |
109 | + (port * EMS_PCI_PORT_BYTES)); | ||
110 | } | 108 | } |
111 | 109 | ||
112 | static void ems_pci_write_reg(const struct net_device *dev, int port, u8 val) | 110 | static void ems_pci_write_reg(const struct sja1000_priv *priv, int port, u8 val) |
113 | { | 111 | { |
114 | writeb(val, (void __iomem *)dev->base_addr | 112 | writeb(val, priv->reg_base + (port * EMS_PCI_PORT_BYTES)); |
115 | + (port * EMS_PCI_PORT_BYTES)); | ||
116 | } | 113 | } |
117 | 114 | ||
118 | static void ems_pci_post_irq(const struct net_device *dev) | 115 | static void ems_pci_post_irq(const struct sja1000_priv *priv) |
119 | { | 116 | { |
120 | struct sja1000_priv *priv = netdev_priv(dev); | ||
121 | struct ems_pci_card *card = (struct ems_pci_card *)priv->priv; | 117 | struct ems_pci_card *card = (struct ems_pci_card *)priv->priv; |
122 | 118 | ||
123 | /* reset int flag of pita */ | 119 | /* reset int flag of pita */ |
@@ -129,17 +125,17 @@ static void ems_pci_post_irq(const struct net_device *dev) | |||
129 | * Check if a CAN controller is present at the specified location | 125 | * Check if a CAN controller is present at the specified location |
130 | * by trying to set 'em into the PeliCAN mode | 126 | * by trying to set 'em into the PeliCAN mode |
131 | */ | 127 | */ |
132 | static inline int ems_pci_check_chan(struct net_device *dev) | 128 | static inline int ems_pci_check_chan(const struct sja1000_priv *priv) |
133 | { | 129 | { |
134 | unsigned char res; | 130 | unsigned char res; |
135 | 131 | ||
136 | /* Make sure SJA1000 is in reset mode */ | 132 | /* Make sure SJA1000 is in reset mode */ |
137 | ems_pci_write_reg(dev, REG_MOD, 1); | 133 | ems_pci_write_reg(priv, REG_MOD, 1); |
138 | 134 | ||
139 | ems_pci_write_reg(dev, REG_CDR, CDR_PELICAN); | 135 | ems_pci_write_reg(priv, REG_CDR, CDR_PELICAN); |
140 | 136 | ||
141 | /* read reset-values */ | 137 | /* read reset-values */ |
142 | res = ems_pci_read_reg(dev, REG_CDR); | 138 | res = ems_pci_read_reg(priv, REG_CDR); |
143 | 139 | ||
144 | if (res == CDR_PELICAN) | 140 | if (res == CDR_PELICAN) |
145 | return 1; | 141 | return 1; |
@@ -257,12 +253,11 @@ static int __devinit ems_pci_add_card(struct pci_dev *pdev, | |||
257 | priv->irq_flags = IRQF_SHARED; | 253 | priv->irq_flags = IRQF_SHARED; |
258 | 254 | ||
259 | dev->irq = pdev->irq; | 255 | dev->irq = pdev->irq; |
260 | dev->base_addr = (unsigned long)(card->base_addr | 256 | priv->reg_base = card->base_addr + EMS_PCI_CAN_BASE_OFFSET |
261 | + EMS_PCI_CAN_BASE_OFFSET | 257 | + (i * EMS_PCI_CAN_CTRL_SIZE); |
262 | + (i * EMS_PCI_CAN_CTRL_SIZE)); | ||
263 | 258 | ||
264 | /* Check if channel is present */ | 259 | /* Check if channel is present */ |
265 | if (ems_pci_check_chan(dev)) { | 260 | if (ems_pci_check_chan(priv)) { |
266 | priv->read_reg = ems_pci_read_reg; | 261 | priv->read_reg = ems_pci_read_reg; |
267 | priv->write_reg = ems_pci_write_reg; | 262 | priv->write_reg = ems_pci_write_reg; |
268 | priv->post_irq = ems_pci_post_irq; | 263 | priv->post_irq = ems_pci_post_irq; |
@@ -286,9 +281,8 @@ static int __devinit ems_pci_add_card(struct pci_dev *pdev, | |||
286 | 281 | ||
287 | card->channels++; | 282 | card->channels++; |
288 | 283 | ||
289 | dev_info(&pdev->dev, "Channel #%d at %#lX, irq %d\n", | 284 | dev_info(&pdev->dev, "Channel #%d at 0x%p, irq %d\n", |
290 | i + 1, dev->base_addr, | 285 | i + 1, priv->reg_base, dev->irq); |
291 | dev->irq); | ||
292 | } else { | 286 | } else { |
293 | free_sja1000dev(dev); | 287 | free_sja1000dev(dev); |
294 | } | 288 | } |