aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/pcmcia/synclink_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/synclink_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/synclink_cs.c')
-rw-r--r--drivers/char/pcmcia/synclink_cs.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 776103e56042..34597144d9c1 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -489,7 +489,7 @@ static void mgslpc_release(u_long arg);
489static int mgslpc_event(event_t event, int priority, 489static int mgslpc_event(event_t event, int priority,
490 event_callback_args_t *args); 490 event_callback_args_t *args);
491static dev_link_t *mgslpc_attach(void); 491static dev_link_t *mgslpc_attach(void);
492static void mgslpc_detach(dev_link_t *); 492static void mgslpc_detach(struct pcmcia_device *p_dev);
493 493
494static dev_info_t dev_info = "synclink_cs"; 494static dev_info_t dev_info = "synclink_cs";
495static dev_link_t *dev_list = NULL; 495static dev_link_t *dev_list = NULL;
@@ -598,7 +598,7 @@ static dev_link_t *mgslpc_attach(void)
598 ret = pcmcia_register_client(&link->handle, &client_reg); 598 ret = pcmcia_register_client(&link->handle, &client_reg);
599 if (ret != CS_SUCCESS) { 599 if (ret != CS_SUCCESS) {
600 cs_error(link->handle, RegisterClient, ret); 600 cs_error(link->handle, RegisterClient, ret);
601 mgslpc_detach(link); 601 mgslpc_detach(link->handle);
602 return NULL; 602 return NULL;
603 } 603 }
604 604
@@ -736,17 +736,16 @@ static void mgslpc_release(u_long arg)
736 pcmcia_release_io(link->handle, &link->io); 736 pcmcia_release_io(link->handle, &link->io);
737 if (link->irq.AssignedIRQ) 737 if (link->irq.AssignedIRQ)
738 pcmcia_release_irq(link->handle, &link->irq); 738 pcmcia_release_irq(link->handle, &link->irq);
739 if (link->state & DEV_STALE_LINK)
740 mgslpc_detach(link);
741} 739}
742 740
743static void mgslpc_detach(dev_link_t *link) 741static void mgslpc_detach(struct pcmcia_device *p_dev)
744{ 742{
743 dev_link_t *link = dev_to_instance(p_dev);
745 dev_link_t **linkp; 744 dev_link_t **linkp;
746 745
747 if (debug_level >= DEBUG_LEVEL_INFO) 746 if (debug_level >= DEBUG_LEVEL_INFO)
748 printk("mgslpc_detach(0x%p)\n", link); 747 printk("mgslpc_detach(0x%p)\n", link);
749 748
750 /* find device */ 749 /* find device */
751 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) 750 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
752 if (*linkp == link) break; 751 if (*linkp == link) break;
@@ -754,20 +753,10 @@ static void mgslpc_detach(dev_link_t *link)
754 return; 753 return;
755 754
756 if (link->state & DEV_CONFIG) { 755 if (link->state & DEV_CONFIG) {
757 /* device is configured/active, mark it so when 756 ((MGSLPC_INFO *)link->priv)->stop = 1;
758 * release() is called a proper detach() occurs. 757 mgslpc_release((u_long)link);
759 */
760 if (debug_level >= DEBUG_LEVEL_INFO)
761 printk(KERN_DEBUG "synclinkpc: detach postponed, '%s' "
762 "still locked\n", link->dev->dev_name);
763 link->state |= DEV_STALE_LINK;
764 return;
765 } 758 }
766 759
767 /* Break the link with Card Services */
768 if (link->handle)
769 pcmcia_deregister_client(link->handle);
770
771 /* Unlink device structure, and free it */ 760 /* Unlink device structure, and free it */
772 *linkp = link->next; 761 *linkp = link->next;
773 mgslpc_remove_device((MGSLPC_INFO *)link->priv); 762 mgslpc_remove_device((MGSLPC_INFO *)link->priv);
@@ -809,13 +798,6 @@ static int mgslpc_event(event_t event, int priority,
809 printk("mgslpc_event(0x%06x)\n", event); 798 printk("mgslpc_event(0x%06x)\n", event);
810 799
811 switch (event) { 800 switch (event) {
812 case CS_EVENT_CARD_REMOVAL:
813 link->state &= ~DEV_PRESENT;
814 if (link->state & DEV_CONFIG) {
815 ((MGSLPC_INFO *)link->priv)->stop = 1;
816 mgslpc_release((u_long)link);
817 }
818 break;
819 case CS_EVENT_CARD_INSERTION: 801 case CS_EVENT_CARD_INSERTION:
820 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 802 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
821 mgslpc_config(link); 803 mgslpc_config(link);
@@ -3102,7 +3084,7 @@ static struct pcmcia_driver mgslpc_driver = {
3102 }, 3084 },
3103 .attach = mgslpc_attach, 3085 .attach = mgslpc_attach,
3104 .event = mgslpc_event, 3086 .event = mgslpc_event,
3105 .detach = mgslpc_detach, 3087 .remove = mgslpc_detach,
3106 .id_table = mgslpc_ids, 3088 .id_table = mgslpc_ids,
3107 .suspend = mgslpc_suspend, 3089 .suspend = mgslpc_suspend,
3108 .resume = mgslpc_resume, 3090 .resume = mgslpc_resume,