aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth/dtl1_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/bluetooth/dtl1_cs.c')
-rw-r--r--drivers/bluetooth/dtl1_cs.c111
1 files changed, 32 insertions, 79 deletions
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index dec5980a1cd6..0449bc45ae5e 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -89,14 +89,8 @@ typedef struct dtl1_info_t {
89 89
90static void dtl1_config(dev_link_t *link); 90static void dtl1_config(dev_link_t *link);
91static void dtl1_release(dev_link_t *link); 91static void dtl1_release(dev_link_t *link);
92static int dtl1_event(event_t event, int priority, event_callback_args_t *args);
93 92
94static dev_info_t dev_info = "dtl1_cs"; 93static void dtl1_detach(struct pcmcia_device *p_dev);
95
96static dev_link_t *dtl1_attach(void);
97static void dtl1_detach(dev_link_t *);
98
99static dev_link_t *dev_list = NULL;
100 94
101 95
102/* Transmit states */ 96/* Transmit states */
@@ -561,17 +555,15 @@ static int dtl1_close(dtl1_info_t *info)
561 return 0; 555 return 0;
562} 556}
563 557
564static dev_link_t *dtl1_attach(void) 558static int dtl1_attach(struct pcmcia_device *p_dev)
565{ 559{
566 dtl1_info_t *info; 560 dtl1_info_t *info;
567 client_reg_t client_reg;
568 dev_link_t *link; 561 dev_link_t *link;
569 int ret;
570 562
571 /* Create new info device */ 563 /* Create new info device */
572 info = kzalloc(sizeof(*info), GFP_KERNEL); 564 info = kzalloc(sizeof(*info), GFP_KERNEL);
573 if (!info) 565 if (!info)
574 return NULL; 566 return -ENOMEM;
575 567
576 link = &info->link; 568 link = &info->link;
577 link->priv = info; 569 link->priv = info;
@@ -588,50 +580,24 @@ static dev_link_t *dtl1_attach(void)
588 link->conf.Vcc = 50; 580 link->conf.Vcc = 50;
589 link->conf.IntType = INT_MEMORY_AND_IO; 581 link->conf.IntType = INT_MEMORY_AND_IO;
590 582
591 /* Register with Card Services */ 583 link->handle = p_dev;
592 link->next = dev_list; 584 p_dev->instance = link;
593 dev_list = link;
594 client_reg.dev_info = &dev_info;
595 client_reg.Version = 0x0210;
596 client_reg.event_callback_args.client_data = link;
597
598 ret = pcmcia_register_client(&link->handle, &client_reg);
599 if (ret != CS_SUCCESS) {
600 cs_error(link->handle, RegisterClient, ret);
601 dtl1_detach(link);
602 return NULL;
603 }
604 585
605 return link; 586 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
587 dtl1_config(link);
588
589 return 0;
606} 590}
607 591
608 592
609static void dtl1_detach(dev_link_t *link) 593static void dtl1_detach(struct pcmcia_device *p_dev)
610{ 594{
595 dev_link_t *link = dev_to_instance(p_dev);
611 dtl1_info_t *info = link->priv; 596 dtl1_info_t *info = link->priv;
612 dev_link_t **linkp;
613 int ret;
614
615 /* Locate device structure */
616 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
617 if (*linkp == link)
618 break;
619
620 if (*linkp == NULL)
621 return;
622 597
623 if (link->state & DEV_CONFIG) 598 if (link->state & DEV_CONFIG)
624 dtl1_release(link); 599 dtl1_release(link);
625 600
626 if (link->handle) {
627 ret = pcmcia_deregister_client(link->handle);
628 if (ret != CS_SUCCESS)
629 cs_error(link->handle, DeregisterClient, ret);
630 }
631
632 /* Unlink device structure, free bits */
633 *linkp = link->next;
634
635 kfree(info); 601 kfree(info);
636} 602}
637 603
@@ -763,46 +729,33 @@ static void dtl1_release(dev_link_t *link)
763 link->state &= ~DEV_CONFIG; 729 link->state &= ~DEV_CONFIG;
764} 730}
765 731
732static int dtl1_suspend(struct pcmcia_device *dev)
733{
734 dev_link_t *link = dev_to_instance(dev);
766 735
767static int dtl1_event(event_t event, int priority, event_callback_args_t *args) 736 link->state |= DEV_SUSPEND;
737 if (link->state & DEV_CONFIG)
738 pcmcia_release_configuration(link->handle);
739
740 return 0;
741}
742
743static int dtl1_resume(struct pcmcia_device *dev)
768{ 744{
769 dev_link_t *link = args->client_data; 745 dev_link_t *link = dev_to_instance(dev);
770 dtl1_info_t *info = link->priv;
771 746
772 switch (event) { 747 link->state &= ~DEV_SUSPEND;
773 case CS_EVENT_CARD_REMOVAL: 748 if (DEV_OK(link))
774 link->state &= ~DEV_PRESENT; 749 pcmcia_request_configuration(link->handle, &link->conf);
775 if (link->state & DEV_CONFIG) {
776 dtl1_close(info);
777 dtl1_release(link);
778 }
779 break;
780 case CS_EVENT_CARD_INSERTION:
781 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
782 dtl1_config(link);
783 break;
784 case CS_EVENT_PM_SUSPEND:
785 link->state |= DEV_SUSPEND;
786 /* Fall through... */
787 case CS_EVENT_RESET_PHYSICAL:
788 if (link->state & DEV_CONFIG)
789 pcmcia_release_configuration(link->handle);
790 break;
791 case CS_EVENT_PM_RESUME:
792 link->state &= ~DEV_SUSPEND;
793 /* Fall through... */
794 case CS_EVENT_CARD_RESET:
795 if (DEV_OK(link))
796 pcmcia_request_configuration(link->handle, &link->conf);
797 break;
798 }
799 750
800 return 0; 751 return 0;
801} 752}
802 753
754
803static struct pcmcia_device_id dtl1_ids[] = { 755static struct pcmcia_device_id dtl1_ids[] = {
804 PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d), 756 PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d),
805 PCMCIA_DEVICE_PROD_ID12("Socket", "CF", 0xb38bcc2e, 0x44ebf863), 757 PCMCIA_DEVICE_PROD_ID12("Socket", "CF", 0xb38bcc2e, 0x44ebf863),
758 PCMCIA_DEVICE_PROD_ID12("Socket", "CF+ Personal Network Card", 0xb38bcc2e, 0xe732bae3),
806 PCMCIA_DEVICE_NULL 759 PCMCIA_DEVICE_NULL
807}; 760};
808MODULE_DEVICE_TABLE(pcmcia, dtl1_ids); 761MODULE_DEVICE_TABLE(pcmcia, dtl1_ids);
@@ -812,10 +765,11 @@ static struct pcmcia_driver dtl1_driver = {
812 .drv = { 765 .drv = {
813 .name = "dtl1_cs", 766 .name = "dtl1_cs",
814 }, 767 },
815 .attach = dtl1_attach, 768 .probe = dtl1_attach,
816 .event = dtl1_event, 769 .remove = dtl1_detach,
817 .detach = dtl1_detach,
818 .id_table = dtl1_ids, 770 .id_table = dtl1_ids,
771 .suspend = dtl1_suspend,
772 .resume = dtl1_resume,
819}; 773};
820 774
821static int __init init_dtl1_cs(void) 775static int __init init_dtl1_cs(void)
@@ -827,7 +781,6 @@ static int __init init_dtl1_cs(void)
827static void __exit exit_dtl1_cs(void) 781static void __exit exit_dtl1_cs(void)
828{ 782{
829 pcmcia_unregister_driver(&dtl1_driver); 783 pcmcia_unregister_driver(&dtl1_driver);
830 BUG_ON(dev_list != NULL);
831} 784}
832 785
833module_init(init_dtl1_cs); 786module_init(init_dtl1_cs);