diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2005-11-14 15:23:14 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-01-05 18:03:10 -0500 |
commit | cc3b4866bee996c922e875b8c8efe9f0d8803aae (patch) | |
tree | 6632837b6986f33566f75ed971cecbdc210e3201 /drivers/net/wireless/ray_cs.c | |
parent | 8e9e793d68fcda6cc84c18cedf85ca0f91d801a8 (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/net/wireless/ray_cs.c')
-rw-r--r-- | drivers/net/wireless/ray_cs.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index c2cb6c8e6d7c..33a89e292126 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c | |||
@@ -94,7 +94,7 @@ static void ray_config(dev_link_t *link); | |||
94 | static void ray_release(dev_link_t *link); | 94 | static void ray_release(dev_link_t *link); |
95 | static int ray_event(event_t event, int priority, event_callback_args_t *args); | 95 | static int ray_event(event_t event, int priority, event_callback_args_t *args); |
96 | static dev_link_t *ray_attach(void); | 96 | static dev_link_t *ray_attach(void); |
97 | static void ray_detach(dev_link_t *); | 97 | static void ray_detach(struct pcmcia_device *p_dev); |
98 | 98 | ||
99 | /***** Prototypes indicated by device structure ******************************/ | 99 | /***** Prototypes indicated by device structure ******************************/ |
100 | static int ray_dev_close(struct net_device *dev); | 100 | static int ray_dev_close(struct net_device *dev); |
@@ -402,7 +402,7 @@ static dev_link_t *ray_attach(void) | |||
402 | if (ret != 0) { | 402 | if (ret != 0) { |
403 | printk("ray_cs ray_attach RegisterClient unhappy - detaching\n"); | 403 | printk("ray_cs ray_attach RegisterClient unhappy - detaching\n"); |
404 | cs_error(link->handle, RegisterClient, ret); | 404 | cs_error(link->handle, RegisterClient, ret); |
405 | ray_detach(link); | 405 | ray_detach(link->handle); |
406 | return NULL; | 406 | return NULL; |
407 | } | 407 | } |
408 | DEBUG(2,"ray_cs ray_attach ending\n"); | 408 | DEBUG(2,"ray_cs ray_attach ending\n"); |
@@ -418,9 +418,12 @@ fail_alloc_dev: | |||
418 | structures are freed. Otherwise, the structures will be freed | 418 | structures are freed. Otherwise, the structures will be freed |
419 | when the device is released. | 419 | when the device is released. |
420 | =============================================================================*/ | 420 | =============================================================================*/ |
421 | static void ray_detach(dev_link_t *link) | 421 | static void ray_detach(struct pcmcia_device *p_dev) |
422 | { | 422 | { |
423 | dev_link_t *link = dev_to_instance(p_dev); | ||
423 | dev_link_t **linkp; | 424 | dev_link_t **linkp; |
425 | struct net_device *dev; | ||
426 | ray_dev_t *local; | ||
424 | 427 | ||
425 | DEBUG(1, "ray_detach(0x%p)\n", link); | 428 | DEBUG(1, "ray_detach(0x%p)\n", link); |
426 | 429 | ||
@@ -430,22 +433,18 @@ static void ray_detach(dev_link_t *link) | |||
430 | if (*linkp == NULL) | 433 | if (*linkp == NULL) |
431 | return; | 434 | return; |
432 | 435 | ||
433 | /* If the device is currently configured and active, we won't | 436 | dev = link->priv; |
434 | actually delete it yet. Instead, it is marked so that when | 437 | |
435 | the release() function is called, that will trigger a proper | 438 | if (link->state & DEV_CONFIG) { |
436 | detach(). | 439 | ray_release(link); |
437 | */ | 440 | |
438 | if (link->state & DEV_CONFIG) | 441 | local = (ray_dev_t *)dev->priv; |
439 | ray_release(link); | 442 | del_timer(&local->timer); |
443 | } | ||
440 | 444 | ||
441 | /* Break the link with Card Services */ | ||
442 | if (link->handle) | ||
443 | pcmcia_deregister_client(link->handle); | ||
444 | |||
445 | /* Unlink device structure, free pieces */ | 445 | /* Unlink device structure, free pieces */ |
446 | *linkp = link->next; | 446 | *linkp = link->next; |
447 | if (link->priv) { | 447 | if (link->priv) { |
448 | struct net_device *dev = link->priv; | ||
449 | if (link->dev) unregister_netdev(dev); | 448 | if (link->dev) unregister_netdev(dev); |
450 | free_netdev(dev); | 449 | free_netdev(dev); |
451 | } | 450 | } |
@@ -940,19 +939,9 @@ static int ray_event(event_t event, int priority, | |||
940 | event_callback_args_t *args) | 939 | event_callback_args_t *args) |
941 | { | 940 | { |
942 | dev_link_t *link = args->client_data; | 941 | dev_link_t *link = args->client_data; |
943 | struct net_device *dev = link->priv; | ||
944 | ray_dev_t *local = (ray_dev_t *)dev->priv; | ||
945 | DEBUG(1, "ray_event(0x%06x)\n", event); | 942 | DEBUG(1, "ray_event(0x%06x)\n", event); |
946 | 943 | ||
947 | switch (event) { | 944 | switch (event) { |
948 | case CS_EVENT_CARD_REMOVAL: | ||
949 | link->state &= ~DEV_PRESENT; | ||
950 | netif_device_detach(dev); | ||
951 | if (link->state & DEV_CONFIG) { | ||
952 | ray_release(link); | ||
953 | del_timer(&local->timer); | ||
954 | } | ||
955 | break; | ||
956 | case CS_EVENT_CARD_INSERTION: | 945 | case CS_EVENT_CARD_INSERTION: |
957 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | 946 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; |
958 | ray_config(link); | 947 | ray_config(link); |
@@ -2958,7 +2947,7 @@ static struct pcmcia_driver ray_driver = { | |||
2958 | }, | 2947 | }, |
2959 | .attach = ray_attach, | 2948 | .attach = ray_attach, |
2960 | .event = ray_event, | 2949 | .event = ray_event, |
2961 | .detach = ray_detach, | 2950 | .remove = ray_detach, |
2962 | .id_table = ray_ids, | 2951 | .id_table = ray_ids, |
2963 | .suspend = ray_suspend, | 2952 | .suspend = ray_suspend, |
2964 | .resume = ray_resume, | 2953 | .resume = ray_resume, |