diff options
Diffstat (limited to 'drivers/bluetooth/bt3c_cs.c')
-rw-r--r-- | drivers/bluetooth/bt3c_cs.c | 110 |
1 files changed, 31 insertions, 79 deletions
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index d2a0add19cc8..e522d19ad886 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c | |||
@@ -90,14 +90,8 @@ typedef struct bt3c_info_t { | |||
90 | 90 | ||
91 | static void bt3c_config(dev_link_t *link); | 91 | static void bt3c_config(dev_link_t *link); |
92 | static void bt3c_release(dev_link_t *link); | 92 | static void bt3c_release(dev_link_t *link); |
93 | static int bt3c_event(event_t event, int priority, event_callback_args_t *args); | ||
94 | 93 | ||
95 | static dev_info_t dev_info = "bt3c_cs"; | 94 | static void bt3c_detach(struct pcmcia_device *p_dev); |
96 | |||
97 | static dev_link_t *bt3c_attach(void); | ||
98 | static void bt3c_detach(dev_link_t *); | ||
99 | |||
100 | static dev_link_t *dev_list = NULL; | ||
101 | 95 | ||
102 | 96 | ||
103 | /* Transmit states */ | 97 | /* Transmit states */ |
@@ -663,17 +657,15 @@ static int bt3c_close(bt3c_info_t *info) | |||
663 | return 0; | 657 | return 0; |
664 | } | 658 | } |
665 | 659 | ||
666 | static dev_link_t *bt3c_attach(void) | 660 | static int bt3c_attach(struct pcmcia_device *p_dev) |
667 | { | 661 | { |
668 | bt3c_info_t *info; | 662 | bt3c_info_t *info; |
669 | client_reg_t client_reg; | ||
670 | dev_link_t *link; | 663 | dev_link_t *link; |
671 | int ret; | ||
672 | 664 | ||
673 | /* Create new info device */ | 665 | /* Create new info device */ |
674 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 666 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
675 | if (!info) | 667 | if (!info) |
676 | return NULL; | 668 | return -ENOMEM; |
677 | 669 | ||
678 | link = &info->link; | 670 | link = &info->link; |
679 | link->priv = info; | 671 | link->priv = info; |
@@ -690,50 +682,24 @@ static dev_link_t *bt3c_attach(void) | |||
690 | link->conf.Vcc = 50; | 682 | link->conf.Vcc = 50; |
691 | link->conf.IntType = INT_MEMORY_AND_IO; | 683 | link->conf.IntType = INT_MEMORY_AND_IO; |
692 | 684 | ||
693 | /* Register with Card Services */ | 685 | link->handle = p_dev; |
694 | link->next = dev_list; | 686 | p_dev->instance = link; |
695 | dev_list = link; | ||
696 | client_reg.dev_info = &dev_info; | ||
697 | client_reg.Version = 0x0210; | ||
698 | client_reg.event_callback_args.client_data = link; | ||
699 | |||
700 | ret = pcmcia_register_client(&link->handle, &client_reg); | ||
701 | if (ret != CS_SUCCESS) { | ||
702 | cs_error(link->handle, RegisterClient, ret); | ||
703 | bt3c_detach(link); | ||
704 | return NULL; | ||
705 | } | ||
706 | 687 | ||
707 | return link; | 688 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; |
689 | bt3c_config(link); | ||
690 | |||
691 | return 0; | ||
708 | } | 692 | } |
709 | 693 | ||
710 | 694 | ||
711 | static void bt3c_detach(dev_link_t *link) | 695 | static void bt3c_detach(struct pcmcia_device *p_dev) |
712 | { | 696 | { |
697 | dev_link_t *link = dev_to_instance(p_dev); | ||
713 | bt3c_info_t *info = link->priv; | 698 | bt3c_info_t *info = link->priv; |
714 | dev_link_t **linkp; | ||
715 | int ret; | ||
716 | |||
717 | /* Locate device structure */ | ||
718 | for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) | ||
719 | if (*linkp == link) | ||
720 | break; | ||
721 | |||
722 | if (*linkp == NULL) | ||
723 | return; | ||
724 | 699 | ||
725 | if (link->state & DEV_CONFIG) | 700 | if (link->state & DEV_CONFIG) |
726 | bt3c_release(link); | 701 | bt3c_release(link); |
727 | 702 | ||
728 | if (link->handle) { | ||
729 | ret = pcmcia_deregister_client(link->handle); | ||
730 | if (ret != CS_SUCCESS) | ||
731 | cs_error(link->handle, DeregisterClient, ret); | ||
732 | } | ||
733 | |||
734 | /* Unlink device structure, free bits */ | ||
735 | *linkp = link->next; | ||
736 | |||
737 | kfree(info); | 703 | kfree(info); |
738 | } | 704 | } |
739 | 705 | ||
@@ -891,43 +857,29 @@ static void bt3c_release(dev_link_t *link) | |||
891 | link->state &= ~DEV_CONFIG; | 857 | link->state &= ~DEV_CONFIG; |
892 | } | 858 | } |
893 | 859 | ||
860 | static int bt3c_suspend(struct pcmcia_device *dev) | ||
861 | { | ||
862 | dev_link_t *link = dev_to_instance(dev); | ||
894 | 863 | ||
895 | static int bt3c_event(event_t event, int priority, event_callback_args_t *args) | 864 | link->state |= DEV_SUSPEND; |
865 | if (link->state & DEV_CONFIG) | ||
866 | pcmcia_release_configuration(link->handle); | ||
867 | |||
868 | return 0; | ||
869 | } | ||
870 | |||
871 | static int bt3c_resume(struct pcmcia_device *dev) | ||
896 | { | 872 | { |
897 | dev_link_t *link = args->client_data; | 873 | dev_link_t *link = dev_to_instance(dev); |
898 | bt3c_info_t *info = link->priv; | ||
899 | 874 | ||
900 | switch (event) { | 875 | link->state &= ~DEV_SUSPEND; |
901 | case CS_EVENT_CARD_REMOVAL: | 876 | if (DEV_OK(link)) |
902 | link->state &= ~DEV_PRESENT; | 877 | pcmcia_request_configuration(link->handle, &link->conf); |
903 | if (link->state & DEV_CONFIG) { | ||
904 | bt3c_close(info); | ||
905 | bt3c_release(link); | ||
906 | } | ||
907 | break; | ||
908 | case CS_EVENT_CARD_INSERTION: | ||
909 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
910 | bt3c_config(link); | ||
911 | break; | ||
912 | case CS_EVENT_PM_SUSPEND: | ||
913 | link->state |= DEV_SUSPEND; | ||
914 | /* Fall through... */ | ||
915 | case CS_EVENT_RESET_PHYSICAL: | ||
916 | if (link->state & DEV_CONFIG) | ||
917 | pcmcia_release_configuration(link->handle); | ||
918 | break; | ||
919 | case CS_EVENT_PM_RESUME: | ||
920 | link->state &= ~DEV_SUSPEND; | ||
921 | /* Fall through... */ | ||
922 | case CS_EVENT_CARD_RESET: | ||
923 | if (DEV_OK(link)) | ||
924 | pcmcia_request_configuration(link->handle, &link->conf); | ||
925 | break; | ||
926 | } | ||
927 | 878 | ||
928 | return 0; | 879 | return 0; |
929 | } | 880 | } |
930 | 881 | ||
882 | |||
931 | static struct pcmcia_device_id bt3c_ids[] = { | 883 | static struct pcmcia_device_id bt3c_ids[] = { |
932 | PCMCIA_DEVICE_PROD_ID13("3COM", "Bluetooth PC Card", 0xefce0a31, 0xd4ce9b02), | 884 | PCMCIA_DEVICE_PROD_ID13("3COM", "Bluetooth PC Card", 0xefce0a31, 0xd4ce9b02), |
933 | PCMCIA_DEVICE_NULL | 885 | PCMCIA_DEVICE_NULL |
@@ -939,10 +891,11 @@ static struct pcmcia_driver bt3c_driver = { | |||
939 | .drv = { | 891 | .drv = { |
940 | .name = "bt3c_cs", | 892 | .name = "bt3c_cs", |
941 | }, | 893 | }, |
942 | .attach = bt3c_attach, | 894 | .probe = bt3c_attach, |
943 | .event = bt3c_event, | 895 | .remove = bt3c_detach, |
944 | .detach = bt3c_detach, | ||
945 | .id_table = bt3c_ids, | 896 | .id_table = bt3c_ids, |
897 | .suspend = bt3c_suspend, | ||
898 | .resume = bt3c_resume, | ||
946 | }; | 899 | }; |
947 | 900 | ||
948 | static int __init init_bt3c_cs(void) | 901 | static int __init init_bt3c_cs(void) |
@@ -954,7 +907,6 @@ static int __init init_bt3c_cs(void) | |||
954 | static void __exit exit_bt3c_cs(void) | 907 | static void __exit exit_bt3c_cs(void) |
955 | { | 908 | { |
956 | pcmcia_unregister_driver(&bt3c_driver); | 909 | pcmcia_unregister_driver(&bt3c_driver); |
957 | BUG_ON(dev_list != NULL); | ||
958 | } | 910 | } |
959 | 911 | ||
960 | module_init(init_bt3c_cs); | 912 | module_init(init_bt3c_cs); |