diff options
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/airo_cs.c | 158 | ||||
-rw-r--r-- | drivers/net/wireless/atmel_cs.c | 162 | ||||
-rw-r--r-- | drivers/net/wireless/hostap/hostap_cs.c | 198 | ||||
-rw-r--r-- | drivers/net/wireless/netwave_cs.c | 127 | ||||
-rw-r--r-- | drivers/net/wireless/orinoco_cs.c | 187 | ||||
-rw-r--r-- | drivers/net/wireless/ray_cs.c | 279 | ||||
-rw-r--r-- | drivers/net/wireless/ray_cs.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/spectrum_cs.c | 173 | ||||
-rw-r--r-- | drivers/net/wireless/wavelan_cs.c | 189 | ||||
-rw-r--r-- | drivers/net/wireless/wavelan_cs.p.h | 6 | ||||
-rw-r--r-- | drivers/net/wireless/wl3501.h | 1 | ||||
-rw-r--r-- | drivers/net/wireless/wl3501_cs.c | 178 |
12 files changed, 615 insertions, 1045 deletions
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index a496460ce224..af0cbb6c5c0c 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c | |||
@@ -80,8 +80,8 @@ MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards"); | |||
80 | event handler. | 80 | event handler. |
81 | */ | 81 | */ |
82 | 82 | ||
83 | static void airo_config(dev_link_t *link); | 83 | static int airo_config(struct pcmcia_device *link); |
84 | static void airo_release(dev_link_t *link); | 84 | static void airo_release(struct pcmcia_device *link); |
85 | 85 | ||
86 | /* | 86 | /* |
87 | The attach() and detach() entry points are used to create and destroy | 87 | The attach() and detach() entry points are used to create and destroy |
@@ -101,10 +101,10 @@ static void airo_detach(struct pcmcia_device *p_dev); | |||
101 | /* | 101 | /* |
102 | A linked list of "instances" of the aironet device. Each actual | 102 | A linked list of "instances" of the aironet device. Each actual |
103 | PCMCIA card corresponds to one device instance, and is described | 103 | PCMCIA card corresponds to one device instance, and is described |
104 | by one dev_link_t structure (defined in ds.h). | 104 | by one struct pcmcia_device structure (defined in ds.h). |
105 | 105 | ||
106 | You may not want to use a linked list for this -- for example, the | 106 | You may not want to use a linked list for this -- for example, the |
107 | memory card driver uses an array of dev_link_t pointers, where minor | 107 | memory card driver uses an array of struct pcmcia_device pointers, where minor |
108 | device numbers are used to derive the corresponding array index. | 108 | device numbers are used to derive the corresponding array index. |
109 | */ | 109 | */ |
110 | 110 | ||
@@ -114,7 +114,7 @@ static void airo_detach(struct pcmcia_device *p_dev); | |||
114 | example, ethernet cards, modems). In other cases, there may be | 114 | example, ethernet cards, modems). In other cases, there may be |
115 | many actual or logical devices (SCSI adapters, memory cards with | 115 | many actual or logical devices (SCSI adapters, memory cards with |
116 | multiple partitions). The dev_node_t structures need to be kept | 116 | multiple partitions). The dev_node_t structures need to be kept |
117 | in a linked list starting at the 'dev' field of a dev_link_t | 117 | in a linked list starting at the 'dev' field of a struct pcmcia_device |
118 | structure. We allocate them in the card's private data structure, | 118 | structure. We allocate them in the card's private data structure, |
119 | because they generally shouldn't be allocated dynamically. | 119 | because they generally shouldn't be allocated dynamically. |
120 | 120 | ||
@@ -141,24 +141,16 @@ typedef struct local_info_t { | |||
141 | 141 | ||
142 | ======================================================================*/ | 142 | ======================================================================*/ |
143 | 143 | ||
144 | static int airo_attach(struct pcmcia_device *p_dev) | 144 | static int airo_probe(struct pcmcia_device *p_dev) |
145 | { | 145 | { |
146 | dev_link_t *link; | ||
147 | local_info_t *local; | 146 | local_info_t *local; |
148 | 147 | ||
149 | DEBUG(0, "airo_attach()\n"); | 148 | DEBUG(0, "airo_attach()\n"); |
150 | 149 | ||
151 | /* Initialize the dev_link_t structure */ | ||
152 | link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); | ||
153 | if (!link) { | ||
154 | printk(KERN_ERR "airo_cs: no memory for new device\n"); | ||
155 | return -ENOMEM; | ||
156 | } | ||
157 | |||
158 | /* Interrupt setup */ | 150 | /* Interrupt setup */ |
159 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; | 151 | p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE; |
160 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 152 | p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; |
161 | link->irq.Handler = NULL; | 153 | p_dev->irq.Handler = NULL; |
162 | 154 | ||
163 | /* | 155 | /* |
164 | General socket configuration defaults can go here. In this | 156 | General socket configuration defaults can go here. In this |
@@ -167,26 +159,18 @@ static int airo_attach(struct pcmcia_device *p_dev) | |||
167 | and attributes of IO windows) are fixed by the nature of the | 159 | and attributes of IO windows) are fixed by the nature of the |
168 | device, and can be hard-wired here. | 160 | device, and can be hard-wired here. |
169 | */ | 161 | */ |
170 | link->conf.Attributes = 0; | 162 | p_dev->conf.Attributes = 0; |
171 | link->conf.Vcc = 50; | 163 | p_dev->conf.IntType = INT_MEMORY_AND_IO; |
172 | link->conf.IntType = INT_MEMORY_AND_IO; | ||
173 | 164 | ||
174 | /* Allocate space for private device-specific data */ | 165 | /* Allocate space for private device-specific data */ |
175 | local = kzalloc(sizeof(local_info_t), GFP_KERNEL); | 166 | local = kzalloc(sizeof(local_info_t), GFP_KERNEL); |
176 | if (!local) { | 167 | if (!local) { |
177 | printk(KERN_ERR "airo_cs: no memory for new device\n"); | 168 | printk(KERN_ERR "airo_cs: no memory for new device\n"); |
178 | kfree (link); | ||
179 | return -ENOMEM; | 169 | return -ENOMEM; |
180 | } | 170 | } |
181 | link->priv = local; | 171 | p_dev->priv = local; |
182 | 172 | ||
183 | link->handle = p_dev; | 173 | return airo_config(p_dev); |
184 | p_dev->instance = link; | ||
185 | |||
186 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
187 | airo_config(link); | ||
188 | |||
189 | return 0; | ||
190 | } /* airo_attach */ | 174 | } /* airo_attach */ |
191 | 175 | ||
192 | /*====================================================================== | 176 | /*====================================================================== |
@@ -198,14 +182,11 @@ static int airo_attach(struct pcmcia_device *p_dev) | |||
198 | 182 | ||
199 | ======================================================================*/ | 183 | ======================================================================*/ |
200 | 184 | ||
201 | static void airo_detach(struct pcmcia_device *p_dev) | 185 | static void airo_detach(struct pcmcia_device *link) |
202 | { | 186 | { |
203 | dev_link_t *link = dev_to_instance(p_dev); | ||
204 | |||
205 | DEBUG(0, "airo_detach(0x%p)\n", link); | 187 | DEBUG(0, "airo_detach(0x%p)\n", link); |
206 | 188 | ||
207 | if (link->state & DEV_CONFIG) | 189 | airo_release(link); |
208 | airo_release(link); | ||
209 | 190 | ||
210 | if ( ((local_info_t*)link->priv)->eth_dev ) { | 191 | if ( ((local_info_t*)link->priv)->eth_dev ) { |
211 | stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 ); | 192 | stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 ); |
@@ -213,7 +194,6 @@ static void airo_detach(struct pcmcia_device *p_dev) | |||
213 | ((local_info_t*)link->priv)->eth_dev = NULL; | 194 | ((local_info_t*)link->priv)->eth_dev = NULL; |
214 | 195 | ||
215 | kfree(link->priv); | 196 | kfree(link->priv); |
216 | kfree(link); | ||
217 | } /* airo_detach */ | 197 | } /* airo_detach */ |
218 | 198 | ||
219 | /*====================================================================== | 199 | /*====================================================================== |
@@ -227,9 +207,8 @@ static void airo_detach(struct pcmcia_device *p_dev) | |||
227 | #define CS_CHECK(fn, ret) \ | 207 | #define CS_CHECK(fn, ret) \ |
228 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 208 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
229 | 209 | ||
230 | static void airo_config(dev_link_t *link) | 210 | static int airo_config(struct pcmcia_device *link) |
231 | { | 211 | { |
232 | client_handle_t handle; | ||
233 | tuple_t tuple; | 212 | tuple_t tuple; |
234 | cisparse_t parse; | 213 | cisparse_t parse; |
235 | local_info_t *dev; | 214 | local_info_t *dev; |
@@ -237,8 +216,7 @@ static void airo_config(dev_link_t *link) | |||
237 | u_char buf[64]; | 216 | u_char buf[64]; |
238 | win_req_t req; | 217 | win_req_t req; |
239 | memreq_t map; | 218 | memreq_t map; |
240 | 219 | ||
241 | handle = link->handle; | ||
242 | dev = link->priv; | 220 | dev = link->priv; |
243 | 221 | ||
244 | DEBUG(0, "airo_config(0x%p)\n", link); | 222 | DEBUG(0, "airo_config(0x%p)\n", link); |
@@ -252,15 +230,12 @@ static void airo_config(dev_link_t *link) | |||
252 | tuple.TupleData = buf; | 230 | tuple.TupleData = buf; |
253 | tuple.TupleDataMax = sizeof(buf); | 231 | tuple.TupleDataMax = sizeof(buf); |
254 | tuple.TupleOffset = 0; | 232 | tuple.TupleOffset = 0; |
255 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 233 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
256 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | 234 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
257 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); | 235 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); |
258 | link->conf.ConfigBase = parse.config.base; | 236 | link->conf.ConfigBase = parse.config.base; |
259 | link->conf.Present = parse.config.rmask[0]; | 237 | link->conf.Present = parse.config.rmask[0]; |
260 | 238 | ||
261 | /* Configure card */ | ||
262 | link->state |= DEV_CONFIG; | ||
263 | |||
264 | /* | 239 | /* |
265 | In this loop, we scan the CIS for configuration table entries, | 240 | In this loop, we scan the CIS for configuration table entries, |
266 | each of which describes a valid card configuration, including | 241 | each of which describes a valid card configuration, including |
@@ -274,12 +249,12 @@ static void airo_config(dev_link_t *link) | |||
274 | will only use the CIS to fill in implementation-defined details. | 249 | will only use the CIS to fill in implementation-defined details. |
275 | */ | 250 | */ |
276 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 251 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
277 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 252 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
278 | while (1) { | 253 | while (1) { |
279 | cistpl_cftable_entry_t dflt = { 0 }; | 254 | cistpl_cftable_entry_t dflt = { 0 }; |
280 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | 255 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); |
281 | if (pcmcia_get_tuple_data(handle, &tuple) != 0 || | 256 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || |
282 | pcmcia_parse_tuple(handle, &tuple, &parse) != 0) | 257 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) |
283 | goto next_entry; | 258 | goto next_entry; |
284 | 259 | ||
285 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; | 260 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; |
@@ -294,16 +269,11 @@ static void airo_config(dev_link_t *link) | |||
294 | 269 | ||
295 | /* Use power settings for Vcc and Vpp if present */ | 270 | /* Use power settings for Vcc and Vpp if present */ |
296 | /* Note that the CIS values need to be rescaled */ | 271 | /* Note that the CIS values need to be rescaled */ |
297 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) | ||
298 | link->conf.Vcc = cfg->vcc.param[CISTPL_POWER_VNOM]/10000; | ||
299 | else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) | ||
300 | link->conf.Vcc = dflt.vcc.param[CISTPL_POWER_VNOM]/10000; | ||
301 | |||
302 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | 272 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) |
303 | link->conf.Vpp1 = link->conf.Vpp2 = | 273 | link->conf.Vpp = |
304 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | 274 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; |
305 | else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) | 275 | else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) |
306 | link->conf.Vpp1 = link->conf.Vpp2 = | 276 | link->conf.Vpp = |
307 | dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; | 277 | dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; |
308 | 278 | ||
309 | /* Do we need to allocate an interrupt? */ | 279 | /* Do we need to allocate an interrupt? */ |
@@ -329,12 +299,12 @@ static void airo_config(dev_link_t *link) | |||
329 | } | 299 | } |
330 | 300 | ||
331 | /* This reserves IO space but doesn't actually enable it */ | 301 | /* This reserves IO space but doesn't actually enable it */ |
332 | if (pcmcia_request_io(link->handle, &link->io) != 0) | 302 | if (pcmcia_request_io(link, &link->io) != 0) |
333 | goto next_entry; | 303 | goto next_entry; |
334 | 304 | ||
335 | /* | 305 | /* |
336 | Now set up a common memory window, if needed. There is room | 306 | Now set up a common memory window, if needed. There is room |
337 | in the dev_link_t structure for one memory window handle, | 307 | in the struct pcmcia_device structure for one memory window handle, |
338 | but if the base addresses need to be saved, or if multiple | 308 | but if the base addresses need to be saved, or if multiple |
339 | windows are needed, the info should go in the private data | 309 | windows are needed, the info should go in the private data |
340 | structure for this device. | 310 | structure for this device. |
@@ -350,7 +320,7 @@ static void airo_config(dev_link_t *link) | |||
350 | req.Base = mem->win[0].host_addr; | 320 | req.Base = mem->win[0].host_addr; |
351 | req.Size = mem->win[0].len; | 321 | req.Size = mem->win[0].len; |
352 | req.AccessSpeed = 0; | 322 | req.AccessSpeed = 0; |
353 | if (pcmcia_request_window(&link->handle, &req, &link->win) != 0) | 323 | if (pcmcia_request_window(&link, &req, &link->win) != 0) |
354 | goto next_entry; | 324 | goto next_entry; |
355 | map.Page = 0; map.CardOffset = mem->win[0].card_addr; | 325 | map.Page = 0; map.CardOffset = mem->win[0].card_addr; |
356 | if (pcmcia_map_mem_page(link->win, &map) != 0) | 326 | if (pcmcia_map_mem_page(link->win, &map) != 0) |
@@ -360,7 +330,7 @@ static void airo_config(dev_link_t *link) | |||
360 | break; | 330 | break; |
361 | 331 | ||
362 | next_entry: | 332 | next_entry: |
363 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); | 333 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); |
364 | } | 334 | } |
365 | 335 | ||
366 | /* | 336 | /* |
@@ -369,33 +339,32 @@ static void airo_config(dev_link_t *link) | |||
369 | irq structure is initialized. | 339 | irq structure is initialized. |
370 | */ | 340 | */ |
371 | if (link->conf.Attributes & CONF_ENABLE_IRQ) | 341 | if (link->conf.Attributes & CONF_ENABLE_IRQ) |
372 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); | 342 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
373 | 343 | ||
374 | /* | 344 | /* |
375 | This actually configures the PCMCIA socket -- setting up | 345 | This actually configures the PCMCIA socket -- setting up |
376 | the I/O windows and the interrupt mapping, and putting the | 346 | the I/O windows and the interrupt mapping, and putting the |
377 | card and host interface into "Memory and IO" mode. | 347 | card and host interface into "Memory and IO" mode. |
378 | */ | 348 | */ |
379 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); | 349 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); |
380 | ((local_info_t*)link->priv)->eth_dev = | 350 | ((local_info_t*)link->priv)->eth_dev = |
381 | init_airo_card( link->irq.AssignedIRQ, | 351 | init_airo_card( link->irq.AssignedIRQ, |
382 | link->io.BasePort1, 1, &handle_to_dev(handle) ); | 352 | link->io.BasePort1, 1, &handle_to_dev(link) ); |
383 | if (!((local_info_t*)link->priv)->eth_dev) goto cs_failed; | 353 | if (!((local_info_t*)link->priv)->eth_dev) goto cs_failed; |
384 | 354 | ||
385 | /* | 355 | /* |
386 | At this point, the dev_node_t structure(s) need to be | 356 | At this point, the dev_node_t structure(s) need to be |
387 | initialized and arranged in a linked list at link->dev. | 357 | initialized and arranged in a linked list at link->dev_node. |
388 | */ | 358 | */ |
389 | strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); | 359 | strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); |
390 | dev->node.major = dev->node.minor = 0; | 360 | dev->node.major = dev->node.minor = 0; |
391 | link->dev = &dev->node; | 361 | link->dev_node = &dev->node; |
392 | 362 | ||
393 | /* Finally, report what we've done */ | 363 | /* Finally, report what we've done */ |
394 | printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", | 364 | printk(KERN_INFO "%s: index 0x%02x: ", |
395 | dev->node.dev_name, link->conf.ConfigIndex, | 365 | dev->node.dev_name, link->conf.ConfigIndex); |
396 | link->conf.Vcc/10, link->conf.Vcc%10); | 366 | if (link->conf.Vpp) |
397 | if (link->conf.Vpp1) | 367 | printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10); |
398 | printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10); | ||
399 | if (link->conf.Attributes & CONF_ENABLE_IRQ) | 368 | if (link->conf.Attributes & CONF_ENABLE_IRQ) |
400 | printk(", irq %d", link->irq.AssignedIRQ); | 369 | printk(", irq %d", link->irq.AssignedIRQ); |
401 | if (link->io.NumPorts1) | 370 | if (link->io.NumPorts1) |
@@ -408,14 +377,12 @@ static void airo_config(dev_link_t *link) | |||
408 | printk(", mem 0x%06lx-0x%06lx", req.Base, | 377 | printk(", mem 0x%06lx-0x%06lx", req.Base, |
409 | req.Base+req.Size-1); | 378 | req.Base+req.Size-1); |
410 | printk("\n"); | 379 | printk("\n"); |
411 | 380 | return 0; | |
412 | link->state &= ~DEV_CONFIG_PENDING; | 381 | |
413 | return; | ||
414 | |||
415 | cs_failed: | 382 | cs_failed: |
416 | cs_error(link->handle, last_fn, last_ret); | 383 | cs_error(link, last_fn, last_ret); |
417 | airo_release(link); | 384 | airo_release(link); |
418 | 385 | return -ENODEV; | |
419 | } /* airo_config */ | 386 | } /* airo_config */ |
420 | 387 | ||
421 | /*====================================================================== | 388 | /*====================================================================== |
@@ -426,51 +393,26 @@ static void airo_config(dev_link_t *link) | |||
426 | 393 | ||
427 | ======================================================================*/ | 394 | ======================================================================*/ |
428 | 395 | ||
429 | static void airo_release(dev_link_t *link) | 396 | static void airo_release(struct pcmcia_device *link) |
430 | { | 397 | { |
431 | DEBUG(0, "airo_release(0x%p)\n", link); | 398 | DEBUG(0, "airo_release(0x%p)\n", link); |
432 | 399 | pcmcia_disable_device(link); | |
433 | /* Unlink the device chain */ | ||
434 | link->dev = NULL; | ||
435 | |||
436 | /* | ||
437 | In a normal driver, additional code may be needed to release | ||
438 | other kernel data structures associated with this device. | ||
439 | */ | ||
440 | |||
441 | /* Don't bother checking to see if these succeed or not */ | ||
442 | if (link->win) | ||
443 | pcmcia_release_window(link->win); | ||
444 | pcmcia_release_configuration(link->handle); | ||
445 | if (link->io.NumPorts1) | ||
446 | pcmcia_release_io(link->handle, &link->io); | ||
447 | if (link->irq.AssignedIRQ) | ||
448 | pcmcia_release_irq(link->handle, &link->irq); | ||
449 | link->state &= ~DEV_CONFIG; | ||
450 | } | 400 | } |
451 | 401 | ||
452 | static int airo_suspend(struct pcmcia_device *p_dev) | 402 | static int airo_suspend(struct pcmcia_device *link) |
453 | { | 403 | { |
454 | dev_link_t *link = dev_to_instance(p_dev); | ||
455 | local_info_t *local = link->priv; | 404 | local_info_t *local = link->priv; |
456 | 405 | ||
457 | link->state |= DEV_SUSPEND; | 406 | netif_device_detach(local->eth_dev); |
458 | if (link->state & DEV_CONFIG) { | ||
459 | netif_device_detach(local->eth_dev); | ||
460 | pcmcia_release_configuration(link->handle); | ||
461 | } | ||
462 | 407 | ||
463 | return 0; | 408 | return 0; |
464 | } | 409 | } |
465 | 410 | ||
466 | static int airo_resume(struct pcmcia_device *p_dev) | 411 | static int airo_resume(struct pcmcia_device *link) |
467 | { | 412 | { |
468 | dev_link_t *link = dev_to_instance(p_dev); | ||
469 | local_info_t *local = link->priv; | 413 | local_info_t *local = link->priv; |
470 | 414 | ||
471 | link->state &= ~DEV_SUSPEND; | 415 | if (link->open) { |
472 | if (link->state & DEV_CONFIG) { | ||
473 | pcmcia_request_configuration(link->handle, &link->conf); | ||
474 | reset_airo_card(local->eth_dev); | 416 | reset_airo_card(local->eth_dev); |
475 | netif_device_attach(local->eth_dev); | 417 | netif_device_attach(local->eth_dev); |
476 | } | 418 | } |
@@ -492,7 +434,7 @@ static struct pcmcia_driver airo_driver = { | |||
492 | .drv = { | 434 | .drv = { |
493 | .name = "airo_cs", | 435 | .name = "airo_cs", |
494 | }, | 436 | }, |
495 | .probe = airo_attach, | 437 | .probe = airo_probe, |
496 | .remove = airo_detach, | 438 | .remove = airo_detach, |
497 | .id_table = airo_ids, | 439 | .id_table = airo_ids, |
498 | .suspend = airo_suspend, | 440 | .suspend = airo_suspend, |
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index d6f4a5a3e55a..26bf1127524d 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c | |||
@@ -91,8 +91,8 @@ MODULE_SUPPORTED_DEVICE("Atmel at76c50x PCMCIA cards"); | |||
91 | event handler. | 91 | event handler. |
92 | */ | 92 | */ |
93 | 93 | ||
94 | static void atmel_config(dev_link_t *link); | 94 | static int atmel_config(struct pcmcia_device *link); |
95 | static void atmel_release(dev_link_t *link); | 95 | static void atmel_release(struct pcmcia_device *link); |
96 | 96 | ||
97 | /* | 97 | /* |
98 | The attach() and detach() entry points are used to create and destroy | 98 | The attach() and detach() entry points are used to create and destroy |
@@ -112,10 +112,10 @@ static void atmel_detach(struct pcmcia_device *p_dev); | |||
112 | /* | 112 | /* |
113 | A linked list of "instances" of the atmelnet device. Each actual | 113 | A linked list of "instances" of the atmelnet device. Each actual |
114 | PCMCIA card corresponds to one device instance, and is described | 114 | PCMCIA card corresponds to one device instance, and is described |
115 | by one dev_link_t structure (defined in ds.h). | 115 | by one struct pcmcia_device structure (defined in ds.h). |
116 | 116 | ||
117 | You may not want to use a linked list for this -- for example, the | 117 | You may not want to use a linked list for this -- for example, the |
118 | memory card driver uses an array of dev_link_t pointers, where minor | 118 | memory card driver uses an array of struct pcmcia_device pointers, where minor |
119 | device numbers are used to derive the corresponding array index. | 119 | device numbers are used to derive the corresponding array index. |
120 | */ | 120 | */ |
121 | 121 | ||
@@ -125,7 +125,7 @@ static void atmel_detach(struct pcmcia_device *p_dev); | |||
125 | example, ethernet cards, modems). In other cases, there may be | 125 | example, ethernet cards, modems). In other cases, there may be |
126 | many actual or logical devices (SCSI adapters, memory cards with | 126 | many actual or logical devices (SCSI adapters, memory cards with |
127 | multiple partitions). The dev_node_t structures need to be kept | 127 | multiple partitions). The dev_node_t structures need to be kept |
128 | in a linked list starting at the 'dev' field of a dev_link_t | 128 | in a linked list starting at the 'dev' field of a struct pcmcia_device |
129 | structure. We allocate them in the card's private data structure, | 129 | structure. We allocate them in the card's private data structure, |
130 | because they generally shouldn't be allocated dynamically. | 130 | because they generally shouldn't be allocated dynamically. |
131 | 131 | ||
@@ -152,24 +152,16 @@ typedef struct local_info_t { | |||
152 | 152 | ||
153 | ======================================================================*/ | 153 | ======================================================================*/ |
154 | 154 | ||
155 | static int atmel_attach(struct pcmcia_device *p_dev) | 155 | static int atmel_probe(struct pcmcia_device *p_dev) |
156 | { | 156 | { |
157 | dev_link_t *link; | ||
158 | local_info_t *local; | 157 | local_info_t *local; |
159 | 158 | ||
160 | DEBUG(0, "atmel_attach()\n"); | 159 | DEBUG(0, "atmel_attach()\n"); |
161 | 160 | ||
162 | /* Initialize the dev_link_t structure */ | ||
163 | link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); | ||
164 | if (!link) { | ||
165 | printk(KERN_ERR "atmel_cs: no memory for new device\n"); | ||
166 | return -ENOMEM; | ||
167 | } | ||
168 | |||
169 | /* Interrupt setup */ | 161 | /* Interrupt setup */ |
170 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; | 162 | p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE; |
171 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 163 | p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; |
172 | link->irq.Handler = NULL; | 164 | p_dev->irq.Handler = NULL; |
173 | 165 | ||
174 | /* | 166 | /* |
175 | General socket configuration defaults can go here. In this | 167 | General socket configuration defaults can go here. In this |
@@ -178,26 +170,18 @@ static int atmel_attach(struct pcmcia_device *p_dev) | |||
178 | and attributes of IO windows) are fixed by the nature of the | 170 | and attributes of IO windows) are fixed by the nature of the |
179 | device, and can be hard-wired here. | 171 | device, and can be hard-wired here. |
180 | */ | 172 | */ |
181 | link->conf.Attributes = 0; | 173 | p_dev->conf.Attributes = 0; |
182 | link->conf.Vcc = 50; | 174 | p_dev->conf.IntType = INT_MEMORY_AND_IO; |
183 | link->conf.IntType = INT_MEMORY_AND_IO; | ||
184 | 175 | ||
185 | /* Allocate space for private device-specific data */ | 176 | /* Allocate space for private device-specific data */ |
186 | local = kzalloc(sizeof(local_info_t), GFP_KERNEL); | 177 | local = kzalloc(sizeof(local_info_t), GFP_KERNEL); |
187 | if (!local) { | 178 | if (!local) { |
188 | printk(KERN_ERR "atmel_cs: no memory for new device\n"); | 179 | printk(KERN_ERR "atmel_cs: no memory for new device\n"); |
189 | kfree (link); | ||
190 | return -ENOMEM; | 180 | return -ENOMEM; |
191 | } | 181 | } |
192 | link->priv = local; | 182 | p_dev->priv = local; |
193 | 183 | ||
194 | link->handle = p_dev; | 184 | return atmel_config(p_dev); |
195 | p_dev->instance = link; | ||
196 | |||
197 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
198 | atmel_config(link); | ||
199 | |||
200 | return 0; | ||
201 | } /* atmel_attach */ | 185 | } /* atmel_attach */ |
202 | 186 | ||
203 | /*====================================================================== | 187 | /*====================================================================== |
@@ -209,17 +193,13 @@ static int atmel_attach(struct pcmcia_device *p_dev) | |||
209 | 193 | ||
210 | ======================================================================*/ | 194 | ======================================================================*/ |
211 | 195 | ||
212 | static void atmel_detach(struct pcmcia_device *p_dev) | 196 | static void atmel_detach(struct pcmcia_device *link) |
213 | { | 197 | { |
214 | dev_link_t *link = dev_to_instance(p_dev); | ||
215 | |||
216 | DEBUG(0, "atmel_detach(0x%p)\n", link); | 198 | DEBUG(0, "atmel_detach(0x%p)\n", link); |
217 | 199 | ||
218 | if (link->state & DEV_CONFIG) | 200 | atmel_release(link); |
219 | atmel_release(link); | ||
220 | 201 | ||
221 | kfree(link->priv); | 202 | kfree(link->priv); |
222 | kfree(link); | ||
223 | } | 203 | } |
224 | 204 | ||
225 | /*====================================================================== | 205 | /*====================================================================== |
@@ -236,19 +216,17 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | |||
236 | /* Call-back function to interrogate PCMCIA-specific information | 216 | /* Call-back function to interrogate PCMCIA-specific information |
237 | about the current existance of the card */ | 217 | about the current existance of the card */ |
238 | static int card_present(void *arg) | 218 | static int card_present(void *arg) |
239 | { | 219 | { |
240 | dev_link_t *link = (dev_link_t *)arg; | 220 | struct pcmcia_device *link = (struct pcmcia_device *)arg; |
241 | if (link->state & DEV_SUSPEND) | 221 | |
242 | return 0; | 222 | if (pcmcia_dev_present(link)) |
243 | else if (link->state & DEV_PRESENT) | ||
244 | return 1; | 223 | return 1; |
245 | 224 | ||
246 | return 0; | 225 | return 0; |
247 | } | 226 | } |
248 | 227 | ||
249 | static void atmel_config(dev_link_t *link) | 228 | static int atmel_config(struct pcmcia_device *link) |
250 | { | 229 | { |
251 | client_handle_t handle; | ||
252 | tuple_t tuple; | 230 | tuple_t tuple; |
253 | cisparse_t parse; | 231 | cisparse_t parse; |
254 | local_info_t *dev; | 232 | local_info_t *dev; |
@@ -256,9 +234,8 @@ static void atmel_config(dev_link_t *link) | |||
256 | u_char buf[64]; | 234 | u_char buf[64]; |
257 | struct pcmcia_device_id *did; | 235 | struct pcmcia_device_id *did; |
258 | 236 | ||
259 | handle = link->handle; | ||
260 | dev = link->priv; | 237 | dev = link->priv; |
261 | did = handle_to_dev(handle).driver_data; | 238 | did = handle_to_dev(link).driver_data; |
262 | 239 | ||
263 | DEBUG(0, "atmel_config(0x%p)\n", link); | 240 | DEBUG(0, "atmel_config(0x%p)\n", link); |
264 | 241 | ||
@@ -272,15 +249,12 @@ static void atmel_config(dev_link_t *link) | |||
272 | registers. | 249 | registers. |
273 | */ | 250 | */ |
274 | tuple.DesiredTuple = CISTPL_CONFIG; | 251 | tuple.DesiredTuple = CISTPL_CONFIG; |
275 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 252 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
276 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | 253 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
277 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); | 254 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); |
278 | link->conf.ConfigBase = parse.config.base; | 255 | link->conf.ConfigBase = parse.config.base; |
279 | link->conf.Present = parse.config.rmask[0]; | 256 | link->conf.Present = parse.config.rmask[0]; |
280 | 257 | ||
281 | /* Configure card */ | ||
282 | link->state |= DEV_CONFIG; | ||
283 | |||
284 | /* | 258 | /* |
285 | In this loop, we scan the CIS for configuration table entries, | 259 | In this loop, we scan the CIS for configuration table entries, |
286 | each of which describes a valid card configuration, including | 260 | each of which describes a valid card configuration, including |
@@ -294,12 +268,12 @@ static void atmel_config(dev_link_t *link) | |||
294 | will only use the CIS to fill in implementation-defined details. | 268 | will only use the CIS to fill in implementation-defined details. |
295 | */ | 269 | */ |
296 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 270 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
297 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 271 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
298 | while (1) { | 272 | while (1) { |
299 | cistpl_cftable_entry_t dflt = { 0 }; | 273 | cistpl_cftable_entry_t dflt = { 0 }; |
300 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | 274 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); |
301 | if (pcmcia_get_tuple_data(handle, &tuple) != 0 || | 275 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || |
302 | pcmcia_parse_tuple(handle, &tuple, &parse) != 0) | 276 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) |
303 | goto next_entry; | 277 | goto next_entry; |
304 | 278 | ||
305 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; | 279 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; |
@@ -314,16 +288,11 @@ static void atmel_config(dev_link_t *link) | |||
314 | 288 | ||
315 | /* Use power settings for Vcc and Vpp if present */ | 289 | /* Use power settings for Vcc and Vpp if present */ |
316 | /* Note that the CIS values need to be rescaled */ | 290 | /* Note that the CIS values need to be rescaled */ |
317 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) | ||
318 | link->conf.Vcc = cfg->vcc.param[CISTPL_POWER_VNOM]/10000; | ||
319 | else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) | ||
320 | link->conf.Vcc = dflt.vcc.param[CISTPL_POWER_VNOM]/10000; | ||
321 | |||
322 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | 291 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) |
323 | link->conf.Vpp1 = link->conf.Vpp2 = | 292 | link->conf.Vpp = |
324 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | 293 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; |
325 | else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) | 294 | else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) |
326 | link->conf.Vpp1 = link->conf.Vpp2 = | 295 | link->conf.Vpp = |
327 | dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; | 296 | dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; |
328 | 297 | ||
329 | /* Do we need to allocate an interrupt? */ | 298 | /* Do we need to allocate an interrupt? */ |
@@ -349,14 +318,14 @@ static void atmel_config(dev_link_t *link) | |||
349 | } | 318 | } |
350 | 319 | ||
351 | /* This reserves IO space but doesn't actually enable it */ | 320 | /* This reserves IO space but doesn't actually enable it */ |
352 | if (pcmcia_request_io(link->handle, &link->io) != 0) | 321 | if (pcmcia_request_io(link, &link->io) != 0) |
353 | goto next_entry; | 322 | goto next_entry; |
354 | 323 | ||
355 | /* If we got this far, we're cool! */ | 324 | /* If we got this far, we're cool! */ |
356 | break; | 325 | break; |
357 | 326 | ||
358 | next_entry: | 327 | next_entry: |
359 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); | 328 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); |
360 | } | 329 | } |
361 | 330 | ||
362 | /* | 331 | /* |
@@ -365,14 +334,14 @@ static void atmel_config(dev_link_t *link) | |||
365 | irq structure is initialized. | 334 | irq structure is initialized. |
366 | */ | 335 | */ |
367 | if (link->conf.Attributes & CONF_ENABLE_IRQ) | 336 | if (link->conf.Attributes & CONF_ENABLE_IRQ) |
368 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); | 337 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
369 | 338 | ||
370 | /* | 339 | /* |
371 | This actually configures the PCMCIA socket -- setting up | 340 | This actually configures the PCMCIA socket -- setting up |
372 | the I/O windows and the interrupt mapping, and putting the | 341 | the I/O windows and the interrupt mapping, and putting the |
373 | card and host interface into "Memory and IO" mode. | 342 | card and host interface into "Memory and IO" mode. |
374 | */ | 343 | */ |
375 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); | 344 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); |
376 | 345 | ||
377 | if (link->irq.AssignedIRQ == 0) { | 346 | if (link->irq.AssignedIRQ == 0) { |
378 | printk(KERN_ALERT | 347 | printk(KERN_ALERT |
@@ -384,7 +353,7 @@ static void atmel_config(dev_link_t *link) | |||
384 | init_atmel_card(link->irq.AssignedIRQ, | 353 | init_atmel_card(link->irq.AssignedIRQ, |
385 | link->io.BasePort1, | 354 | link->io.BasePort1, |
386 | did ? did->driver_info : ATMEL_FW_TYPE_NONE, | 355 | did ? did->driver_info : ATMEL_FW_TYPE_NONE, |
387 | &handle_to_dev(handle), | 356 | &handle_to_dev(link), |
388 | card_present, | 357 | card_present, |
389 | link); | 358 | link); |
390 | if (!((local_info_t*)link->priv)->eth_dev) | 359 | if (!((local_info_t*)link->priv)->eth_dev) |
@@ -393,18 +362,18 @@ static void atmel_config(dev_link_t *link) | |||
393 | 362 | ||
394 | /* | 363 | /* |
395 | At this point, the dev_node_t structure(s) need to be | 364 | At this point, the dev_node_t structure(s) need to be |
396 | initialized and arranged in a linked list at link->dev. | 365 | initialized and arranged in a linked list at link->dev_node. |
397 | */ | 366 | */ |
398 | strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); | 367 | strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); |
399 | dev->node.major = dev->node.minor = 0; | 368 | dev->node.major = dev->node.minor = 0; |
400 | link->dev = &dev->node; | 369 | link->dev_node = &dev->node; |
401 | 370 | ||
402 | link->state &= ~DEV_CONFIG_PENDING; | 371 | return 0; |
403 | return; | 372 | |
404 | |||
405 | cs_failed: | 373 | cs_failed: |
406 | cs_error(link->handle, last_fn, last_ret); | 374 | cs_error(link, last_fn, last_ret); |
407 | atmel_release(link); | 375 | atmel_release(link); |
376 | return -ENODEV; | ||
408 | } | 377 | } |
409 | 378 | ||
410 | /*====================================================================== | 379 | /*====================================================================== |
@@ -415,53 +384,34 @@ static void atmel_config(dev_link_t *link) | |||
415 | 384 | ||
416 | ======================================================================*/ | 385 | ======================================================================*/ |
417 | 386 | ||
418 | static void atmel_release(dev_link_t *link) | 387 | static void atmel_release(struct pcmcia_device *link) |
419 | { | 388 | { |
420 | struct net_device *dev = ((local_info_t*)link->priv)->eth_dev; | 389 | struct net_device *dev = ((local_info_t*)link->priv)->eth_dev; |
421 | 390 | ||
422 | DEBUG(0, "atmel_release(0x%p)\n", link); | 391 | DEBUG(0, "atmel_release(0x%p)\n", link); |
423 | 392 | ||
424 | /* Unlink the device chain */ | 393 | if (dev) |
425 | link->dev = NULL; | ||
426 | |||
427 | if (dev) | ||
428 | stop_atmel_card(dev); | 394 | stop_atmel_card(dev); |
429 | ((local_info_t*)link->priv)->eth_dev = NULL; | 395 | ((local_info_t*)link->priv)->eth_dev = NULL; |
430 | 396 | ||
431 | /* Don't bother checking to see if these succeed or not */ | 397 | pcmcia_disable_device(link); |
432 | pcmcia_release_configuration(link->handle); | ||
433 | if (link->io.NumPorts1) | ||
434 | pcmcia_release_io(link->handle, &link->io); | ||
435 | if (link->irq.AssignedIRQ) | ||
436 | pcmcia_release_irq(link->handle, &link->irq); | ||
437 | link->state &= ~DEV_CONFIG; | ||
438 | } | 398 | } |
439 | 399 | ||
440 | static int atmel_suspend(struct pcmcia_device *dev) | 400 | static int atmel_suspend(struct pcmcia_device *link) |
441 | { | 401 | { |
442 | dev_link_t *link = dev_to_instance(dev); | ||
443 | local_info_t *local = link->priv; | 402 | local_info_t *local = link->priv; |
444 | 403 | ||
445 | link->state |= DEV_SUSPEND; | 404 | netif_device_detach(local->eth_dev); |
446 | if (link->state & DEV_CONFIG) { | ||
447 | netif_device_detach(local->eth_dev); | ||
448 | pcmcia_release_configuration(link->handle); | ||
449 | } | ||
450 | 405 | ||
451 | return 0; | 406 | return 0; |
452 | } | 407 | } |
453 | 408 | ||
454 | static int atmel_resume(struct pcmcia_device *dev) | 409 | static int atmel_resume(struct pcmcia_device *link) |
455 | { | 410 | { |
456 | dev_link_t *link = dev_to_instance(dev); | ||
457 | local_info_t *local = link->priv; | 411 | local_info_t *local = link->priv; |
458 | 412 | ||
459 | link->state &= ~DEV_SUSPEND; | 413 | atmel_open(local->eth_dev); |
460 | if (link->state & DEV_CONFIG) { | 414 | netif_device_attach(local->eth_dev); |
461 | pcmcia_request_configuration(link->handle, &link->conf); | ||
462 | atmel_open(local->eth_dev); | ||
463 | netif_device_attach(local->eth_dev); | ||
464 | } | ||
465 | 415 | ||
466 | return 0; | 416 | return 0; |
467 | } | 417 | } |
@@ -515,7 +465,7 @@ static struct pcmcia_driver atmel_driver = { | |||
515 | .drv = { | 465 | .drv = { |
516 | .name = "atmel_cs", | 466 | .name = "atmel_cs", |
517 | }, | 467 | }, |
518 | .probe = atmel_attach, | 468 | .probe = atmel_probe, |
519 | .remove = atmel_detach, | 469 | .remove = atmel_detach, |
520 | .id_table = atmel_ids, | 470 | .id_table = atmel_ids, |
521 | .suspend = atmel_suspend, | 471 | .suspend = atmel_suspend, |
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index d335b250923a..55bed923fbe9 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c | |||
@@ -42,7 +42,7 @@ MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry"); | |||
42 | /* struct local_info::hw_priv */ | 42 | /* struct local_info::hw_priv */ |
43 | struct hostap_cs_priv { | 43 | struct hostap_cs_priv { |
44 | dev_node_t node; | 44 | dev_node_t node; |
45 | dev_link_t *link; | 45 | struct pcmcia_device *link; |
46 | int sandisk_connectplus; | 46 | int sandisk_connectplus; |
47 | }; | 47 | }; |
48 | 48 | ||
@@ -204,15 +204,13 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len) | |||
204 | 204 | ||
205 | static void prism2_detach(struct pcmcia_device *p_dev); | 205 | static void prism2_detach(struct pcmcia_device *p_dev); |
206 | static void prism2_release(u_long arg); | 206 | static void prism2_release(u_long arg); |
207 | static int prism2_config(dev_link_t *link); | 207 | static int prism2_config(struct pcmcia_device *link); |
208 | 208 | ||
209 | 209 | ||
210 | static int prism2_pccard_card_present(local_info_t *local) | 210 | static int prism2_pccard_card_present(local_info_t *local) |
211 | { | 211 | { |
212 | struct hostap_cs_priv *hw_priv = local->hw_priv; | 212 | struct hostap_cs_priv *hw_priv = local->hw_priv; |
213 | if (hw_priv != NULL && hw_priv->link != NULL && | 213 | if (hw_priv != NULL && hw_priv->link != NULL && pcmcia_dev_present(hw_priv->link)) |
214 | ((hw_priv->link->state & (DEV_PRESENT | DEV_CONFIG)) == | ||
215 | (DEV_PRESENT | DEV_CONFIG))) | ||
216 | return 1; | 214 | return 1; |
217 | return 0; | 215 | return 0; |
218 | } | 216 | } |
@@ -237,7 +235,7 @@ static void sandisk_set_iobase(local_info_t *local) | |||
237 | reg.Action = CS_WRITE; | 235 | reg.Action = CS_WRITE; |
238 | reg.Offset = 0x10; /* 0x3f0 IO base 1 */ | 236 | reg.Offset = 0x10; /* 0x3f0 IO base 1 */ |
239 | reg.Value = hw_priv->link->io.BasePort1 & 0x00ff; | 237 | reg.Value = hw_priv->link->io.BasePort1 & 0x00ff; |
240 | res = pcmcia_access_configuration_register(hw_priv->link->handle, | 238 | res = pcmcia_access_configuration_register(hw_priv->link, |
241 | ®); | 239 | ®); |
242 | if (res != CS_SUCCESS) { | 240 | if (res != CS_SUCCESS) { |
243 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -" | 241 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -" |
@@ -249,7 +247,7 @@ static void sandisk_set_iobase(local_info_t *local) | |||
249 | reg.Action = CS_WRITE; | 247 | reg.Action = CS_WRITE; |
250 | reg.Offset = 0x12; /* 0x3f2 IO base 2 */ | 248 | reg.Offset = 0x12; /* 0x3f2 IO base 2 */ |
251 | reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8; | 249 | reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8; |
252 | res = pcmcia_access_configuration_register(hw_priv->link->handle, | 250 | res = pcmcia_access_configuration_register(hw_priv->link, |
253 | ®); | 251 | ®); |
254 | if (res != CS_SUCCESS) { | 252 | if (res != CS_SUCCESS) { |
255 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -" | 253 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -" |
@@ -301,9 +299,9 @@ static int sandisk_enable_wireless(struct net_device *dev) | |||
301 | tuple.TupleData = buf; | 299 | tuple.TupleData = buf; |
302 | tuple.TupleDataMax = sizeof(buf); | 300 | tuple.TupleDataMax = sizeof(buf); |
303 | tuple.TupleOffset = 0; | 301 | tuple.TupleOffset = 0; |
304 | if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) || | 302 | if (pcmcia_get_first_tuple(hw_priv->link, &tuple) || |
305 | pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) || | 303 | pcmcia_get_tuple_data(hw_priv->link, &tuple) || |
306 | pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) || | 304 | pcmcia_parse_tuple(hw_priv->link, &tuple, parse) || |
307 | parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) { | 305 | parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) { |
308 | /* No SanDisk manfid found */ | 306 | /* No SanDisk manfid found */ |
309 | ret = -ENODEV; | 307 | ret = -ENODEV; |
@@ -311,9 +309,9 @@ static int sandisk_enable_wireless(struct net_device *dev) | |||
311 | } | 309 | } |
312 | 310 | ||
313 | tuple.DesiredTuple = CISTPL_LONGLINK_MFC; | 311 | tuple.DesiredTuple = CISTPL_LONGLINK_MFC; |
314 | if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) || | 312 | if (pcmcia_get_first_tuple(hw_priv->link, &tuple) || |
315 | pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) || | 313 | pcmcia_get_tuple_data(hw_priv->link, &tuple) || |
316 | pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) || | 314 | pcmcia_parse_tuple(hw_priv->link, &tuple, parse) || |
317 | parse->longlink_mfc.nfn < 2) { | 315 | parse->longlink_mfc.nfn < 2) { |
318 | /* No multi-function links found */ | 316 | /* No multi-function links found */ |
319 | ret = -ENODEV; | 317 | ret = -ENODEV; |
@@ -328,7 +326,7 @@ static int sandisk_enable_wireless(struct net_device *dev) | |||
328 | reg.Action = CS_WRITE; | 326 | reg.Action = CS_WRITE; |
329 | reg.Offset = CISREG_COR; | 327 | reg.Offset = CISREG_COR; |
330 | reg.Value = COR_SOFT_RESET; | 328 | reg.Value = COR_SOFT_RESET; |
331 | res = pcmcia_access_configuration_register(hw_priv->link->handle, | 329 | res = pcmcia_access_configuration_register(hw_priv->link, |
332 | ®); | 330 | ®); |
333 | if (res != CS_SUCCESS) { | 331 | if (res != CS_SUCCESS) { |
334 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", | 332 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", |
@@ -345,7 +343,7 @@ static int sandisk_enable_wireless(struct net_device *dev) | |||
345 | * will be enabled during the first cor_sreset call. | 343 | * will be enabled during the first cor_sreset call. |
346 | */ | 344 | */ |
347 | reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA; | 345 | reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA; |
348 | res = pcmcia_access_configuration_register(hw_priv->link->handle, | 346 | res = pcmcia_access_configuration_register(hw_priv->link, |
349 | ®); | 347 | ®); |
350 | if (res != CS_SUCCESS) { | 348 | if (res != CS_SUCCESS) { |
351 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", | 349 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", |
@@ -380,7 +378,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local) | |||
380 | reg.Action = CS_READ; | 378 | reg.Action = CS_READ; |
381 | reg.Offset = CISREG_COR; | 379 | reg.Offset = CISREG_COR; |
382 | reg.Value = 0; | 380 | reg.Value = 0; |
383 | res = pcmcia_access_configuration_register(hw_priv->link->handle, | 381 | res = pcmcia_access_configuration_register(hw_priv->link, |
384 | ®); | 382 | ®); |
385 | if (res != CS_SUCCESS) { | 383 | if (res != CS_SUCCESS) { |
386 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n", | 384 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n", |
@@ -392,7 +390,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local) | |||
392 | 390 | ||
393 | reg.Action = CS_WRITE; | 391 | reg.Action = CS_WRITE; |
394 | reg.Value |= COR_SOFT_RESET; | 392 | reg.Value |= COR_SOFT_RESET; |
395 | res = pcmcia_access_configuration_register(hw_priv->link->handle, | 393 | res = pcmcia_access_configuration_register(hw_priv->link, |
396 | ®); | 394 | ®); |
397 | if (res != CS_SUCCESS) { | 395 | if (res != CS_SUCCESS) { |
398 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n", | 396 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n", |
@@ -405,7 +403,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local) | |||
405 | reg.Value &= ~COR_SOFT_RESET; | 403 | reg.Value &= ~COR_SOFT_RESET; |
406 | if (hw_priv->sandisk_connectplus) | 404 | if (hw_priv->sandisk_connectplus) |
407 | reg.Value |= COR_IREQ_ENA; | 405 | reg.Value |= COR_IREQ_ENA; |
408 | res = pcmcia_access_configuration_register(hw_priv->link->handle, | 406 | res = pcmcia_access_configuration_register(hw_priv->link, |
409 | ®); | 407 | ®); |
410 | if (res != CS_SUCCESS) { | 408 | if (res != CS_SUCCESS) { |
411 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n", | 409 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n", |
@@ -439,7 +437,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) | |||
439 | reg.Action = CS_READ; | 437 | reg.Action = CS_READ; |
440 | reg.Offset = CISREG_COR; | 438 | reg.Offset = CISREG_COR; |
441 | reg.Value = 0; | 439 | reg.Value = 0; |
442 | res = pcmcia_access_configuration_register(hw_priv->link->handle, | 440 | res = pcmcia_access_configuration_register(hw_priv->link, |
443 | ®); | 441 | ®); |
444 | if (res != CS_SUCCESS) { | 442 | if (res != CS_SUCCESS) { |
445 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 " | 443 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 " |
@@ -452,7 +450,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) | |||
452 | 450 | ||
453 | reg.Action = CS_WRITE; | 451 | reg.Action = CS_WRITE; |
454 | reg.Value |= COR_SOFT_RESET; | 452 | reg.Value |= COR_SOFT_RESET; |
455 | res = pcmcia_access_configuration_register(hw_priv->link->handle, | 453 | res = pcmcia_access_configuration_register(hw_priv->link, |
456 | ®); | 454 | ®); |
457 | if (res != CS_SUCCESS) { | 455 | if (res != CS_SUCCESS) { |
458 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 " | 456 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 " |
@@ -466,7 +464,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) | |||
466 | reg.Action = CS_WRITE; | 464 | reg.Action = CS_WRITE; |
467 | reg.Value = hcr; | 465 | reg.Value = hcr; |
468 | reg.Offset = CISREG_CCSR; | 466 | reg.Offset = CISREG_CCSR; |
469 | res = pcmcia_access_configuration_register(hw_priv->link->handle, | 467 | res = pcmcia_access_configuration_register(hw_priv->link, |
470 | ®); | 468 | ®); |
471 | if (res != CS_SUCCESS) { | 469 | if (res != CS_SUCCESS) { |
472 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 " | 470 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 " |
@@ -478,7 +476,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) | |||
478 | reg.Action = CS_WRITE; | 476 | reg.Action = CS_WRITE; |
479 | reg.Offset = CISREG_COR; | 477 | reg.Offset = CISREG_COR; |
480 | reg.Value = old_cor & ~COR_SOFT_RESET; | 478 | reg.Value = old_cor & ~COR_SOFT_RESET; |
481 | res = pcmcia_access_configuration_register(hw_priv->link->handle, | 479 | res = pcmcia_access_configuration_register(hw_priv->link, |
482 | ®); | 480 | ®); |
483 | if (res != CS_SUCCESS) { | 481 | if (res != CS_SUCCESS) { |
484 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 " | 482 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 " |
@@ -501,40 +499,27 @@ static struct prism2_helper_functions prism2_pccard_funcs = | |||
501 | 499 | ||
502 | /* allocate local data and register with CardServices | 500 | /* allocate local data and register with CardServices |
503 | * initialize dev_link structure, but do not configure the card yet */ | 501 | * initialize dev_link structure, but do not configure the card yet */ |
504 | static int prism2_attach(struct pcmcia_device *p_dev) | 502 | static int hostap_cs_probe(struct pcmcia_device *p_dev) |
505 | { | 503 | { |
506 | dev_link_t *link; | 504 | int ret; |
507 | |||
508 | link = kmalloc(sizeof(dev_link_t), GFP_KERNEL); | ||
509 | if (link == NULL) | ||
510 | return -ENOMEM; | ||
511 | |||
512 | memset(link, 0, sizeof(dev_link_t)); | ||
513 | 505 | ||
514 | PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info); | 506 | PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info); |
515 | link->conf.Vcc = 33; | 507 | p_dev->conf.IntType = INT_MEMORY_AND_IO; |
516 | link->conf.IntType = INT_MEMORY_AND_IO; | ||
517 | |||
518 | link->handle = p_dev; | ||
519 | p_dev->instance = link; | ||
520 | 508 | ||
521 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | 509 | ret = prism2_config(p_dev); |
522 | if (prism2_config(link)) | 510 | if (ret) { |
523 | PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n"); | 511 | PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n"); |
512 | } | ||
524 | 513 | ||
525 | return 0; | 514 | return ret; |
526 | } | 515 | } |
527 | 516 | ||
528 | 517 | ||
529 | static void prism2_detach(struct pcmcia_device *p_dev) | 518 | static void prism2_detach(struct pcmcia_device *link) |
530 | { | 519 | { |
531 | dev_link_t *link = dev_to_instance(p_dev); | ||
532 | |||
533 | PDEBUG(DEBUG_FLOW, "prism2_detach\n"); | 520 | PDEBUG(DEBUG_FLOW, "prism2_detach\n"); |
534 | 521 | ||
535 | if (link->state & DEV_CONFIG) { | 522 | prism2_release((u_long)link); |
536 | prism2_release((u_long)link); | ||
537 | } | ||
538 | 523 | ||
539 | /* release net devices */ | 524 | /* release net devices */ |
540 | if (link->priv) { | 525 | if (link->priv) { |
@@ -547,7 +532,6 @@ static void prism2_detach(struct pcmcia_device *p_dev) | |||
547 | prism2_free_local_data(dev); | 532 | prism2_free_local_data(dev); |
548 | kfree(hw_priv); | 533 | kfree(hw_priv); |
549 | } | 534 | } |
550 | kfree(link); | ||
551 | } | 535 | } |
552 | 536 | ||
553 | 537 | ||
@@ -558,7 +542,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | |||
558 | do { int ret = (retf); \ | 542 | do { int ret = (retf); \ |
559 | if (ret != 0) { \ | 543 | if (ret != 0) { \ |
560 | PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", ret); \ | 544 | PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", ret); \ |
561 | cs_error(link->handle, fn, ret); \ | 545 | cs_error(link, fn, ret); \ |
562 | goto next_entry; \ | 546 | goto next_entry; \ |
563 | } \ | 547 | } \ |
564 | } while (0) | 548 | } while (0) |
@@ -566,7 +550,7 @@ if (ret != 0) { \ | |||
566 | 550 | ||
567 | /* run after a CARD_INSERTION event is received to configure the PCMCIA | 551 | /* run after a CARD_INSERTION event is received to configure the PCMCIA |
568 | * socket and make the device available to the system */ | 552 | * socket and make the device available to the system */ |
569 | static int prism2_config(dev_link_t *link) | 553 | static int prism2_config(struct pcmcia_device *link) |
570 | { | 554 | { |
571 | struct net_device *dev; | 555 | struct net_device *dev; |
572 | struct hostap_interface *iface; | 556 | struct hostap_interface *iface; |
@@ -595,27 +579,24 @@ static int prism2_config(dev_link_t *link) | |||
595 | tuple.TupleData = buf; | 579 | tuple.TupleData = buf; |
596 | tuple.TupleDataMax = sizeof(buf); | 580 | tuple.TupleDataMax = sizeof(buf); |
597 | tuple.TupleOffset = 0; | 581 | tuple.TupleOffset = 0; |
598 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple)); | 582 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
599 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link->handle, &tuple)); | 583 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
600 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link->handle, &tuple, parse)); | 584 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse)); |
601 | link->conf.ConfigBase = parse->config.base; | 585 | link->conf.ConfigBase = parse->config.base; |
602 | link->conf.Present = parse->config.rmask[0]; | 586 | link->conf.Present = parse->config.rmask[0]; |
603 | 587 | ||
604 | CS_CHECK(GetConfigurationInfo, | 588 | CS_CHECK(GetConfigurationInfo, |
605 | pcmcia_get_configuration_info(link->handle, &conf)); | 589 | pcmcia_get_configuration_info(link, &conf)); |
606 | PDEBUG(DEBUG_HW, "%s: %s Vcc=%d (from config)\n", dev_info, | ||
607 | ignore_cis_vcc ? "ignoring" : "setting", conf.Vcc); | ||
608 | link->conf.Vcc = conf.Vcc; | ||
609 | 590 | ||
610 | /* Look for an appropriate configuration table entry in the CIS */ | 591 | /* Look for an appropriate configuration table entry in the CIS */ |
611 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 592 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
612 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple)); | 593 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
613 | for (;;) { | 594 | for (;;) { |
614 | cistpl_cftable_entry_t *cfg = &(parse->cftable_entry); | 595 | cistpl_cftable_entry_t *cfg = &(parse->cftable_entry); |
615 | CFG_CHECK2(GetTupleData, | 596 | CFG_CHECK2(GetTupleData, |
616 | pcmcia_get_tuple_data(link->handle, &tuple)); | 597 | pcmcia_get_tuple_data(link, &tuple)); |
617 | CFG_CHECK2(ParseTuple, | 598 | CFG_CHECK2(ParseTuple, |
618 | pcmcia_parse_tuple(link->handle, &tuple, parse)); | 599 | pcmcia_parse_tuple(link, &tuple, parse)); |
619 | 600 | ||
620 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | 601 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) |
621 | dflt = *cfg; | 602 | dflt = *cfg; |
@@ -650,10 +631,10 @@ static int prism2_config(dev_link_t *link) | |||
650 | } | 631 | } |
651 | 632 | ||
652 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | 633 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) |
653 | link->conf.Vpp1 = link->conf.Vpp2 = | 634 | link->conf.Vpp = |
654 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | 635 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; |
655 | else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) | 636 | else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) |
656 | link->conf.Vpp1 = link->conf.Vpp2 = | 637 | link->conf.Vpp = |
657 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | 638 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; |
658 | 639 | ||
659 | /* Do we need to allocate an interrupt? */ | 640 | /* Do we need to allocate an interrupt? */ |
@@ -695,19 +676,19 @@ static int prism2_config(dev_link_t *link) | |||
695 | 676 | ||
696 | /* This reserves IO space but doesn't actually enable it */ | 677 | /* This reserves IO space but doesn't actually enable it */ |
697 | CFG_CHECK2(RequestIO, | 678 | CFG_CHECK2(RequestIO, |
698 | pcmcia_request_io(link->handle, &link->io)); | 679 | pcmcia_request_io(link, &link->io)); |
699 | 680 | ||
700 | /* This configuration table entry is OK */ | 681 | /* This configuration table entry is OK */ |
701 | break; | 682 | break; |
702 | 683 | ||
703 | next_entry: | 684 | next_entry: |
704 | CS_CHECK(GetNextTuple, | 685 | CS_CHECK(GetNextTuple, |
705 | pcmcia_get_next_tuple(link->handle, &tuple)); | 686 | pcmcia_get_next_tuple(link, &tuple)); |
706 | } | 687 | } |
707 | 688 | ||
708 | /* Need to allocate net_device before requesting IRQ handler */ | 689 | /* Need to allocate net_device before requesting IRQ handler */ |
709 | dev = prism2_init_local_data(&prism2_pccard_funcs, 0, | 690 | dev = prism2_init_local_data(&prism2_pccard_funcs, 0, |
710 | &handle_to_dev(link->handle)); | 691 | &handle_to_dev(link)); |
711 | if (dev == NULL) | 692 | if (dev == NULL) |
712 | goto failed; | 693 | goto failed; |
713 | link->priv = dev; | 694 | link->priv = dev; |
@@ -717,7 +698,7 @@ static int prism2_config(dev_link_t *link) | |||
717 | local->hw_priv = hw_priv; | 698 | local->hw_priv = hw_priv; |
718 | hw_priv->link = link; | 699 | hw_priv->link = link; |
719 | strcpy(hw_priv->node.dev_name, dev->name); | 700 | strcpy(hw_priv->node.dev_name, dev->name); |
720 | link->dev = &hw_priv->node; | 701 | link->dev_node = &hw_priv->node; |
721 | 702 | ||
722 | /* | 703 | /* |
723 | * Allocate an interrupt line. Note that this does not assign a | 704 | * Allocate an interrupt line. Note that this does not assign a |
@@ -730,7 +711,7 @@ static int prism2_config(dev_link_t *link) | |||
730 | link->irq.Handler = prism2_interrupt; | 711 | link->irq.Handler = prism2_interrupt; |
731 | link->irq.Instance = dev; | 712 | link->irq.Instance = dev; |
732 | CS_CHECK(RequestIRQ, | 713 | CS_CHECK(RequestIRQ, |
733 | pcmcia_request_irq(link->handle, &link->irq)); | 714 | pcmcia_request_irq(link, &link->irq)); |
734 | } | 715 | } |
735 | 716 | ||
736 | /* | 717 | /* |
@@ -739,18 +720,17 @@ static int prism2_config(dev_link_t *link) | |||
739 | * card and host interface into "Memory and IO" mode. | 720 | * card and host interface into "Memory and IO" mode. |
740 | */ | 721 | */ |
741 | CS_CHECK(RequestConfiguration, | 722 | CS_CHECK(RequestConfiguration, |
742 | pcmcia_request_configuration(link->handle, &link->conf)); | 723 | pcmcia_request_configuration(link, &link->conf)); |
743 | 724 | ||
744 | dev->irq = link->irq.AssignedIRQ; | 725 | dev->irq = link->irq.AssignedIRQ; |
745 | dev->base_addr = link->io.BasePort1; | 726 | dev->base_addr = link->io.BasePort1; |
746 | 727 | ||
747 | /* Finally, report what we've done */ | 728 | /* Finally, report what we've done */ |
748 | printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", | 729 | printk(KERN_INFO "%s: index 0x%02x: ", |
749 | dev_info, link->conf.ConfigIndex, | 730 | dev_info, link->conf.ConfigIndex); |
750 | link->conf.Vcc / 10, link->conf.Vcc % 10); | 731 | if (link->conf.Vpp) |
751 | if (link->conf.Vpp1) | 732 | printk(", Vpp %d.%d", link->conf.Vpp / 10, |
752 | printk(", Vpp %d.%d", link->conf.Vpp1 / 10, | 733 | link->conf.Vpp % 10); |
753 | link->conf.Vpp1 % 10); | ||
754 | if (link->conf.Attributes & CONF_ENABLE_IRQ) | 734 | if (link->conf.Attributes & CONF_ENABLE_IRQ) |
755 | printk(", irq %d", link->irq.AssignedIRQ); | 735 | printk(", irq %d", link->irq.AssignedIRQ); |
756 | if (link->io.NumPorts1) | 736 | if (link->io.NumPorts1) |
@@ -761,9 +741,6 @@ static int prism2_config(dev_link_t *link) | |||
761 | link->io.BasePort2+link->io.NumPorts2-1); | 741 | link->io.BasePort2+link->io.NumPorts2-1); |
762 | printk("\n"); | 742 | printk("\n"); |
763 | 743 | ||
764 | link->state |= DEV_CONFIG; | ||
765 | link->state &= ~DEV_CONFIG_PENDING; | ||
766 | |||
767 | local->shutdown = 0; | 744 | local->shutdown = 0; |
768 | 745 | ||
769 | sandisk_enable_wireless(dev); | 746 | sandisk_enable_wireless(dev); |
@@ -778,7 +755,7 @@ static int prism2_config(dev_link_t *link) | |||
778 | return ret; | 755 | return ret; |
779 | 756 | ||
780 | cs_failed: | 757 | cs_failed: |
781 | cs_error(link->handle, last_fn, last_ret); | 758 | cs_error(link, last_fn, last_ret); |
782 | 759 | ||
783 | failed: | 760 | failed: |
784 | kfree(parse); | 761 | kfree(parse); |
@@ -790,7 +767,7 @@ static int prism2_config(dev_link_t *link) | |||
790 | 767 | ||
791 | static void prism2_release(u_long arg) | 768 | static void prism2_release(u_long arg) |
792 | { | 769 | { |
793 | dev_link_t *link = (dev_link_t *)arg; | 770 | struct pcmcia_device *link = (struct pcmcia_device *)arg; |
794 | 771 | ||
795 | PDEBUG(DEBUG_FLOW, "prism2_release\n"); | 772 | PDEBUG(DEBUG_FLOW, "prism2_release\n"); |
796 | 773 | ||
@@ -799,71 +776,54 @@ static void prism2_release(u_long arg) | |||
799 | struct hostap_interface *iface; | 776 | struct hostap_interface *iface; |
800 | 777 | ||
801 | iface = netdev_priv(dev); | 778 | iface = netdev_priv(dev); |
802 | if (link->state & DEV_CONFIG) | 779 | prism2_hw_shutdown(dev, 0); |
803 | prism2_hw_shutdown(dev, 0); | ||
804 | iface->local->shutdown = 1; | 780 | iface->local->shutdown = 1; |
805 | } | 781 | } |
806 | 782 | ||
807 | if (link->win) | 783 | pcmcia_disable_device(link); |
808 | pcmcia_release_window(link->win); | ||
809 | pcmcia_release_configuration(link->handle); | ||
810 | if (link->io.NumPorts1) | ||
811 | pcmcia_release_io(link->handle, &link->io); | ||
812 | if (link->irq.AssignedIRQ) | ||
813 | pcmcia_release_irq(link->handle, &link->irq); | ||
814 | |||
815 | link->state &= ~DEV_CONFIG; | ||
816 | |||
817 | PDEBUG(DEBUG_FLOW, "release - done\n"); | 784 | PDEBUG(DEBUG_FLOW, "release - done\n"); |
818 | } | 785 | } |
819 | 786 | ||
820 | static int hostap_cs_suspend(struct pcmcia_device *p_dev) | 787 | static int hostap_cs_suspend(struct pcmcia_device *link) |
821 | { | 788 | { |
822 | dev_link_t *link = dev_to_instance(p_dev); | ||
823 | struct net_device *dev = (struct net_device *) link->priv; | 789 | struct net_device *dev = (struct net_device *) link->priv; |
824 | int dev_open = 0; | 790 | int dev_open = 0; |
791 | struct hostap_interface *iface = NULL; | ||
825 | 792 | ||
826 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); | 793 | if (dev) |
827 | 794 | iface = netdev_priv(dev); | |
828 | link->state |= DEV_SUSPEND; | ||
829 | 795 | ||
830 | if (link->state & DEV_CONFIG) { | 796 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); |
831 | struct hostap_interface *iface = netdev_priv(dev); | 797 | if (iface && iface->local) |
832 | if (iface && iface->local) | 798 | dev_open = iface->local->num_dev_open > 0; |
833 | dev_open = iface->local->num_dev_open > 0; | 799 | if (dev_open) { |
834 | if (dev_open) { | 800 | netif_stop_queue(dev); |
835 | netif_stop_queue(dev); | 801 | netif_device_detach(dev); |
836 | netif_device_detach(dev); | ||
837 | } | ||
838 | prism2_suspend(dev); | ||
839 | pcmcia_release_configuration(link->handle); | ||
840 | } | 802 | } |
803 | prism2_suspend(dev); | ||
841 | 804 | ||
842 | return 0; | 805 | return 0; |
843 | } | 806 | } |
844 | 807 | ||
845 | static int hostap_cs_resume(struct pcmcia_device *p_dev) | 808 | static int hostap_cs_resume(struct pcmcia_device *link) |
846 | { | 809 | { |
847 | dev_link_t *link = dev_to_instance(p_dev); | ||
848 | struct net_device *dev = (struct net_device *) link->priv; | 810 | struct net_device *dev = (struct net_device *) link->priv; |
849 | int dev_open = 0; | 811 | int dev_open = 0; |
812 | struct hostap_interface *iface = NULL; | ||
850 | 813 | ||
851 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); | 814 | if (dev) |
815 | iface = netdev_priv(dev); | ||
852 | 816 | ||
853 | link->state &= ~DEV_SUSPEND; | 817 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); |
854 | if (link->state & DEV_CONFIG) { | ||
855 | struct hostap_interface *iface = netdev_priv(dev); | ||
856 | if (iface && iface->local) | ||
857 | dev_open = iface->local->num_dev_open > 0; | ||
858 | 818 | ||
859 | pcmcia_request_configuration(link->handle, &link->conf); | 819 | if (iface && iface->local) |
820 | dev_open = iface->local->num_dev_open > 0; | ||
860 | 821 | ||
861 | prism2_hw_shutdown(dev, 1); | 822 | prism2_hw_shutdown(dev, 1); |
862 | prism2_hw_config(dev, dev_open ? 0 : 1); | 823 | prism2_hw_config(dev, dev_open ? 0 : 1); |
863 | if (dev_open) { | 824 | if (dev_open) { |
864 | netif_device_attach(dev); | 825 | netif_device_attach(dev); |
865 | netif_start_queue(dev); | 826 | netif_start_queue(dev); |
866 | } | ||
867 | } | 827 | } |
868 | 828 | ||
869 | return 0; | 829 | return 0; |
@@ -930,7 +890,7 @@ static struct pcmcia_driver hostap_driver = { | |||
930 | .drv = { | 890 | .drv = { |
931 | .name = "hostap_cs", | 891 | .name = "hostap_cs", |
932 | }, | 892 | }, |
933 | .probe = prism2_attach, | 893 | .probe = hostap_cs_probe, |
934 | .remove = prism2_detach, | 894 | .remove = prism2_detach, |
935 | .owner = THIS_MODULE, | 895 | .owner = THIS_MODULE, |
936 | .id_table = hostap_cs_ids, | 896 | .id_table = hostap_cs_ids, |
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index 75ce6ddb0cf5..9343d970537b 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c | |||
@@ -190,8 +190,8 @@ module_param(mem_speed, int, 0); | |||
190 | /*====================================================================*/ | 190 | /*====================================================================*/ |
191 | 191 | ||
192 | /* PCMCIA (Card Services) related functions */ | 192 | /* PCMCIA (Card Services) related functions */ |
193 | static void netwave_release(dev_link_t *link); /* Card removal */ | 193 | static void netwave_release(struct pcmcia_device *link); /* Card removal */ |
194 | static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card | 194 | static int netwave_pcmcia_config(struct pcmcia_device *arg); /* Runs after card |
195 | insertion */ | 195 | insertion */ |
196 | static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */ | 196 | static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */ |
197 | 197 | ||
@@ -221,10 +221,10 @@ static struct iw_statistics* netwave_get_wireless_stats(struct net_device *dev); | |||
221 | static void set_multicast_list(struct net_device *dev); | 221 | static void set_multicast_list(struct net_device *dev); |
222 | 222 | ||
223 | /* | 223 | /* |
224 | A dev_link_t structure has fields for most things that are needed | 224 | A struct pcmcia_device structure has fields for most things that are needed |
225 | to keep track of a socket, but there will usually be some device | 225 | to keep track of a socket, but there will usually be some device |
226 | specific information that also needs to be kept track of. The | 226 | specific information that also needs to be kept track of. The |
227 | 'priv' pointer in a dev_link_t structure can be used to point to | 227 | 'priv' pointer in a struct pcmcia_device structure can be used to point to |
228 | a device-specific private data structure, like this. | 228 | a device-specific private data structure, like this. |
229 | 229 | ||
230 | A driver needs to provide a dev_node_t structure for each device | 230 | A driver needs to provide a dev_node_t structure for each device |
@@ -232,7 +232,7 @@ static void set_multicast_list(struct net_device *dev); | |||
232 | example, ethernet cards, modems). In other cases, there may be | 232 | example, ethernet cards, modems). In other cases, there may be |
233 | many actual or logical devices (SCSI adapters, memory cards with | 233 | many actual or logical devices (SCSI adapters, memory cards with |
234 | multiple partitions). The dev_node_t structures need to be kept | 234 | multiple partitions). The dev_node_t structures need to be kept |
235 | in a linked list starting at the 'dev' field of a dev_link_t | 235 | in a linked list starting at the 'dev' field of a struct pcmcia_device |
236 | structure. We allocate them in the card's private data structure, | 236 | structure. We allocate them in the card's private data structure, |
237 | because they generally can't be allocated dynamically. | 237 | because they generally can't be allocated dynamically. |
238 | */ | 238 | */ |
@@ -268,7 +268,7 @@ struct site_survey { | |||
268 | }; | 268 | }; |
269 | 269 | ||
270 | typedef struct netwave_private { | 270 | typedef struct netwave_private { |
271 | dev_link_t link; | 271 | struct pcmcia_device *p_dev; |
272 | spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ | 272 | spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ |
273 | dev_node_t node; | 273 | dev_node_t node; |
274 | u_char __iomem *ramBase; | 274 | u_char __iomem *ramBase; |
@@ -376,20 +376,19 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev) | |||
376 | * configure the card at this point -- we wait until we receive a | 376 | * configure the card at this point -- we wait until we receive a |
377 | * card insertion event. | 377 | * card insertion event. |
378 | */ | 378 | */ |
379 | static int netwave_attach(struct pcmcia_device *p_dev) | 379 | static int netwave_probe(struct pcmcia_device *link) |
380 | { | 380 | { |
381 | dev_link_t *link; | ||
382 | struct net_device *dev; | 381 | struct net_device *dev; |
383 | netwave_private *priv; | 382 | netwave_private *priv; |
384 | 383 | ||
385 | DEBUG(0, "netwave_attach()\n"); | 384 | DEBUG(0, "netwave_attach()\n"); |
386 | 385 | ||
387 | /* Initialize the dev_link_t structure */ | 386 | /* Initialize the struct pcmcia_device structure */ |
388 | dev = alloc_etherdev(sizeof(netwave_private)); | 387 | dev = alloc_etherdev(sizeof(netwave_private)); |
389 | if (!dev) | 388 | if (!dev) |
390 | return -ENOMEM; | 389 | return -ENOMEM; |
391 | priv = netdev_priv(dev); | 390 | priv = netdev_priv(dev); |
392 | link = &priv->link; | 391 | priv->p_dev = link; |
393 | link->priv = dev; | 392 | link->priv = dev; |
394 | 393 | ||
395 | /* The io structure describes IO port mapping */ | 394 | /* The io structure describes IO port mapping */ |
@@ -406,7 +405,6 @@ static int netwave_attach(struct pcmcia_device *p_dev) | |||
406 | 405 | ||
407 | /* General socket configuration */ | 406 | /* General socket configuration */ |
408 | link->conf.Attributes = CONF_ENABLE_IRQ; | 407 | link->conf.Attributes = CONF_ENABLE_IRQ; |
409 | link->conf.Vcc = 50; | ||
410 | link->conf.IntType = INT_MEMORY_AND_IO; | 408 | link->conf.IntType = INT_MEMORY_AND_IO; |
411 | link->conf.ConfigIndex = 1; | 409 | link->conf.ConfigIndex = 1; |
412 | link->conf.Present = PRESENT_OPTION; | 410 | link->conf.Present = PRESENT_OPTION; |
@@ -430,13 +428,7 @@ static int netwave_attach(struct pcmcia_device *p_dev) | |||
430 | dev->stop = &netwave_close; | 428 | dev->stop = &netwave_close; |
431 | link->irq.Instance = dev; | 429 | link->irq.Instance = dev; |
432 | 430 | ||
433 | link->handle = p_dev; | 431 | return netwave_pcmcia_config( link); |
434 | p_dev->instance = link; | ||
435 | |||
436 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
437 | netwave_pcmcia_config( link); | ||
438 | |||
439 | return 0; | ||
440 | } /* netwave_attach */ | 432 | } /* netwave_attach */ |
441 | 433 | ||
442 | /* | 434 | /* |
@@ -447,17 +439,15 @@ static int netwave_attach(struct pcmcia_device *p_dev) | |||
447 | * structures are freed. Otherwise, the structures will be freed | 439 | * structures are freed. Otherwise, the structures will be freed |
448 | * when the device is released. | 440 | * when the device is released. |
449 | */ | 441 | */ |
450 | static void netwave_detach(struct pcmcia_device *p_dev) | 442 | static void netwave_detach(struct pcmcia_device *link) |
451 | { | 443 | { |
452 | dev_link_t *link = dev_to_instance(p_dev); | ||
453 | struct net_device *dev = link->priv; | 444 | struct net_device *dev = link->priv; |
454 | 445 | ||
455 | DEBUG(0, "netwave_detach(0x%p)\n", link); | 446 | DEBUG(0, "netwave_detach(0x%p)\n", link); |
456 | 447 | ||
457 | if (link->state & DEV_CONFIG) | 448 | netwave_release(link); |
458 | netwave_release(link); | ||
459 | 449 | ||
460 | if (link->dev) | 450 | if (link->dev_node) |
461 | unregister_netdev(dev); | 451 | unregister_netdev(dev); |
462 | 452 | ||
463 | free_netdev(dev); | 453 | free_netdev(dev); |
@@ -743,8 +733,7 @@ static const struct iw_handler_def netwave_handler_def = | |||
743 | #define CS_CHECK(fn, ret) \ | 733 | #define CS_CHECK(fn, ret) \ |
744 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 734 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
745 | 735 | ||
746 | static void netwave_pcmcia_config(dev_link_t *link) { | 736 | static int netwave_pcmcia_config(struct pcmcia_device *link) { |
747 | client_handle_t handle = link->handle; | ||
748 | struct net_device *dev = link->priv; | 737 | struct net_device *dev = link->priv; |
749 | netwave_private *priv = netdev_priv(dev); | 738 | netwave_private *priv = netdev_priv(dev); |
750 | tuple_t tuple; | 739 | tuple_t tuple; |
@@ -766,15 +755,12 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
766 | tuple.TupleDataMax = 64; | 755 | tuple.TupleDataMax = 64; |
767 | tuple.TupleOffset = 0; | 756 | tuple.TupleOffset = 0; |
768 | tuple.DesiredTuple = CISTPL_CONFIG; | 757 | tuple.DesiredTuple = CISTPL_CONFIG; |
769 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 758 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
770 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | 759 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
771 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); | 760 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); |
772 | link->conf.ConfigBase = parse.config.base; | 761 | link->conf.ConfigBase = parse.config.base; |
773 | link->conf.Present = parse.config.rmask[0]; | 762 | link->conf.Present = parse.config.rmask[0]; |
774 | 763 | ||
775 | /* Configure card */ | ||
776 | link->state |= DEV_CONFIG; | ||
777 | |||
778 | /* | 764 | /* |
779 | * Try allocating IO ports. This tries a few fixed addresses. | 765 | * Try allocating IO ports. This tries a few fixed addresses. |
780 | * If you want, you can also read the card's config table to | 766 | * If you want, you can also read the card's config table to |
@@ -782,11 +768,11 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
782 | */ | 768 | */ |
783 | for (i = j = 0x0; j < 0x400; j += 0x20) { | 769 | for (i = j = 0x0; j < 0x400; j += 0x20) { |
784 | link->io.BasePort1 = j ^ 0x300; | 770 | link->io.BasePort1 = j ^ 0x300; |
785 | i = pcmcia_request_io(link->handle, &link->io); | 771 | i = pcmcia_request_io(link, &link->io); |
786 | if (i == CS_SUCCESS) break; | 772 | if (i == CS_SUCCESS) break; |
787 | } | 773 | } |
788 | if (i != CS_SUCCESS) { | 774 | if (i != CS_SUCCESS) { |
789 | cs_error(link->handle, RequestIO, i); | 775 | cs_error(link, RequestIO, i); |
790 | goto failed; | 776 | goto failed; |
791 | } | 777 | } |
792 | 778 | ||
@@ -794,16 +780,16 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
794 | * Now allocate an interrupt line. Note that this does not | 780 | * Now allocate an interrupt line. Note that this does not |
795 | * actually assign a handler to the interrupt. | 781 | * actually assign a handler to the interrupt. |
796 | */ | 782 | */ |
797 | CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); | 783 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
798 | 784 | ||
799 | /* | 785 | /* |
800 | * This actually configures the PCMCIA socket -- setting up | 786 | * This actually configures the PCMCIA socket -- setting up |
801 | * the I/O windows and the interrupt mapping. | 787 | * the I/O windows and the interrupt mapping. |
802 | */ | 788 | */ |
803 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); | 789 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); |
804 | 790 | ||
805 | /* | 791 | /* |
806 | * Allocate a 32K memory window. Note that the dev_link_t | 792 | * Allocate a 32K memory window. Note that the struct pcmcia_device |
807 | * structure provides space for one window handle -- if your | 793 | * structure provides space for one window handle -- if your |
808 | * device needs several windows, you'll need to keep track of | 794 | * device needs several windows, you'll need to keep track of |
809 | * the handles in your private data structure, dev->priv. | 795 | * the handles in your private data structure, dev->priv. |
@@ -813,7 +799,7 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
813 | req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_CM|WIN_ENABLE; | 799 | req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_CM|WIN_ENABLE; |
814 | req.Base = 0; req.Size = 0x8000; | 800 | req.Base = 0; req.Size = 0x8000; |
815 | req.AccessSpeed = mem_speed; | 801 | req.AccessSpeed = mem_speed; |
816 | CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win)); | 802 | CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win)); |
817 | mem.CardOffset = 0x20000; mem.Page = 0; | 803 | mem.CardOffset = 0x20000; mem.Page = 0; |
818 | CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); | 804 | CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); |
819 | 805 | ||
@@ -823,7 +809,7 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
823 | 809 | ||
824 | dev->irq = link->irq.AssignedIRQ; | 810 | dev->irq = link->irq.AssignedIRQ; |
825 | dev->base_addr = link->io.BasePort1; | 811 | dev->base_addr = link->io.BasePort1; |
826 | SET_NETDEV_DEV(dev, &handle_to_dev(handle)); | 812 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); |
827 | 813 | ||
828 | if (register_netdev(dev) != 0) { | 814 | if (register_netdev(dev) != 0) { |
829 | printk(KERN_DEBUG "netwave_cs: register_netdev() failed\n"); | 815 | printk(KERN_DEBUG "netwave_cs: register_netdev() failed\n"); |
@@ -831,8 +817,7 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
831 | } | 817 | } |
832 | 818 | ||
833 | strcpy(priv->node.dev_name, dev->name); | 819 | strcpy(priv->node.dev_name, dev->name); |
834 | link->dev = &priv->node; | 820 | link->dev_node = &priv->node; |
835 | link->state &= ~DEV_CONFIG_PENDING; | ||
836 | 821 | ||
837 | /* Reset card before reading physical address */ | 822 | /* Reset card before reading physical address */ |
838 | netwave_doreset(dev->base_addr, ramBase); | 823 | netwave_doreset(dev->base_addr, ramBase); |
@@ -852,12 +837,13 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
852 | printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n", | 837 | printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n", |
853 | get_uint16(ramBase + NETWAVE_EREG_ARW), | 838 | get_uint16(ramBase + NETWAVE_EREG_ARW), |
854 | get_uint16(ramBase + NETWAVE_EREG_ARW+2)); | 839 | get_uint16(ramBase + NETWAVE_EREG_ARW+2)); |
855 | return; | 840 | return 0; |
856 | 841 | ||
857 | cs_failed: | 842 | cs_failed: |
858 | cs_error(link->handle, last_fn, last_ret); | 843 | cs_error(link, last_fn, last_ret); |
859 | failed: | 844 | failed: |
860 | netwave_release(link); | 845 | netwave_release(link); |
846 | return -ENODEV; | ||
861 | } /* netwave_pcmcia_config */ | 847 | } /* netwave_pcmcia_config */ |
862 | 848 | ||
863 | /* | 849 | /* |
@@ -867,52 +853,35 @@ failed: | |||
867 | * device, and release the PCMCIA configuration. If the device is | 853 | * device, and release the PCMCIA configuration. If the device is |
868 | * still open, this will be postponed until it is closed. | 854 | * still open, this will be postponed until it is closed. |
869 | */ | 855 | */ |
870 | static void netwave_release(dev_link_t *link) | 856 | static void netwave_release(struct pcmcia_device *link) |
871 | { | 857 | { |
872 | struct net_device *dev = link->priv; | 858 | struct net_device *dev = link->priv; |
873 | netwave_private *priv = netdev_priv(dev); | 859 | netwave_private *priv = netdev_priv(dev); |
874 | |||
875 | DEBUG(0, "netwave_release(0x%p)\n", link); | ||
876 | 860 | ||
877 | /* Don't bother checking to see if these succeed or not */ | 861 | DEBUG(0, "netwave_release(0x%p)\n", link); |
878 | if (link->win) { | ||
879 | iounmap(priv->ramBase); | ||
880 | pcmcia_release_window(link->win); | ||
881 | } | ||
882 | pcmcia_release_configuration(link->handle); | ||
883 | pcmcia_release_io(link->handle, &link->io); | ||
884 | pcmcia_release_irq(link->handle, &link->irq); | ||
885 | 862 | ||
886 | link->state &= ~DEV_CONFIG; | 863 | pcmcia_disable_device(link); |
864 | if (link->win) | ||
865 | iounmap(priv->ramBase); | ||
887 | } | 866 | } |
888 | 867 | ||
889 | static int netwave_suspend(struct pcmcia_device *p_dev) | 868 | static int netwave_suspend(struct pcmcia_device *link) |
890 | { | 869 | { |
891 | dev_link_t *link = dev_to_instance(p_dev); | ||
892 | struct net_device *dev = link->priv; | 870 | struct net_device *dev = link->priv; |
893 | 871 | ||
894 | link->state |= DEV_SUSPEND; | 872 | if (link->open) |
895 | if (link->state & DEV_CONFIG) { | 873 | netif_device_detach(dev); |
896 | if (link->open) | ||
897 | netif_device_detach(dev); | ||
898 | pcmcia_release_configuration(link->handle); | ||
899 | } | ||
900 | 874 | ||
901 | return 0; | 875 | return 0; |
902 | } | 876 | } |
903 | 877 | ||
904 | static int netwave_resume(struct pcmcia_device *p_dev) | 878 | static int netwave_resume(struct pcmcia_device *link) |
905 | { | 879 | { |
906 | dev_link_t *link = dev_to_instance(p_dev); | ||
907 | struct net_device *dev = link->priv; | 880 | struct net_device *dev = link->priv; |
908 | 881 | ||
909 | link->state &= ~DEV_SUSPEND; | 882 | if (link->open) { |
910 | if (link->state & DEV_CONFIG) { | 883 | netwave_reset(dev); |
911 | pcmcia_request_configuration(link->handle, &link->conf); | 884 | netif_device_attach(dev); |
912 | if (link->open) { | ||
913 | netwave_reset(dev); | ||
914 | netif_device_attach(dev); | ||
915 | } | ||
916 | } | 885 | } |
917 | 886 | ||
918 | return 0; | 887 | return 0; |
@@ -1119,7 +1088,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id, struct pt_regs *regs | |||
1119 | u_char __iomem *ramBase; | 1088 | u_char __iomem *ramBase; |
1120 | struct net_device *dev = (struct net_device *)dev_id; | 1089 | struct net_device *dev = (struct net_device *)dev_id; |
1121 | struct netwave_private *priv = netdev_priv(dev); | 1090 | struct netwave_private *priv = netdev_priv(dev); |
1122 | dev_link_t *link = &priv->link; | 1091 | struct pcmcia_device *link = priv->p_dev; |
1123 | int i; | 1092 | int i; |
1124 | 1093 | ||
1125 | if (!netif_device_present(dev)) | 1094 | if (!netif_device_present(dev)) |
@@ -1138,7 +1107,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id, struct pt_regs *regs | |||
1138 | 1107 | ||
1139 | status = inb(iobase + NETWAVE_REG_ASR); | 1108 | status = inb(iobase + NETWAVE_REG_ASR); |
1140 | 1109 | ||
1141 | if (!DEV_OK(link)) { | 1110 | if (!pcmcia_dev_present(link)) { |
1142 | DEBUG(1, "netwave_interrupt: Interrupt with status 0x%x " | 1111 | DEBUG(1, "netwave_interrupt: Interrupt with status 0x%x " |
1143 | "from removed or suspended card!\n", status); | 1112 | "from removed or suspended card!\n", status); |
1144 | break; | 1113 | break; |
@@ -1373,11 +1342,11 @@ static int netwave_rx(struct net_device *dev) | |||
1373 | 1342 | ||
1374 | static int netwave_open(struct net_device *dev) { | 1343 | static int netwave_open(struct net_device *dev) { |
1375 | netwave_private *priv = netdev_priv(dev); | 1344 | netwave_private *priv = netdev_priv(dev); |
1376 | dev_link_t *link = &priv->link; | 1345 | struct pcmcia_device *link = priv->p_dev; |
1377 | 1346 | ||
1378 | DEBUG(1, "netwave_open: starting.\n"); | 1347 | DEBUG(1, "netwave_open: starting.\n"); |
1379 | 1348 | ||
1380 | if (!DEV_OK(link)) | 1349 | if (!pcmcia_dev_present(link)) |
1381 | return -ENODEV; | 1350 | return -ENODEV; |
1382 | 1351 | ||
1383 | link->open++; | 1352 | link->open++; |
@@ -1390,7 +1359,7 @@ static int netwave_open(struct net_device *dev) { | |||
1390 | 1359 | ||
1391 | static int netwave_close(struct net_device *dev) { | 1360 | static int netwave_close(struct net_device *dev) { |
1392 | netwave_private *priv = netdev_priv(dev); | 1361 | netwave_private *priv = netdev_priv(dev); |
1393 | dev_link_t *link = &priv->link; | 1362 | struct pcmcia_device *link = priv->p_dev; |
1394 | 1363 | ||
1395 | DEBUG(1, "netwave_close: finishing.\n"); | 1364 | DEBUG(1, "netwave_close: finishing.\n"); |
1396 | 1365 | ||
@@ -1411,7 +1380,7 @@ static struct pcmcia_driver netwave_driver = { | |||
1411 | .drv = { | 1380 | .drv = { |
1412 | .name = "netwave_cs", | 1381 | .name = "netwave_cs", |
1413 | }, | 1382 | }, |
1414 | .probe = netwave_attach, | 1383 | .probe = netwave_probe, |
1415 | .remove = netwave_detach, | 1384 | .remove = netwave_detach, |
1416 | .id_table = netwave_ids, | 1385 | .id_table = netwave_ids, |
1417 | .suspend = netwave_suspend, | 1386 | .suspend = netwave_suspend, |
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index ec6f2a48895b..434f7d7ad841 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c | |||
@@ -49,7 +49,7 @@ MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket | |||
49 | /* PCMCIA specific device information (goes in the card field of | 49 | /* PCMCIA specific device information (goes in the card field of |
50 | * struct orinoco_private */ | 50 | * struct orinoco_private */ |
51 | struct orinoco_pccard { | 51 | struct orinoco_pccard { |
52 | dev_link_t link; | 52 | struct pcmcia_device *p_dev; |
53 | dev_node_t node; | 53 | dev_node_t node; |
54 | 54 | ||
55 | /* Used to handle hard reset */ | 55 | /* Used to handle hard reset */ |
@@ -63,8 +63,8 @@ struct orinoco_pccard { | |||
63 | /* Function prototypes */ | 63 | /* Function prototypes */ |
64 | /********************************************************************/ | 64 | /********************************************************************/ |
65 | 65 | ||
66 | static void orinoco_cs_config(dev_link_t *link); | 66 | static int orinoco_cs_config(struct pcmcia_device *link); |
67 | static void orinoco_cs_release(dev_link_t *link); | 67 | static void orinoco_cs_release(struct pcmcia_device *link); |
68 | static void orinoco_cs_detach(struct pcmcia_device *p_dev); | 68 | static void orinoco_cs_detach(struct pcmcia_device *p_dev); |
69 | 69 | ||
70 | /********************************************************************/ | 70 | /********************************************************************/ |
@@ -75,13 +75,13 @@ static int | |||
75 | orinoco_cs_hard_reset(struct orinoco_private *priv) | 75 | orinoco_cs_hard_reset(struct orinoco_private *priv) |
76 | { | 76 | { |
77 | struct orinoco_pccard *card = priv->card; | 77 | struct orinoco_pccard *card = priv->card; |
78 | dev_link_t *link = &card->link; | 78 | struct pcmcia_device *link = card->p_dev; |
79 | int err; | 79 | int err; |
80 | 80 | ||
81 | /* We need atomic ops here, because we're not holding the lock */ | 81 | /* We need atomic ops here, because we're not holding the lock */ |
82 | set_bit(0, &card->hard_reset_in_progress); | 82 | set_bit(0, &card->hard_reset_in_progress); |
83 | 83 | ||
84 | err = pcmcia_reset_card(link->handle, NULL); | 84 | err = pcmcia_reset_card(link, NULL); |
85 | if (err) | 85 | if (err) |
86 | return err; | 86 | return err; |
87 | 87 | ||
@@ -104,12 +104,11 @@ orinoco_cs_hard_reset(struct orinoco_private *priv) | |||
104 | * configure the card at this point -- we wait until we receive a card | 104 | * configure the card at this point -- we wait until we receive a card |
105 | * insertion event. */ | 105 | * insertion event. */ |
106 | static int | 106 | static int |
107 | orinoco_cs_attach(struct pcmcia_device *p_dev) | 107 | orinoco_cs_probe(struct pcmcia_device *link) |
108 | { | 108 | { |
109 | struct net_device *dev; | 109 | struct net_device *dev; |
110 | struct orinoco_private *priv; | 110 | struct orinoco_private *priv; |
111 | struct orinoco_pccard *card; | 111 | struct orinoco_pccard *card; |
112 | dev_link_t *link; | ||
113 | 112 | ||
114 | dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset); | 113 | dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset); |
115 | if (! dev) | 114 | if (! dev) |
@@ -118,7 +117,7 @@ orinoco_cs_attach(struct pcmcia_device *p_dev) | |||
118 | card = priv->card; | 117 | card = priv->card; |
119 | 118 | ||
120 | /* Link both structures together */ | 119 | /* Link both structures together */ |
121 | link = &card->link; | 120 | card->p_dev = link; |
122 | link->priv = dev; | 121 | link->priv = dev; |
123 | 122 | ||
124 | /* Interrupt setup */ | 123 | /* Interrupt setup */ |
@@ -135,16 +134,7 @@ orinoco_cs_attach(struct pcmcia_device *p_dev) | |||
135 | link->conf.Attributes = 0; | 134 | link->conf.Attributes = 0; |
136 | link->conf.IntType = INT_MEMORY_AND_IO; | 135 | link->conf.IntType = INT_MEMORY_AND_IO; |
137 | 136 | ||
138 | /* Register with Card Services */ | 137 | return orinoco_cs_config(link); |
139 | link->next = NULL; | ||
140 | |||
141 | link->handle = p_dev; | ||
142 | p_dev->instance = link; | ||
143 | |||
144 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
145 | orinoco_cs_config(link); | ||
146 | |||
147 | return 0; | ||
148 | } /* orinoco_cs_attach */ | 138 | } /* orinoco_cs_attach */ |
149 | 139 | ||
150 | /* | 140 | /* |
@@ -153,16 +143,14 @@ orinoco_cs_attach(struct pcmcia_device *p_dev) | |||
153 | * are freed. Otherwise, the structures will be freed when the device | 143 | * are freed. Otherwise, the structures will be freed when the device |
154 | * is released. | 144 | * is released. |
155 | */ | 145 | */ |
156 | static void orinoco_cs_detach(struct pcmcia_device *p_dev) | 146 | static void orinoco_cs_detach(struct pcmcia_device *link) |
157 | { | 147 | { |
158 | dev_link_t *link = dev_to_instance(p_dev); | ||
159 | struct net_device *dev = link->priv; | 148 | struct net_device *dev = link->priv; |
160 | 149 | ||
161 | if (link->state & DEV_CONFIG) | 150 | orinoco_cs_release(link); |
162 | orinoco_cs_release(link); | ||
163 | 151 | ||
164 | DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); | 152 | DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node); |
165 | if (link->dev) { | 153 | if (link->dev_node) { |
166 | DEBUG(0, PFX "About to unregister net device %p\n", | 154 | DEBUG(0, PFX "About to unregister net device %p\n", |
167 | dev); | 155 | dev); |
168 | unregister_netdev(dev); | 156 | unregister_netdev(dev); |
@@ -180,11 +168,10 @@ static void orinoco_cs_detach(struct pcmcia_device *p_dev) | |||
180 | last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \ | 168 | last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \ |
181 | } while (0) | 169 | } while (0) |
182 | 170 | ||
183 | static void | 171 | static int |
184 | orinoco_cs_config(dev_link_t *link) | 172 | orinoco_cs_config(struct pcmcia_device *link) |
185 | { | 173 | { |
186 | struct net_device *dev = link->priv; | 174 | struct net_device *dev = link->priv; |
187 | client_handle_t handle = link->handle; | ||
188 | struct orinoco_private *priv = netdev_priv(dev); | 175 | struct orinoco_private *priv = netdev_priv(dev); |
189 | struct orinoco_pccard *card = priv->card; | 176 | struct orinoco_pccard *card = priv->card; |
190 | hermes_t *hw = &priv->hw; | 177 | hermes_t *hw = &priv->hw; |
@@ -196,7 +183,7 @@ orinoco_cs_config(dev_link_t *link) | |||
196 | cisparse_t parse; | 183 | cisparse_t parse; |
197 | void __iomem *mem; | 184 | void __iomem *mem; |
198 | 185 | ||
199 | CS_CHECK(ValidateCIS, pcmcia_validate_cis(handle, &info)); | 186 | CS_CHECK(ValidateCIS, pcmcia_validate_cis(link, &info)); |
200 | 187 | ||
201 | /* | 188 | /* |
202 | * This reads the card's CONFIG tuple to find its | 189 | * This reads the card's CONFIG tuple to find its |
@@ -207,19 +194,15 @@ orinoco_cs_config(dev_link_t *link) | |||
207 | tuple.TupleData = buf; | 194 | tuple.TupleData = buf; |
208 | tuple.TupleDataMax = sizeof(buf); | 195 | tuple.TupleDataMax = sizeof(buf); |
209 | tuple.TupleOffset = 0; | 196 | tuple.TupleOffset = 0; |
210 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 197 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
211 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | 198 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
212 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); | 199 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); |
213 | link->conf.ConfigBase = parse.config.base; | 200 | link->conf.ConfigBase = parse.config.base; |
214 | link->conf.Present = parse.config.rmask[0]; | 201 | link->conf.Present = parse.config.rmask[0]; |
215 | 202 | ||
216 | /* Configure card */ | ||
217 | link->state |= DEV_CONFIG; | ||
218 | |||
219 | /* Look up the current Vcc */ | 203 | /* Look up the current Vcc */ |
220 | CS_CHECK(GetConfigurationInfo, | 204 | CS_CHECK(GetConfigurationInfo, |
221 | pcmcia_get_configuration_info(handle, &conf)); | 205 | pcmcia_get_configuration_info(link, &conf)); |
222 | link->conf.Vcc = conf.Vcc; | ||
223 | 206 | ||
224 | /* | 207 | /* |
225 | * In this loop, we scan the CIS for configuration table | 208 | * In this loop, we scan the CIS for configuration table |
@@ -236,13 +219,13 @@ orinoco_cs_config(dev_link_t *link) | |||
236 | * implementation-defined details. | 219 | * implementation-defined details. |
237 | */ | 220 | */ |
238 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 221 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
239 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 222 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
240 | while (1) { | 223 | while (1) { |
241 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | 224 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); |
242 | cistpl_cftable_entry_t dflt = { .index = 0 }; | 225 | cistpl_cftable_entry_t dflt = { .index = 0 }; |
243 | 226 | ||
244 | if ( (pcmcia_get_tuple_data(handle, &tuple) != 0) | 227 | if ( (pcmcia_get_tuple_data(link, &tuple) != 0) |
245 | || (pcmcia_parse_tuple(handle, &tuple, &parse) != 0)) | 228 | || (pcmcia_parse_tuple(link, &tuple, &parse) != 0)) |
246 | goto next_entry; | 229 | goto next_entry; |
247 | 230 | ||
248 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | 231 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) |
@@ -274,10 +257,10 @@ orinoco_cs_config(dev_link_t *link) | |||
274 | } | 257 | } |
275 | 258 | ||
276 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | 259 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) |
277 | link->conf.Vpp1 = link->conf.Vpp2 = | 260 | link->conf.Vpp = |
278 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | 261 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; |
279 | else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) | 262 | else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) |
280 | link->conf.Vpp1 = link->conf.Vpp2 = | 263 | link->conf.Vpp = |
281 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | 264 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; |
282 | 265 | ||
283 | /* Do we need to allocate an interrupt? */ | 266 | /* Do we need to allocate an interrupt? */ |
@@ -307,7 +290,7 @@ orinoco_cs_config(dev_link_t *link) | |||
307 | } | 290 | } |
308 | 291 | ||
309 | /* This reserves IO space but doesn't actually enable it */ | 292 | /* This reserves IO space but doesn't actually enable it */ |
310 | if (pcmcia_request_io(link->handle, &link->io) != 0) | 293 | if (pcmcia_request_io(link, &link->io) != 0) |
311 | goto next_entry; | 294 | goto next_entry; |
312 | } | 295 | } |
313 | 296 | ||
@@ -317,9 +300,8 @@ orinoco_cs_config(dev_link_t *link) | |||
317 | break; | 300 | break; |
318 | 301 | ||
319 | next_entry: | 302 | next_entry: |
320 | if (link->io.NumPorts1) | 303 | pcmcia_disable_device(link); |
321 | pcmcia_release_io(link->handle, &link->io); | 304 | last_ret = pcmcia_get_next_tuple(link, &tuple); |
322 | last_ret = pcmcia_get_next_tuple(handle, &tuple); | ||
323 | if (last_ret == CS_NO_MORE_ITEMS) { | 305 | if (last_ret == CS_NO_MORE_ITEMS) { |
324 | printk(KERN_ERR PFX "GetNextTuple(): No matching " | 306 | printk(KERN_ERR PFX "GetNextTuple(): No matching " |
325 | "CIS configuration. Maybe you need the " | 307 | "CIS configuration. Maybe you need the " |
@@ -333,7 +315,7 @@ orinoco_cs_config(dev_link_t *link) | |||
333 | * a handler to the interrupt, unless the 'Handler' member of | 315 | * a handler to the interrupt, unless the 'Handler' member of |
334 | * the irq structure is initialized. | 316 | * the irq structure is initialized. |
335 | */ | 317 | */ |
336 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); | 318 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
337 | 319 | ||
338 | /* We initialize the hermes structure before completing PCMCIA | 320 | /* We initialize the hermes structure before completing PCMCIA |
339 | * configuration just in case the interrupt handler gets | 321 | * configuration just in case the interrupt handler gets |
@@ -350,7 +332,7 @@ orinoco_cs_config(dev_link_t *link) | |||
350 | * card and host interface into "Memory and IO" mode. | 332 | * card and host interface into "Memory and IO" mode. |
351 | */ | 333 | */ |
352 | CS_CHECK(RequestConfiguration, | 334 | CS_CHECK(RequestConfiguration, |
353 | pcmcia_request_configuration(link->handle, &link->conf)); | 335 | pcmcia_request_configuration(link, &link->conf)); |
354 | 336 | ||
355 | /* Ok, we have the configuration, prepare to register the netdev */ | 337 | /* Ok, we have the configuration, prepare to register the netdev */ |
356 | dev->base_addr = link->io.BasePort1; | 338 | dev->base_addr = link->io.BasePort1; |
@@ -358,7 +340,7 @@ orinoco_cs_config(dev_link_t *link) | |||
358 | SET_MODULE_OWNER(dev); | 340 | SET_MODULE_OWNER(dev); |
359 | card->node.major = card->node.minor = 0; | 341 | card->node.major = card->node.minor = 0; |
360 | 342 | ||
361 | SET_NETDEV_DEV(dev, &handle_to_dev(handle)); | 343 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); |
362 | /* Tell the stack we exist */ | 344 | /* Tell the stack we exist */ |
363 | if (register_netdev(dev) != 0) { | 345 | if (register_netdev(dev) != 0) { |
364 | printk(KERN_ERR PFX "register_netdev() failed\n"); | 346 | printk(KERN_ERR PFX "register_netdev() failed\n"); |
@@ -366,20 +348,18 @@ orinoco_cs_config(dev_link_t *link) | |||
366 | } | 348 | } |
367 | 349 | ||
368 | /* At this point, the dev_node_t structure(s) needs to be | 350 | /* At this point, the dev_node_t structure(s) needs to be |
369 | * initialized and arranged in a linked list at link->dev. */ | 351 | * initialized and arranged in a linked list at link->dev_node. */ |
370 | strcpy(card->node.dev_name, dev->name); | 352 | strcpy(card->node.dev_name, dev->name); |
371 | link->dev = &card->node; /* link->dev being non-NULL is also | 353 | link->dev_node = &card->node; /* link->dev_node being non-NULL is also |
372 | used to indicate that the | 354 | used to indicate that the |
373 | net_device has been registered */ | 355 | net_device has been registered */ |
374 | link->state &= ~DEV_CONFIG_PENDING; | ||
375 | 356 | ||
376 | /* Finally, report what we've done */ | 357 | /* Finally, report what we've done */ |
377 | printk(KERN_DEBUG "%s: index 0x%02x: Vcc %d.%d", | 358 | printk(KERN_DEBUG "%s: index 0x%02x: ", |
378 | dev->name, link->conf.ConfigIndex, | 359 | dev->name, link->conf.ConfigIndex); |
379 | link->conf.Vcc / 10, link->conf.Vcc % 10); | 360 | if (link->conf.Vpp) |
380 | if (link->conf.Vpp1) | 361 | printk(", Vpp %d.%d", link->conf.Vpp / 10, |
381 | printk(", Vpp %d.%d", link->conf.Vpp1 / 10, | 362 | link->conf.Vpp % 10); |
382 | link->conf.Vpp1 % 10); | ||
383 | printk(", irq %d", link->irq.AssignedIRQ); | 363 | printk(", irq %d", link->irq.AssignedIRQ); |
384 | if (link->io.NumPorts1) | 364 | if (link->io.NumPorts1) |
385 | printk(", io 0x%04x-0x%04x", link->io.BasePort1, | 365 | printk(", io 0x%04x-0x%04x", link->io.BasePort1, |
@@ -389,13 +369,14 @@ orinoco_cs_config(dev_link_t *link) | |||
389 | link->io.BasePort2 + link->io.NumPorts2 - 1); | 369 | link->io.BasePort2 + link->io.NumPorts2 - 1); |
390 | printk("\n"); | 370 | printk("\n"); |
391 | 371 | ||
392 | return; | 372 | return 0; |
393 | 373 | ||
394 | cs_failed: | 374 | cs_failed: |
395 | cs_error(link->handle, last_fn, last_ret); | 375 | cs_error(link, last_fn, last_ret); |
396 | 376 | ||
397 | failed: | 377 | failed: |
398 | orinoco_cs_release(link); | 378 | orinoco_cs_release(link); |
379 | return -ENODEV; | ||
399 | } /* orinoco_cs_config */ | 380 | } /* orinoco_cs_config */ |
400 | 381 | ||
401 | /* | 382 | /* |
@@ -404,7 +385,7 @@ orinoco_cs_config(dev_link_t *link) | |||
404 | * still open, this will be postponed until it is closed. | 385 | * still open, this will be postponed until it is closed. |
405 | */ | 386 | */ |
406 | static void | 387 | static void |
407 | orinoco_cs_release(dev_link_t *link) | 388 | orinoco_cs_release(struct pcmcia_device *link) |
408 | { | 389 | { |
409 | struct net_device *dev = link->priv; | 390 | struct net_device *dev = link->priv; |
410 | struct orinoco_private *priv = netdev_priv(dev); | 391 | struct orinoco_private *priv = netdev_priv(dev); |
@@ -416,88 +397,68 @@ orinoco_cs_release(dev_link_t *link) | |||
416 | priv->hw_unavailable++; | 397 | priv->hw_unavailable++; |
417 | spin_unlock_irqrestore(&priv->lock, flags); | 398 | spin_unlock_irqrestore(&priv->lock, flags); |
418 | 399 | ||
419 | /* Don't bother checking to see if these succeed or not */ | 400 | pcmcia_disable_device(link); |
420 | pcmcia_release_configuration(link->handle); | ||
421 | if (link->io.NumPorts1) | ||
422 | pcmcia_release_io(link->handle, &link->io); | ||
423 | if (link->irq.AssignedIRQ) | ||
424 | pcmcia_release_irq(link->handle, &link->irq); | ||
425 | link->state &= ~DEV_CONFIG; | ||
426 | if (priv->hw.iobase) | 401 | if (priv->hw.iobase) |
427 | ioport_unmap(priv->hw.iobase); | 402 | ioport_unmap(priv->hw.iobase); |
428 | } /* orinoco_cs_release */ | 403 | } /* orinoco_cs_release */ |
429 | 404 | ||
430 | static int orinoco_cs_suspend(struct pcmcia_device *p_dev) | 405 | static int orinoco_cs_suspend(struct pcmcia_device *link) |
431 | { | 406 | { |
432 | dev_link_t *link = dev_to_instance(p_dev); | ||
433 | struct net_device *dev = link->priv; | 407 | struct net_device *dev = link->priv; |
434 | struct orinoco_private *priv = netdev_priv(dev); | 408 | struct orinoco_private *priv = netdev_priv(dev); |
435 | struct orinoco_pccard *card = priv->card; | 409 | struct orinoco_pccard *card = priv->card; |
436 | int err = 0; | 410 | int err = 0; |
437 | unsigned long flags; | 411 | unsigned long flags; |
438 | 412 | ||
439 | link->state |= DEV_SUSPEND; | 413 | /* This is probably racy, but I can't think of |
440 | if (link->state & DEV_CONFIG) { | 414 | a better way, short of rewriting the PCMCIA |
441 | /* This is probably racy, but I can't think of | 415 | layer to not suck :-( */ |
442 | a better way, short of rewriting the PCMCIA | 416 | if (! test_bit(0, &card->hard_reset_in_progress)) { |
443 | layer to not suck :-( */ | 417 | spin_lock_irqsave(&priv->lock, flags); |
444 | if (! test_bit(0, &card->hard_reset_in_progress)) { | ||
445 | spin_lock_irqsave(&priv->lock, flags); | ||
446 | 418 | ||
447 | err = __orinoco_down(dev); | 419 | err = __orinoco_down(dev); |
448 | if (err) | 420 | if (err) |
449 | printk(KERN_WARNING "%s: Error %d downing interface\n", | 421 | printk(KERN_WARNING "%s: Error %d downing interface\n", |
450 | dev->name, err); | 422 | dev->name, err); |
451 | 423 | ||
452 | netif_device_detach(dev); | 424 | netif_device_detach(dev); |
453 | priv->hw_unavailable++; | 425 | priv->hw_unavailable++; |
454 | 426 | ||
455 | spin_unlock_irqrestore(&priv->lock, flags); | 427 | spin_unlock_irqrestore(&priv->lock, flags); |
456 | } | ||
457 | |||
458 | pcmcia_release_configuration(link->handle); | ||
459 | } | 428 | } |
460 | 429 | ||
461 | return 0; | 430 | return 0; |
462 | } | 431 | } |
463 | 432 | ||
464 | static int orinoco_cs_resume(struct pcmcia_device *p_dev) | 433 | static int orinoco_cs_resume(struct pcmcia_device *link) |
465 | { | 434 | { |
466 | dev_link_t *link = dev_to_instance(p_dev); | ||
467 | struct net_device *dev = link->priv; | 435 | struct net_device *dev = link->priv; |
468 | struct orinoco_private *priv = netdev_priv(dev); | 436 | struct orinoco_private *priv = netdev_priv(dev); |
469 | struct orinoco_pccard *card = priv->card; | 437 | struct orinoco_pccard *card = priv->card; |
470 | int err = 0; | 438 | int err = 0; |
471 | unsigned long flags; | 439 | unsigned long flags; |
472 | 440 | ||
473 | link->state &= ~DEV_SUSPEND; | 441 | if (! test_bit(0, &card->hard_reset_in_progress)) { |
474 | if (link->state & DEV_CONFIG) { | 442 | err = orinoco_reinit_firmware(dev); |
475 | /* FIXME: should we double check that this is | 443 | if (err) { |
476 | * the same card as we had before */ | 444 | printk(KERN_ERR "%s: Error %d re-initializing firmware\n", |
477 | pcmcia_request_configuration(link->handle, &link->conf); | 445 | dev->name, err); |
478 | 446 | return -EIO; | |
479 | if (! test_bit(0, &card->hard_reset_in_progress)) { | 447 | } |
480 | err = orinoco_reinit_firmware(dev); | ||
481 | if (err) { | ||
482 | printk(KERN_ERR "%s: Error %d re-initializing firmware\n", | ||
483 | dev->name, err); | ||
484 | return -EIO; | ||
485 | } | ||
486 | |||
487 | spin_lock_irqsave(&priv->lock, flags); | ||
488 | 448 | ||
489 | netif_device_attach(dev); | 449 | spin_lock_irqsave(&priv->lock, flags); |
490 | priv->hw_unavailable--; | ||
491 | 450 | ||
492 | if (priv->open && ! priv->hw_unavailable) { | 451 | netif_device_attach(dev); |
493 | err = __orinoco_up(dev); | 452 | priv->hw_unavailable--; |
494 | if (err) | ||
495 | printk(KERN_ERR "%s: Error %d restarting card\n", | ||
496 | dev->name, err); | ||
497 | } | ||
498 | 453 | ||
499 | spin_unlock_irqrestore(&priv->lock, flags); | 454 | if (priv->open && ! priv->hw_unavailable) { |
455 | err = __orinoco_up(dev); | ||
456 | if (err) | ||
457 | printk(KERN_ERR "%s: Error %d restarting card\n", | ||
458 | dev->name, err); | ||
500 | } | 459 | } |
460 | |||
461 | spin_unlock_irqrestore(&priv->lock, flags); | ||
501 | } | 462 | } |
502 | 463 | ||
503 | return 0; | 464 | return 0; |
@@ -604,7 +565,7 @@ static struct pcmcia_driver orinoco_driver = { | |||
604 | .drv = { | 565 | .drv = { |
605 | .name = DRIVER_NAME, | 566 | .name = DRIVER_NAME, |
606 | }, | 567 | }, |
607 | .probe = orinoco_cs_attach, | 568 | .probe = orinoco_cs_probe, |
608 | .remove = orinoco_cs_detach, | 569 | .remove = orinoco_cs_detach, |
609 | .id_table = orinoco_cs_ids, | 570 | .id_table = orinoco_cs_ids, |
610 | .suspend = orinoco_cs_suspend, | 571 | .suspend = orinoco_cs_suspend, |
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index 7880d8c31aad..879eb427607c 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c | |||
@@ -90,8 +90,8 @@ module_param(pc_debug, int, 0); | |||
90 | #define DEBUG(n, args...) | 90 | #define DEBUG(n, args...) |
91 | #endif | 91 | #endif |
92 | /** Prototypes based on PCMCIA skeleton driver *******************************/ | 92 | /** Prototypes based on PCMCIA skeleton driver *******************************/ |
93 | static void ray_config(dev_link_t *link); | 93 | static int ray_config(struct pcmcia_device *link); |
94 | static void ray_release(dev_link_t *link); | 94 | static void ray_release(struct pcmcia_device *link); |
95 | static void ray_detach(struct pcmcia_device *p_dev); | 95 | static void ray_detach(struct pcmcia_device *p_dev); |
96 | 96 | ||
97 | /***** Prototypes indicated by device structure ******************************/ | 97 | /***** Prototypes indicated by device structure ******************************/ |
@@ -190,20 +190,17 @@ static int bc; | |||
190 | static char *phy_addr = NULL; | 190 | static char *phy_addr = NULL; |
191 | 191 | ||
192 | 192 | ||
193 | /* A linked list of "instances" of the ray device. Each actual | 193 | /* A struct pcmcia_device structure has fields for most things that are needed |
194 | PCMCIA card corresponds to one device instance, and is described | ||
195 | by one dev_link_t structure (defined in ds.h). | ||
196 | */ | ||
197 | static dev_link_t *dev_list = NULL; | ||
198 | |||
199 | /* A dev_link_t structure has fields for most things that are needed | ||
200 | to keep track of a socket, but there will usually be some device | 194 | to keep track of a socket, but there will usually be some device |
201 | specific information that also needs to be kept track of. The | 195 | specific information that also needs to be kept track of. The |
202 | 'priv' pointer in a dev_link_t structure can be used to point to | 196 | 'priv' pointer in a struct pcmcia_device structure can be used to point to |
203 | a device-specific private data structure, like this. | 197 | a device-specific private data structure, like this. |
204 | */ | 198 | */ |
205 | static unsigned int ray_mem_speed = 500; | 199 | static unsigned int ray_mem_speed = 500; |
206 | 200 | ||
201 | /* WARNING: THIS DRIVER IS NOT CAPABLE OF HANDLING MULTIPLE DEVICES! */ | ||
202 | static struct pcmcia_device *this_device = NULL; | ||
203 | |||
207 | MODULE_AUTHOR("Corey Thomas <corey@world.std.com>"); | 204 | MODULE_AUTHOR("Corey Thomas <corey@world.std.com>"); |
208 | MODULE_DESCRIPTION("Raylink/WebGear wireless LAN driver"); | 205 | MODULE_DESCRIPTION("Raylink/WebGear wireless LAN driver"); |
209 | MODULE_LICENSE("GPL"); | 206 | MODULE_LICENSE("GPL"); |
@@ -306,56 +303,46 @@ static char rcsid[] = "Raylink/WebGear wireless LAN - Corey <Thomas corey@world. | |||
306 | configure the card at this point -- we wait until we receive a | 303 | configure the card at this point -- we wait until we receive a |
307 | card insertion event. | 304 | card insertion event. |
308 | =============================================================================*/ | 305 | =============================================================================*/ |
309 | static int ray_attach(struct pcmcia_device *p_dev) | 306 | static int ray_probe(struct pcmcia_device *p_dev) |
310 | { | 307 | { |
311 | dev_link_t *link; | ||
312 | ray_dev_t *local; | 308 | ray_dev_t *local; |
313 | struct net_device *dev; | 309 | struct net_device *dev; |
314 | |||
315 | DEBUG(1, "ray_attach()\n"); | ||
316 | 310 | ||
317 | /* Initialize the dev_link_t structure */ | 311 | DEBUG(1, "ray_attach()\n"); |
318 | link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); | ||
319 | |||
320 | if (!link) | ||
321 | return -ENOMEM; | ||
322 | 312 | ||
323 | /* Allocate space for private device-specific data */ | 313 | /* Allocate space for private device-specific data */ |
324 | dev = alloc_etherdev(sizeof(ray_dev_t)); | 314 | dev = alloc_etherdev(sizeof(ray_dev_t)); |
325 | |||
326 | if (!dev) | 315 | if (!dev) |
327 | goto fail_alloc_dev; | 316 | goto fail_alloc_dev; |
328 | 317 | ||
329 | local = dev->priv; | 318 | local = dev->priv; |
330 | 319 | local->finder = p_dev; | |
331 | memset(link, 0, sizeof(struct dev_link_t)); | ||
332 | 320 | ||
333 | /* The io structure describes IO port mapping. None used here */ | 321 | /* The io structure describes IO port mapping. None used here */ |
334 | link->io.NumPorts1 = 0; | 322 | p_dev->io.NumPorts1 = 0; |
335 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | 323 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; |
336 | link->io.IOAddrLines = 5; | 324 | p_dev->io.IOAddrLines = 5; |
337 | 325 | ||
338 | /* Interrupt setup. For PCMCIA, driver takes what's given */ | 326 | /* Interrupt setup. For PCMCIA, driver takes what's given */ |
339 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; | 327 | p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; |
340 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 328 | p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; |
341 | link->irq.Handler = &ray_interrupt; | 329 | p_dev->irq.Handler = &ray_interrupt; |
342 | 330 | ||
343 | /* General socket configuration */ | 331 | /* General socket configuration */ |
344 | link->conf.Attributes = CONF_ENABLE_IRQ; | 332 | p_dev->conf.Attributes = CONF_ENABLE_IRQ; |
345 | link->conf.Vcc = 50; | 333 | p_dev->conf.IntType = INT_MEMORY_AND_IO; |
346 | link->conf.IntType = INT_MEMORY_AND_IO; | 334 | p_dev->conf.ConfigIndex = 1; |
347 | link->conf.ConfigIndex = 1; | 335 | p_dev->conf.Present = PRESENT_OPTION; |
348 | link->conf.Present = PRESENT_OPTION; | 336 | |
349 | 337 | p_dev->priv = dev; | |
350 | link->priv = dev; | 338 | p_dev->irq.Instance = dev; |
351 | link->irq.Instance = dev; | ||
352 | 339 | ||
353 | local->finder = link; | 340 | local->finder = p_dev; |
354 | local->card_status = CARD_INSERTED; | 341 | local->card_status = CARD_INSERTED; |
355 | local->authentication_state = UNAUTHENTICATED; | 342 | local->authentication_state = UNAUTHENTICATED; |
356 | local->num_multi = 0; | 343 | local->num_multi = 0; |
357 | DEBUG(2,"ray_attach link = %p, dev = %p, local = %p, intr = %p\n", | 344 | DEBUG(2,"ray_attach p_dev = %p, dev = %p, local = %p, intr = %p\n", |
358 | link,dev,local,&ray_interrupt); | 345 | p_dev,dev,local,&ray_interrupt); |
359 | 346 | ||
360 | /* Raylink entries in the device structure */ | 347 | /* Raylink entries in the device structure */ |
361 | dev->hard_start_xmit = &ray_dev_start_xmit; | 348 | dev->hard_start_xmit = &ray_dev_start_xmit; |
@@ -379,16 +366,10 @@ static int ray_attach(struct pcmcia_device *p_dev) | |||
379 | 366 | ||
380 | init_timer(&local->timer); | 367 | init_timer(&local->timer); |
381 | 368 | ||
382 | link->handle = p_dev; | 369 | this_device = p_dev; |
383 | p_dev->instance = link; | 370 | return ray_config(p_dev); |
384 | |||
385 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
386 | ray_config(link); | ||
387 | |||
388 | return 0; | ||
389 | 371 | ||
390 | fail_alloc_dev: | 372 | fail_alloc_dev: |
391 | kfree(link); | ||
392 | return -ENOMEM; | 373 | return -ENOMEM; |
393 | } /* ray_attach */ | 374 | } /* ray_attach */ |
394 | /*============================================================================= | 375 | /*============================================================================= |
@@ -397,37 +378,25 @@ fail_alloc_dev: | |||
397 | structures are freed. Otherwise, the structures will be freed | 378 | structures are freed. Otherwise, the structures will be freed |
398 | when the device is released. | 379 | when the device is released. |
399 | =============================================================================*/ | 380 | =============================================================================*/ |
400 | static void ray_detach(struct pcmcia_device *p_dev) | 381 | static void ray_detach(struct pcmcia_device *link) |
401 | { | 382 | { |
402 | dev_link_t *link = dev_to_instance(p_dev); | ||
403 | dev_link_t **linkp; | ||
404 | struct net_device *dev; | 383 | struct net_device *dev; |
405 | ray_dev_t *local; | 384 | ray_dev_t *local; |
406 | 385 | ||
407 | DEBUG(1, "ray_detach(0x%p)\n", link); | 386 | DEBUG(1, "ray_detach(0x%p)\n", link); |
408 | |||
409 | /* Locate device structure */ | ||
410 | for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) | ||
411 | if (*linkp == link) break; | ||
412 | if (*linkp == NULL) | ||
413 | return; | ||
414 | 387 | ||
388 | this_device = NULL; | ||
415 | dev = link->priv; | 389 | dev = link->priv; |
416 | 390 | ||
417 | if (link->state & DEV_CONFIG) { | 391 | ray_release(link); |
418 | ray_release(link); | ||
419 | 392 | ||
420 | local = (ray_dev_t *)dev->priv; | 393 | local = (ray_dev_t *)dev->priv; |
421 | del_timer(&local->timer); | 394 | del_timer(&local->timer); |
422 | } | ||
423 | 395 | ||
424 | /* Unlink device structure, free pieces */ | ||
425 | *linkp = link->next; | ||
426 | if (link->priv) { | 396 | if (link->priv) { |
427 | if (link->dev) unregister_netdev(dev); | 397 | if (link->dev_node) unregister_netdev(dev); |
428 | free_netdev(dev); | 398 | free_netdev(dev); |
429 | } | 399 | } |
430 | kfree(link); | ||
431 | DEBUG(2,"ray_cs ray_detach ending\n"); | 400 | DEBUG(2,"ray_cs ray_detach ending\n"); |
432 | } /* ray_detach */ | 401 | } /* ray_detach */ |
433 | /*============================================================================= | 402 | /*============================================================================= |
@@ -438,9 +407,8 @@ static void ray_detach(struct pcmcia_device *p_dev) | |||
438 | #define CS_CHECK(fn, ret) \ | 407 | #define CS_CHECK(fn, ret) \ |
439 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 408 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
440 | #define MAX_TUPLE_SIZE 128 | 409 | #define MAX_TUPLE_SIZE 128 |
441 | static void ray_config(dev_link_t *link) | 410 | static int ray_config(struct pcmcia_device *link) |
442 | { | 411 | { |
443 | client_handle_t handle = link->handle; | ||
444 | tuple_t tuple; | 412 | tuple_t tuple; |
445 | cisparse_t parse; | 413 | cisparse_t parse; |
446 | int last_fn = 0, last_ret = 0; | 414 | int last_fn = 0, last_ret = 0; |
@@ -455,48 +423,45 @@ static void ray_config(dev_link_t *link) | |||
455 | 423 | ||
456 | /* This reads the card's CONFIG tuple to find its configuration regs */ | 424 | /* This reads the card's CONFIG tuple to find its configuration regs */ |
457 | tuple.DesiredTuple = CISTPL_CONFIG; | 425 | tuple.DesiredTuple = CISTPL_CONFIG; |
458 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 426 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
459 | tuple.TupleData = buf; | 427 | tuple.TupleData = buf; |
460 | tuple.TupleDataMax = MAX_TUPLE_SIZE; | 428 | tuple.TupleDataMax = MAX_TUPLE_SIZE; |
461 | tuple.TupleOffset = 0; | 429 | tuple.TupleOffset = 0; |
462 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | 430 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
463 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); | 431 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); |
464 | link->conf.ConfigBase = parse.config.base; | 432 | link->conf.ConfigBase = parse.config.base; |
465 | link->conf.Present = parse.config.rmask[0]; | 433 | link->conf.Present = parse.config.rmask[0]; |
466 | 434 | ||
467 | /* Determine card type and firmware version */ | 435 | /* Determine card type and firmware version */ |
468 | buf[0] = buf[MAX_TUPLE_SIZE - 1] = 0; | 436 | buf[0] = buf[MAX_TUPLE_SIZE - 1] = 0; |
469 | tuple.DesiredTuple = CISTPL_VERS_1; | 437 | tuple.DesiredTuple = CISTPL_VERS_1; |
470 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 438 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
471 | tuple.TupleData = buf; | 439 | tuple.TupleData = buf; |
472 | tuple.TupleDataMax = MAX_TUPLE_SIZE; | 440 | tuple.TupleDataMax = MAX_TUPLE_SIZE; |
473 | tuple.TupleOffset = 2; | 441 | tuple.TupleOffset = 2; |
474 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | 442 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
475 | 443 | ||
476 | for (i=0; i<tuple.TupleDataLen - 4; i++) | 444 | for (i=0; i<tuple.TupleDataLen - 4; i++) |
477 | if (buf[i] == 0) buf[i] = ' '; | 445 | if (buf[i] == 0) buf[i] = ' '; |
478 | printk(KERN_INFO "ray_cs Detected: %s\n",buf); | 446 | printk(KERN_INFO "ray_cs Detected: %s\n",buf); |
479 | 447 | ||
480 | /* Configure card */ | ||
481 | link->state |= DEV_CONFIG; | ||
482 | |||
483 | /* Now allocate an interrupt line. Note that this does not | 448 | /* Now allocate an interrupt line. Note that this does not |
484 | actually assign a handler to the interrupt. | 449 | actually assign a handler to the interrupt. |
485 | */ | 450 | */ |
486 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); | 451 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
487 | dev->irq = link->irq.AssignedIRQ; | 452 | dev->irq = link->irq.AssignedIRQ; |
488 | 453 | ||
489 | /* This actually configures the PCMCIA socket -- setting up | 454 | /* This actually configures the PCMCIA socket -- setting up |
490 | the I/O windows and the interrupt mapping. | 455 | the I/O windows and the interrupt mapping. |
491 | */ | 456 | */ |
492 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); | 457 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); |
493 | 458 | ||
494 | /*** Set up 32k window for shared memory (transmit and control) ************/ | 459 | /*** Set up 32k window for shared memory (transmit and control) ************/ |
495 | req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT; | 460 | req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT; |
496 | req.Base = 0; | 461 | req.Base = 0; |
497 | req.Size = 0x8000; | 462 | req.Size = 0x8000; |
498 | req.AccessSpeed = ray_mem_speed; | 463 | req.AccessSpeed = ray_mem_speed; |
499 | CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win)); | 464 | CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win)); |
500 | mem.CardOffset = 0x0000; mem.Page = 0; | 465 | mem.CardOffset = 0x0000; mem.Page = 0; |
501 | CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); | 466 | CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); |
502 | local->sram = ioremap(req.Base,req.Size); | 467 | local->sram = ioremap(req.Base,req.Size); |
@@ -506,7 +471,7 @@ static void ray_config(dev_link_t *link) | |||
506 | req.Base = 0; | 471 | req.Base = 0; |
507 | req.Size = 0x4000; | 472 | req.Size = 0x4000; |
508 | req.AccessSpeed = ray_mem_speed; | 473 | req.AccessSpeed = ray_mem_speed; |
509 | CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &local->rmem_handle)); | 474 | CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &local->rmem_handle)); |
510 | mem.CardOffset = 0x8000; mem.Page = 0; | 475 | mem.CardOffset = 0x8000; mem.Page = 0; |
511 | CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->rmem_handle, &mem)); | 476 | CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->rmem_handle, &mem)); |
512 | local->rmem = ioremap(req.Base,req.Size); | 477 | local->rmem = ioremap(req.Base,req.Size); |
@@ -516,7 +481,7 @@ static void ray_config(dev_link_t *link) | |||
516 | req.Base = 0; | 481 | req.Base = 0; |
517 | req.Size = 0x1000; | 482 | req.Size = 0x1000; |
518 | req.AccessSpeed = ray_mem_speed; | 483 | req.AccessSpeed = ray_mem_speed; |
519 | CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &local->amem_handle)); | 484 | CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &local->amem_handle)); |
520 | mem.CardOffset = 0x0000; mem.Page = 0; | 485 | mem.CardOffset = 0x0000; mem.Page = 0; |
521 | CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->amem_handle, &mem)); | 486 | CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->amem_handle, &mem)); |
522 | local->amem = ioremap(req.Base,req.Size); | 487 | local->amem = ioremap(req.Base,req.Size); |
@@ -526,32 +491,32 @@ static void ray_config(dev_link_t *link) | |||
526 | DEBUG(3,"ray_config amem=%p\n",local->amem); | 491 | DEBUG(3,"ray_config amem=%p\n",local->amem); |
527 | if (ray_init(dev) < 0) { | 492 | if (ray_init(dev) < 0) { |
528 | ray_release(link); | 493 | ray_release(link); |
529 | return; | 494 | return -ENODEV; |
530 | } | 495 | } |
531 | 496 | ||
532 | SET_NETDEV_DEV(dev, &handle_to_dev(handle)); | 497 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); |
533 | i = register_netdev(dev); | 498 | i = register_netdev(dev); |
534 | if (i != 0) { | 499 | if (i != 0) { |
535 | printk("ray_config register_netdev() failed\n"); | 500 | printk("ray_config register_netdev() failed\n"); |
536 | ray_release(link); | 501 | ray_release(link); |
537 | return; | 502 | return i; |
538 | } | 503 | } |
539 | 504 | ||
540 | strcpy(local->node.dev_name, dev->name); | 505 | strcpy(local->node.dev_name, dev->name); |
541 | link->dev = &local->node; | 506 | link->dev_node = &local->node; |
542 | 507 | ||
543 | link->state &= ~DEV_CONFIG_PENDING; | ||
544 | printk(KERN_INFO "%s: RayLink, irq %d, hw_addr ", | 508 | printk(KERN_INFO "%s: RayLink, irq %d, hw_addr ", |
545 | dev->name, dev->irq); | 509 | dev->name, dev->irq); |
546 | for (i = 0; i < 6; i++) | 510 | for (i = 0; i < 6; i++) |
547 | printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n")); | 511 | printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n")); |
548 | 512 | ||
549 | return; | 513 | return 0; |
550 | 514 | ||
551 | cs_failed: | 515 | cs_failed: |
552 | cs_error(link->handle, last_fn, last_ret); | 516 | cs_error(link, last_fn, last_ret); |
553 | 517 | ||
554 | ray_release(link); | 518 | ray_release(link); |
519 | return -ENODEV; | ||
555 | } /* ray_config */ | 520 | } /* ray_config */ |
556 | 521 | ||
557 | static inline struct ccs __iomem *ccs_base(ray_dev_t *dev) | 522 | static inline struct ccs __iomem *ccs_base(ray_dev_t *dev) |
@@ -578,9 +543,9 @@ static int ray_init(struct net_device *dev) | |||
578 | UCHAR *p; | 543 | UCHAR *p; |
579 | struct ccs __iomem *pccs; | 544 | struct ccs __iomem *pccs; |
580 | ray_dev_t *local = (ray_dev_t *)dev->priv; | 545 | ray_dev_t *local = (ray_dev_t *)dev->priv; |
581 | dev_link_t *link = local->finder; | 546 | struct pcmcia_device *link = local->finder; |
582 | DEBUG(1, "ray_init(0x%p)\n", dev); | 547 | DEBUG(1, "ray_init(0x%p)\n", dev); |
583 | if (!(link->state & DEV_PRESENT)) { | 548 | if (!(pcmcia_dev_present(link))) { |
584 | DEBUG(0,"ray_init - device not present\n"); | 549 | DEBUG(0,"ray_init - device not present\n"); |
585 | return -1; | 550 | return -1; |
586 | } | 551 | } |
@@ -640,10 +605,10 @@ static int dl_startup_params(struct net_device *dev) | |||
640 | int ccsindex; | 605 | int ccsindex; |
641 | ray_dev_t *local = (ray_dev_t *)dev->priv; | 606 | ray_dev_t *local = (ray_dev_t *)dev->priv; |
642 | struct ccs __iomem *pccs; | 607 | struct ccs __iomem *pccs; |
643 | dev_link_t *link = local->finder; | 608 | struct pcmcia_device *link = local->finder; |
644 | 609 | ||
645 | DEBUG(1,"dl_startup_params entered\n"); | 610 | DEBUG(1,"dl_startup_params entered\n"); |
646 | if (!(link->state & DEV_PRESENT)) { | 611 | if (!(pcmcia_dev_present(link))) { |
647 | DEBUG(2,"ray_cs dl_startup_params - device not present\n"); | 612 | DEBUG(2,"ray_cs dl_startup_params - device not present\n"); |
648 | return -1; | 613 | return -1; |
649 | } | 614 | } |
@@ -747,9 +712,9 @@ static void verify_dl_startup(u_long data) | |||
747 | ray_dev_t *local = (ray_dev_t *)data; | 712 | ray_dev_t *local = (ray_dev_t *)data; |
748 | struct ccs __iomem *pccs = ccs_base(local) + local->dl_param_ccs; | 713 | struct ccs __iomem *pccs = ccs_base(local) + local->dl_param_ccs; |
749 | UCHAR status; | 714 | UCHAR status; |
750 | dev_link_t *link = local->finder; | 715 | struct pcmcia_device *link = local->finder; |
751 | 716 | ||
752 | if (!(link->state & DEV_PRESENT)) { | 717 | if (!(pcmcia_dev_present(link))) { |
753 | DEBUG(2,"ray_cs verify_dl_startup - device not present\n"); | 718 | DEBUG(2,"ray_cs verify_dl_startup - device not present\n"); |
754 | return; | 719 | return; |
755 | } | 720 | } |
@@ -787,8 +752,8 @@ static void start_net(u_long data) | |||
787 | ray_dev_t *local = (ray_dev_t *)data; | 752 | ray_dev_t *local = (ray_dev_t *)data; |
788 | struct ccs __iomem *pccs; | 753 | struct ccs __iomem *pccs; |
789 | int ccsindex; | 754 | int ccsindex; |
790 | dev_link_t *link = local->finder; | 755 | struct pcmcia_device *link = local->finder; |
791 | if (!(link->state & DEV_PRESENT)) { | 756 | if (!(pcmcia_dev_present(link))) { |
792 | DEBUG(2,"ray_cs start_net - device not present\n"); | 757 | DEBUG(2,"ray_cs start_net - device not present\n"); |
793 | return; | 758 | return; |
794 | } | 759 | } |
@@ -814,9 +779,9 @@ static void join_net(u_long data) | |||
814 | 779 | ||
815 | struct ccs __iomem *pccs; | 780 | struct ccs __iomem *pccs; |
816 | int ccsindex; | 781 | int ccsindex; |
817 | dev_link_t *link = local->finder; | 782 | struct pcmcia_device *link = local->finder; |
818 | 783 | ||
819 | if (!(link->state & DEV_PRESENT)) { | 784 | if (!(pcmcia_dev_present(link))) { |
820 | DEBUG(2,"ray_cs join_net - device not present\n"); | 785 | DEBUG(2,"ray_cs join_net - device not present\n"); |
821 | return; | 786 | return; |
822 | } | 787 | } |
@@ -840,7 +805,7 @@ static void join_net(u_long data) | |||
840 | device, and release the PCMCIA configuration. If the device is | 805 | device, and release the PCMCIA configuration. If the device is |
841 | still open, this will be postponed until it is closed. | 806 | still open, this will be postponed until it is closed. |
842 | =============================================================================*/ | 807 | =============================================================================*/ |
843 | static void ray_release(dev_link_t *link) | 808 | static void ray_release(struct pcmcia_device *link) |
844 | { | 809 | { |
845 | struct net_device *dev = link->priv; | 810 | struct net_device *dev = link->priv; |
846 | ray_dev_t *local = dev->priv; | 811 | ray_dev_t *local = dev->priv; |
@@ -849,56 +814,38 @@ static void ray_release(dev_link_t *link) | |||
849 | DEBUG(1, "ray_release(0x%p)\n", link); | 814 | DEBUG(1, "ray_release(0x%p)\n", link); |
850 | 815 | ||
851 | del_timer(&local->timer); | 816 | del_timer(&local->timer); |
852 | link->state &= ~DEV_CONFIG; | ||
853 | 817 | ||
854 | iounmap(local->sram); | 818 | iounmap(local->sram); |
855 | iounmap(local->rmem); | 819 | iounmap(local->rmem); |
856 | iounmap(local->amem); | 820 | iounmap(local->amem); |
857 | /* Do bother checking to see if these succeed or not */ | 821 | /* Do bother checking to see if these succeed or not */ |
858 | i = pcmcia_release_window(link->win); | ||
859 | if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(link->win) ret = %x\n",i); | ||
860 | i = pcmcia_release_window(local->amem_handle); | 822 | i = pcmcia_release_window(local->amem_handle); |
861 | if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->amem) ret = %x\n",i); | 823 | if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->amem) ret = %x\n",i); |
862 | i = pcmcia_release_window(local->rmem_handle); | 824 | i = pcmcia_release_window(local->rmem_handle); |
863 | if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->rmem) ret = %x\n",i); | 825 | if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->rmem) ret = %x\n",i); |
864 | i = pcmcia_release_configuration(link->handle); | 826 | pcmcia_disable_device(link); |
865 | if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseConfiguration ret = %x\n",i); | ||
866 | i = pcmcia_release_irq(link->handle, &link->irq); | ||
867 | if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseIRQ ret = %x\n",i); | ||
868 | 827 | ||
869 | DEBUG(2,"ray_release ending\n"); | 828 | DEBUG(2,"ray_release ending\n"); |
870 | } | 829 | } |
871 | 830 | ||
872 | static int ray_suspend(struct pcmcia_device *p_dev) | 831 | static int ray_suspend(struct pcmcia_device *link) |
873 | { | 832 | { |
874 | dev_link_t *link = dev_to_instance(p_dev); | ||
875 | struct net_device *dev = link->priv; | 833 | struct net_device *dev = link->priv; |
876 | 834 | ||
877 | link->state |= DEV_SUSPEND; | 835 | if (link->open) |
878 | if (link->state & DEV_CONFIG) { | 836 | netif_device_detach(dev); |
879 | if (link->open) | ||
880 | netif_device_detach(dev); | ||
881 | |||
882 | pcmcia_release_configuration(link->handle); | ||
883 | } | ||
884 | |||
885 | 837 | ||
886 | return 0; | 838 | return 0; |
887 | } | 839 | } |
888 | 840 | ||
889 | static int ray_resume(struct pcmcia_device *p_dev) | 841 | static int ray_resume(struct pcmcia_device *link) |
890 | { | 842 | { |
891 | dev_link_t *link = dev_to_instance(p_dev); | ||
892 | struct net_device *dev = link->priv; | 843 | struct net_device *dev = link->priv; |
893 | 844 | ||
894 | link->state &= ~DEV_SUSPEND; | 845 | if (link->open) { |
895 | if (link->state & DEV_CONFIG) { | 846 | ray_reset(dev); |
896 | pcmcia_request_configuration(link->handle, &link->conf); | 847 | netif_device_attach(dev); |
897 | if (link->open) { | 848 | } |
898 | ray_reset(dev); | ||
899 | netif_device_attach(dev); | ||
900 | } | ||
901 | } | ||
902 | 849 | ||
903 | return 0; | 850 | return 0; |
904 | } | 851 | } |
@@ -910,10 +857,10 @@ int ray_dev_init(struct net_device *dev) | |||
910 | int i; | 857 | int i; |
911 | #endif /* RAY_IMMEDIATE_INIT */ | 858 | #endif /* RAY_IMMEDIATE_INIT */ |
912 | ray_dev_t *local = dev->priv; | 859 | ray_dev_t *local = dev->priv; |
913 | dev_link_t *link = local->finder; | 860 | struct pcmcia_device *link = local->finder; |
914 | 861 | ||
915 | DEBUG(1,"ray_dev_init(dev=%p)\n",dev); | 862 | DEBUG(1,"ray_dev_init(dev=%p)\n",dev); |
916 | if (!(link->state & DEV_PRESENT)) { | 863 | if (!(pcmcia_dev_present(link))) { |
917 | DEBUG(2,"ray_dev_init - device not present\n"); | 864 | DEBUG(2,"ray_dev_init - device not present\n"); |
918 | return -1; | 865 | return -1; |
919 | } | 866 | } |
@@ -944,10 +891,10 @@ int ray_dev_init(struct net_device *dev) | |||
944 | static int ray_dev_config(struct net_device *dev, struct ifmap *map) | 891 | static int ray_dev_config(struct net_device *dev, struct ifmap *map) |
945 | { | 892 | { |
946 | ray_dev_t *local = dev->priv; | 893 | ray_dev_t *local = dev->priv; |
947 | dev_link_t *link = local->finder; | 894 | struct pcmcia_device *link = local->finder; |
948 | /* Dummy routine to satisfy device structure */ | 895 | /* Dummy routine to satisfy device structure */ |
949 | DEBUG(1,"ray_dev_config(dev=%p,ifmap=%p)\n",dev,map); | 896 | DEBUG(1,"ray_dev_config(dev=%p,ifmap=%p)\n",dev,map); |
950 | if (!(link->state & DEV_PRESENT)) { | 897 | if (!(pcmcia_dev_present(link))) { |
951 | DEBUG(2,"ray_dev_config - device not present\n"); | 898 | DEBUG(2,"ray_dev_config - device not present\n"); |
952 | return -1; | 899 | return -1; |
953 | } | 900 | } |
@@ -958,10 +905,10 @@ static int ray_dev_config(struct net_device *dev, struct ifmap *map) | |||
958 | static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev) | 905 | static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev) |
959 | { | 906 | { |
960 | ray_dev_t *local = dev->priv; | 907 | ray_dev_t *local = dev->priv; |
961 | dev_link_t *link = local->finder; | 908 | struct pcmcia_device *link = local->finder; |
962 | short length = skb->len; | 909 | short length = skb->len; |
963 | 910 | ||
964 | if (!(link->state & DEV_PRESENT)) { | 911 | if (!(pcmcia_dev_present(link))) { |
965 | DEBUG(2,"ray_dev_start_xmit - device not present\n"); | 912 | DEBUG(2,"ray_dev_start_xmit - device not present\n"); |
966 | return -1; | 913 | return -1; |
967 | } | 914 | } |
@@ -1570,7 +1517,7 @@ static int ray_commit(struct net_device *dev, | |||
1570 | static iw_stats * ray_get_wireless_stats(struct net_device * dev) | 1517 | static iw_stats * ray_get_wireless_stats(struct net_device * dev) |
1571 | { | 1518 | { |
1572 | ray_dev_t * local = (ray_dev_t *) dev->priv; | 1519 | ray_dev_t * local = (ray_dev_t *) dev->priv; |
1573 | dev_link_t *link = local->finder; | 1520 | struct pcmcia_device *link = local->finder; |
1574 | struct status __iomem *p = local->sram + STATUS_BASE; | 1521 | struct status __iomem *p = local->sram + STATUS_BASE; |
1575 | 1522 | ||
1576 | if(local == (ray_dev_t *) NULL) | 1523 | if(local == (ray_dev_t *) NULL) |
@@ -1588,7 +1535,7 @@ static iw_stats * ray_get_wireless_stats(struct net_device * dev) | |||
1588 | } | 1535 | } |
1589 | #endif /* WIRELESS_SPY */ | 1536 | #endif /* WIRELESS_SPY */ |
1590 | 1537 | ||
1591 | if((link->state & DEV_PRESENT)) { | 1538 | if(pcmcia_dev_present(link)) { |
1592 | local->wstats.qual.noise = readb(&p->rxnoise); | 1539 | local->wstats.qual.noise = readb(&p->rxnoise); |
1593 | local->wstats.qual.updated |= 4; | 1540 | local->wstats.qual.updated |= 4; |
1594 | } | 1541 | } |
@@ -1657,18 +1604,14 @@ static const struct iw_handler_def ray_handler_def = | |||
1657 | /*===========================================================================*/ | 1604 | /*===========================================================================*/ |
1658 | static int ray_open(struct net_device *dev) | 1605 | static int ray_open(struct net_device *dev) |
1659 | { | 1606 | { |
1660 | dev_link_t *link; | ||
1661 | ray_dev_t *local = (ray_dev_t *)dev->priv; | 1607 | ray_dev_t *local = (ray_dev_t *)dev->priv; |
1608 | struct pcmcia_device *link; | ||
1609 | link = local->finder; | ||
1662 | 1610 | ||
1663 | DEBUG(1, "ray_open('%s')\n", dev->name); | 1611 | DEBUG(1, "ray_open('%s')\n", dev->name); |
1664 | 1612 | ||
1665 | for (link = dev_list; link; link = link->next) | 1613 | if (link->open == 0) |
1666 | if (link->priv == dev) break; | 1614 | local->num_multi = 0; |
1667 | if (!DEV_OK(link)) { | ||
1668 | return -ENODEV; | ||
1669 | } | ||
1670 | |||
1671 | if (link->open == 0) local->num_multi = 0; | ||
1672 | link->open++; | 1615 | link->open++; |
1673 | 1616 | ||
1674 | /* If the card is not started, time to start it ! - Jean II */ | 1617 | /* If the card is not started, time to start it ! - Jean II */ |
@@ -1695,15 +1638,12 @@ static int ray_open(struct net_device *dev) | |||
1695 | /*===========================================================================*/ | 1638 | /*===========================================================================*/ |
1696 | static int ray_dev_close(struct net_device *dev) | 1639 | static int ray_dev_close(struct net_device *dev) |
1697 | { | 1640 | { |
1698 | dev_link_t *link; | 1641 | ray_dev_t *local = (ray_dev_t *)dev->priv; |
1642 | struct pcmcia_device *link; | ||
1643 | link = local->finder; | ||
1699 | 1644 | ||
1700 | DEBUG(1, "ray_dev_close('%s')\n", dev->name); | 1645 | DEBUG(1, "ray_dev_close('%s')\n", dev->name); |
1701 | 1646 | ||
1702 | for (link = dev_list; link; link = link->next) | ||
1703 | if (link->priv == dev) break; | ||
1704 | if (link == NULL) | ||
1705 | return -ENODEV; | ||
1706 | |||
1707 | link->open--; | 1647 | link->open--; |
1708 | netif_stop_queue(dev); | 1648 | netif_stop_queue(dev); |
1709 | 1649 | ||
@@ -1725,9 +1665,9 @@ static void ray_reset(struct net_device *dev) { | |||
1725 | static int interrupt_ecf(ray_dev_t *local, int ccs) | 1665 | static int interrupt_ecf(ray_dev_t *local, int ccs) |
1726 | { | 1666 | { |
1727 | int i = 50; | 1667 | int i = 50; |
1728 | dev_link_t *link = local->finder; | 1668 | struct pcmcia_device *link = local->finder; |
1729 | 1669 | ||
1730 | if (!(link->state & DEV_PRESENT)) { | 1670 | if (!(pcmcia_dev_present(link))) { |
1731 | DEBUG(2,"ray_cs interrupt_ecf - device not present\n"); | 1671 | DEBUG(2,"ray_cs interrupt_ecf - device not present\n"); |
1732 | return -1; | 1672 | return -1; |
1733 | } | 1673 | } |
@@ -1752,9 +1692,9 @@ static int get_free_tx_ccs(ray_dev_t *local) | |||
1752 | { | 1692 | { |
1753 | int i; | 1693 | int i; |
1754 | struct ccs __iomem *pccs = ccs_base(local); | 1694 | struct ccs __iomem *pccs = ccs_base(local); |
1755 | dev_link_t *link = local->finder; | 1695 | struct pcmcia_device *link = local->finder; |
1756 | 1696 | ||
1757 | if (!(link->state & DEV_PRESENT)) { | 1697 | if (!(pcmcia_dev_present(link))) { |
1758 | DEBUG(2,"ray_cs get_free_tx_ccs - device not present\n"); | 1698 | DEBUG(2,"ray_cs get_free_tx_ccs - device not present\n"); |
1759 | return ECARDGONE; | 1699 | return ECARDGONE; |
1760 | } | 1700 | } |
@@ -1783,9 +1723,9 @@ static int get_free_ccs(ray_dev_t *local) | |||
1783 | { | 1723 | { |
1784 | int i; | 1724 | int i; |
1785 | struct ccs __iomem *pccs = ccs_base(local); | 1725 | struct ccs __iomem *pccs = ccs_base(local); |
1786 | dev_link_t *link = local->finder; | 1726 | struct pcmcia_device *link = local->finder; |
1787 | 1727 | ||
1788 | if (!(link->state & DEV_PRESENT)) { | 1728 | if (!(pcmcia_dev_present(link))) { |
1789 | DEBUG(2,"ray_cs get_free_ccs - device not present\n"); | 1729 | DEBUG(2,"ray_cs get_free_ccs - device not present\n"); |
1790 | return ECARDGONE; | 1730 | return ECARDGONE; |
1791 | } | 1731 | } |
@@ -1858,9 +1798,9 @@ static int parse_addr(char *in_str, UCHAR *out) | |||
1858 | static struct net_device_stats *ray_get_stats(struct net_device *dev) | 1798 | static struct net_device_stats *ray_get_stats(struct net_device *dev) |
1859 | { | 1799 | { |
1860 | ray_dev_t *local = (ray_dev_t *)dev->priv; | 1800 | ray_dev_t *local = (ray_dev_t *)dev->priv; |
1861 | dev_link_t *link = local->finder; | 1801 | struct pcmcia_device *link = local->finder; |
1862 | struct status __iomem *p = local->sram + STATUS_BASE; | 1802 | struct status __iomem *p = local->sram + STATUS_BASE; |
1863 | if (!(link->state & DEV_PRESENT)) { | 1803 | if (!(pcmcia_dev_present(link))) { |
1864 | DEBUG(2,"ray_cs net_device_stats - device not present\n"); | 1804 | DEBUG(2,"ray_cs net_device_stats - device not present\n"); |
1865 | return &local->stats; | 1805 | return &local->stats; |
1866 | } | 1806 | } |
@@ -1888,12 +1828,12 @@ static struct net_device_stats *ray_get_stats(struct net_device *dev) | |||
1888 | static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, int len) | 1828 | static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, int len) |
1889 | { | 1829 | { |
1890 | ray_dev_t *local = (ray_dev_t *)dev->priv; | 1830 | ray_dev_t *local = (ray_dev_t *)dev->priv; |
1891 | dev_link_t *link = local->finder; | 1831 | struct pcmcia_device *link = local->finder; |
1892 | int ccsindex; | 1832 | int ccsindex; |
1893 | int i; | 1833 | int i; |
1894 | struct ccs __iomem *pccs; | 1834 | struct ccs __iomem *pccs; |
1895 | 1835 | ||
1896 | if (!(link->state & DEV_PRESENT)) { | 1836 | if (!(pcmcia_dev_present(link))) { |
1897 | DEBUG(2,"ray_update_parm - device not present\n"); | 1837 | DEBUG(2,"ray_update_parm - device not present\n"); |
1898 | return; | 1838 | return; |
1899 | } | 1839 | } |
@@ -1925,10 +1865,10 @@ static void ray_update_multi_list(struct net_device *dev, int all) | |||
1925 | struct ccs __iomem *pccs; | 1865 | struct ccs __iomem *pccs; |
1926 | int i = 0; | 1866 | int i = 0; |
1927 | ray_dev_t *local = (ray_dev_t *)dev->priv; | 1867 | ray_dev_t *local = (ray_dev_t *)dev->priv; |
1928 | dev_link_t *link = local->finder; | 1868 | struct pcmcia_device *link = local->finder; |
1929 | void __iomem *p = local->sram + HOST_TO_ECF_BASE; | 1869 | void __iomem *p = local->sram + HOST_TO_ECF_BASE; |
1930 | 1870 | ||
1931 | if (!(link->state & DEV_PRESENT)) { | 1871 | if (!(pcmcia_dev_present(link))) { |
1932 | DEBUG(2,"ray_update_multi_list - device not present\n"); | 1872 | DEBUG(2,"ray_update_multi_list - device not present\n"); |
1933 | return; | 1873 | return; |
1934 | } | 1874 | } |
@@ -2005,7 +1945,7 @@ static void set_multicast_list(struct net_device *dev) | |||
2005 | static irqreturn_t ray_interrupt(int irq, void *dev_id, struct pt_regs * regs) | 1945 | static irqreturn_t ray_interrupt(int irq, void *dev_id, struct pt_regs * regs) |
2006 | { | 1946 | { |
2007 | struct net_device *dev = (struct net_device *)dev_id; | 1947 | struct net_device *dev = (struct net_device *)dev_id; |
2008 | dev_link_t *link; | 1948 | struct pcmcia_device *link; |
2009 | ray_dev_t *local; | 1949 | ray_dev_t *local; |
2010 | struct ccs __iomem *pccs; | 1950 | struct ccs __iomem *pccs; |
2011 | struct rcs __iomem *prcs; | 1951 | struct rcs __iomem *prcs; |
@@ -2020,8 +1960,8 @@ static irqreturn_t ray_interrupt(int irq, void *dev_id, struct pt_regs * regs) | |||
2020 | DEBUG(4,"ray_cs: interrupt for *dev=%p\n",dev); | 1960 | DEBUG(4,"ray_cs: interrupt for *dev=%p\n",dev); |
2021 | 1961 | ||
2022 | local = (ray_dev_t *)dev->priv; | 1962 | local = (ray_dev_t *)dev->priv; |
2023 | link = (dev_link_t *)local->finder; | 1963 | link = (struct pcmcia_device *)local->finder; |
2024 | if ( ! (link->state & DEV_PRESENT) || link->state & DEV_SUSPEND ) { | 1964 | if (!pcmcia_dev_present(link)) { |
2025 | DEBUG(2,"ray_cs interrupt from device not present or suspended.\n"); | 1965 | DEBUG(2,"ray_cs interrupt from device not present or suspended.\n"); |
2026 | return IRQ_NONE; | 1966 | return IRQ_NONE; |
2027 | } | 1967 | } |
@@ -2540,9 +2480,9 @@ static void release_frag_chain(ray_dev_t *local, struct rcs __iomem * prcs) | |||
2540 | /*===========================================================================*/ | 2480 | /*===========================================================================*/ |
2541 | static void authenticate(ray_dev_t *local) | 2481 | static void authenticate(ray_dev_t *local) |
2542 | { | 2482 | { |
2543 | dev_link_t *link = local->finder; | 2483 | struct pcmcia_device *link = local->finder; |
2544 | DEBUG(0,"ray_cs Starting authentication.\n"); | 2484 | DEBUG(0,"ray_cs Starting authentication.\n"); |
2545 | if (!(link->state & DEV_PRESENT)) { | 2485 | if (!(pcmcia_dev_present(link))) { |
2546 | DEBUG(2,"ray_cs authenticate - device not present\n"); | 2486 | DEBUG(2,"ray_cs authenticate - device not present\n"); |
2547 | return; | 2487 | return; |
2548 | } | 2488 | } |
@@ -2606,10 +2546,10 @@ static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs, | |||
2606 | static void associate(ray_dev_t *local) | 2546 | static void associate(ray_dev_t *local) |
2607 | { | 2547 | { |
2608 | struct ccs __iomem *pccs; | 2548 | struct ccs __iomem *pccs; |
2609 | dev_link_t *link = local->finder; | 2549 | struct pcmcia_device *link = local->finder; |
2610 | struct net_device *dev = link->priv; | 2550 | struct net_device *dev = link->priv; |
2611 | int ccsindex; | 2551 | int ccsindex; |
2612 | if (!(link->state & DEV_PRESENT)) { | 2552 | if (!(pcmcia_dev_present(link))) { |
2613 | DEBUG(2,"ray_cs associate - device not present\n"); | 2553 | DEBUG(2,"ray_cs associate - device not present\n"); |
2614 | return; | 2554 | return; |
2615 | } | 2555 | } |
@@ -2689,14 +2629,14 @@ static int ray_cs_proc_read(char *buf, char **start, off_t offset, int len) | |||
2689 | * eg ifconfig | 2629 | * eg ifconfig |
2690 | */ | 2630 | */ |
2691 | int i; | 2631 | int i; |
2692 | dev_link_t *link; | 2632 | struct pcmcia_device *link; |
2693 | struct net_device *dev; | 2633 | struct net_device *dev; |
2694 | ray_dev_t *local; | 2634 | ray_dev_t *local; |
2695 | UCHAR *p; | 2635 | UCHAR *p; |
2696 | struct freq_hop_element *pfh; | 2636 | struct freq_hop_element *pfh; |
2697 | UCHAR c[33]; | 2637 | UCHAR c[33]; |
2698 | 2638 | ||
2699 | link = dev_list; | 2639 | link = this_device; |
2700 | if (!link) | 2640 | if (!link) |
2701 | return 0; | 2641 | return 0; |
2702 | dev = (struct net_device *)link->priv; | 2642 | dev = (struct net_device *)link->priv; |
@@ -2898,7 +2838,7 @@ static struct pcmcia_driver ray_driver = { | |||
2898 | .drv = { | 2838 | .drv = { |
2899 | .name = "ray_cs", | 2839 | .name = "ray_cs", |
2900 | }, | 2840 | }, |
2901 | .probe = ray_attach, | 2841 | .probe = ray_probe, |
2902 | .remove = ray_detach, | 2842 | .remove = ray_detach, |
2903 | .id_table = ray_ids, | 2843 | .id_table = ray_ids, |
2904 | .suspend = ray_suspend, | 2844 | .suspend = ray_suspend, |
@@ -2940,7 +2880,6 @@ static void __exit exit_ray_cs(void) | |||
2940 | #endif | 2880 | #endif |
2941 | 2881 | ||
2942 | pcmcia_unregister_driver(&ray_driver); | 2882 | pcmcia_unregister_driver(&ray_driver); |
2943 | BUG_ON(dev_list != NULL); | ||
2944 | } /* exit_ray_cs */ | 2883 | } /* exit_ray_cs */ |
2945 | 2884 | ||
2946 | module_init(init_ray_cs); | 2885 | module_init(init_ray_cs); |
diff --git a/drivers/net/wireless/ray_cs.h b/drivers/net/wireless/ray_cs.h index 42660fe64bfd..bd73ebf03340 100644 --- a/drivers/net/wireless/ray_cs.h +++ b/drivers/net/wireless/ray_cs.h | |||
@@ -31,7 +31,7 @@ typedef struct ray_dev_t { | |||
31 | void __iomem *sram; /* pointer to beginning of shared RAM */ | 31 | void __iomem *sram; /* pointer to beginning of shared RAM */ |
32 | void __iomem *amem; /* pointer to attribute mem window */ | 32 | void __iomem *amem; /* pointer to attribute mem window */ |
33 | void __iomem *rmem; /* pointer to receive buffer window */ | 33 | void __iomem *rmem; /* pointer to receive buffer window */ |
34 | dev_link_t *finder; /* pointer back to dev_link_t for card */ | 34 | struct pcmcia_device *finder; /* pointer back to struct pcmcia_device for card */ |
35 | struct timer_list timer; | 35 | struct timer_list timer; |
36 | long tx_ccs_lock; | 36 | long tx_ccs_lock; |
37 | long ccs_lock; | 37 | long ccs_lock; |
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c index 5fa6fbe35bb9..f7b77ce54d7b 100644 --- a/drivers/net/wireless/spectrum_cs.c +++ b/drivers/net/wireless/spectrum_cs.c | |||
@@ -63,7 +63,7 @@ MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket | |||
63 | /* PCMCIA specific device information (goes in the card field of | 63 | /* PCMCIA specific device information (goes in the card field of |
64 | * struct orinoco_private */ | 64 | * struct orinoco_private */ |
65 | struct orinoco_pccard { | 65 | struct orinoco_pccard { |
66 | dev_link_t link; | 66 | struct pcmcia_device *p_dev; |
67 | dev_node_t node; | 67 | dev_node_t node; |
68 | }; | 68 | }; |
69 | 69 | ||
@@ -71,8 +71,8 @@ struct orinoco_pccard { | |||
71 | /* Function prototypes */ | 71 | /* Function prototypes */ |
72 | /********************************************************************/ | 72 | /********************************************************************/ |
73 | 73 | ||
74 | static void spectrum_cs_config(dev_link_t *link); | 74 | static int spectrum_cs_config(struct pcmcia_device *link); |
75 | static void spectrum_cs_release(dev_link_t *link); | 75 | static void spectrum_cs_release(struct pcmcia_device *link); |
76 | 76 | ||
77 | /********************************************************************/ | 77 | /********************************************************************/ |
78 | /* Firmware downloader */ | 78 | /* Firmware downloader */ |
@@ -238,14 +238,14 @@ spectrum_aux_open(hermes_t *hw) | |||
238 | * If IDLE is 1, stop the firmware, so that it can be safely rewritten. | 238 | * If IDLE is 1, stop the firmware, so that it can be safely rewritten. |
239 | */ | 239 | */ |
240 | static int | 240 | static int |
241 | spectrum_reset(dev_link_t *link, int idle) | 241 | spectrum_reset(struct pcmcia_device *link, int idle) |
242 | { | 242 | { |
243 | int last_ret, last_fn; | 243 | int last_ret, last_fn; |
244 | conf_reg_t reg; | 244 | conf_reg_t reg; |
245 | u_int save_cor; | 245 | u_int save_cor; |
246 | 246 | ||
247 | /* Doing it if hardware is gone is guaranteed crash */ | 247 | /* Doing it if hardware is gone is guaranteed crash */ |
248 | if (!(link->state & DEV_CONFIG)) | 248 | if (pcmcia_dev_present(link)) |
249 | return -ENODEV; | 249 | return -ENODEV; |
250 | 250 | ||
251 | /* Save original COR value */ | 251 | /* Save original COR value */ |
@@ -253,7 +253,7 @@ spectrum_reset(dev_link_t *link, int idle) | |||
253 | reg.Action = CS_READ; | 253 | reg.Action = CS_READ; |
254 | reg.Offset = CISREG_COR; | 254 | reg.Offset = CISREG_COR; |
255 | CS_CHECK(AccessConfigurationRegister, | 255 | CS_CHECK(AccessConfigurationRegister, |
256 | pcmcia_access_configuration_register(link->handle, ®)); | 256 | pcmcia_access_configuration_register(link, ®)); |
257 | save_cor = reg.Value; | 257 | save_cor = reg.Value; |
258 | 258 | ||
259 | /* Soft-Reset card */ | 259 | /* Soft-Reset card */ |
@@ -261,14 +261,14 @@ spectrum_reset(dev_link_t *link, int idle) | |||
261 | reg.Offset = CISREG_COR; | 261 | reg.Offset = CISREG_COR; |
262 | reg.Value = (save_cor | COR_SOFT_RESET); | 262 | reg.Value = (save_cor | COR_SOFT_RESET); |
263 | CS_CHECK(AccessConfigurationRegister, | 263 | CS_CHECK(AccessConfigurationRegister, |
264 | pcmcia_access_configuration_register(link->handle, ®)); | 264 | pcmcia_access_configuration_register(link, ®)); |
265 | udelay(1000); | 265 | udelay(1000); |
266 | 266 | ||
267 | /* Read CCSR */ | 267 | /* Read CCSR */ |
268 | reg.Action = CS_READ; | 268 | reg.Action = CS_READ; |
269 | reg.Offset = CISREG_CCSR; | 269 | reg.Offset = CISREG_CCSR; |
270 | CS_CHECK(AccessConfigurationRegister, | 270 | CS_CHECK(AccessConfigurationRegister, |
271 | pcmcia_access_configuration_register(link->handle, ®)); | 271 | pcmcia_access_configuration_register(link, ®)); |
272 | 272 | ||
273 | /* | 273 | /* |
274 | * Start or stop the firmware. Memory width bit should be | 274 | * Start or stop the firmware. Memory width bit should be |
@@ -278,7 +278,7 @@ spectrum_reset(dev_link_t *link, int idle) | |||
278 | reg.Offset = CISREG_CCSR; | 278 | reg.Offset = CISREG_CCSR; |
279 | reg.Value = (idle ? HCR_IDLE : HCR_RUN) | (reg.Value & HCR_MEM16); | 279 | reg.Value = (idle ? HCR_IDLE : HCR_RUN) | (reg.Value & HCR_MEM16); |
280 | CS_CHECK(AccessConfigurationRegister, | 280 | CS_CHECK(AccessConfigurationRegister, |
281 | pcmcia_access_configuration_register(link->handle, ®)); | 281 | pcmcia_access_configuration_register(link, ®)); |
282 | udelay(1000); | 282 | udelay(1000); |
283 | 283 | ||
284 | /* Restore original COR configuration index */ | 284 | /* Restore original COR configuration index */ |
@@ -286,12 +286,12 @@ spectrum_reset(dev_link_t *link, int idle) | |||
286 | reg.Offset = CISREG_COR; | 286 | reg.Offset = CISREG_COR; |
287 | reg.Value = (save_cor & ~COR_SOFT_RESET); | 287 | reg.Value = (save_cor & ~COR_SOFT_RESET); |
288 | CS_CHECK(AccessConfigurationRegister, | 288 | CS_CHECK(AccessConfigurationRegister, |
289 | pcmcia_access_configuration_register(link->handle, ®)); | 289 | pcmcia_access_configuration_register(link, ®)); |
290 | udelay(1000); | 290 | udelay(1000); |
291 | return 0; | 291 | return 0; |
292 | 292 | ||
293 | cs_failed: | 293 | cs_failed: |
294 | cs_error(link->handle, last_fn, last_ret); | 294 | cs_error(link, last_fn, last_ret); |
295 | return -ENODEV; | 295 | return -ENODEV; |
296 | } | 296 | } |
297 | 297 | ||
@@ -441,7 +441,7 @@ spectrum_load_blocks(hermes_t *hw, const struct dblock *first_block) | |||
441 | * care of the PDA - read it and then write it on top of the firmware. | 441 | * care of the PDA - read it and then write it on top of the firmware. |
442 | */ | 442 | */ |
443 | static int | 443 | static int |
444 | spectrum_dl_image(hermes_t *hw, dev_link_t *link, | 444 | spectrum_dl_image(hermes_t *hw, struct pcmcia_device *link, |
445 | const unsigned char *image) | 445 | const unsigned char *image) |
446 | { | 446 | { |
447 | int ret; | 447 | int ret; |
@@ -505,14 +505,13 @@ spectrum_dl_image(hermes_t *hw, dev_link_t *link, | |||
505 | * reset on the card, to make sure it's in a sane state. | 505 | * reset on the card, to make sure it's in a sane state. |
506 | */ | 506 | */ |
507 | static int | 507 | static int |
508 | spectrum_dl_firmware(hermes_t *hw, dev_link_t *link) | 508 | spectrum_dl_firmware(hermes_t *hw, struct pcmcia_device *link) |
509 | { | 509 | { |
510 | int ret; | 510 | int ret; |
511 | client_handle_t handle = link->handle; | ||
512 | const struct firmware *fw_entry; | 511 | const struct firmware *fw_entry; |
513 | 512 | ||
514 | if (request_firmware(&fw_entry, primary_fw_name, | 513 | if (request_firmware(&fw_entry, primary_fw_name, |
515 | &handle_to_dev(handle)) == 0) { | 514 | &handle_to_dev(link)) == 0) { |
516 | primsym = fw_entry->data; | 515 | primsym = fw_entry->data; |
517 | } else { | 516 | } else { |
518 | printk(KERN_ERR PFX "Cannot find firmware: %s\n", | 517 | printk(KERN_ERR PFX "Cannot find firmware: %s\n", |
@@ -521,7 +520,7 @@ spectrum_dl_firmware(hermes_t *hw, dev_link_t *link) | |||
521 | } | 520 | } |
522 | 521 | ||
523 | if (request_firmware(&fw_entry, secondary_fw_name, | 522 | if (request_firmware(&fw_entry, secondary_fw_name, |
524 | &handle_to_dev(handle)) == 0) { | 523 | &handle_to_dev(link)) == 0) { |
525 | secsym = fw_entry->data; | 524 | secsym = fw_entry->data; |
526 | } else { | 525 | } else { |
527 | printk(KERN_ERR PFX "Cannot find firmware: %s\n", | 526 | printk(KERN_ERR PFX "Cannot find firmware: %s\n", |
@@ -554,12 +553,12 @@ static int | |||
554 | spectrum_cs_hard_reset(struct orinoco_private *priv) | 553 | spectrum_cs_hard_reset(struct orinoco_private *priv) |
555 | { | 554 | { |
556 | struct orinoco_pccard *card = priv->card; | 555 | struct orinoco_pccard *card = priv->card; |
557 | dev_link_t *link = &card->link; | 556 | struct pcmcia_device *link = card->p_dev; |
558 | int err; | 557 | int err; |
559 | 558 | ||
560 | if (!hermes_present(&priv->hw)) { | 559 | if (!hermes_present(&priv->hw)) { |
561 | /* The firmware needs to be reloaded */ | 560 | /* The firmware needs to be reloaded */ |
562 | if (spectrum_dl_firmware(&priv->hw, &card->link) != 0) { | 561 | if (spectrum_dl_firmware(&priv->hw, link) != 0) { |
563 | printk(KERN_ERR PFX "Firmware download failed\n"); | 562 | printk(KERN_ERR PFX "Firmware download failed\n"); |
564 | err = -ENODEV; | 563 | err = -ENODEV; |
565 | } | 564 | } |
@@ -584,12 +583,11 @@ spectrum_cs_hard_reset(struct orinoco_private *priv) | |||
584 | * configure the card at this point -- we wait until we receive a card | 583 | * configure the card at this point -- we wait until we receive a card |
585 | * insertion event. */ | 584 | * insertion event. */ |
586 | static int | 585 | static int |
587 | spectrum_cs_attach(struct pcmcia_device *p_dev) | 586 | spectrum_cs_probe(struct pcmcia_device *link) |
588 | { | 587 | { |
589 | struct net_device *dev; | 588 | struct net_device *dev; |
590 | struct orinoco_private *priv; | 589 | struct orinoco_private *priv; |
591 | struct orinoco_pccard *card; | 590 | struct orinoco_pccard *card; |
592 | dev_link_t *link; | ||
593 | 591 | ||
594 | dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset); | 592 | dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset); |
595 | if (! dev) | 593 | if (! dev) |
@@ -598,7 +596,7 @@ spectrum_cs_attach(struct pcmcia_device *p_dev) | |||
598 | card = priv->card; | 596 | card = priv->card; |
599 | 597 | ||
600 | /* Link both structures together */ | 598 | /* Link both structures together */ |
601 | link = &card->link; | 599 | card->p_dev = link; |
602 | link->priv = dev; | 600 | link->priv = dev; |
603 | 601 | ||
604 | /* Interrupt setup */ | 602 | /* Interrupt setup */ |
@@ -615,13 +613,7 @@ spectrum_cs_attach(struct pcmcia_device *p_dev) | |||
615 | link->conf.Attributes = 0; | 613 | link->conf.Attributes = 0; |
616 | link->conf.IntType = INT_MEMORY_AND_IO; | 614 | link->conf.IntType = INT_MEMORY_AND_IO; |
617 | 615 | ||
618 | link->handle = p_dev; | 616 | return spectrum_cs_config(link); |
619 | p_dev->instance = link; | ||
620 | |||
621 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
622 | spectrum_cs_config(link); | ||
623 | |||
624 | return 0; | ||
625 | } /* spectrum_cs_attach */ | 617 | } /* spectrum_cs_attach */ |
626 | 618 | ||
627 | /* | 619 | /* |
@@ -630,16 +622,14 @@ spectrum_cs_attach(struct pcmcia_device *p_dev) | |||
630 | * are freed. Otherwise, the structures will be freed when the device | 622 | * are freed. Otherwise, the structures will be freed when the device |
631 | * is released. | 623 | * is released. |
632 | */ | 624 | */ |
633 | static void spectrum_cs_detach(struct pcmcia_device *p_dev) | 625 | static void spectrum_cs_detach(struct pcmcia_device *link) |
634 | { | 626 | { |
635 | dev_link_t *link = dev_to_instance(p_dev); | ||
636 | struct net_device *dev = link->priv; | 627 | struct net_device *dev = link->priv; |
637 | 628 | ||
638 | if (link->state & DEV_CONFIG) | 629 | spectrum_cs_release(link); |
639 | spectrum_cs_release(link); | ||
640 | 630 | ||
641 | DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); | 631 | DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node); |
642 | if (link->dev) { | 632 | if (link->dev_node) { |
643 | DEBUG(0, PFX "About to unregister net device %p\n", | 633 | DEBUG(0, PFX "About to unregister net device %p\n", |
644 | dev); | 634 | dev); |
645 | unregister_netdev(dev); | 635 | unregister_netdev(dev); |
@@ -653,11 +643,10 @@ static void spectrum_cs_detach(struct pcmcia_device *p_dev) | |||
653 | * device available to the system. | 643 | * device available to the system. |
654 | */ | 644 | */ |
655 | 645 | ||
656 | static void | 646 | static int |
657 | spectrum_cs_config(dev_link_t *link) | 647 | spectrum_cs_config(struct pcmcia_device *link) |
658 | { | 648 | { |
659 | struct net_device *dev = link->priv; | 649 | struct net_device *dev = link->priv; |
660 | client_handle_t handle = link->handle; | ||
661 | struct orinoco_private *priv = netdev_priv(dev); | 650 | struct orinoco_private *priv = netdev_priv(dev); |
662 | struct orinoco_pccard *card = priv->card; | 651 | struct orinoco_pccard *card = priv->card; |
663 | hermes_t *hw = &priv->hw; | 652 | hermes_t *hw = &priv->hw; |
@@ -669,7 +658,7 @@ spectrum_cs_config(dev_link_t *link) | |||
669 | cisparse_t parse; | 658 | cisparse_t parse; |
670 | void __iomem *mem; | 659 | void __iomem *mem; |
671 | 660 | ||
672 | CS_CHECK(ValidateCIS, pcmcia_validate_cis(handle, &info)); | 661 | CS_CHECK(ValidateCIS, pcmcia_validate_cis(link, &info)); |
673 | 662 | ||
674 | /* | 663 | /* |
675 | * This reads the card's CONFIG tuple to find its | 664 | * This reads the card's CONFIG tuple to find its |
@@ -680,19 +669,15 @@ spectrum_cs_config(dev_link_t *link) | |||
680 | tuple.TupleData = buf; | 669 | tuple.TupleData = buf; |
681 | tuple.TupleDataMax = sizeof(buf); | 670 | tuple.TupleDataMax = sizeof(buf); |
682 | tuple.TupleOffset = 0; | 671 | tuple.TupleOffset = 0; |
683 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 672 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
684 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | 673 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
685 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); | 674 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); |
686 | link->conf.ConfigBase = parse.config.base; | 675 | link->conf.ConfigBase = parse.config.base; |
687 | link->conf.Present = parse.config.rmask[0]; | 676 | link->conf.Present = parse.config.rmask[0]; |
688 | 677 | ||
689 | /* Configure card */ | ||
690 | link->state |= DEV_CONFIG; | ||
691 | |||
692 | /* Look up the current Vcc */ | 678 | /* Look up the current Vcc */ |
693 | CS_CHECK(GetConfigurationInfo, | 679 | CS_CHECK(GetConfigurationInfo, |
694 | pcmcia_get_configuration_info(handle, &conf)); | 680 | pcmcia_get_configuration_info(link, &conf)); |
695 | link->conf.Vcc = conf.Vcc; | ||
696 | 681 | ||
697 | /* | 682 | /* |
698 | * In this loop, we scan the CIS for configuration table | 683 | * In this loop, we scan the CIS for configuration table |
@@ -709,13 +694,13 @@ spectrum_cs_config(dev_link_t *link) | |||
709 | * implementation-defined details. | 694 | * implementation-defined details. |
710 | */ | 695 | */ |
711 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 696 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
712 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 697 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
713 | while (1) { | 698 | while (1) { |
714 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | 699 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); |
715 | cistpl_cftable_entry_t dflt = { .index = 0 }; | 700 | cistpl_cftable_entry_t dflt = { .index = 0 }; |
716 | 701 | ||
717 | if ( (pcmcia_get_tuple_data(handle, &tuple) != 0) | 702 | if ( (pcmcia_get_tuple_data(link, &tuple) != 0) |
718 | || (pcmcia_parse_tuple(handle, &tuple, &parse) != 0)) | 703 | || (pcmcia_parse_tuple(link, &tuple, &parse) != 0)) |
719 | goto next_entry; | 704 | goto next_entry; |
720 | 705 | ||
721 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | 706 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) |
@@ -747,10 +732,10 @@ spectrum_cs_config(dev_link_t *link) | |||
747 | } | 732 | } |
748 | 733 | ||
749 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | 734 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) |
750 | link->conf.Vpp1 = link->conf.Vpp2 = | 735 | link->conf.Vpp = |
751 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | 736 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; |
752 | else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) | 737 | else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) |
753 | link->conf.Vpp1 = link->conf.Vpp2 = | 738 | link->conf.Vpp = |
754 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | 739 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; |
755 | 740 | ||
756 | /* Do we need to allocate an interrupt? */ | 741 | /* Do we need to allocate an interrupt? */ |
@@ -780,7 +765,7 @@ spectrum_cs_config(dev_link_t *link) | |||
780 | } | 765 | } |
781 | 766 | ||
782 | /* This reserves IO space but doesn't actually enable it */ | 767 | /* This reserves IO space but doesn't actually enable it */ |
783 | if (pcmcia_request_io(link->handle, &link->io) != 0) | 768 | if (pcmcia_request_io(link, &link->io) != 0) |
784 | goto next_entry; | 769 | goto next_entry; |
785 | } | 770 | } |
786 | 771 | ||
@@ -790,9 +775,8 @@ spectrum_cs_config(dev_link_t *link) | |||
790 | break; | 775 | break; |
791 | 776 | ||
792 | next_entry: | 777 | next_entry: |
793 | if (link->io.NumPorts1) | 778 | pcmcia_disable_device(link); |
794 | pcmcia_release_io(link->handle, &link->io); | 779 | last_ret = pcmcia_get_next_tuple(link, &tuple); |
795 | last_ret = pcmcia_get_next_tuple(handle, &tuple); | ||
796 | if (last_ret == CS_NO_MORE_ITEMS) { | 780 | if (last_ret == CS_NO_MORE_ITEMS) { |
797 | printk(KERN_ERR PFX "GetNextTuple(): No matching " | 781 | printk(KERN_ERR PFX "GetNextTuple(): No matching " |
798 | "CIS configuration. Maybe you need the " | 782 | "CIS configuration. Maybe you need the " |
@@ -806,7 +790,7 @@ spectrum_cs_config(dev_link_t *link) | |||
806 | * a handler to the interrupt, unless the 'Handler' member of | 790 | * a handler to the interrupt, unless the 'Handler' member of |
807 | * the irq structure is initialized. | 791 | * the irq structure is initialized. |
808 | */ | 792 | */ |
809 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); | 793 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
810 | 794 | ||
811 | /* We initialize the hermes structure before completing PCMCIA | 795 | /* We initialize the hermes structure before completing PCMCIA |
812 | * configuration just in case the interrupt handler gets | 796 | * configuration just in case the interrupt handler gets |
@@ -823,7 +807,7 @@ spectrum_cs_config(dev_link_t *link) | |||
823 | * card and host interface into "Memory and IO" mode. | 807 | * card and host interface into "Memory and IO" mode. |
824 | */ | 808 | */ |
825 | CS_CHECK(RequestConfiguration, | 809 | CS_CHECK(RequestConfiguration, |
826 | pcmcia_request_configuration(link->handle, &link->conf)); | 810 | pcmcia_request_configuration(link, &link->conf)); |
827 | 811 | ||
828 | /* Ok, we have the configuration, prepare to register the netdev */ | 812 | /* Ok, we have the configuration, prepare to register the netdev */ |
829 | dev->base_addr = link->io.BasePort1; | 813 | dev->base_addr = link->io.BasePort1; |
@@ -836,7 +820,7 @@ spectrum_cs_config(dev_link_t *link) | |||
836 | goto failed; | 820 | goto failed; |
837 | } | 821 | } |
838 | 822 | ||
839 | SET_NETDEV_DEV(dev, &handle_to_dev(handle)); | 823 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); |
840 | /* Tell the stack we exist */ | 824 | /* Tell the stack we exist */ |
841 | if (register_netdev(dev) != 0) { | 825 | if (register_netdev(dev) != 0) { |
842 | printk(KERN_ERR PFX "register_netdev() failed\n"); | 826 | printk(KERN_ERR PFX "register_netdev() failed\n"); |
@@ -844,20 +828,18 @@ spectrum_cs_config(dev_link_t *link) | |||
844 | } | 828 | } |
845 | 829 | ||
846 | /* At this point, the dev_node_t structure(s) needs to be | 830 | /* At this point, the dev_node_t structure(s) needs to be |
847 | * initialized and arranged in a linked list at link->dev. */ | 831 | * initialized and arranged in a linked list at link->dev_node. */ |
848 | strcpy(card->node.dev_name, dev->name); | 832 | strcpy(card->node.dev_name, dev->name); |
849 | link->dev = &card->node; /* link->dev being non-NULL is also | 833 | link->dev_node = &card->node; /* link->dev_node being non-NULL is also |
850 | used to indicate that the | 834 | used to indicate that the |
851 | net_device has been registered */ | 835 | net_device has been registered */ |
852 | link->state &= ~DEV_CONFIG_PENDING; | ||
853 | 836 | ||
854 | /* Finally, report what we've done */ | 837 | /* Finally, report what we've done */ |
855 | printk(KERN_DEBUG "%s: index 0x%02x: Vcc %d.%d", | 838 | printk(KERN_DEBUG "%s: index 0x%02x: ", |
856 | dev->name, link->conf.ConfigIndex, | 839 | dev->name, link->conf.ConfigIndex); |
857 | link->conf.Vcc / 10, link->conf.Vcc % 10); | 840 | if (link->conf.Vpp) |
858 | if (link->conf.Vpp1) | 841 | printk(", Vpp %d.%d", link->conf.Vpp / 10, |
859 | printk(", Vpp %d.%d", link->conf.Vpp1 / 10, | 842 | link->conf.Vpp % 10); |
860 | link->conf.Vpp1 % 10); | ||
861 | printk(", irq %d", link->irq.AssignedIRQ); | 843 | printk(", irq %d", link->irq.AssignedIRQ); |
862 | if (link->io.NumPorts1) | 844 | if (link->io.NumPorts1) |
863 | printk(", io 0x%04x-0x%04x", link->io.BasePort1, | 845 | printk(", io 0x%04x-0x%04x", link->io.BasePort1, |
@@ -867,13 +849,14 @@ spectrum_cs_config(dev_link_t *link) | |||
867 | link->io.BasePort2 + link->io.NumPorts2 - 1); | 849 | link->io.BasePort2 + link->io.NumPorts2 - 1); |
868 | printk("\n"); | 850 | printk("\n"); |
869 | 851 | ||
870 | return; | 852 | return 0; |
871 | 853 | ||
872 | cs_failed: | 854 | cs_failed: |
873 | cs_error(link->handle, last_fn, last_ret); | 855 | cs_error(link, last_fn, last_ret); |
874 | 856 | ||
875 | failed: | 857 | failed: |
876 | spectrum_cs_release(link); | 858 | spectrum_cs_release(link); |
859 | return -ENODEV; | ||
877 | } /* spectrum_cs_config */ | 860 | } /* spectrum_cs_config */ |
878 | 861 | ||
879 | /* | 862 | /* |
@@ -882,7 +865,7 @@ spectrum_cs_config(dev_link_t *link) | |||
882 | * still open, this will be postponed until it is closed. | 865 | * still open, this will be postponed until it is closed. |
883 | */ | 866 | */ |
884 | static void | 867 | static void |
885 | spectrum_cs_release(dev_link_t *link) | 868 | spectrum_cs_release(struct pcmcia_device *link) |
886 | { | 869 | { |
887 | struct net_device *dev = link->priv; | 870 | struct net_device *dev = link->priv; |
888 | struct orinoco_private *priv = netdev_priv(dev); | 871 | struct orinoco_private *priv = netdev_priv(dev); |
@@ -894,64 +877,46 @@ spectrum_cs_release(dev_link_t *link) | |||
894 | priv->hw_unavailable++; | 877 | priv->hw_unavailable++; |
895 | spin_unlock_irqrestore(&priv->lock, flags); | 878 | spin_unlock_irqrestore(&priv->lock, flags); |
896 | 879 | ||
897 | /* Don't bother checking to see if these succeed or not */ | 880 | pcmcia_disable_device(link); |
898 | pcmcia_release_configuration(link->handle); | ||
899 | if (link->io.NumPorts1) | ||
900 | pcmcia_release_io(link->handle, &link->io); | ||
901 | if (link->irq.AssignedIRQ) | ||
902 | pcmcia_release_irq(link->handle, &link->irq); | ||
903 | link->state &= ~DEV_CONFIG; | ||
904 | if (priv->hw.iobase) | 881 | if (priv->hw.iobase) |
905 | ioport_unmap(priv->hw.iobase); | 882 | ioport_unmap(priv->hw.iobase); |
906 | } /* spectrum_cs_release */ | 883 | } /* spectrum_cs_release */ |
907 | 884 | ||
908 | 885 | ||
909 | static int | 886 | static int |
910 | spectrum_cs_suspend(struct pcmcia_device *p_dev) | 887 | spectrum_cs_suspend(struct pcmcia_device *link) |
911 | { | 888 | { |
912 | dev_link_t *link = dev_to_instance(p_dev); | ||
913 | struct net_device *dev = link->priv; | 889 | struct net_device *dev = link->priv; |
914 | struct orinoco_private *priv = netdev_priv(dev); | 890 | struct orinoco_private *priv = netdev_priv(dev); |
915 | unsigned long flags; | 891 | unsigned long flags; |
916 | int err = 0; | 892 | int err = 0; |
917 | 893 | ||
918 | link->state |= DEV_SUSPEND; | ||
919 | /* Mark the device as stopped, to block IO until later */ | 894 | /* Mark the device as stopped, to block IO until later */ |
920 | if (link->state & DEV_CONFIG) { | 895 | spin_lock_irqsave(&priv->lock, flags); |
921 | spin_lock_irqsave(&priv->lock, flags); | ||
922 | |||
923 | err = __orinoco_down(dev); | ||
924 | if (err) | ||
925 | printk(KERN_WARNING "%s: Error %d downing interface\n", | ||
926 | dev->name, err); | ||
927 | 896 | ||
928 | netif_device_detach(dev); | 897 | err = __orinoco_down(dev); |
929 | priv->hw_unavailable++; | 898 | if (err) |
899 | printk(KERN_WARNING "%s: Error %d downing interface\n", | ||
900 | dev->name, err); | ||
930 | 901 | ||
931 | spin_unlock_irqrestore(&priv->lock, flags); | 902 | netif_device_detach(dev); |
903 | priv->hw_unavailable++; | ||
932 | 904 | ||
933 | pcmcia_release_configuration(link->handle); | 905 | spin_unlock_irqrestore(&priv->lock, flags); |
934 | } | ||
935 | 906 | ||
936 | return 0; | 907 | return 0; |
937 | } | 908 | } |
938 | 909 | ||
939 | static int | 910 | static int |
940 | spectrum_cs_resume(struct pcmcia_device *p_dev) | 911 | spectrum_cs_resume(struct pcmcia_device *link) |
941 | { | 912 | { |
942 | dev_link_t *link = dev_to_instance(p_dev); | ||
943 | struct net_device *dev = link->priv; | 913 | struct net_device *dev = link->priv; |
944 | struct orinoco_private *priv = netdev_priv(dev); | 914 | struct orinoco_private *priv = netdev_priv(dev); |
945 | 915 | ||
946 | link->state &= ~DEV_SUSPEND; | 916 | netif_device_attach(dev); |
947 | if (link->state & DEV_CONFIG) { | 917 | priv->hw_unavailable--; |
948 | /* FIXME: should we double check that this is | 918 | schedule_work(&priv->reset_work); |
949 | * the same card as we had before */ | 919 | |
950 | pcmcia_request_configuration(link->handle, &link->conf); | ||
951 | netif_device_attach(dev); | ||
952 | priv->hw_unavailable--; | ||
953 | schedule_work(&priv->reset_work); | ||
954 | } | ||
955 | return 0; | 920 | return 0; |
956 | } | 921 | } |
957 | 922 | ||
@@ -979,7 +944,7 @@ static struct pcmcia_driver orinoco_driver = { | |||
979 | .drv = { | 944 | .drv = { |
980 | .name = DRIVER_NAME, | 945 | .name = DRIVER_NAME, |
981 | }, | 946 | }, |
982 | .probe = spectrum_cs_attach, | 947 | .probe = spectrum_cs_probe, |
983 | .remove = spectrum_cs_detach, | 948 | .remove = spectrum_cs_detach, |
984 | .suspend = spectrum_cs_suspend, | 949 | .suspend = spectrum_cs_suspend, |
985 | .resume = spectrum_cs_resume, | 950 | .resume = spectrum_cs_resume, |
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index 98122f3a4bc2..f7724eb2fa7e 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c | |||
@@ -1005,7 +1005,7 @@ static inline void | |||
1005 | wv_82593_reconfig(struct net_device * dev) | 1005 | wv_82593_reconfig(struct net_device * dev) |
1006 | { | 1006 | { |
1007 | net_local * lp = netdev_priv(dev); | 1007 | net_local * lp = netdev_priv(dev); |
1008 | dev_link_t * link = lp->link; | 1008 | struct pcmcia_device * link = lp->link; |
1009 | unsigned long flags; | 1009 | unsigned long flags; |
1010 | 1010 | ||
1011 | /* Arm the flag, will be cleard in wv_82593_config() */ | 1011 | /* Arm the flag, will be cleard in wv_82593_config() */ |
@@ -3744,16 +3744,16 @@ wv_pcmcia_reset(struct net_device * dev) | |||
3744 | { | 3744 | { |
3745 | int i; | 3745 | int i; |
3746 | conf_reg_t reg = { 0, CS_READ, CISREG_COR, 0 }; | 3746 | conf_reg_t reg = { 0, CS_READ, CISREG_COR, 0 }; |
3747 | dev_link_t * link = ((net_local *)netdev_priv(dev))->link; | 3747 | struct pcmcia_device * link = ((net_local *)netdev_priv(dev))->link; |
3748 | 3748 | ||
3749 | #ifdef DEBUG_CONFIG_TRACE | 3749 | #ifdef DEBUG_CONFIG_TRACE |
3750 | printk(KERN_DEBUG "%s: ->wv_pcmcia_reset()\n", dev->name); | 3750 | printk(KERN_DEBUG "%s: ->wv_pcmcia_reset()\n", dev->name); |
3751 | #endif | 3751 | #endif |
3752 | 3752 | ||
3753 | i = pcmcia_access_configuration_register(link->handle, ®); | 3753 | i = pcmcia_access_configuration_register(link, ®); |
3754 | if(i != CS_SUCCESS) | 3754 | if(i != CS_SUCCESS) |
3755 | { | 3755 | { |
3756 | cs_error(link->handle, AccessConfigurationRegister, i); | 3756 | cs_error(link, AccessConfigurationRegister, i); |
3757 | return FALSE; | 3757 | return FALSE; |
3758 | } | 3758 | } |
3759 | 3759 | ||
@@ -3764,19 +3764,19 @@ wv_pcmcia_reset(struct net_device * dev) | |||
3764 | 3764 | ||
3765 | reg.Action = CS_WRITE; | 3765 | reg.Action = CS_WRITE; |
3766 | reg.Value = reg.Value | COR_SW_RESET; | 3766 | reg.Value = reg.Value | COR_SW_RESET; |
3767 | i = pcmcia_access_configuration_register(link->handle, ®); | 3767 | i = pcmcia_access_configuration_register(link, ®); |
3768 | if(i != CS_SUCCESS) | 3768 | if(i != CS_SUCCESS) |
3769 | { | 3769 | { |
3770 | cs_error(link->handle, AccessConfigurationRegister, i); | 3770 | cs_error(link, AccessConfigurationRegister, i); |
3771 | return FALSE; | 3771 | return FALSE; |
3772 | } | 3772 | } |
3773 | 3773 | ||
3774 | reg.Action = CS_WRITE; | 3774 | reg.Action = CS_WRITE; |
3775 | reg.Value = COR_LEVEL_IRQ | COR_CONFIG; | 3775 | reg.Value = COR_LEVEL_IRQ | COR_CONFIG; |
3776 | i = pcmcia_access_configuration_register(link->handle, ®); | 3776 | i = pcmcia_access_configuration_register(link, ®); |
3777 | if(i != CS_SUCCESS) | 3777 | if(i != CS_SUCCESS) |
3778 | { | 3778 | { |
3779 | cs_error(link->handle, AccessConfigurationRegister, i); | 3779 | cs_error(link, AccessConfigurationRegister, i); |
3780 | return FALSE; | 3780 | return FALSE; |
3781 | } | 3781 | } |
3782 | 3782 | ||
@@ -3940,9 +3940,8 @@ wv_hw_reset(struct net_device * dev) | |||
3940 | * (called by wavelan_event()) | 3940 | * (called by wavelan_event()) |
3941 | */ | 3941 | */ |
3942 | static inline int | 3942 | static inline int |
3943 | wv_pcmcia_config(dev_link_t * link) | 3943 | wv_pcmcia_config(struct pcmcia_device * link) |
3944 | { | 3944 | { |
3945 | client_handle_t handle = link->handle; | ||
3946 | tuple_t tuple; | 3945 | tuple_t tuple; |
3947 | cisparse_t parse; | 3946 | cisparse_t parse; |
3948 | struct net_device * dev = (struct net_device *) link->priv; | 3947 | struct net_device * dev = (struct net_device *) link->priv; |
@@ -3965,16 +3964,16 @@ wv_pcmcia_config(dev_link_t * link) | |||
3965 | { | 3964 | { |
3966 | tuple.Attributes = 0; | 3965 | tuple.Attributes = 0; |
3967 | tuple.DesiredTuple = CISTPL_CONFIG; | 3966 | tuple.DesiredTuple = CISTPL_CONFIG; |
3968 | i = pcmcia_get_first_tuple(handle, &tuple); | 3967 | i = pcmcia_get_first_tuple(link, &tuple); |
3969 | if(i != CS_SUCCESS) | 3968 | if(i != CS_SUCCESS) |
3970 | break; | 3969 | break; |
3971 | tuple.TupleData = (cisdata_t *)buf; | 3970 | tuple.TupleData = (cisdata_t *)buf; |
3972 | tuple.TupleDataMax = 64; | 3971 | tuple.TupleDataMax = 64; |
3973 | tuple.TupleOffset = 0; | 3972 | tuple.TupleOffset = 0; |
3974 | i = pcmcia_get_tuple_data(handle, &tuple); | 3973 | i = pcmcia_get_tuple_data(link, &tuple); |
3975 | if(i != CS_SUCCESS) | 3974 | if(i != CS_SUCCESS) |
3976 | break; | 3975 | break; |
3977 | i = pcmcia_parse_tuple(handle, &tuple, &parse); | 3976 | i = pcmcia_parse_tuple(link, &tuple, &parse); |
3978 | if(i != CS_SUCCESS) | 3977 | if(i != CS_SUCCESS) |
3979 | break; | 3978 | break; |
3980 | link->conf.ConfigBase = parse.config.base; | 3979 | link->conf.ConfigBase = parse.config.base; |
@@ -3983,19 +3982,16 @@ wv_pcmcia_config(dev_link_t * link) | |||
3983 | while(0); | 3982 | while(0); |
3984 | if(i != CS_SUCCESS) | 3983 | if(i != CS_SUCCESS) |
3985 | { | 3984 | { |
3986 | cs_error(link->handle, ParseTuple, i); | 3985 | cs_error(link, ParseTuple, i); |
3987 | link->state &= ~DEV_CONFIG_PENDING; | ||
3988 | return FALSE; | 3986 | return FALSE; |
3989 | } | 3987 | } |
3990 | 3988 | ||
3991 | /* Configure card */ | ||
3992 | link->state |= DEV_CONFIG; | ||
3993 | do | 3989 | do |
3994 | { | 3990 | { |
3995 | i = pcmcia_request_io(link->handle, &link->io); | 3991 | i = pcmcia_request_io(link, &link->io); |
3996 | if(i != CS_SUCCESS) | 3992 | if(i != CS_SUCCESS) |
3997 | { | 3993 | { |
3998 | cs_error(link->handle, RequestIO, i); | 3994 | cs_error(link, RequestIO, i); |
3999 | break; | 3995 | break; |
4000 | } | 3996 | } |
4001 | 3997 | ||
@@ -4003,10 +3999,10 @@ wv_pcmcia_config(dev_link_t * link) | |||
4003 | * Now allocate an interrupt line. Note that this does not | 3999 | * Now allocate an interrupt line. Note that this does not |
4004 | * actually assign a handler to the interrupt. | 4000 | * actually assign a handler to the interrupt. |
4005 | */ | 4001 | */ |
4006 | i = pcmcia_request_irq(link->handle, &link->irq); | 4002 | i = pcmcia_request_irq(link, &link->irq); |
4007 | if(i != CS_SUCCESS) | 4003 | if(i != CS_SUCCESS) |
4008 | { | 4004 | { |
4009 | cs_error(link->handle, RequestIRQ, i); | 4005 | cs_error(link, RequestIRQ, i); |
4010 | break; | 4006 | break; |
4011 | } | 4007 | } |
4012 | 4008 | ||
@@ -4015,15 +4011,15 @@ wv_pcmcia_config(dev_link_t * link) | |||
4015 | * the I/O windows and the interrupt mapping. | 4011 | * the I/O windows and the interrupt mapping. |
4016 | */ | 4012 | */ |
4017 | link->conf.ConfigIndex = 1; | 4013 | link->conf.ConfigIndex = 1; |
4018 | i = pcmcia_request_configuration(link->handle, &link->conf); | 4014 | i = pcmcia_request_configuration(link, &link->conf); |
4019 | if(i != CS_SUCCESS) | 4015 | if(i != CS_SUCCESS) |
4020 | { | 4016 | { |
4021 | cs_error(link->handle, RequestConfiguration, i); | 4017 | cs_error(link, RequestConfiguration, i); |
4022 | break; | 4018 | break; |
4023 | } | 4019 | } |
4024 | 4020 | ||
4025 | /* | 4021 | /* |
4026 | * Allocate a small memory window. Note that the dev_link_t | 4022 | * Allocate a small memory window. Note that the struct pcmcia_device |
4027 | * structure provides space for one window handle -- if your | 4023 | * structure provides space for one window handle -- if your |
4028 | * device needs several windows, you'll need to keep track of | 4024 | * device needs several windows, you'll need to keep track of |
4029 | * the handles in your private data structure, link->priv. | 4025 | * the handles in your private data structure, link->priv. |
@@ -4031,10 +4027,10 @@ wv_pcmcia_config(dev_link_t * link) | |||
4031 | req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; | 4027 | req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; |
4032 | req.Base = req.Size = 0; | 4028 | req.Base = req.Size = 0; |
4033 | req.AccessSpeed = mem_speed; | 4029 | req.AccessSpeed = mem_speed; |
4034 | i = pcmcia_request_window(&link->handle, &req, &link->win); | 4030 | i = pcmcia_request_window(&link, &req, &link->win); |
4035 | if(i != CS_SUCCESS) | 4031 | if(i != CS_SUCCESS) |
4036 | { | 4032 | { |
4037 | cs_error(link->handle, RequestWindow, i); | 4033 | cs_error(link, RequestWindow, i); |
4038 | break; | 4034 | break; |
4039 | } | 4035 | } |
4040 | 4036 | ||
@@ -4046,7 +4042,7 @@ wv_pcmcia_config(dev_link_t * link) | |||
4046 | i = pcmcia_map_mem_page(link->win, &mem); | 4042 | i = pcmcia_map_mem_page(link->win, &mem); |
4047 | if(i != CS_SUCCESS) | 4043 | if(i != CS_SUCCESS) |
4048 | { | 4044 | { |
4049 | cs_error(link->handle, MapMemPage, i); | 4045 | cs_error(link, MapMemPage, i); |
4050 | break; | 4046 | break; |
4051 | } | 4047 | } |
4052 | 4048 | ||
@@ -4060,7 +4056,7 @@ wv_pcmcia_config(dev_link_t * link) | |||
4060 | lp->mem, dev->irq, (u_int) dev->base_addr); | 4056 | lp->mem, dev->irq, (u_int) dev->base_addr); |
4061 | #endif | 4057 | #endif |
4062 | 4058 | ||
4063 | SET_NETDEV_DEV(dev, &handle_to_dev(handle)); | 4059 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); |
4064 | i = register_netdev(dev); | 4060 | i = register_netdev(dev); |
4065 | if(i != 0) | 4061 | if(i != 0) |
4066 | { | 4062 | { |
@@ -4072,7 +4068,6 @@ wv_pcmcia_config(dev_link_t * link) | |||
4072 | } | 4068 | } |
4073 | while(0); /* Humm... Disguised goto !!! */ | 4069 | while(0); /* Humm... Disguised goto !!! */ |
4074 | 4070 | ||
4075 | link->state &= ~DEV_CONFIG_PENDING; | ||
4076 | /* If any step failed, release any partially configured state */ | 4071 | /* If any step failed, release any partially configured state */ |
4077 | if(i != 0) | 4072 | if(i != 0) |
4078 | { | 4073 | { |
@@ -4081,7 +4076,7 @@ wv_pcmcia_config(dev_link_t * link) | |||
4081 | } | 4076 | } |
4082 | 4077 | ||
4083 | strcpy(((net_local *) netdev_priv(dev))->node.dev_name, dev->name); | 4078 | strcpy(((net_local *) netdev_priv(dev))->node.dev_name, dev->name); |
4084 | link->dev = &((net_local *) netdev_priv(dev))->node; | 4079 | link->dev_node = &((net_local *) netdev_priv(dev))->node; |
4085 | 4080 | ||
4086 | #ifdef DEBUG_CONFIG_TRACE | 4081 | #ifdef DEBUG_CONFIG_TRACE |
4087 | printk(KERN_DEBUG "<-wv_pcmcia_config()\n"); | 4082 | printk(KERN_DEBUG "<-wv_pcmcia_config()\n"); |
@@ -4096,26 +4091,20 @@ wv_pcmcia_config(dev_link_t * link) | |||
4096 | * still open, this will be postponed until it is closed. | 4091 | * still open, this will be postponed until it is closed. |
4097 | */ | 4092 | */ |
4098 | static void | 4093 | static void |
4099 | wv_pcmcia_release(dev_link_t *link) | 4094 | wv_pcmcia_release(struct pcmcia_device *link) |
4100 | { | 4095 | { |
4101 | struct net_device * dev = (struct net_device *) link->priv; | 4096 | struct net_device * dev = (struct net_device *) link->priv; |
4102 | net_local * lp = netdev_priv(dev); | 4097 | net_local * lp = netdev_priv(dev); |
4103 | 4098 | ||
4104 | #ifdef DEBUG_CONFIG_TRACE | 4099 | #ifdef DEBUG_CONFIG_TRACE |
4105 | printk(KERN_DEBUG "%s: -> wv_pcmcia_release(0x%p)\n", dev->name, link); | 4100 | printk(KERN_DEBUG "%s: -> wv_pcmcia_release(0x%p)\n", dev->name, link); |
4106 | #endif | 4101 | #endif |
4107 | 4102 | ||
4108 | /* Don't bother checking to see if these succeed or not */ | 4103 | iounmap(lp->mem); |
4109 | iounmap(lp->mem); | 4104 | pcmcia_disable_device(link); |
4110 | pcmcia_release_window(link->win); | ||
4111 | pcmcia_release_configuration(link->handle); | ||
4112 | pcmcia_release_io(link->handle, &link->io); | ||
4113 | pcmcia_release_irq(link->handle, &link->irq); | ||
4114 | |||
4115 | link->state &= ~DEV_CONFIG; | ||
4116 | 4105 | ||
4117 | #ifdef DEBUG_CONFIG_TRACE | 4106 | #ifdef DEBUG_CONFIG_TRACE |
4118 | printk(KERN_DEBUG "%s: <- wv_pcmcia_release()\n", dev->name); | 4107 | printk(KERN_DEBUG "%s: <- wv_pcmcia_release()\n", dev->name); |
4119 | #endif | 4108 | #endif |
4120 | } | 4109 | } |
4121 | 4110 | ||
@@ -4479,7 +4468,7 @@ static int | |||
4479 | wavelan_open(struct net_device * dev) | 4468 | wavelan_open(struct net_device * dev) |
4480 | { | 4469 | { |
4481 | net_local * lp = netdev_priv(dev); | 4470 | net_local * lp = netdev_priv(dev); |
4482 | dev_link_t * link = lp->link; | 4471 | struct pcmcia_device * link = lp->link; |
4483 | kio_addr_t base = dev->base_addr; | 4472 | kio_addr_t base = dev->base_addr; |
4484 | 4473 | ||
4485 | #ifdef DEBUG_CALLBACK_TRACE | 4474 | #ifdef DEBUG_CALLBACK_TRACE |
@@ -4533,7 +4522,7 @@ wavelan_open(struct net_device * dev) | |||
4533 | static int | 4522 | static int |
4534 | wavelan_close(struct net_device * dev) | 4523 | wavelan_close(struct net_device * dev) |
4535 | { | 4524 | { |
4536 | dev_link_t * link = ((net_local *)netdev_priv(dev))->link; | 4525 | struct pcmcia_device * link = ((net_local *)netdev_priv(dev))->link; |
4537 | kio_addr_t base = dev->base_addr; | 4526 | kio_addr_t base = dev->base_addr; |
4538 | 4527 | ||
4539 | #ifdef DEBUG_CALLBACK_TRACE | 4528 | #ifdef DEBUG_CALLBACK_TRACE |
@@ -4587,45 +4576,36 @@ wavelan_close(struct net_device * dev) | |||
4587 | * card insertion event. | 4576 | * card insertion event. |
4588 | */ | 4577 | */ |
4589 | static int | 4578 | static int |
4590 | wavelan_attach(struct pcmcia_device *p_dev) | 4579 | wavelan_probe(struct pcmcia_device *p_dev) |
4591 | { | 4580 | { |
4592 | dev_link_t * link; /* Info for cardmgr */ | ||
4593 | struct net_device * dev; /* Interface generic data */ | 4581 | struct net_device * dev; /* Interface generic data */ |
4594 | net_local * lp; /* Interface specific data */ | 4582 | net_local * lp; /* Interface specific data */ |
4583 | int ret; | ||
4595 | 4584 | ||
4596 | #ifdef DEBUG_CALLBACK_TRACE | 4585 | #ifdef DEBUG_CALLBACK_TRACE |
4597 | printk(KERN_DEBUG "-> wavelan_attach()\n"); | 4586 | printk(KERN_DEBUG "-> wavelan_attach()\n"); |
4598 | #endif | 4587 | #endif |
4599 | 4588 | ||
4600 | /* Initialize the dev_link_t structure */ | ||
4601 | link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); | ||
4602 | if (!link) return -ENOMEM; | ||
4603 | |||
4604 | /* The io structure describes IO port mapping */ | 4589 | /* The io structure describes IO port mapping */ |
4605 | link->io.NumPorts1 = 8; | 4590 | p_dev->io.NumPorts1 = 8; |
4606 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | 4591 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; |
4607 | link->io.IOAddrLines = 3; | 4592 | p_dev->io.IOAddrLines = 3; |
4608 | 4593 | ||
4609 | /* Interrupt setup */ | 4594 | /* Interrupt setup */ |
4610 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; | 4595 | p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; |
4611 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 4596 | p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; |
4612 | link->irq.Handler = wavelan_interrupt; | 4597 | p_dev->irq.Handler = wavelan_interrupt; |
4613 | 4598 | ||
4614 | /* General socket configuration */ | 4599 | /* General socket configuration */ |
4615 | link->conf.Attributes = CONF_ENABLE_IRQ; | 4600 | p_dev->conf.Attributes = CONF_ENABLE_IRQ; |
4616 | link->conf.Vcc = 50; | 4601 | p_dev->conf.IntType = INT_MEMORY_AND_IO; |
4617 | link->conf.IntType = INT_MEMORY_AND_IO; | ||
4618 | |||
4619 | /* Chain drivers */ | ||
4620 | link->next = NULL; | ||
4621 | 4602 | ||
4622 | /* Allocate the generic data structure */ | 4603 | /* Allocate the generic data structure */ |
4623 | dev = alloc_etherdev(sizeof(net_local)); | 4604 | dev = alloc_etherdev(sizeof(net_local)); |
4624 | if (!dev) { | 4605 | if (!dev) |
4625 | kfree(link); | ||
4626 | return -ENOMEM; | 4606 | return -ENOMEM; |
4627 | } | 4607 | |
4628 | link->priv = link->irq.Instance = dev; | 4608 | p_dev->priv = p_dev->irq.Instance = dev; |
4629 | 4609 | ||
4630 | lp = netdev_priv(dev); | 4610 | lp = netdev_priv(dev); |
4631 | 4611 | ||
@@ -4642,7 +4622,6 @@ wavelan_attach(struct pcmcia_device *p_dev) | |||
4642 | spin_lock_init(&lp->spinlock); | 4622 | spin_lock_init(&lp->spinlock); |
4643 | 4623 | ||
4644 | /* back links */ | 4624 | /* back links */ |
4645 | lp->link = link; | ||
4646 | lp->dev = dev; | 4625 | lp->dev = dev; |
4647 | 4626 | ||
4648 | /* wavelan NET3 callbacks */ | 4627 | /* wavelan NET3 callbacks */ |
@@ -4668,15 +4647,18 @@ wavelan_attach(struct pcmcia_device *p_dev) | |||
4668 | /* Other specific data */ | 4647 | /* Other specific data */ |
4669 | dev->mtu = WAVELAN_MTU; | 4648 | dev->mtu = WAVELAN_MTU; |
4670 | 4649 | ||
4671 | link->handle = p_dev; | 4650 | ret = wv_pcmcia_config(p_dev); |
4672 | p_dev->instance = link; | 4651 | if (ret) |
4652 | return ret; | ||
4673 | 4653 | ||
4674 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | 4654 | ret = wv_hw_config(dev); |
4675 | if(wv_pcmcia_config(link) && | 4655 | if (ret) { |
4676 | wv_hw_config(dev)) | ||
4677 | wv_init_info(dev); | ||
4678 | else | ||
4679 | dev->irq = 0; | 4656 | dev->irq = 0; |
4657 | pcmcia_disable_device(p_dev); | ||
4658 | return ret; | ||
4659 | } | ||
4660 | |||
4661 | wv_init_info(dev); | ||
4680 | 4662 | ||
4681 | #ifdef DEBUG_CALLBACK_TRACE | 4663 | #ifdef DEBUG_CALLBACK_TRACE |
4682 | printk(KERN_DEBUG "<- wavelan_attach()\n"); | 4664 | printk(KERN_DEBUG "<- wavelan_attach()\n"); |
@@ -4693,25 +4675,14 @@ wavelan_attach(struct pcmcia_device *p_dev) | |||
4693 | * is released. | 4675 | * is released. |
4694 | */ | 4676 | */ |
4695 | static void | 4677 | static void |
4696 | wavelan_detach(struct pcmcia_device *p_dev) | 4678 | wavelan_detach(struct pcmcia_device *link) |
4697 | { | 4679 | { |
4698 | dev_link_t *link = dev_to_instance(p_dev); | ||
4699 | |||
4700 | #ifdef DEBUG_CALLBACK_TRACE | 4680 | #ifdef DEBUG_CALLBACK_TRACE |
4701 | printk(KERN_DEBUG "-> wavelan_detach(0x%p)\n", link); | 4681 | printk(KERN_DEBUG "-> wavelan_detach(0x%p)\n", link); |
4702 | #endif | 4682 | #endif |
4703 | 4683 | ||
4704 | /* | 4684 | /* Some others haven't done their job : give them another chance */ |
4705 | * If the device is currently configured and active, we won't | 4685 | wv_pcmcia_release(link); |
4706 | * actually delete it yet. Instead, it is marked so that when the | ||
4707 | * release() function is called, that will trigger a proper | ||
4708 | * detach(). | ||
4709 | */ | ||
4710 | if(link->state & DEV_CONFIG) | ||
4711 | { | ||
4712 | /* Some others haven't done their job : give them another chance */ | ||
4713 | wv_pcmcia_release(link); | ||
4714 | } | ||
4715 | 4686 | ||
4716 | /* Free pieces */ | 4687 | /* Free pieces */ |
4717 | if(link->priv) | 4688 | if(link->priv) |
@@ -4720,23 +4691,21 @@ wavelan_detach(struct pcmcia_device *p_dev) | |||
4720 | 4691 | ||
4721 | /* Remove ourselves from the kernel list of ethernet devices */ | 4692 | /* Remove ourselves from the kernel list of ethernet devices */ |
4722 | /* Warning : can't be called from interrupt, timer or wavelan_close() */ | 4693 | /* Warning : can't be called from interrupt, timer or wavelan_close() */ |
4723 | if (link->dev) | 4694 | if (link->dev_node) |
4724 | unregister_netdev(dev); | 4695 | unregister_netdev(dev); |
4725 | link->dev = NULL; | 4696 | link->dev_node = NULL; |
4726 | ((net_local *)netdev_priv(dev))->link = NULL; | 4697 | ((net_local *)netdev_priv(dev))->link = NULL; |
4727 | ((net_local *)netdev_priv(dev))->dev = NULL; | 4698 | ((net_local *)netdev_priv(dev))->dev = NULL; |
4728 | free_netdev(dev); | 4699 | free_netdev(dev); |
4729 | } | 4700 | } |
4730 | kfree(link); | ||
4731 | 4701 | ||
4732 | #ifdef DEBUG_CALLBACK_TRACE | 4702 | #ifdef DEBUG_CALLBACK_TRACE |
4733 | printk(KERN_DEBUG "<- wavelan_detach()\n"); | 4703 | printk(KERN_DEBUG "<- wavelan_detach()\n"); |
4734 | #endif | 4704 | #endif |
4735 | } | 4705 | } |
4736 | 4706 | ||
4737 | static int wavelan_suspend(struct pcmcia_device *p_dev) | 4707 | static int wavelan_suspend(struct pcmcia_device *link) |
4738 | { | 4708 | { |
4739 | dev_link_t *link = dev_to_instance(p_dev); | ||
4740 | struct net_device * dev = (struct net_device *) link->priv; | 4709 | struct net_device * dev = (struct net_device *) link->priv; |
4741 | 4710 | ||
4742 | /* NB: wavelan_close will be called, but too late, so we are | 4711 | /* NB: wavelan_close will be called, but too late, so we are |
@@ -4748,36 +4717,22 @@ static int wavelan_suspend(struct pcmcia_device *p_dev) | |||
4748 | /* Stop receiving new messages and wait end of transmission */ | 4717 | /* Stop receiving new messages and wait end of transmission */ |
4749 | wv_ru_stop(dev); | 4718 | wv_ru_stop(dev); |
4750 | 4719 | ||
4720 | if (link->open) | ||
4721 | netif_device_detach(dev); | ||
4722 | |||
4751 | /* Power down the module */ | 4723 | /* Power down the module */ |
4752 | hacr_write(dev->base_addr, HACR_DEFAULT & (~HACR_PWR_STAT)); | 4724 | hacr_write(dev->base_addr, HACR_DEFAULT & (~HACR_PWR_STAT)); |
4753 | 4725 | ||
4754 | /* The card is now suspended */ | ||
4755 | link->state |= DEV_SUSPEND; | ||
4756 | |||
4757 | if(link->state & DEV_CONFIG) | ||
4758 | { | ||
4759 | if(link->open) | ||
4760 | netif_device_detach(dev); | ||
4761 | pcmcia_release_configuration(link->handle); | ||
4762 | } | ||
4763 | |||
4764 | return 0; | 4726 | return 0; |
4765 | } | 4727 | } |
4766 | 4728 | ||
4767 | static int wavelan_resume(struct pcmcia_device *p_dev) | 4729 | static int wavelan_resume(struct pcmcia_device *link) |
4768 | { | 4730 | { |
4769 | dev_link_t *link = dev_to_instance(p_dev); | ||
4770 | struct net_device * dev = (struct net_device *) link->priv; | 4731 | struct net_device * dev = (struct net_device *) link->priv; |
4771 | 4732 | ||
4772 | link->state &= ~DEV_SUSPEND; | 4733 | if (link->open) { |
4773 | if(link->state & DEV_CONFIG) | 4734 | wv_hw_reset(dev); |
4774 | { | 4735 | netif_device_attach(dev); |
4775 | pcmcia_request_configuration(link->handle, &link->conf); | ||
4776 | if(link->open) /* If RESET -> True, If RESUME -> False ? */ | ||
4777 | { | ||
4778 | wv_hw_reset(dev); | ||
4779 | netif_device_attach(dev); | ||
4780 | } | ||
4781 | } | 4736 | } |
4782 | 4737 | ||
4783 | return 0; | 4738 | return 0; |
@@ -4798,7 +4753,7 @@ static struct pcmcia_driver wavelan_driver = { | |||
4798 | .drv = { | 4753 | .drv = { |
4799 | .name = "wavelan_cs", | 4754 | .name = "wavelan_cs", |
4800 | }, | 4755 | }, |
4801 | .probe = wavelan_attach, | 4756 | .probe = wavelan_probe, |
4802 | .remove = wavelan_detach, | 4757 | .remove = wavelan_detach, |
4803 | .id_table = wavelan_ids, | 4758 | .id_table = wavelan_ids, |
4804 | .suspend = wavelan_suspend, | 4759 | .suspend = wavelan_suspend, |
diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h index 451f6271dcbc..c65fe7a391ec 100644 --- a/drivers/net/wireless/wavelan_cs.p.h +++ b/drivers/net/wireless/wavelan_cs.p.h | |||
@@ -602,7 +602,7 @@ struct net_local | |||
602 | dev_node_t node; /* ???? What is this stuff ???? */ | 602 | dev_node_t node; /* ???? What is this stuff ???? */ |
603 | struct net_device * dev; /* Reverse link... */ | 603 | struct net_device * dev; /* Reverse link... */ |
604 | spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ | 604 | spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ |
605 | dev_link_t * link; /* pcmcia structure */ | 605 | struct pcmcia_device * link; /* pcmcia structure */ |
606 | en_stats stats; /* Ethernet interface statistics */ | 606 | en_stats stats; /* Ethernet interface statistics */ |
607 | int nresets; /* Number of hw resets */ | 607 | int nresets; /* Number of hw resets */ |
608 | u_char configured; /* If it is configured */ | 608 | u_char configured; /* If it is configured */ |
@@ -733,9 +733,9 @@ static int | |||
733 | static inline void | 733 | static inline void |
734 | wv_hw_reset(struct net_device *); /* Same, + start receiver unit */ | 734 | wv_hw_reset(struct net_device *); /* Same, + start receiver unit */ |
735 | static inline int | 735 | static inline int |
736 | wv_pcmcia_config(dev_link_t *); /* Configure the pcmcia interface */ | 736 | wv_pcmcia_config(struct pcmcia_device *); /* Configure the pcmcia interface */ |
737 | static void | 737 | static void |
738 | wv_pcmcia_release(dev_link_t *);/* Remove a device */ | 738 | wv_pcmcia_release(struct pcmcia_device *);/* Remove a device */ |
739 | /* ---------------------- INTERRUPT HANDLING ---------------------- */ | 739 | /* ---------------------- INTERRUPT HANDLING ---------------------- */ |
740 | static irqreturn_t | 740 | static irqreturn_t |
741 | wavelan_interrupt(int, /* Interrupt handler */ | 741 | wavelan_interrupt(int, /* Interrupt handler */ |
diff --git a/drivers/net/wireless/wl3501.h b/drivers/net/wireless/wl3501.h index 4303c50c2ab6..65ceb088f700 100644 --- a/drivers/net/wireless/wl3501.h +++ b/drivers/net/wireless/wl3501.h | |||
@@ -611,5 +611,6 @@ struct wl3501_card { | |||
611 | struct iw_spy_data spy_data; | 611 | struct iw_spy_data spy_data; |
612 | struct iw_public_data wireless_data; | 612 | struct iw_public_data wireless_data; |
613 | struct dev_node_t node; | 613 | struct dev_node_t node; |
614 | struct pcmcia_device *p_dev; | ||
614 | }; | 615 | }; |
615 | #endif | 616 | #endif |
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 48e10b0c7e74..e52a650f6737 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c | |||
@@ -103,8 +103,8 @@ module_param(pc_debug, int, 0); | |||
103 | * release a socket, in response to card insertion and ejection events. They | 103 | * release a socket, in response to card insertion and ejection events. They |
104 | * are invoked from the wl24 event handler. | 104 | * are invoked from the wl24 event handler. |
105 | */ | 105 | */ |
106 | static void wl3501_config(dev_link_t *link); | 106 | static int wl3501_config(struct pcmcia_device *link); |
107 | static void wl3501_release(dev_link_t *link); | 107 | static void wl3501_release(struct pcmcia_device *link); |
108 | 108 | ||
109 | /* | 109 | /* |
110 | * The dev_info variable is the "key" that is used to match up this | 110 | * The dev_info variable is the "key" that is used to match up this |
@@ -226,17 +226,6 @@ static void iw_copy_mgmt_info_element(struct iw_mgmt_info_element *to, | |||
226 | iw_set_mgmt_info_element(from->id, to, from->data, from->len); | 226 | iw_set_mgmt_info_element(from->id, to, from->data, from->len); |
227 | } | 227 | } |
228 | 228 | ||
229 | /* | ||
230 | * A linked list of "instances" of the wl24 device. Each actual PCMCIA card | ||
231 | * corresponds to one device instance, and is described by one dev_link_t | ||
232 | * structure (defined in ds.h). | ||
233 | * | ||
234 | * You may not want to use a linked list for this -- for example, the memory | ||
235 | * card driver uses an array of dev_link_t pointers, where minor device numbers | ||
236 | * are used to derive the corresponding array index. | ||
237 | */ | ||
238 | static dev_link_t *wl3501_dev_list; | ||
239 | |||
240 | static inline void wl3501_switch_page(struct wl3501_card *this, u8 page) | 229 | static inline void wl3501_switch_page(struct wl3501_card *this, u8 page) |
241 | { | 230 | { |
242 | wl3501_outb(page, this->base_addr + WL3501_NIC_BSS); | 231 | wl3501_outb(page, this->base_addr + WL3501_NIC_BSS); |
@@ -1281,15 +1270,10 @@ static int wl3501_close(struct net_device *dev) | |||
1281 | struct wl3501_card *this = dev->priv; | 1270 | struct wl3501_card *this = dev->priv; |
1282 | int rc = -ENODEV; | 1271 | int rc = -ENODEV; |
1283 | unsigned long flags; | 1272 | unsigned long flags; |
1284 | dev_link_t *link; | 1273 | struct pcmcia_device *link; |
1274 | link = this->p_dev; | ||
1285 | 1275 | ||
1286 | spin_lock_irqsave(&this->lock, flags); | 1276 | spin_lock_irqsave(&this->lock, flags); |
1287 | /* Check if the device is in wl3501_dev_list */ | ||
1288 | for (link = wl3501_dev_list; link; link = link->next) | ||
1289 | if (link->priv == dev) | ||
1290 | break; | ||
1291 | if (!link) | ||
1292 | goto out; | ||
1293 | link->open--; | 1277 | link->open--; |
1294 | 1278 | ||
1295 | /* Stop wl3501_hard_start_xmit() from now on */ | 1279 | /* Stop wl3501_hard_start_xmit() from now on */ |
@@ -1301,7 +1285,6 @@ static int wl3501_close(struct net_device *dev) | |||
1301 | 1285 | ||
1302 | rc = 0; | 1286 | rc = 0; |
1303 | printk(KERN_INFO "%s: WL3501 closed\n", dev->name); | 1287 | printk(KERN_INFO "%s: WL3501 closed\n", dev->name); |
1304 | out: | ||
1305 | spin_unlock_irqrestore(&this->lock, flags); | 1288 | spin_unlock_irqrestore(&this->lock, flags); |
1306 | return rc; | 1289 | return rc; |
1307 | } | 1290 | } |
@@ -1400,14 +1383,11 @@ static int wl3501_open(struct net_device *dev) | |||
1400 | int rc = -ENODEV; | 1383 | int rc = -ENODEV; |
1401 | struct wl3501_card *this = dev->priv; | 1384 | struct wl3501_card *this = dev->priv; |
1402 | unsigned long flags; | 1385 | unsigned long flags; |
1403 | dev_link_t *link; | 1386 | struct pcmcia_device *link; |
1387 | link = this->p_dev; | ||
1404 | 1388 | ||
1405 | spin_lock_irqsave(&this->lock, flags); | 1389 | spin_lock_irqsave(&this->lock, flags); |
1406 | /* Check if the device is in wl3501_dev_list */ | 1390 | if (!pcmcia_dev_present(link)) |
1407 | for (link = wl3501_dev_list; link; link = link->next) | ||
1408 | if (link->priv == dev) | ||
1409 | break; | ||
1410 | if (!DEV_OK(link)) | ||
1411 | goto out; | 1391 | goto out; |
1412 | netif_device_attach(dev); | 1392 | netif_device_attach(dev); |
1413 | link->open++; | 1393 | link->open++; |
@@ -1497,38 +1477,23 @@ static struct ethtool_ops ops = { | |||
1497 | * Services. If it has been released, all local data structures are freed. | 1477 | * Services. If it has been released, all local data structures are freed. |
1498 | * Otherwise, the structures will be freed when the device is released. | 1478 | * Otherwise, the structures will be freed when the device is released. |
1499 | */ | 1479 | */ |
1500 | static void wl3501_detach(struct pcmcia_device *p_dev) | 1480 | static void wl3501_detach(struct pcmcia_device *link) |
1501 | { | 1481 | { |
1502 | dev_link_t *link = dev_to_instance(p_dev); | ||
1503 | dev_link_t **linkp; | ||
1504 | struct net_device *dev = link->priv; | 1482 | struct net_device *dev = link->priv; |
1505 | 1483 | ||
1506 | /* Locate device structure */ | ||
1507 | for (linkp = &wl3501_dev_list; *linkp; linkp = &(*linkp)->next) | ||
1508 | if (*linkp == link) | ||
1509 | break; | ||
1510 | if (!*linkp) | ||
1511 | goto out; | ||
1512 | |||
1513 | /* If the device is currently configured and active, we won't actually | 1484 | /* If the device is currently configured and active, we won't actually |
1514 | * delete it yet. Instead, it is marked so that when the release() | 1485 | * delete it yet. Instead, it is marked so that when the release() |
1515 | * function is called, that will trigger a proper detach(). */ | 1486 | * function is called, that will trigger a proper detach(). */ |
1516 | 1487 | ||
1517 | if (link->state & DEV_CONFIG) { | 1488 | while (link->open > 0) |
1518 | while (link->open > 0) | 1489 | wl3501_close(dev); |
1519 | wl3501_close(dev); | ||
1520 | |||
1521 | netif_device_detach(dev); | ||
1522 | wl3501_release(link); | ||
1523 | } | ||
1524 | 1490 | ||
1525 | /* Unlink device structure, free pieces */ | 1491 | netif_device_detach(dev); |
1526 | *linkp = link->next; | 1492 | wl3501_release(link); |
1527 | 1493 | ||
1528 | if (link->priv) | 1494 | if (link->priv) |
1529 | free_netdev(link->priv); | 1495 | free_netdev(link->priv); |
1530 | kfree(link); | 1496 | |
1531 | out: | ||
1532 | return; | 1497 | return; |
1533 | } | 1498 | } |
1534 | 1499 | ||
@@ -1953,33 +1918,26 @@ static const struct iw_handler_def wl3501_handler_def = { | |||
1953 | * The dev_link structure is initialized, but we don't actually configure the | 1918 | * The dev_link structure is initialized, but we don't actually configure the |
1954 | * card at this point -- we wait until we receive a card insertion event. | 1919 | * card at this point -- we wait until we receive a card insertion event. |
1955 | */ | 1920 | */ |
1956 | static int wl3501_attach(struct pcmcia_device *p_dev) | 1921 | static int wl3501_probe(struct pcmcia_device *p_dev) |
1957 | { | 1922 | { |
1958 | dev_link_t *link; | ||
1959 | struct net_device *dev; | 1923 | struct net_device *dev; |
1960 | struct wl3501_card *this; | 1924 | struct wl3501_card *this; |
1961 | 1925 | ||
1962 | /* Initialize the dev_link_t structure */ | ||
1963 | link = kzalloc(sizeof(*link), GFP_KERNEL); | ||
1964 | if (!link) | ||
1965 | return -ENOMEM; | ||
1966 | |||
1967 | /* The io structure describes IO port mapping */ | 1926 | /* The io structure describes IO port mapping */ |
1968 | link->io.NumPorts1 = 16; | 1927 | p_dev->io.NumPorts1 = 16; |
1969 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | 1928 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; |
1970 | link->io.IOAddrLines = 5; | 1929 | p_dev->io.IOAddrLines = 5; |
1971 | 1930 | ||
1972 | /* Interrupt setup */ | 1931 | /* Interrupt setup */ |
1973 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; | 1932 | p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; |
1974 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 1933 | p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; |
1975 | link->irq.Handler = wl3501_interrupt; | 1934 | p_dev->irq.Handler = wl3501_interrupt; |
1976 | 1935 | ||
1977 | /* General socket configuration */ | 1936 | /* General socket configuration */ |
1978 | link->conf.Attributes = CONF_ENABLE_IRQ; | 1937 | p_dev->conf.Attributes = CONF_ENABLE_IRQ; |
1979 | link->conf.Vcc = 50; | 1938 | p_dev->conf.IntType = INT_MEMORY_AND_IO; |
1980 | link->conf.IntType = INT_MEMORY_AND_IO; | 1939 | p_dev->conf.ConfigIndex = 1; |
1981 | link->conf.ConfigIndex = 1; | 1940 | p_dev->conf.Present = PRESENT_OPTION; |
1982 | link->conf.Present = PRESENT_OPTION; | ||
1983 | 1941 | ||
1984 | dev = alloc_etherdev(sizeof(struct wl3501_card)); | 1942 | dev = alloc_etherdev(sizeof(struct wl3501_card)); |
1985 | if (!dev) | 1943 | if (!dev) |
@@ -1992,22 +1950,15 @@ static int wl3501_attach(struct pcmcia_device *p_dev) | |||
1992 | dev->get_stats = wl3501_get_stats; | 1950 | dev->get_stats = wl3501_get_stats; |
1993 | this = dev->priv; | 1951 | this = dev->priv; |
1994 | this->wireless_data.spy_data = &this->spy_data; | 1952 | this->wireless_data.spy_data = &this->spy_data; |
1953 | this->p_dev = p_dev; | ||
1995 | dev->wireless_data = &this->wireless_data; | 1954 | dev->wireless_data = &this->wireless_data; |
1996 | dev->wireless_handlers = (struct iw_handler_def *)&wl3501_handler_def; | 1955 | dev->wireless_handlers = (struct iw_handler_def *)&wl3501_handler_def; |
1997 | SET_ETHTOOL_OPS(dev, &ops); | 1956 | SET_ETHTOOL_OPS(dev, &ops); |
1998 | netif_stop_queue(dev); | 1957 | netif_stop_queue(dev); |
1999 | link->priv = link->irq.Instance = dev; | 1958 | p_dev->priv = p_dev->irq.Instance = dev; |
2000 | |||
2001 | link->handle = p_dev; | ||
2002 | p_dev->instance = link; | ||
2003 | |||
2004 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
2005 | wl3501_config(link); | ||
2006 | 1959 | ||
2007 | return 0; | 1960 | return wl3501_config(p_dev); |
2008 | out_link: | 1961 | out_link: |
2009 | kfree(link); | ||
2010 | link = NULL; | ||
2011 | return -ENOMEM; | 1962 | return -ENOMEM; |
2012 | } | 1963 | } |
2013 | 1964 | ||
@@ -2022,11 +1973,10 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | |||
2022 | * received, to configure the PCMCIA socket, and to make the ethernet device | 1973 | * received, to configure the PCMCIA socket, and to make the ethernet device |
2023 | * available to the system. | 1974 | * available to the system. |
2024 | */ | 1975 | */ |
2025 | static void wl3501_config(dev_link_t *link) | 1976 | static int wl3501_config(struct pcmcia_device *link) |
2026 | { | 1977 | { |
2027 | tuple_t tuple; | 1978 | tuple_t tuple; |
2028 | cisparse_t parse; | 1979 | cisparse_t parse; |
2029 | client_handle_t handle = link->handle; | ||
2030 | struct net_device *dev = link->priv; | 1980 | struct net_device *dev = link->priv; |
2031 | int i = 0, j, last_fn, last_ret; | 1981 | int i = 0, j, last_fn, last_ret; |
2032 | unsigned char bf[64]; | 1982 | unsigned char bf[64]; |
@@ -2035,18 +1985,15 @@ static void wl3501_config(dev_link_t *link) | |||
2035 | /* This reads the card's CONFIG tuple to find its config registers. */ | 1985 | /* This reads the card's CONFIG tuple to find its config registers. */ |
2036 | tuple.Attributes = 0; | 1986 | tuple.Attributes = 0; |
2037 | tuple.DesiredTuple = CISTPL_CONFIG; | 1987 | tuple.DesiredTuple = CISTPL_CONFIG; |
2038 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 1988 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
2039 | tuple.TupleData = bf; | 1989 | tuple.TupleData = bf; |
2040 | tuple.TupleDataMax = sizeof(bf); | 1990 | tuple.TupleDataMax = sizeof(bf); |
2041 | tuple.TupleOffset = 0; | 1991 | tuple.TupleOffset = 0; |
2042 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | 1992 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
2043 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); | 1993 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); |
2044 | link->conf.ConfigBase = parse.config.base; | 1994 | link->conf.ConfigBase = parse.config.base; |
2045 | link->conf.Present = parse.config.rmask[0]; | 1995 | link->conf.Present = parse.config.rmask[0]; |
2046 | 1996 | ||
2047 | /* Configure card */ | ||
2048 | link->state |= DEV_CONFIG; | ||
2049 | |||
2050 | /* Try allocating IO ports. This tries a few fixed addresses. If you | 1997 | /* Try allocating IO ports. This tries a few fixed addresses. If you |
2051 | * want, you can also read the card's config table to pick addresses -- | 1998 | * want, you can also read the card's config table to pick addresses -- |
2052 | * see the serial driver for an example. */ | 1999 | * see the serial driver for an example. */ |
@@ -2056,28 +2003,28 @@ static void wl3501_config(dev_link_t *link) | |||
2056 | * 0x200-0x2ff, and so on, because this seems safer */ | 2003 | * 0x200-0x2ff, and so on, because this seems safer */ |
2057 | link->io.BasePort1 = j; | 2004 | link->io.BasePort1 = j; |
2058 | link->io.BasePort2 = link->io.BasePort1 + 0x10; | 2005 | link->io.BasePort2 = link->io.BasePort1 + 0x10; |
2059 | i = pcmcia_request_io(link->handle, &link->io); | 2006 | i = pcmcia_request_io(link, &link->io); |
2060 | if (i == CS_SUCCESS) | 2007 | if (i == CS_SUCCESS) |
2061 | break; | 2008 | break; |
2062 | } | 2009 | } |
2063 | if (i != CS_SUCCESS) { | 2010 | if (i != CS_SUCCESS) { |
2064 | cs_error(link->handle, RequestIO, i); | 2011 | cs_error(link, RequestIO, i); |
2065 | goto failed; | 2012 | goto failed; |
2066 | } | 2013 | } |
2067 | 2014 | ||
2068 | /* Now allocate an interrupt line. Note that this does not actually | 2015 | /* Now allocate an interrupt line. Note that this does not actually |
2069 | * assign a handler to the interrupt. */ | 2016 | * assign a handler to the interrupt. */ |
2070 | 2017 | ||
2071 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); | 2018 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
2072 | 2019 | ||
2073 | /* This actually configures the PCMCIA socket -- setting up the I/O | 2020 | /* This actually configures the PCMCIA socket -- setting up the I/O |
2074 | * windows and the interrupt mapping. */ | 2021 | * windows and the interrupt mapping. */ |
2075 | 2022 | ||
2076 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); | 2023 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); |
2077 | 2024 | ||
2078 | dev->irq = link->irq.AssignedIRQ; | 2025 | dev->irq = link->irq.AssignedIRQ; |
2079 | dev->base_addr = link->io.BasePort1; | 2026 | dev->base_addr = link->io.BasePort1; |
2080 | SET_NETDEV_DEV(dev, &handle_to_dev(handle)); | 2027 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); |
2081 | if (register_netdev(dev)) { | 2028 | if (register_netdev(dev)) { |
2082 | printk(KERN_NOTICE "wl3501_cs: register_netdev() failed\n"); | 2029 | printk(KERN_NOTICE "wl3501_cs: register_netdev() failed\n"); |
2083 | goto failed; | 2030 | goto failed; |
@@ -2088,10 +2035,9 @@ static void wl3501_config(dev_link_t *link) | |||
2088 | this = dev->priv; | 2035 | this = dev->priv; |
2089 | /* | 2036 | /* |
2090 | * At this point, the dev_node_t structure(s) should be initialized and | 2037 | * At this point, the dev_node_t structure(s) should be initialized and |
2091 | * arranged in a linked list at link->dev. | 2038 | * arranged in a linked list at link->dev_node. |
2092 | */ | 2039 | */ |
2093 | link->dev = &this->node; | 2040 | link->dev_node = &this->node; |
2094 | link->state &= ~DEV_CONFIG_PENDING; | ||
2095 | 2041 | ||
2096 | this->base_addr = dev->base_addr; | 2042 | this->base_addr = dev->base_addr; |
2097 | 2043 | ||
@@ -2127,13 +2073,13 @@ static void wl3501_config(dev_link_t *link) | |||
2127 | spin_lock_init(&this->lock); | 2073 | spin_lock_init(&this->lock); |
2128 | init_waitqueue_head(&this->wait); | 2074 | init_waitqueue_head(&this->wait); |
2129 | netif_start_queue(dev); | 2075 | netif_start_queue(dev); |
2130 | goto out; | 2076 | return 0; |
2077 | |||
2131 | cs_failed: | 2078 | cs_failed: |
2132 | cs_error(link->handle, last_fn, last_ret); | 2079 | cs_error(link, last_fn, last_ret); |
2133 | failed: | 2080 | failed: |
2134 | wl3501_release(link); | 2081 | wl3501_release(link); |
2135 | out: | 2082 | return -ENODEV; |
2136 | return; | ||
2137 | } | 2083 | } |
2138 | 2084 | ||
2139 | /** | 2085 | /** |
@@ -2144,52 +2090,36 @@ out: | |||
2144 | * and release the PCMCIA configuration. If the device is still open, this | 2090 | * and release the PCMCIA configuration. If the device is still open, this |
2145 | * will be postponed until it is closed. | 2091 | * will be postponed until it is closed. |
2146 | */ | 2092 | */ |
2147 | static void wl3501_release(dev_link_t *link) | 2093 | static void wl3501_release(struct pcmcia_device *link) |
2148 | { | 2094 | { |
2149 | struct net_device *dev = link->priv; | 2095 | struct net_device *dev = link->priv; |
2150 | 2096 | ||
2151 | /* Unlink the device chain */ | 2097 | /* Unlink the device chain */ |
2152 | if (link->dev) { | 2098 | if (link->dev_node) |
2153 | unregister_netdev(dev); | 2099 | unregister_netdev(dev); |
2154 | link->dev = NULL; | ||
2155 | } | ||
2156 | 2100 | ||
2157 | /* Don't bother checking to see if these succeed or not */ | 2101 | pcmcia_disable_device(link); |
2158 | pcmcia_release_configuration(link->handle); | ||
2159 | pcmcia_release_io(link->handle, &link->io); | ||
2160 | pcmcia_release_irq(link->handle, &link->irq); | ||
2161 | link->state &= ~DEV_CONFIG; | ||
2162 | } | 2102 | } |
2163 | 2103 | ||
2164 | static int wl3501_suspend(struct pcmcia_device *p_dev) | 2104 | static int wl3501_suspend(struct pcmcia_device *link) |
2165 | { | 2105 | { |
2166 | dev_link_t *link = dev_to_instance(p_dev); | ||
2167 | struct net_device *dev = link->priv; | 2106 | struct net_device *dev = link->priv; |
2168 | 2107 | ||
2169 | link->state |= DEV_SUSPEND; | ||
2170 | |||
2171 | wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND); | 2108 | wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND); |
2172 | if (link->state & DEV_CONFIG) { | 2109 | if (link->open) |
2173 | if (link->open) | 2110 | netif_device_detach(dev); |
2174 | netif_device_detach(dev); | ||
2175 | pcmcia_release_configuration(link->handle); | ||
2176 | } | ||
2177 | 2111 | ||
2178 | return 0; | 2112 | return 0; |
2179 | } | 2113 | } |
2180 | 2114 | ||
2181 | static int wl3501_resume(struct pcmcia_device *p_dev) | 2115 | static int wl3501_resume(struct pcmcia_device *link) |
2182 | { | 2116 | { |
2183 | dev_link_t *link = dev_to_instance(p_dev); | ||
2184 | struct net_device *dev = link->priv; | 2117 | struct net_device *dev = link->priv; |
2185 | 2118 | ||
2186 | wl3501_pwr_mgmt(dev->priv, WL3501_RESUME); | 2119 | wl3501_pwr_mgmt(dev->priv, WL3501_RESUME); |
2187 | if (link->state & DEV_CONFIG) { | 2120 | if (link->open) { |
2188 | pcmcia_request_configuration(link->handle, &link->conf); | 2121 | wl3501_reset(dev); |
2189 | if (link->open) { | 2122 | netif_device_attach(dev); |
2190 | wl3501_reset(dev); | ||
2191 | netif_device_attach(dev); | ||
2192 | } | ||
2193 | } | 2123 | } |
2194 | 2124 | ||
2195 | return 0; | 2125 | return 0; |
@@ -2207,7 +2137,7 @@ static struct pcmcia_driver wl3501_driver = { | |||
2207 | .drv = { | 2137 | .drv = { |
2208 | .name = "wl3501_cs", | 2138 | .name = "wl3501_cs", |
2209 | }, | 2139 | }, |
2210 | .probe = wl3501_attach, | 2140 | .probe = wl3501_probe, |
2211 | .remove = wl3501_detach, | 2141 | .remove = wl3501_detach, |
2212 | .id_table = wl3501_ids, | 2142 | .id_table = wl3501_ids, |
2213 | .suspend = wl3501_suspend, | 2143 | .suspend = wl3501_suspend, |
@@ -2221,9 +2151,7 @@ static int __init wl3501_init_module(void) | |||
2221 | 2151 | ||
2222 | static void __exit wl3501_exit_module(void) | 2152 | static void __exit wl3501_exit_module(void) |
2223 | { | 2153 | { |
2224 | dprintk(0, ": unloading"); | ||
2225 | pcmcia_unregister_driver(&wl3501_driver); | 2154 | pcmcia_unregister_driver(&wl3501_driver); |
2226 | BUG_ON(wl3501_dev_list != NULL); | ||
2227 | } | 2155 | } |
2228 | 2156 | ||
2229 | module_init(wl3501_init_module); | 2157 | module_init(wl3501_init_module); |