aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
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/usb/host
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/usb/host')
-rw-r--r--drivers/usb/host/sl811_cs.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index cb8c2bdbbd04..ed3e7014dbbc 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -73,6 +73,8 @@ typedef struct local_info_t {
73 dev_node_t node; 73 dev_node_t node;
74} local_info_t; 74} local_info_t;
75 75
76static void sl811_cs_release(dev_link_t * link);
77
76/*====================================================================*/ 78/*====================================================================*/
77 79
78static void release_platform_dev(struct device * dev) 80static void release_platform_dev(struct device * dev)
@@ -138,8 +140,9 @@ static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq)
138 140
139/*====================================================================*/ 141/*====================================================================*/
140 142
141static void sl811_cs_detach(dev_link_t *link) 143static void sl811_cs_detach(struct pcmcia_device *p_dev)
142{ 144{
145 dev_link_t *link = dev_to_instance(p_dev);
143 dev_link_t **linkp; 146 dev_link_t **linkp;
144 147
145 DBG(0, "sl811_cs_detach(0x%p)\n", link); 148 DBG(0, "sl811_cs_detach(0x%p)\n", link);
@@ -152,9 +155,9 @@ static void sl811_cs_detach(dev_link_t *link)
152 if (*linkp == NULL) 155 if (*linkp == NULL)
153 return; 156 return;
154 157
155 /* Break the link with Card Services */ 158 link->state &= ~DEV_PRESENT;
156 if (link->handle) 159 if (link->state & DEV_CONFIG)
157 pcmcia_deregister_client(link->handle); 160 sl811_cs_release(link);
158 161
159 /* Unlink device structure, and free it */ 162 /* Unlink device structure, and free it */
160 *linkp = link->next; 163 *linkp = link->next;
@@ -167,13 +170,6 @@ static void sl811_cs_release(dev_link_t * link)
167 170
168 DBG(0, "sl811_cs_release(0x%p)\n", link); 171 DBG(0, "sl811_cs_release(0x%p)\n", link);
169 172
170 if (link->open) {
171 DBG(1, "sl811_cs: release postponed, '%s' still open\n",
172 link->dev->dev_name);
173 link->state |= DEV_STALE_CONFIG;
174 return;
175 }
176
177 /* Unlink the device chain */ 173 /* Unlink the device chain */
178 link->dev = NULL; 174 link->dev = NULL;
179 175
@@ -184,9 +180,6 @@ static void sl811_cs_release(dev_link_t * link)
184 if (link->irq.AssignedIRQ) 180 if (link->irq.AssignedIRQ)
185 pcmcia_release_irq(link->handle, &link->irq); 181 pcmcia_release_irq(link->handle, &link->irq);
186 link->state &= ~DEV_CONFIG; 182 link->state &= ~DEV_CONFIG;
187
188 if (link->state & DEV_STALE_LINK)
189 sl811_cs_detach(link);
190} 183}
191 184
192static void sl811_cs_config(dev_link_t *link) 185static void sl811_cs_config(dev_link_t *link)
@@ -353,12 +346,6 @@ sl811_cs_event(event_t event, int priority, event_callback_args_t *args)
353 DBG(1, "sl811_cs_event(0x%06x)\n", event); 346 DBG(1, "sl811_cs_event(0x%06x)\n", event);
354 347
355 switch (event) { 348 switch (event) {
356 case CS_EVENT_CARD_REMOVAL:
357 link->state &= ~DEV_PRESENT;
358 if (link->state & DEV_CONFIG)
359 sl811_cs_release(link);
360 break;
361
362 case CS_EVENT_CARD_INSERTION: 349 case CS_EVENT_CARD_INSERTION:
363 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 350 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
364 sl811_cs_config(link); 351 sl811_cs_config(link);
@@ -400,7 +387,7 @@ static dev_link_t *sl811_cs_attach(void)
400 ret = pcmcia_register_client(&link->handle, &client_reg); 387 ret = pcmcia_register_client(&link->handle, &client_reg);
401 if (ret != CS_SUCCESS) { 388 if (ret != CS_SUCCESS) {
402 cs_error(link->handle, RegisterClient, ret); 389 cs_error(link->handle, RegisterClient, ret);
403 sl811_cs_detach(link); 390 sl811_cs_detach(link->handle);
404 return NULL; 391 return NULL;
405 } 392 }
406 393
@@ -420,7 +407,7 @@ static struct pcmcia_driver sl811_cs_driver = {
420 }, 407 },
421 .attach = sl811_cs_attach, 408 .attach = sl811_cs_attach,
422 .event = sl811_cs_event, 409 .event = sl811_cs_event,
423 .detach = sl811_cs_detach, 410 .remove = sl811_cs_detach,
424 .id_table = sl811_ids, 411 .id_table = sl811_ids,
425 .suspend = sl811_suspend, 412 .suspend = sl811_suspend,
426 .resume = sl811_resume, 413 .resume = sl811_resume,