aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/pcmcia/cm4040_cs.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2005-11-14 15:23:14 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-01-05 18:03:10 -0500
commitcc3b4866bee996c922e875b8c8efe9f0d8803aae (patch)
tree6632837b6986f33566f75ed971cecbdc210e3201 /drivers/char/pcmcia/cm4040_cs.c
parent8e9e793d68fcda6cc84c18cedf85ca0f91d801a8 (diff)
[PATCH] pcmcia: unify detach, REMOVAL_EVENT handlers into one remove callback
Unify the "detach" and REMOVAL_EVENT handlers to one "remove" function. Old functionality is preserved, for the moment. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/char/pcmcia/cm4040_cs.c')
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c52
1 files changed, 17 insertions, 35 deletions
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 3622fd39c47b..e08ab949c116 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -65,7 +65,7 @@ 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(dev_link_t *link); 68static void reader_detach(struct pcmcia_device *p_dev);
69 69
70static int major; 70static int major;
71 71
@@ -652,10 +652,6 @@ static int reader_event(event_t event, int priority,
652 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 652 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
653 reader_config(link, devno); 653 reader_config(link, devno);
654 break; 654 break;
655 case CS_EVENT_CARD_REMOVAL:
656 DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n");
657 link->state &= ~DEV_PRESENT;
658 break;
659 655
660 default: 656 default:
661 DEBUGP(5, dev, "reader_event: unknown event %.2x\n", 657 DEBUGP(5, dev, "reader_event: unknown event %.2x\n",
@@ -734,7 +730,7 @@ static dev_link_t *reader_attach(void)
734 i = pcmcia_register_client(&link->handle, &client_reg); 730 i = pcmcia_register_client(&link->handle, &client_reg);
735 if (i) { 731 if (i) {
736 cs_error(link->handle, RegisterClient, i); 732 cs_error(link->handle, RegisterClient, i);
737 reader_detach(link); 733 reader_detach(link->handle);
738 return NULL; 734 return NULL;
739 } 735 }
740 init_waitqueue_head(&dev->devq); 736 init_waitqueue_head(&dev->devq);
@@ -747,36 +743,28 @@ static dev_link_t *reader_attach(void)
747 return link; 743 return link;
748} 744}
749 745
750static void reader_detach_by_devno(int devno, dev_link_t *link) 746static void reader_detach(struct pcmcia_device *p_dev)
751{ 747{
748 dev_link_t *link = dev_to_instance(p_dev);
752 struct reader_dev *dev = link->priv; 749 struct reader_dev *dev = link->priv;
753 750 int devno;
754 if (link->state & DEV_CONFIG) {
755 DEBUGP(5, dev, "device still configured (try to release it)\n");
756 reader_release(link);
757 }
758
759 pcmcia_deregister_client(link->handle);
760 dev_table[devno] = NULL;
761 DEBUGP(5, dev, "freeing dev=%p\n", dev);
762 cm4040_stop_poll(dev);
763 kfree(dev);
764 return;
765}
766
767static void reader_detach(dev_link_t *link)
768{
769 int i;
770 751
771 /* find device */ 752 /* find device */
772 for (i = 0; i < CM_MAX_DEV; i++) { 753 for (devno = 0; devno < CM_MAX_DEV; devno++) {
773 if (dev_table[i] == link) 754 if (dev_table[devno] == link)
774 break; 755 break;
775 } 756 }
776 if (i == CM_MAX_DEV) 757 if (devno == CM_MAX_DEV)
777 return; 758 return;
778 759
779 reader_detach_by_devno(i, link); 760 link->state &= ~DEV_PRESENT;
761
762 if (link->state & DEV_CONFIG)
763 reader_release(link);
764
765 dev_table[devno] = NULL;
766 kfree(dev);
767
780 return; 768 return;
781} 769}
782 770
@@ -803,7 +791,7 @@ static struct pcmcia_driver reader_driver = {
803 .name = "cm4040_cs", 791 .name = "cm4040_cs",
804 }, 792 },
805 .attach = reader_attach, 793 .attach = reader_attach,
806 .detach = reader_detach, 794 .remove = reader_detach,
807 .suspend = reader_suspend, 795 .suspend = reader_suspend,
808 .resume = reader_resume, 796 .resume = reader_resume,
809 .event = reader_event, 797 .event = reader_event,
@@ -825,14 +813,8 @@ static int __init cm4040_init(void)
825 813
826static void __exit cm4040_exit(void) 814static void __exit cm4040_exit(void)
827{ 815{
828 int i;
829
830 printk(KERN_INFO MODULE_NAME ": unloading\n"); 816 printk(KERN_INFO MODULE_NAME ": unloading\n");
831 pcmcia_unregister_driver(&reader_driver); 817 pcmcia_unregister_driver(&reader_driver);
832 for (i = 0; i < CM_MAX_DEV; i++) {
833 if (dev_table[i])
834 reader_detach_by_devno(i, dev_table[i]);
835 }
836 unregister_chrdev(major, DEVICE_NAME); 818 unregister_chrdev(major, DEVICE_NAME);
837} 819}
838 820