diff options
Diffstat (limited to 'drivers/net/wireless/spectrum_cs.c')
-rw-r--r-- | drivers/net/wireless/spectrum_cs.c | 173 |
1 files changed, 69 insertions, 104 deletions
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, |