aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/pcmcia/cm4040_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/pcmcia/cm4040_cs.c')
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c67
1 files changed, 11 insertions, 56 deletions
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index e08ab949c116..46eb371bf17e 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -65,7 +65,6 @@ static char *version =
65#define POLL_PERIOD msecs_to_jiffies(10) 65#define POLL_PERIOD msecs_to_jiffies(10)
66 66
67static void reader_release(dev_link_t *link); 67static void reader_release(dev_link_t *link);
68static void reader_detach(struct pcmcia_device *p_dev);
69 68
70static int major; 69static int major;
71 70
@@ -86,7 +85,6 @@ struct reader_dev {
86 struct timer_list poll_timer; 85 struct timer_list poll_timer;
87}; 86};
88 87
89static dev_info_t dev_info = MODULE_NAME;
90static dev_link_t *dev_table[CM_MAX_DEV]; 88static dev_link_t *dev_table[CM_MAX_DEV];
91 89
92#ifndef PCMCIA_DEBUG 90#ifndef PCMCIA_DEBUG
@@ -629,39 +627,6 @@ cs_release:
629 link->state &= ~DEV_CONFIG_PENDING; 627 link->state &= ~DEV_CONFIG_PENDING;
630} 628}
631 629
632static int reader_event(event_t event, int priority,
633 event_callback_args_t *args)
634{
635 dev_link_t *link;
636 struct reader_dev *dev;
637 int devno;
638
639 link = args->client_data;
640 dev = link->priv;
641 DEBUGP(3, dev, "-> reader_event\n");
642 for (devno = 0; devno < CM_MAX_DEV; devno++) {
643 if (dev_table[devno] == link)
644 break;
645 }
646 if (devno == CM_MAX_DEV)
647 return CS_BAD_ADAPTER;
648
649 switch (event) {
650 case CS_EVENT_CARD_INSERTION:
651 DEBUGP(5, dev, "CS_EVENT_CARD_INSERTION\n");
652 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
653 reader_config(link, devno);
654 break;
655
656 default:
657 DEBUGP(5, dev, "reader_event: unknown event %.2x\n",
658 event);
659 break;
660 }
661 DEBUGP(3, dev, "<- reader_event\n");
662 return CS_SUCCESS;
663}
664
665static int reader_suspend(struct pcmcia_device *p_dev) 630static int reader_suspend(struct pcmcia_device *p_dev)
666{ 631{
667 dev_link_t *link = dev_to_instance(p_dev); 632 dev_link_t *link = dev_to_instance(p_dev);
@@ -691,11 +656,10 @@ static void reader_release(dev_link_t *link)
691 pcmcia_release_io(link->handle, &link->io); 656 pcmcia_release_io(link->handle, &link->io);
692} 657}
693 658
694static dev_link_t *reader_attach(void) 659static int reader_attach(struct pcmcia_device *p_dev)
695{ 660{
696 struct reader_dev *dev; 661 struct reader_dev *dev;
697 dev_link_t *link; 662 dev_link_t *link;
698 client_reg_t client_reg;
699 int i; 663 int i;
700 664
701 for (i = 0; i < CM_MAX_DEV; i++) { 665 for (i = 0; i < CM_MAX_DEV; i++) {
@@ -704,11 +668,11 @@ static dev_link_t *reader_attach(void)
704 } 668 }
705 669
706 if (i == CM_MAX_DEV) 670 if (i == CM_MAX_DEV)
707 return NULL; 671 return -ENODEV;
708 672
709 dev = kzalloc(sizeof(struct reader_dev), GFP_KERNEL); 673 dev = kzalloc(sizeof(struct reader_dev), GFP_KERNEL);
710 if (dev == NULL) 674 if (dev == NULL)
711 return NULL; 675 return -ENOMEM;
712 676
713 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT; 677 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT;
714 dev->buffer_status = 0; 678 dev->buffer_status = 0;
@@ -719,20 +683,6 @@ static dev_link_t *reader_attach(void)
719 link->conf.IntType = INT_MEMORY_AND_IO; 683 link->conf.IntType = INT_MEMORY_AND_IO;
720 dev_table[i] = link; 684 dev_table[i] = link;
721 685
722 client_reg.dev_info = &dev_info;
723 client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
724 client_reg.EventMask=
725 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
726 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
727 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
728 client_reg.Version = 0x0210;
729 client_reg.event_callback_args.client_data = link;
730 i = pcmcia_register_client(&link->handle, &client_reg);
731 if (i) {
732 cs_error(link->handle, RegisterClient, i);
733 reader_detach(link->handle);
734 return NULL;
735 }
736 init_waitqueue_head(&dev->devq); 686 init_waitqueue_head(&dev->devq);
737 init_waitqueue_head(&dev->poll_wait); 687 init_waitqueue_head(&dev->poll_wait);
738 init_waitqueue_head(&dev->read_wait); 688 init_waitqueue_head(&dev->read_wait);
@@ -740,7 +690,13 @@ static dev_link_t *reader_attach(void)
740 init_timer(&dev->poll_timer); 690 init_timer(&dev->poll_timer);
741 dev->poll_timer.function = &cm4040_do_poll; 691 dev->poll_timer.function = &cm4040_do_poll;
742 692
743 return link; 693 link->handle = p_dev;
694 p_dev->instance = link;
695
696 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
697 reader_config(link, i);
698
699 return 0;
744} 700}
745 701
746static void reader_detach(struct pcmcia_device *p_dev) 702static void reader_detach(struct pcmcia_device *p_dev)
@@ -790,11 +746,10 @@ static struct pcmcia_driver reader_driver = {
790 .drv = { 746 .drv = {
791 .name = "cm4040_cs", 747 .name = "cm4040_cs",
792 }, 748 },
793 .attach = reader_attach, 749 .probe = reader_attach,
794 .remove = reader_detach, 750 .remove = reader_detach,
795 .suspend = reader_suspend, 751 .suspend = reader_suspend,
796 .resume = reader_resume, 752 .resume = reader_resume,
797 .event = reader_event,
798 .id_table = cm4040_ids, 753 .id_table = cm4040_ids,
799}; 754};
800 755