diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2005-11-14 15:21:18 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-01-05 17:59:02 -0500 |
commit | 98e4c28b7ec390c2dad6a4c69d69629c0f7e8b10 (patch) | |
tree | b3d46f0643352e541d6a39e6da09059687cf713d /drivers/net/wireless/hostap/hostap_cs.c | |
parent | 63e7ebd06402951bc8863ba5b7bc9b9f42044849 (diff) |
[PATCH] pcmcia: new suspend core
Move the suspend and resume methods out of the event handler, and into
special functions. Also use these functions for pre- and post-reset, as
almost all drivers already do, and the remaining ones can easily be
converted.
Bugfix to include/pcmcia/ds.c
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/wireless/hostap/hostap_cs.c')
-rw-r--r-- | drivers/net/wireless/hostap/hostap_cs.c | 88 |
1 files changed, 49 insertions, 39 deletions
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index 2643976a6677..ba4a7da98ccd 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c | |||
@@ -846,20 +846,64 @@ static void prism2_release(u_long arg) | |||
846 | PDEBUG(DEBUG_FLOW, "release - done\n"); | 846 | PDEBUG(DEBUG_FLOW, "release - done\n"); |
847 | } | 847 | } |
848 | 848 | ||
849 | static int hostap_cs_suspend(struct pcmcia_device *p_dev) | ||
850 | { | ||
851 | dev_link_t *link = dev_to_instance(p_dev); | ||
852 | struct net_device *dev = (struct net_device *) link->priv; | ||
853 | int dev_open = 0; | ||
849 | 854 | ||
850 | static int prism2_event(event_t event, int priority, | 855 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); |
851 | event_callback_args_t *args) | 856 | |
857 | link->state |= DEV_SUSPEND; | ||
858 | |||
859 | if (link->state & DEV_CONFIG) { | ||
860 | struct hostap_interface *iface = netdev_priv(dev); | ||
861 | if (iface && iface->local) | ||
862 | dev_open = iface->local->num_dev_open > 0; | ||
863 | if (dev_open) { | ||
864 | netif_stop_queue(dev); | ||
865 | netif_device_detach(dev); | ||
866 | } | ||
867 | prism2_suspend(dev); | ||
868 | pcmcia_release_configuration(link->handle); | ||
869 | } | ||
870 | |||
871 | return 0; | ||
872 | } | ||
873 | |||
874 | static int hostap_cs_resume(struct pcmcia_device *p_dev) | ||
852 | { | 875 | { |
853 | dev_link_t *link = args->client_data; | 876 | dev_link_t *link = dev_to_instance(p_dev); |
854 | struct net_device *dev = (struct net_device *) link->priv; | 877 | struct net_device *dev = (struct net_device *) link->priv; |
855 | int dev_open = 0; | 878 | int dev_open = 0; |
856 | 879 | ||
880 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); | ||
881 | |||
882 | link->state &= ~DEV_SUSPEND; | ||
857 | if (link->state & DEV_CONFIG) { | 883 | if (link->state & DEV_CONFIG) { |
858 | struct hostap_interface *iface = netdev_priv(dev); | 884 | struct hostap_interface *iface = netdev_priv(dev); |
859 | if (iface && iface->local) | 885 | if (iface && iface->local) |
860 | dev_open = iface->local->num_dev_open > 0; | 886 | dev_open = iface->local->num_dev_open > 0; |
887 | |||
888 | pcmcia_request_configuration(link->handle, &link->conf); | ||
889 | |||
890 | prism2_hw_shutdown(dev, 1); | ||
891 | prism2_hw_config(dev, dev_open ? 0 : 1); | ||
892 | if (dev_open) { | ||
893 | netif_device_attach(dev); | ||
894 | netif_start_queue(dev); | ||
895 | } | ||
861 | } | 896 | } |
862 | 897 | ||
898 | return 0; | ||
899 | } | ||
900 | |||
901 | static int prism2_event(event_t event, int priority, | ||
902 | event_callback_args_t *args) | ||
903 | { | ||
904 | dev_link_t *link = args->client_data; | ||
905 | struct net_device *dev = (struct net_device *) link->priv; | ||
906 | |||
863 | switch (event) { | 907 | switch (event) { |
864 | case CS_EVENT_CARD_INSERTION: | 908 | case CS_EVENT_CARD_INSERTION: |
865 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_INSERTION\n", dev_info); | 909 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_INSERTION\n", dev_info); |
@@ -879,42 +923,6 @@ static int prism2_event(event_t event, int priority, | |||
879 | } | 923 | } |
880 | break; | 924 | break; |
881 | 925 | ||
882 | case CS_EVENT_PM_SUSPEND: | ||
883 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); | ||
884 | link->state |= DEV_SUSPEND; | ||
885 | /* fall through */ | ||
886 | |||
887 | case CS_EVENT_RESET_PHYSICAL: | ||
888 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_RESET_PHYSICAL\n", dev_info); | ||
889 | if (link->state & DEV_CONFIG) { | ||
890 | if (dev_open) { | ||
891 | netif_stop_queue(dev); | ||
892 | netif_device_detach(dev); | ||
893 | } | ||
894 | prism2_suspend(dev); | ||
895 | pcmcia_release_configuration(link->handle); | ||
896 | } | ||
897 | break; | ||
898 | |||
899 | case CS_EVENT_PM_RESUME: | ||
900 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); | ||
901 | link->state &= ~DEV_SUSPEND; | ||
902 | /* fall through */ | ||
903 | |||
904 | case CS_EVENT_CARD_RESET: | ||
905 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_RESET\n", dev_info); | ||
906 | if (link->state & DEV_CONFIG) { | ||
907 | pcmcia_request_configuration(link->handle, | ||
908 | &link->conf); | ||
909 | prism2_hw_shutdown(dev, 1); | ||
910 | prism2_hw_config(dev, dev_open ? 0 : 1); | ||
911 | if (dev_open) { | ||
912 | netif_device_attach(dev); | ||
913 | netif_start_queue(dev); | ||
914 | } | ||
915 | } | ||
916 | break; | ||
917 | |||
918 | default: | 926 | default: |
919 | PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n", | 927 | PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n", |
920 | dev_info, event); | 928 | dev_info, event); |
@@ -987,6 +995,8 @@ static struct pcmcia_driver hostap_driver = { | |||
987 | .owner = THIS_MODULE, | 995 | .owner = THIS_MODULE, |
988 | .event = prism2_event, | 996 | .event = prism2_event, |
989 | .id_table = hostap_cs_ids, | 997 | .id_table = hostap_cs_ids, |
998 | .suspend = hostap_cs_suspend, | ||
999 | .resume = hostap_cs_resume, | ||
990 | }; | 1000 | }; |
991 | 1001 | ||
992 | static int __init init_prism2_pccard(void) | 1002 | static int __init init_prism2_pccard(void) |