diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-03-01 18:02:33 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-03-31 10:15:52 -0500 |
commit | 8661bb5b4af1849c1f5a4e80c4e275fd13c155d6 (patch) | |
tree | ad99d85ea8d6f5c4c99b93f869bfd412994fb4ee /drivers/net/wireless | |
parent | 50db3fdbbc98260fb538c1cc3f8cc597ba7bffe7 (diff) |
[PATCH] pcmcia: default suspend and resume handling
In all but one case, the suspend and resume functions of PCMCIA drivers
contain mostly of calls to pcmcia_release_configuration() and
pcmcia_request_configuration(). Therefore, move this code out of the
drivers and into the core.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/airo_cs.c | 9 | ||||
-rw-r--r-- | drivers/net/wireless/atmel_cs.c | 7 | ||||
-rw-r--r-- | drivers/net/wireless/hostap/hostap_cs.c | 6 | ||||
-rw-r--r-- | drivers/net/wireless/netwave_cs.c | 18 | ||||
-rw-r--r-- | drivers/net/wireless/orinoco_cs.c | 8 | ||||
-rw-r--r-- | drivers/net/wireless/ray_cs.c | 22 | ||||
-rw-r--r-- | drivers/net/wireless/spectrum_cs.c | 7 | ||||
-rw-r--r-- | drivers/net/wireless/wavelan_cs.c | 24 | ||||
-rw-r--r-- | drivers/net/wireless/wl3501_cs.c | 18 |
9 files changed, 25 insertions, 94 deletions
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index 489ef7f3d950..adb90b679d7d 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c | |||
@@ -437,11 +437,8 @@ static int airo_suspend(struct pcmcia_device *p_dev) | |||
437 | dev_link_t *link = dev_to_instance(p_dev); | 437 | dev_link_t *link = dev_to_instance(p_dev); |
438 | local_info_t *local = link->priv; | 438 | local_info_t *local = link->priv; |
439 | 439 | ||
440 | link->state |= DEV_SUSPEND; | 440 | if (link->state & DEV_CONFIG) |
441 | if (link->state & DEV_CONFIG) { | ||
442 | netif_device_detach(local->eth_dev); | 441 | netif_device_detach(local->eth_dev); |
443 | pcmcia_release_configuration(link->handle); | ||
444 | } | ||
445 | 442 | ||
446 | return 0; | 443 | return 0; |
447 | } | 444 | } |
@@ -451,9 +448,7 @@ static int airo_resume(struct pcmcia_device *p_dev) | |||
451 | dev_link_t *link = dev_to_instance(p_dev); | 448 | dev_link_t *link = dev_to_instance(p_dev); |
452 | local_info_t *local = link->priv; | 449 | local_info_t *local = link->priv; |
453 | 450 | ||
454 | link->state &= ~DEV_SUSPEND; | 451 | if ((link->state & DEV_CONFIG) && (link->open)) { |
455 | if (link->state & DEV_CONFIG) { | ||
456 | pcmcia_request_configuration(link->handle, &link->conf); | ||
457 | reset_airo_card(local->eth_dev); | 452 | reset_airo_card(local->eth_dev); |
458 | netif_device_attach(local->eth_dev); | 453 | netif_device_attach(local->eth_dev); |
459 | } | 454 | } |
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index 1da8e6197ffb..89dbc783ff80 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c | |||
@@ -433,11 +433,8 @@ static int atmel_suspend(struct pcmcia_device *dev) | |||
433 | dev_link_t *link = dev_to_instance(dev); | 433 | dev_link_t *link = dev_to_instance(dev); |
434 | local_info_t *local = link->priv; | 434 | local_info_t *local = link->priv; |
435 | 435 | ||
436 | link->state |= DEV_SUSPEND; | 436 | if (link->state & DEV_CONFIG) |
437 | if (link->state & DEV_CONFIG) { | ||
438 | netif_device_detach(local->eth_dev); | 437 | netif_device_detach(local->eth_dev); |
439 | pcmcia_release_configuration(link->handle); | ||
440 | } | ||
441 | 438 | ||
442 | return 0; | 439 | return 0; |
443 | } | 440 | } |
@@ -447,9 +444,7 @@ static int atmel_resume(struct pcmcia_device *dev) | |||
447 | dev_link_t *link = dev_to_instance(dev); | 444 | dev_link_t *link = dev_to_instance(dev); |
448 | local_info_t *local = link->priv; | 445 | local_info_t *local = link->priv; |
449 | 446 | ||
450 | link->state &= ~DEV_SUSPEND; | ||
451 | if (link->state & DEV_CONFIG) { | 447 | if (link->state & DEV_CONFIG) { |
452 | pcmcia_request_configuration(link->handle, &link->conf); | ||
453 | atmel_open(local->eth_dev); | 448 | atmel_open(local->eth_dev); |
454 | netif_device_attach(local->eth_dev); | 449 | netif_device_attach(local->eth_dev); |
455 | } | 450 | } |
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index 7a1023f3875b..0fb625185452 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c | |||
@@ -816,8 +816,6 @@ static int hostap_cs_suspend(struct pcmcia_device *p_dev) | |||
816 | 816 | ||
817 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); | 817 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); |
818 | 818 | ||
819 | link->state |= DEV_SUSPEND; | ||
820 | |||
821 | if (link->state & DEV_CONFIG) { | 819 | if (link->state & DEV_CONFIG) { |
822 | struct hostap_interface *iface = netdev_priv(dev); | 820 | struct hostap_interface *iface = netdev_priv(dev); |
823 | if (iface && iface->local) | 821 | if (iface && iface->local) |
@@ -827,7 +825,6 @@ static int hostap_cs_suspend(struct pcmcia_device *p_dev) | |||
827 | netif_device_detach(dev); | 825 | netif_device_detach(dev); |
828 | } | 826 | } |
829 | prism2_suspend(dev); | 827 | prism2_suspend(dev); |
830 | pcmcia_release_configuration(link->handle); | ||
831 | } | 828 | } |
832 | 829 | ||
833 | return 0; | 830 | return 0; |
@@ -841,14 +838,11 @@ static int hostap_cs_resume(struct pcmcia_device *p_dev) | |||
841 | 838 | ||
842 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); | 839 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); |
843 | 840 | ||
844 | link->state &= ~DEV_SUSPEND; | ||
845 | if (link->state & DEV_CONFIG) { | 841 | if (link->state & DEV_CONFIG) { |
846 | struct hostap_interface *iface = netdev_priv(dev); | 842 | struct hostap_interface *iface = netdev_priv(dev); |
847 | if (iface && iface->local) | 843 | if (iface && iface->local) |
848 | dev_open = iface->local->num_dev_open > 0; | 844 | dev_open = iface->local->num_dev_open > 0; |
849 | 845 | ||
850 | pcmcia_request_configuration(link->handle, &link->conf); | ||
851 | |||
852 | prism2_hw_shutdown(dev, 1); | 846 | prism2_hw_shutdown(dev, 1); |
853 | prism2_hw_config(dev, dev_open ? 0 : 1); | 847 | prism2_hw_config(dev, dev_open ? 0 : 1); |
854 | if (dev_open) { | 848 | if (dev_open) { |
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index dfb47ac9da50..545717b5e1e5 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c | |||
@@ -884,12 +884,8 @@ static int netwave_suspend(struct pcmcia_device *p_dev) | |||
884 | dev_link_t *link = dev_to_instance(p_dev); | 884 | dev_link_t *link = dev_to_instance(p_dev); |
885 | struct net_device *dev = link->priv; | 885 | struct net_device *dev = link->priv; |
886 | 886 | ||
887 | link->state |= DEV_SUSPEND; | 887 | if ((link->state & DEV_CONFIG) && (link->open)) |
888 | if (link->state & DEV_CONFIG) { | 888 | netif_device_detach(dev); |
889 | if (link->open) | ||
890 | netif_device_detach(dev); | ||
891 | pcmcia_release_configuration(link->handle); | ||
892 | } | ||
893 | 889 | ||
894 | return 0; | 890 | return 0; |
895 | } | 891 | } |
@@ -899,13 +895,9 @@ static int netwave_resume(struct pcmcia_device *p_dev) | |||
899 | dev_link_t *link = dev_to_instance(p_dev); | 895 | dev_link_t *link = dev_to_instance(p_dev); |
900 | struct net_device *dev = link->priv; | 896 | struct net_device *dev = link->priv; |
901 | 897 | ||
902 | link->state &= ~DEV_SUSPEND; | 898 | if ((link->state & DEV_CONFIG) && (link->open)) { |
903 | if (link->state & DEV_CONFIG) { | 899 | netwave_reset(dev); |
904 | pcmcia_request_configuration(link->handle, &link->conf); | 900 | netif_device_attach(dev); |
905 | if (link->open) { | ||
906 | netwave_reset(dev); | ||
907 | netif_device_attach(dev); | ||
908 | } | ||
909 | } | 901 | } |
910 | 902 | ||
911 | return 0; | 903 | return 0; |
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index 0ce4165efc8f..89e16cd1be8c 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c | |||
@@ -429,7 +429,6 @@ static int orinoco_cs_suspend(struct pcmcia_device *p_dev) | |||
429 | int err = 0; | 429 | int err = 0; |
430 | unsigned long flags; | 430 | unsigned long flags; |
431 | 431 | ||
432 | link->state |= DEV_SUSPEND; | ||
433 | if (link->state & DEV_CONFIG) { | 432 | if (link->state & DEV_CONFIG) { |
434 | /* This is probably racy, but I can't think of | 433 | /* This is probably racy, but I can't think of |
435 | a better way, short of rewriting the PCMCIA | 434 | a better way, short of rewriting the PCMCIA |
@@ -447,8 +446,6 @@ static int orinoco_cs_suspend(struct pcmcia_device *p_dev) | |||
447 | 446 | ||
448 | spin_unlock_irqrestore(&priv->lock, flags); | 447 | spin_unlock_irqrestore(&priv->lock, flags); |
449 | } | 448 | } |
450 | |||
451 | pcmcia_release_configuration(link->handle); | ||
452 | } | 449 | } |
453 | 450 | ||
454 | return 0; | 451 | return 0; |
@@ -463,12 +460,7 @@ static int orinoco_cs_resume(struct pcmcia_device *p_dev) | |||
463 | int err = 0; | 460 | int err = 0; |
464 | unsigned long flags; | 461 | unsigned long flags; |
465 | 462 | ||
466 | link->state &= ~DEV_SUSPEND; | ||
467 | if (link->state & DEV_CONFIG) { | 463 | if (link->state & DEV_CONFIG) { |
468 | /* FIXME: should we double check that this is | ||
469 | * the same card as we had before */ | ||
470 | pcmcia_request_configuration(link->handle, &link->conf); | ||
471 | |||
472 | if (! test_bit(0, &card->hard_reset_in_progress)) { | 464 | if (! test_bit(0, &card->hard_reset_in_progress)) { |
473 | err = orinoco_reinit_firmware(dev); | 465 | err = orinoco_reinit_firmware(dev); |
474 | if (err) { | 466 | if (err) { |
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index fc81ac67009d..ed4bf5013f1a 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c | |||
@@ -868,14 +868,8 @@ static int ray_suspend(struct pcmcia_device *p_dev) | |||
868 | dev_link_t *link = dev_to_instance(p_dev); | 868 | dev_link_t *link = dev_to_instance(p_dev); |
869 | struct net_device *dev = link->priv; | 869 | struct net_device *dev = link->priv; |
870 | 870 | ||
871 | link->state |= DEV_SUSPEND; | 871 | if ((link->state & DEV_CONFIG) && (link->open)) |
872 | if (link->state & DEV_CONFIG) { | 872 | netif_device_detach(dev); |
873 | if (link->open) | ||
874 | netif_device_detach(dev); | ||
875 | |||
876 | pcmcia_release_configuration(link->handle); | ||
877 | } | ||
878 | |||
879 | 873 | ||
880 | return 0; | 874 | return 0; |
881 | } | 875 | } |
@@ -885,14 +879,10 @@ static int ray_resume(struct pcmcia_device *p_dev) | |||
885 | dev_link_t *link = dev_to_instance(p_dev); | 879 | dev_link_t *link = dev_to_instance(p_dev); |
886 | struct net_device *dev = link->priv; | 880 | struct net_device *dev = link->priv; |
887 | 881 | ||
888 | link->state &= ~DEV_SUSPEND; | 882 | if ((link->state & DEV_CONFIG) && (link->open)) { |
889 | if (link->state & DEV_CONFIG) { | 883 | ray_reset(dev); |
890 | pcmcia_request_configuration(link->handle, &link->conf); | 884 | netif_device_attach(dev); |
891 | if (link->open) { | 885 | } |
892 | ray_reset(dev); | ||
893 | netif_device_attach(dev); | ||
894 | } | ||
895 | } | ||
896 | 886 | ||
897 | return 0; | 887 | return 0; |
898 | } | 888 | } |
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c index b7ed99f8d319..0429f1dc7fad 100644 --- a/drivers/net/wireless/spectrum_cs.c +++ b/drivers/net/wireless/spectrum_cs.c | |||
@@ -908,7 +908,6 @@ spectrum_cs_suspend(struct pcmcia_device *p_dev) | |||
908 | unsigned long flags; | 908 | unsigned long flags; |
909 | int err = 0; | 909 | int err = 0; |
910 | 910 | ||
911 | link->state |= DEV_SUSPEND; | ||
912 | /* Mark the device as stopped, to block IO until later */ | 911 | /* Mark the device as stopped, to block IO until later */ |
913 | if (link->state & DEV_CONFIG) { | 912 | if (link->state & DEV_CONFIG) { |
914 | spin_lock_irqsave(&priv->lock, flags); | 913 | spin_lock_irqsave(&priv->lock, flags); |
@@ -922,8 +921,6 @@ spectrum_cs_suspend(struct pcmcia_device *p_dev) | |||
922 | priv->hw_unavailable++; | 921 | priv->hw_unavailable++; |
923 | 922 | ||
924 | spin_unlock_irqrestore(&priv->lock, flags); | 923 | spin_unlock_irqrestore(&priv->lock, flags); |
925 | |||
926 | pcmcia_release_configuration(link->handle); | ||
927 | } | 924 | } |
928 | 925 | ||
929 | return 0; | 926 | return 0; |
@@ -936,11 +933,7 @@ spectrum_cs_resume(struct pcmcia_device *p_dev) | |||
936 | struct net_device *dev = link->priv; | 933 | struct net_device *dev = link->priv; |
937 | struct orinoco_private *priv = netdev_priv(dev); | 934 | struct orinoco_private *priv = netdev_priv(dev); |
938 | 935 | ||
939 | link->state &= ~DEV_SUSPEND; | ||
940 | if (link->state & DEV_CONFIG) { | 936 | if (link->state & DEV_CONFIG) { |
941 | /* FIXME: should we double check that this is | ||
942 | * the same card as we had before */ | ||
943 | pcmcia_request_configuration(link->handle, &link->conf); | ||
944 | netif_device_attach(dev); | 937 | netif_device_attach(dev); |
945 | priv->hw_unavailable--; | 938 | priv->hw_unavailable--; |
946 | schedule_work(&priv->reset_work); | 939 | schedule_work(&priv->reset_work); |
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index 696aeb9d8f52..8cabcfe3a654 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c | |||
@@ -4742,19 +4742,12 @@ static int wavelan_suspend(struct pcmcia_device *p_dev) | |||
4742 | /* Stop receiving new messages and wait end of transmission */ | 4742 | /* Stop receiving new messages and wait end of transmission */ |
4743 | wv_ru_stop(dev); | 4743 | wv_ru_stop(dev); |
4744 | 4744 | ||
4745 | if ((link->state & DEV_CONFIG) && (link->open)) | ||
4746 | netif_device_detach(dev); | ||
4747 | |||
4745 | /* Power down the module */ | 4748 | /* Power down the module */ |
4746 | hacr_write(dev->base_addr, HACR_DEFAULT & (~HACR_PWR_STAT)); | 4749 | hacr_write(dev->base_addr, HACR_DEFAULT & (~HACR_PWR_STAT)); |
4747 | 4750 | ||
4748 | /* The card is now suspended */ | ||
4749 | link->state |= DEV_SUSPEND; | ||
4750 | |||
4751 | if(link->state & DEV_CONFIG) | ||
4752 | { | ||
4753 | if(link->open) | ||
4754 | netif_device_detach(dev); | ||
4755 | pcmcia_release_configuration(link->handle); | ||
4756 | } | ||
4757 | |||
4758 | return 0; | 4751 | return 0; |
4759 | } | 4752 | } |
4760 | 4753 | ||
@@ -4764,14 +4757,9 @@ static int wavelan_resume(struct pcmcia_device *p_dev) | |||
4764 | struct net_device * dev = (struct net_device *) link->priv; | 4757 | struct net_device * dev = (struct net_device *) link->priv; |
4765 | 4758 | ||
4766 | link->state &= ~DEV_SUSPEND; | 4759 | link->state &= ~DEV_SUSPEND; |
4767 | if(link->state & DEV_CONFIG) | 4760 | if ((link->state & DEV_CONFIG) && (link->open)) { |
4768 | { | 4761 | wv_hw_reset(dev); |
4769 | pcmcia_request_configuration(link->handle, &link->conf); | 4762 | netif_device_attach(dev); |
4770 | if(link->open) /* If RESET -> True, If RESUME -> False ? */ | ||
4771 | { | ||
4772 | wv_hw_reset(dev); | ||
4773 | netif_device_attach(dev); | ||
4774 | } | ||
4775 | } | 4763 | } |
4776 | 4764 | ||
4777 | return 0; | 4765 | return 0; |
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 0c81b3e7d7ff..3a93a8bb2e1f 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c | |||
@@ -2160,14 +2160,9 @@ static int wl3501_suspend(struct pcmcia_device *p_dev) | |||
2160 | dev_link_t *link = dev_to_instance(p_dev); | 2160 | dev_link_t *link = dev_to_instance(p_dev); |
2161 | struct net_device *dev = link->priv; | 2161 | struct net_device *dev = link->priv; |
2162 | 2162 | ||
2163 | link->state |= DEV_SUSPEND; | ||
2164 | |||
2165 | wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND); | 2163 | wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND); |
2166 | if (link->state & DEV_CONFIG) { | 2164 | if ((link->state & DEV_CONFIG) && (link->open)) |
2167 | if (link->open) | 2165 | netif_device_detach(dev); |
2168 | netif_device_detach(dev); | ||
2169 | pcmcia_release_configuration(link->handle); | ||
2170 | } | ||
2171 | 2166 | ||
2172 | return 0; | 2167 | return 0; |
2173 | } | 2168 | } |
@@ -2178,12 +2173,9 @@ static int wl3501_resume(struct pcmcia_device *p_dev) | |||
2178 | struct net_device *dev = link->priv; | 2173 | struct net_device *dev = link->priv; |
2179 | 2174 | ||
2180 | wl3501_pwr_mgmt(dev->priv, WL3501_RESUME); | 2175 | wl3501_pwr_mgmt(dev->priv, WL3501_RESUME); |
2181 | if (link->state & DEV_CONFIG) { | 2176 | if ((link->state & DEV_CONFIG) && (link->open)) { |
2182 | pcmcia_request_configuration(link->handle, &link->conf); | 2177 | wl3501_reset(dev); |
2183 | if (link->open) { | 2178 | netif_device_attach(dev); |
2184 | wl3501_reset(dev); | ||
2185 | netif_device_attach(dev); | ||
2186 | } | ||
2187 | } | 2179 | } |
2188 | 2180 | ||
2189 | return 0; | 2181 | return 0; |