diff options
Diffstat (limited to 'drivers/bluetooth/bluecard_cs.c')
-rw-r--r-- | drivers/bluetooth/bluecard_cs.c | 109 |
1 files changed, 30 insertions, 79 deletions
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index f36c563d72c4..9888bc151755 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c | |||
@@ -87,14 +87,8 @@ typedef struct bluecard_info_t { | |||
87 | 87 | ||
88 | static void bluecard_config(dev_link_t *link); | 88 | static void bluecard_config(dev_link_t *link); |
89 | static void bluecard_release(dev_link_t *link); | 89 | static void bluecard_release(dev_link_t *link); |
90 | static int bluecard_event(event_t event, int priority, event_callback_args_t *args); | ||
91 | 90 | ||
92 | static dev_info_t dev_info = "bluecard_cs"; | 91 | static void bluecard_detach(struct pcmcia_device *p_dev); |
93 | |||
94 | static dev_link_t *bluecard_attach(void); | ||
95 | static void bluecard_detach(dev_link_t *); | ||
96 | |||
97 | static dev_link_t *dev_list = NULL; | ||
98 | 92 | ||
99 | 93 | ||
100 | /* Default baud rate: 57600, 115200, 230400 or 460800 */ | 94 | /* Default baud rate: 57600, 115200, 230400 or 460800 */ |
@@ -862,17 +856,15 @@ static int bluecard_close(bluecard_info_t *info) | |||
862 | return 0; | 856 | return 0; |
863 | } | 857 | } |
864 | 858 | ||
865 | static dev_link_t *bluecard_attach(void) | 859 | static int bluecard_attach(struct pcmcia_device *p_dev) |
866 | { | 860 | { |
867 | bluecard_info_t *info; | 861 | bluecard_info_t *info; |
868 | client_reg_t client_reg; | ||
869 | dev_link_t *link; | 862 | dev_link_t *link; |
870 | int ret; | ||
871 | 863 | ||
872 | /* Create new info device */ | 864 | /* Create new info device */ |
873 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 865 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
874 | if (!info) | 866 | if (!info) |
875 | return NULL; | 867 | return -ENOMEM; |
876 | 868 | ||
877 | link = &info->link; | 869 | link = &info->link; |
878 | link->priv = info; | 870 | link->priv = info; |
@@ -889,50 +881,24 @@ static dev_link_t *bluecard_attach(void) | |||
889 | link->conf.Vcc = 50; | 881 | link->conf.Vcc = 50; |
890 | link->conf.IntType = INT_MEMORY_AND_IO; | 882 | link->conf.IntType = INT_MEMORY_AND_IO; |
891 | 883 | ||
892 | /* Register with Card Services */ | 884 | link->handle = p_dev; |
893 | link->next = dev_list; | 885 | p_dev->instance = link; |
894 | dev_list = link; | ||
895 | client_reg.dev_info = &dev_info; | ||
896 | client_reg.Version = 0x0210; | ||
897 | client_reg.event_callback_args.client_data = link; | ||
898 | |||
899 | ret = pcmcia_register_client(&link->handle, &client_reg); | ||
900 | if (ret != CS_SUCCESS) { | ||
901 | cs_error(link->handle, RegisterClient, ret); | ||
902 | bluecard_detach(link); | ||
903 | return NULL; | ||
904 | } | ||
905 | 886 | ||
906 | return link; | 887 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; |
888 | bluecard_config(link); | ||
889 | |||
890 | return 0; | ||
907 | } | 891 | } |
908 | 892 | ||
909 | 893 | ||
910 | static void bluecard_detach(dev_link_t *link) | 894 | static void bluecard_detach(struct pcmcia_device *p_dev) |
911 | { | 895 | { |
896 | dev_link_t *link = dev_to_instance(p_dev); | ||
912 | bluecard_info_t *info = link->priv; | 897 | bluecard_info_t *info = link->priv; |
913 | dev_link_t **linkp; | ||
914 | int ret; | ||
915 | |||
916 | /* Locate device structure */ | ||
917 | for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) | ||
918 | if (*linkp == link) | ||
919 | break; | ||
920 | |||
921 | if (*linkp == NULL) | ||
922 | return; | ||
923 | 898 | ||
924 | if (link->state & DEV_CONFIG) | 899 | if (link->state & DEV_CONFIG) |
925 | bluecard_release(link); | 900 | bluecard_release(link); |
926 | 901 | ||
927 | if (link->handle) { | ||
928 | ret = pcmcia_deregister_client(link->handle); | ||
929 | if (ret != CS_SUCCESS) | ||
930 | cs_error(link->handle, DeregisterClient, ret); | ||
931 | } | ||
932 | |||
933 | /* Unlink device structure, free bits */ | ||
934 | *linkp = link->next; | ||
935 | |||
936 | kfree(info); | 902 | kfree(info); |
937 | } | 903 | } |
938 | 904 | ||
@@ -1045,39 +1011,24 @@ static void bluecard_release(dev_link_t *link) | |||
1045 | link->state &= ~DEV_CONFIG; | 1011 | link->state &= ~DEV_CONFIG; |
1046 | } | 1012 | } |
1047 | 1013 | ||
1014 | static int bluecard_suspend(struct pcmcia_device *dev) | ||
1015 | { | ||
1016 | dev_link_t *link = dev_to_instance(dev); | ||
1017 | |||
1018 | link->state |= DEV_SUSPEND; | ||
1019 | if (link->state & DEV_CONFIG) | ||
1020 | pcmcia_release_configuration(link->handle); | ||
1048 | 1021 | ||
1049 | static int bluecard_event(event_t event, int priority, event_callback_args_t *args) | 1022 | return 0; |
1023 | } | ||
1024 | |||
1025 | static int bluecard_resume(struct pcmcia_device *dev) | ||
1050 | { | 1026 | { |
1051 | dev_link_t *link = args->client_data; | 1027 | dev_link_t *link = dev_to_instance(dev); |
1052 | bluecard_info_t *info = link->priv; | ||
1053 | 1028 | ||
1054 | switch (event) { | 1029 | link->state &= ~DEV_SUSPEND; |
1055 | case CS_EVENT_CARD_REMOVAL: | 1030 | if (DEV_OK(link)) |
1056 | link->state &= ~DEV_PRESENT; | 1031 | pcmcia_request_configuration(link->handle, &link->conf); |
1057 | if (link->state & DEV_CONFIG) { | ||
1058 | bluecard_close(info); | ||
1059 | bluecard_release(link); | ||
1060 | } | ||
1061 | break; | ||
1062 | case CS_EVENT_CARD_INSERTION: | ||
1063 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
1064 | bluecard_config(link); | ||
1065 | break; | ||
1066 | case CS_EVENT_PM_SUSPEND: | ||
1067 | link->state |= DEV_SUSPEND; | ||
1068 | /* Fall through... */ | ||
1069 | case CS_EVENT_RESET_PHYSICAL: | ||
1070 | if (link->state & DEV_CONFIG) | ||
1071 | pcmcia_release_configuration(link->handle); | ||
1072 | break; | ||
1073 | case CS_EVENT_PM_RESUME: | ||
1074 | link->state &= ~DEV_SUSPEND; | ||
1075 | /* Fall through... */ | ||
1076 | case CS_EVENT_CARD_RESET: | ||
1077 | if (DEV_OK(link)) | ||
1078 | pcmcia_request_configuration(link->handle, &link->conf); | ||
1079 | break; | ||
1080 | } | ||
1081 | 1032 | ||
1082 | return 0; | 1033 | return 0; |
1083 | } | 1034 | } |
@@ -1095,10 +1046,11 @@ static struct pcmcia_driver bluecard_driver = { | |||
1095 | .drv = { | 1046 | .drv = { |
1096 | .name = "bluecard_cs", | 1047 | .name = "bluecard_cs", |
1097 | }, | 1048 | }, |
1098 | .attach = bluecard_attach, | 1049 | .probe = bluecard_attach, |
1099 | .event = bluecard_event, | 1050 | .remove = bluecard_detach, |
1100 | .detach = bluecard_detach, | ||
1101 | .id_table = bluecard_ids, | 1051 | .id_table = bluecard_ids, |
1052 | .suspend = bluecard_suspend, | ||
1053 | .resume = bluecard_resume, | ||
1102 | }; | 1054 | }; |
1103 | 1055 | ||
1104 | static int __init init_bluecard_cs(void) | 1056 | static int __init init_bluecard_cs(void) |
@@ -1110,7 +1062,6 @@ static int __init init_bluecard_cs(void) | |||
1110 | static void __exit exit_bluecard_cs(void) | 1062 | static void __exit exit_bluecard_cs(void) |
1111 | { | 1063 | { |
1112 | pcmcia_unregister_driver(&bluecard_driver); | 1064 | pcmcia_unregister_driver(&bluecard_driver); |
1113 | BUG_ON(dev_list != NULL); | ||
1114 | } | 1065 | } |
1115 | 1066 | ||
1116 | module_init(init_bluecard_cs); | 1067 | module_init(init_bluecard_cs); |