diff options
Diffstat (limited to 'drivers/net/pcmcia/ibmtr_cs.c')
-rw-r--r-- | drivers/net/pcmcia/ibmtr_cs.c | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c index 06618af1a468..37f4a6fdc3ef 100644 --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c | |||
@@ -69,17 +69,6 @@ | |||
69 | #define PCMCIA | 69 | #define PCMCIA |
70 | #include "../tokenring/ibmtr.c" | 70 | #include "../tokenring/ibmtr.c" |
71 | 71 | ||
72 | #ifdef PCMCIA_DEBUG | ||
73 | static int pc_debug = PCMCIA_DEBUG; | ||
74 | module_param(pc_debug, int, 0); | ||
75 | #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) | ||
76 | static char *version = | ||
77 | "ibmtr_cs.c 1.10 1996/01/06 05:19:00 (Steve Kipisz)\n" | ||
78 | " 2.2.7 1999/05/03 12:00:00 (Mike Phillips)\n" | ||
79 | " 2.4.2 2001/30/28 Midnight (Burt Silverman)\n"; | ||
80 | #else | ||
81 | #define DEBUG(n, args...) | ||
82 | #endif | ||
83 | 72 | ||
84 | /*====================================================================*/ | 73 | /*====================================================================*/ |
85 | 74 | ||
@@ -130,6 +119,12 @@ static const struct ethtool_ops netdev_ethtool_ops = { | |||
130 | .get_drvinfo = netdev_get_drvinfo, | 119 | .get_drvinfo = netdev_get_drvinfo, |
131 | }; | 120 | }; |
132 | 121 | ||
122 | static irqreturn_t ibmtr_interrupt(int irq, void *dev_id) { | ||
123 | ibmtr_dev_t *info = dev_id; | ||
124 | struct net_device *dev = info->dev; | ||
125 | return tok_interrupt(irq, dev); | ||
126 | }; | ||
127 | |||
133 | /*====================================================================== | 128 | /*====================================================================== |
134 | 129 | ||
135 | ibmtr_attach() creates an "instance" of the driver, allocating | 130 | ibmtr_attach() creates an "instance" of the driver, allocating |
@@ -143,7 +138,7 @@ static int __devinit ibmtr_attach(struct pcmcia_device *link) | |||
143 | ibmtr_dev_t *info; | 138 | ibmtr_dev_t *info; |
144 | struct net_device *dev; | 139 | struct net_device *dev; |
145 | 140 | ||
146 | DEBUG(0, "ibmtr_attach()\n"); | 141 | dev_dbg(&link->dev, "ibmtr_attach()\n"); |
147 | 142 | ||
148 | /* Create new token-ring device */ | 143 | /* Create new token-ring device */ |
149 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 144 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
@@ -161,14 +156,13 @@ static int __devinit ibmtr_attach(struct pcmcia_device *link) | |||
161 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | 156 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; |
162 | link->io.NumPorts1 = 4; | 157 | link->io.NumPorts1 = 4; |
163 | link->io.IOAddrLines = 16; | 158 | link->io.IOAddrLines = 16; |
164 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; | 159 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; |
165 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 160 | link->irq.Handler = ibmtr_interrupt; |
166 | link->irq.Handler = &tok_interrupt; | ||
167 | link->conf.Attributes = CONF_ENABLE_IRQ; | 161 | link->conf.Attributes = CONF_ENABLE_IRQ; |
168 | link->conf.IntType = INT_MEMORY_AND_IO; | 162 | link->conf.IntType = INT_MEMORY_AND_IO; |
169 | link->conf.Present = PRESENT_OPTION; | 163 | link->conf.Present = PRESENT_OPTION; |
170 | 164 | ||
171 | link->irq.Instance = info->dev = dev; | 165 | info->dev = dev; |
172 | 166 | ||
173 | SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); | 167 | SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); |
174 | 168 | ||
@@ -190,7 +184,7 @@ static void ibmtr_detach(struct pcmcia_device *link) | |||
190 | struct net_device *dev = info->dev; | 184 | struct net_device *dev = info->dev; |
191 | struct tok_info *ti = netdev_priv(dev); | 185 | struct tok_info *ti = netdev_priv(dev); |
192 | 186 | ||
193 | DEBUG(0, "ibmtr_detach(0x%p)\n", link); | 187 | dev_dbg(&link->dev, "ibmtr_detach\n"); |
194 | 188 | ||
195 | /* | 189 | /* |
196 | * When the card removal interrupt hits tok_interrupt(), | 190 | * When the card removal interrupt hits tok_interrupt(), |
@@ -217,9 +211,6 @@ static void ibmtr_detach(struct pcmcia_device *link) | |||
217 | 211 | ||
218 | ======================================================================*/ | 212 | ======================================================================*/ |
219 | 213 | ||
220 | #define CS_CHECK(fn, ret) \ | ||
221 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | ||
222 | |||
223 | static int __devinit ibmtr_config(struct pcmcia_device *link) | 214 | static int __devinit ibmtr_config(struct pcmcia_device *link) |
224 | { | 215 | { |
225 | ibmtr_dev_t *info = link->priv; | 216 | ibmtr_dev_t *info = link->priv; |
@@ -227,9 +218,9 @@ static int __devinit ibmtr_config(struct pcmcia_device *link) | |||
227 | struct tok_info *ti = netdev_priv(dev); | 218 | struct tok_info *ti = netdev_priv(dev); |
228 | win_req_t req; | 219 | win_req_t req; |
229 | memreq_t mem; | 220 | memreq_t mem; |
230 | int i, last_ret, last_fn; | 221 | int i, ret; |
231 | 222 | ||
232 | DEBUG(0, "ibmtr_config(0x%p)\n", link); | 223 | dev_dbg(&link->dev, "ibmtr_config\n"); |
233 | 224 | ||
234 | link->conf.ConfigIndex = 0x61; | 225 | link->conf.ConfigIndex = 0x61; |
235 | 226 | ||
@@ -241,11 +232,15 @@ static int __devinit ibmtr_config(struct pcmcia_device *link) | |||
241 | if (i != 0) { | 232 | if (i != 0) { |
242 | /* Couldn't get 0xA20-0xA23. Try ALTERNATE at 0xA24-0xA27. */ | 233 | /* Couldn't get 0xA20-0xA23. Try ALTERNATE at 0xA24-0xA27. */ |
243 | link->io.BasePort1 = 0xA24; | 234 | link->io.BasePort1 = 0xA24; |
244 | CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); | 235 | ret = pcmcia_request_io(link, &link->io); |
236 | if (ret) | ||
237 | goto failed; | ||
245 | } | 238 | } |
246 | dev->base_addr = link->io.BasePort1; | 239 | dev->base_addr = link->io.BasePort1; |
247 | 240 | ||
248 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 241 | ret = pcmcia_request_irq(link, &link->irq); |
242 | if (ret) | ||
243 | goto failed; | ||
249 | dev->irq = link->irq.AssignedIRQ; | 244 | dev->irq = link->irq.AssignedIRQ; |
250 | ti->irq = link->irq.AssignedIRQ; | 245 | ti->irq = link->irq.AssignedIRQ; |
251 | ti->global_int_enable=GLOBAL_INT_ENABLE+((dev->irq==9) ? 2 : dev->irq); | 246 | ti->global_int_enable=GLOBAL_INT_ENABLE+((dev->irq==9) ? 2 : dev->irq); |
@@ -256,11 +251,15 @@ static int __devinit ibmtr_config(struct pcmcia_device *link) | |||
256 | req.Base = 0; | 251 | req.Base = 0; |
257 | req.Size = 0x2000; | 252 | req.Size = 0x2000; |
258 | req.AccessSpeed = 250; | 253 | req.AccessSpeed = 250; |
259 | CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win)); | 254 | ret = pcmcia_request_window(link, &req, &link->win); |
255 | if (ret) | ||
256 | goto failed; | ||
260 | 257 | ||
261 | mem.CardOffset = mmiobase; | 258 | mem.CardOffset = mmiobase; |
262 | mem.Page = 0; | 259 | mem.Page = 0; |
263 | CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); | 260 | ret = pcmcia_map_mem_page(link, link->win, &mem); |
261 | if (ret) | ||
262 | goto failed; | ||
264 | ti->mmio = ioremap(req.Base, req.Size); | 263 | ti->mmio = ioremap(req.Base, req.Size); |
265 | 264 | ||
266 | /* Allocate the SRAM memory window */ | 265 | /* Allocate the SRAM memory window */ |
@@ -269,17 +268,23 @@ static int __devinit ibmtr_config(struct pcmcia_device *link) | |||
269 | req.Base = 0; | 268 | req.Base = 0; |
270 | req.Size = sramsize * 1024; | 269 | req.Size = sramsize * 1024; |
271 | req.AccessSpeed = 250; | 270 | req.AccessSpeed = 250; |
272 | CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &info->sram_win_handle)); | 271 | ret = pcmcia_request_window(link, &req, &info->sram_win_handle); |
272 | if (ret) | ||
273 | goto failed; | ||
273 | 274 | ||
274 | mem.CardOffset = srambase; | 275 | mem.CardOffset = srambase; |
275 | mem.Page = 0; | 276 | mem.Page = 0; |
276 | CS_CHECK(MapMemPage, pcmcia_map_mem_page(info->sram_win_handle, &mem)); | 277 | ret = pcmcia_map_mem_page(link, info->sram_win_handle, &mem); |
278 | if (ret) | ||
279 | goto failed; | ||
277 | 280 | ||
278 | ti->sram_base = mem.CardOffset >> 12; | 281 | ti->sram_base = mem.CardOffset >> 12; |
279 | ti->sram_virt = ioremap(req.Base, req.Size); | 282 | ti->sram_virt = ioremap(req.Base, req.Size); |
280 | ti->sram_phys = req.Base; | 283 | ti->sram_phys = req.Base; |
281 | 284 | ||
282 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 285 | ret = pcmcia_request_configuration(link, &link->conf); |
286 | if (ret) | ||
287 | goto failed; | ||
283 | 288 | ||
284 | /* Set up the Token-Ring Controller Configuration Register and | 289 | /* Set up the Token-Ring Controller Configuration Register and |
285 | turn on the card. Check the "Local Area Network Credit Card | 290 | turn on the card. Check the "Local Area Network Credit Card |
@@ -287,7 +292,7 @@ static int __devinit ibmtr_config(struct pcmcia_device *link) | |||
287 | ibmtr_hw_setup(dev, mmiobase); | 292 | ibmtr_hw_setup(dev, mmiobase); |
288 | 293 | ||
289 | link->dev_node = &info->node; | 294 | link->dev_node = &info->node; |
290 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); | 295 | SET_NETDEV_DEV(dev, &link->dev); |
291 | 296 | ||
292 | i = ibmtr_probe_card(dev); | 297 | i = ibmtr_probe_card(dev); |
293 | if (i != 0) { | 298 | if (i != 0) { |
@@ -305,8 +310,6 @@ static int __devinit ibmtr_config(struct pcmcia_device *link) | |||
305 | dev->dev_addr); | 310 | dev->dev_addr); |
306 | return 0; | 311 | return 0; |
307 | 312 | ||
308 | cs_failed: | ||
309 | cs_error(link, last_fn, last_ret); | ||
310 | failed: | 313 | failed: |
311 | ibmtr_release(link); | 314 | ibmtr_release(link); |
312 | return -ENODEV; | 315 | return -ENODEV; |
@@ -325,12 +328,12 @@ static void ibmtr_release(struct pcmcia_device *link) | |||
325 | ibmtr_dev_t *info = link->priv; | 328 | ibmtr_dev_t *info = link->priv; |
326 | struct net_device *dev = info->dev; | 329 | struct net_device *dev = info->dev; |
327 | 330 | ||
328 | DEBUG(0, "ibmtr_release(0x%p)\n", link); | 331 | dev_dbg(&link->dev, "ibmtr_release\n"); |
329 | 332 | ||
330 | if (link->win) { | 333 | if (link->win) { |
331 | struct tok_info *ti = netdev_priv(dev); | 334 | struct tok_info *ti = netdev_priv(dev); |
332 | iounmap(ti->mmio); | 335 | iounmap(ti->mmio); |
333 | pcmcia_release_window(info->sram_win_handle); | 336 | pcmcia_release_window(link, info->sram_win_handle); |
334 | } | 337 | } |
335 | pcmcia_disable_device(link); | 338 | pcmcia_disable_device(link); |
336 | } | 339 | } |