diff options
Diffstat (limited to 'drivers/bluetooth/btuart_cs.c')
-rw-r--r-- | drivers/bluetooth/btuart_cs.c | 110 |
1 files changed, 31 insertions, 79 deletions
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 529a28a3209d..7b4bff4cfa2d 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c | |||
@@ -86,14 +86,8 @@ typedef struct btuart_info_t { | |||
86 | 86 | ||
87 | static void btuart_config(dev_link_t *link); | 87 | static void btuart_config(dev_link_t *link); |
88 | static void btuart_release(dev_link_t *link); | 88 | static void btuart_release(dev_link_t *link); |
89 | static int btuart_event(event_t event, int priority, event_callback_args_t *args); | ||
90 | 89 | ||
91 | static dev_info_t dev_info = "btuart_cs"; | 90 | static void btuart_detach(struct pcmcia_device *p_dev); |
92 | |||
93 | static dev_link_t *btuart_attach(void); | ||
94 | static void btuart_detach(dev_link_t *); | ||
95 | |||
96 | static dev_link_t *dev_list = NULL; | ||
97 | 91 | ||
98 | 92 | ||
99 | /* Maximum baud rate */ | 93 | /* Maximum baud rate */ |
@@ -582,17 +576,15 @@ static int btuart_close(btuart_info_t *info) | |||
582 | return 0; | 576 | return 0; |
583 | } | 577 | } |
584 | 578 | ||
585 | static dev_link_t *btuart_attach(void) | 579 | static int btuart_attach(struct pcmcia_device *p_dev) |
586 | { | 580 | { |
587 | btuart_info_t *info; | 581 | btuart_info_t *info; |
588 | client_reg_t client_reg; | ||
589 | dev_link_t *link; | 582 | dev_link_t *link; |
590 | int ret; | ||
591 | 583 | ||
592 | /* Create new info device */ | 584 | /* Create new info device */ |
593 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 585 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
594 | if (!info) | 586 | if (!info) |
595 | return NULL; | 587 | return -ENOMEM; |
596 | 588 | ||
597 | link = &info->link; | 589 | link = &info->link; |
598 | link->priv = info; | 590 | link->priv = info; |
@@ -609,50 +601,24 @@ static dev_link_t *btuart_attach(void) | |||
609 | link->conf.Vcc = 50; | 601 | link->conf.Vcc = 50; |
610 | link->conf.IntType = INT_MEMORY_AND_IO; | 602 | link->conf.IntType = INT_MEMORY_AND_IO; |
611 | 603 | ||
612 | /* Register with Card Services */ | 604 | link->handle = p_dev; |
613 | link->next = dev_list; | 605 | p_dev->instance = link; |
614 | dev_list = link; | ||
615 | client_reg.dev_info = &dev_info; | ||
616 | client_reg.Version = 0x0210; | ||
617 | client_reg.event_callback_args.client_data = link; | ||
618 | |||
619 | ret = pcmcia_register_client(&link->handle, &client_reg); | ||
620 | if (ret != CS_SUCCESS) { | ||
621 | cs_error(link->handle, RegisterClient, ret); | ||
622 | btuart_detach(link); | ||
623 | return NULL; | ||
624 | } | ||
625 | 606 | ||
626 | return link; | 607 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; |
608 | btuart_config(link); | ||
609 | |||
610 | return 0; | ||
627 | } | 611 | } |
628 | 612 | ||
629 | 613 | ||
630 | static void btuart_detach(dev_link_t *link) | 614 | static void btuart_detach(struct pcmcia_device *p_dev) |
631 | { | 615 | { |
616 | dev_link_t *link = dev_to_instance(p_dev); | ||
632 | btuart_info_t *info = link->priv; | 617 | btuart_info_t *info = link->priv; |
633 | dev_link_t **linkp; | ||
634 | int ret; | ||
635 | |||
636 | /* Locate device structure */ | ||
637 | for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) | ||
638 | if (*linkp == link) | ||
639 | break; | ||
640 | |||
641 | if (*linkp == NULL) | ||
642 | return; | ||
643 | 618 | ||
644 | if (link->state & DEV_CONFIG) | 619 | if (link->state & DEV_CONFIG) |
645 | btuart_release(link); | 620 | btuart_release(link); |
646 | 621 | ||
647 | if (link->handle) { | ||
648 | ret = pcmcia_deregister_client(link->handle); | ||
649 | if (ret != CS_SUCCESS) | ||
650 | cs_error(link->handle, DeregisterClient, ret); | ||
651 | } | ||
652 | |||
653 | /* Unlink device structure, free bits */ | ||
654 | *linkp = link->next; | ||
655 | |||
656 | kfree(info); | 622 | kfree(info); |
657 | } | 623 | } |
658 | 624 | ||
@@ -811,43 +777,29 @@ static void btuart_release(dev_link_t *link) | |||
811 | link->state &= ~DEV_CONFIG; | 777 | link->state &= ~DEV_CONFIG; |
812 | } | 778 | } |
813 | 779 | ||
780 | static int btuart_suspend(struct pcmcia_device *dev) | ||
781 | { | ||
782 | dev_link_t *link = dev_to_instance(dev); | ||
814 | 783 | ||
815 | static int btuart_event(event_t event, int priority, event_callback_args_t *args) | 784 | link->state |= DEV_SUSPEND; |
785 | if (link->state & DEV_CONFIG) | ||
786 | pcmcia_release_configuration(link->handle); | ||
787 | |||
788 | return 0; | ||
789 | } | ||
790 | |||
791 | static int btuart_resume(struct pcmcia_device *dev) | ||
816 | { | 792 | { |
817 | dev_link_t *link = args->client_data; | 793 | dev_link_t *link = dev_to_instance(dev); |
818 | btuart_info_t *info = link->priv; | ||
819 | 794 | ||
820 | switch (event) { | 795 | link->state &= ~DEV_SUSPEND; |
821 | case CS_EVENT_CARD_REMOVAL: | 796 | if (DEV_OK(link)) |
822 | link->state &= ~DEV_PRESENT; | 797 | pcmcia_request_configuration(link->handle, &link->conf); |
823 | if (link->state & DEV_CONFIG) { | ||
824 | btuart_close(info); | ||
825 | btuart_release(link); | ||
826 | } | ||
827 | break; | ||
828 | case CS_EVENT_CARD_INSERTION: | ||
829 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
830 | btuart_config(link); | ||
831 | break; | ||
832 | case CS_EVENT_PM_SUSPEND: | ||
833 | link->state |= DEV_SUSPEND; | ||
834 | /* Fall through... */ | ||
835 | case CS_EVENT_RESET_PHYSICAL: | ||
836 | if (link->state & DEV_CONFIG) | ||
837 | pcmcia_release_configuration(link->handle); | ||
838 | break; | ||
839 | case CS_EVENT_PM_RESUME: | ||
840 | link->state &= ~DEV_SUSPEND; | ||
841 | /* Fall through... */ | ||
842 | case CS_EVENT_CARD_RESET: | ||
843 | if (DEV_OK(link)) | ||
844 | pcmcia_request_configuration(link->handle, &link->conf); | ||
845 | break; | ||
846 | } | ||
847 | 798 | ||
848 | return 0; | 799 | return 0; |
849 | } | 800 | } |
850 | 801 | ||
802 | |||
851 | static struct pcmcia_device_id btuart_ids[] = { | 803 | static struct pcmcia_device_id btuart_ids[] = { |
852 | /* don't use this driver. Use serial_cs + hci_uart instead */ | 804 | /* don't use this driver. Use serial_cs + hci_uart instead */ |
853 | PCMCIA_DEVICE_NULL | 805 | PCMCIA_DEVICE_NULL |
@@ -859,10 +811,11 @@ static struct pcmcia_driver btuart_driver = { | |||
859 | .drv = { | 811 | .drv = { |
860 | .name = "btuart_cs", | 812 | .name = "btuart_cs", |
861 | }, | 813 | }, |
862 | .attach = btuart_attach, | 814 | .probe = btuart_attach, |
863 | .event = btuart_event, | 815 | .remove = btuart_detach, |
864 | .detach = btuart_detach, | ||
865 | .id_table = btuart_ids, | 816 | .id_table = btuart_ids, |
817 | .suspend = btuart_suspend, | ||
818 | .resume = btuart_resume, | ||
866 | }; | 819 | }; |
867 | 820 | ||
868 | static int __init init_btuart_cs(void) | 821 | static int __init init_btuart_cs(void) |
@@ -874,7 +827,6 @@ static int __init init_btuart_cs(void) | |||
874 | static void __exit exit_btuart_cs(void) | 827 | static void __exit exit_btuart_cs(void) |
875 | { | 828 | { |
876 | pcmcia_unregister_driver(&btuart_driver); | 829 | pcmcia_unregister_driver(&btuart_driver); |
877 | BUG_ON(dev_list != NULL); | ||
878 | } | 830 | } |
879 | 831 | ||
880 | module_init(init_btuart_cs); | 832 | module_init(init_btuart_cs); |