diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2006-01-07 09:40:05 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2006-01-07 09:40:05 -0500 |
commit | 123656d4cc8c946f578ebd18c2050f5251720428 (patch) | |
tree | 3d5432eff034a3b9cfdc98b37e245abe5695342d /drivers/mtd | |
parent | a62c80e559809e6c7851ec04d30575e85ad6f6ed (diff) | |
parent | 0aec63e67c69545ca757a73a66f5dcf05fa484bf (diff) |
Merge with Linus' kernel.
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/maps/pcmciamtd.c | 121 |
1 files changed, 36 insertions, 85 deletions
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index af24216a0626..f0f8916da7ad 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c | |||
@@ -66,9 +66,6 @@ struct pcmciamtd_dev { | |||
66 | }; | 66 | }; |
67 | 67 | ||
68 | 68 | ||
69 | static dev_info_t dev_info = "pcmciamtd"; | ||
70 | static dev_link_t *dev_list; | ||
71 | |||
72 | /* Module parameters */ | 69 | /* Module parameters */ |
73 | 70 | ||
74 | /* 2 = do 16-bit transfers, 1 = do 8-bit transfers */ | 71 | /* 2 = do 16-bit transfers, 1 = do 8-bit transfers */ |
@@ -691,55 +688,21 @@ static void pcmciamtd_config(dev_link_t *link) | |||
691 | } | 688 | } |
692 | 689 | ||
693 | 690 | ||
694 | /* The card status event handler. Mostly, this schedules other | 691 | static int pcmciamtd_suspend(struct pcmcia_device *dev) |
695 | * stuff to run after an event is received. A CARD_REMOVAL event | 692 | { |
696 | * also sets some flags to discourage the driver from trying | 693 | DEBUG(2, "EVENT_PM_RESUME"); |
697 | * to talk to the card any more. | 694 | |
698 | */ | 695 | /* get_lock(link); */ |
696 | |||
697 | return 0; | ||
698 | } | ||
699 | 699 | ||
700 | static int pcmciamtd_event(event_t event, int priority, | 700 | static int pcmciamtd_resume(struct pcmcia_device *dev) |
701 | event_callback_args_t *args) | ||
702 | { | 701 | { |
703 | dev_link_t *link = args->client_data; | 702 | DEBUG(2, "EVENT_PM_SUSPEND"); |
704 | 703 | ||
705 | DEBUG(1, "event=0x%06x", event); | 704 | /* free_lock(link); */ |
706 | switch (event) { | 705 | |
707 | case CS_EVENT_CARD_REMOVAL: | ||
708 | DEBUG(2, "EVENT_CARD_REMOVAL"); | ||
709 | link->state &= ~DEV_PRESENT; | ||
710 | if (link->state & DEV_CONFIG) { | ||
711 | struct pcmciamtd_dev *dev = link->priv; | ||
712 | if(dev->mtd_info) { | ||
713 | del_mtd_device(dev->mtd_info); | ||
714 | info("mtd%d: Removed", dev->mtd_info->index); | ||
715 | } | ||
716 | pcmciamtd_release(link); | ||
717 | } | ||
718 | break; | ||
719 | case CS_EVENT_CARD_INSERTION: | ||
720 | DEBUG(2, "EVENT_CARD_INSERTION"); | ||
721 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
722 | pcmciamtd_config(link); | ||
723 | break; | ||
724 | case CS_EVENT_PM_SUSPEND: | ||
725 | DEBUG(2, "EVENT_PM_SUSPEND"); | ||
726 | link->state |= DEV_SUSPEND; | ||
727 | /* Fall through... */ | ||
728 | case CS_EVENT_RESET_PHYSICAL: | ||
729 | DEBUG(2, "EVENT_RESET_PHYSICAL"); | ||
730 | /* get_lock(link); */ | ||
731 | break; | ||
732 | case CS_EVENT_PM_RESUME: | ||
733 | DEBUG(2, "EVENT_PM_RESUME"); | ||
734 | link->state &= ~DEV_SUSPEND; | ||
735 | /* Fall through... */ | ||
736 | case CS_EVENT_CARD_RESET: | ||
737 | DEBUG(2, "EVENT_CARD_RESET"); | ||
738 | /* free_lock(link); */ | ||
739 | break; | ||
740 | default: | ||
741 | DEBUG(2, "Unknown event %d", event); | ||
742 | } | ||
743 | return 0; | 706 | return 0; |
744 | } | 707 | } |
745 | 708 | ||
@@ -750,23 +713,21 @@ static int pcmciamtd_event(event_t event, int priority, | |||
750 | * when the device is released. | 713 | * when the device is released. |
751 | */ | 714 | */ |
752 | 715 | ||
753 | static void pcmciamtd_detach(dev_link_t *link) | 716 | static void pcmciamtd_detach(struct pcmcia_device *p_dev) |
754 | { | 717 | { |
718 | dev_link_t *link = dev_to_instance(p_dev); | ||
719 | |||
755 | DEBUG(3, "link=0x%p", link); | 720 | DEBUG(3, "link=0x%p", link); |
756 | 721 | ||
757 | if(link->state & DEV_CONFIG) { | 722 | if(link->state & DEV_CONFIG) { |
758 | pcmciamtd_release(link); | 723 | struct pcmciamtd_dev *dev = link->priv; |
759 | } | 724 | if(dev->mtd_info) { |
725 | del_mtd_device(dev->mtd_info); | ||
726 | info("mtd%d: Removed", dev->mtd_info->index); | ||
727 | } | ||
760 | 728 | ||
761 | if (link->handle) { | 729 | pcmciamtd_release(link); |
762 | int ret; | ||
763 | DEBUG(2, "Deregistering with card services"); | ||
764 | ret = pcmcia_deregister_client(link->handle); | ||
765 | if (ret != CS_SUCCESS) | ||
766 | cs_error(link->handle, DeregisterClient, ret); | ||
767 | } | 730 | } |
768 | |||
769 | link->state |= DEV_STALE_LINK; | ||
770 | } | 731 | } |
771 | 732 | ||
772 | 733 | ||
@@ -775,16 +736,14 @@ static void pcmciamtd_detach(dev_link_t *link) | |||
775 | * with Card Services. | 736 | * with Card Services. |
776 | */ | 737 | */ |
777 | 738 | ||
778 | static dev_link_t *pcmciamtd_attach(void) | 739 | static int pcmciamtd_attach(struct pcmcia_device *p_dev) |
779 | { | 740 | { |
780 | struct pcmciamtd_dev *dev; | 741 | struct pcmciamtd_dev *dev; |
781 | dev_link_t *link; | 742 | dev_link_t *link; |
782 | client_reg_t client_reg; | ||
783 | int ret; | ||
784 | 743 | ||
785 | /* Create new memory card device */ | 744 | /* Create new memory card device */ |
786 | dev = kmalloc(sizeof(*dev), GFP_KERNEL); | 745 | dev = kmalloc(sizeof(*dev), GFP_KERNEL); |
787 | if (!dev) return NULL; | 746 | if (!dev) return -ENOMEM; |
788 | DEBUG(1, "dev=0x%p", dev); | 747 | DEBUG(1, "dev=0x%p", dev); |
789 | 748 | ||
790 | memset(dev, 0, sizeof(*dev)); | 749 | memset(dev, 0, sizeof(*dev)); |
@@ -794,22 +753,14 @@ static dev_link_t *pcmciamtd_attach(void) | |||
794 | link->conf.Attributes = 0; | 753 | link->conf.Attributes = 0; |
795 | link->conf.IntType = INT_MEMORY; | 754 | link->conf.IntType = INT_MEMORY; |
796 | 755 | ||
797 | link->next = dev_list; | 756 | link->next = NULL; |
798 | dev_list = link; | 757 | link->handle = p_dev; |
799 | 758 | p_dev->instance = link; | |
800 | /* Register with Card Services */ | 759 | |
801 | client_reg.dev_info = &dev_info; | 760 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; |
802 | client_reg.Version = 0x0210; | 761 | pcmciamtd_config(link); |
803 | client_reg.event_callback_args.client_data = link; | 762 | |
804 | DEBUG(2, "Calling RegisterClient"); | 763 | return 0; |
805 | ret = pcmcia_register_client(&link->handle, &client_reg); | ||
806 | if (ret != 0) { | ||
807 | cs_error(link->handle, RegisterClient, ret); | ||
808 | pcmciamtd_detach(link); | ||
809 | return NULL; | ||
810 | } | ||
811 | DEBUG(2, "link = %p", link); | ||
812 | return link; | ||
813 | } | 764 | } |
814 | 765 | ||
815 | static struct pcmcia_device_id pcmciamtd_ids[] = { | 766 | static struct pcmcia_device_id pcmciamtd_ids[] = { |
@@ -843,11 +794,12 @@ static struct pcmcia_driver pcmciamtd_driver = { | |||
843 | .drv = { | 794 | .drv = { |
844 | .name = "pcmciamtd" | 795 | .name = "pcmciamtd" |
845 | }, | 796 | }, |
846 | .attach = pcmciamtd_attach, | 797 | .probe = pcmciamtd_attach, |
847 | .event = pcmciamtd_event, | 798 | .remove = pcmciamtd_detach, |
848 | .detach = pcmciamtd_detach, | ||
849 | .owner = THIS_MODULE, | 799 | .owner = THIS_MODULE, |
850 | .id_table = pcmciamtd_ids, | 800 | .id_table = pcmciamtd_ids, |
801 | .suspend = pcmciamtd_suspend, | ||
802 | .resume = pcmciamtd_resume, | ||
851 | }; | 803 | }; |
852 | 804 | ||
853 | 805 | ||
@@ -875,7 +827,6 @@ static void __exit exit_pcmciamtd(void) | |||
875 | { | 827 | { |
876 | DEBUG(1, DRIVER_DESC " unloading"); | 828 | DEBUG(1, DRIVER_DESC " unloading"); |
877 | pcmcia_unregister_driver(&pcmciamtd_driver); | 829 | pcmcia_unregister_driver(&pcmciamtd_driver); |
878 | BUG_ON(dev_list != NULL); | ||
879 | } | 830 | } |
880 | 831 | ||
881 | module_init(init_pcmciamtd); | 832 | module_init(init_pcmciamtd); |