From cc3b4866bee996c922e875b8c8efe9f0d8803aae Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 14 Nov 2005 21:23:14 +0100 Subject: [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 --- drivers/bluetooth/bluecard_cs.c | 24 +++++------------------- drivers/bluetooth/bt3c_cs.c | 24 +++++------------------- drivers/bluetooth/btuart_cs.c | 24 +++++------------------- drivers/bluetooth/dtl1_cs.c | 24 +++++------------------- 4 files changed, 20 insertions(+), 76 deletions(-) (limited to 'drivers/bluetooth') diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index 5b24131e543..f5088cb3812 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -92,7 +92,7 @@ static int bluecard_event(event_t event, int priority, event_callback_args_t *ar static dev_info_t dev_info = "bluecard_cs"; static dev_link_t *bluecard_attach(void); -static void bluecard_detach(dev_link_t *); +static void bluecard_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list = NULL; @@ -899,7 +899,7 @@ static dev_link_t *bluecard_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - bluecard_detach(link); + bluecard_detach(link->handle); return NULL; } @@ -907,11 +907,11 @@ static dev_link_t *bluecard_attach(void) } -static void bluecard_detach(dev_link_t *link) +static void bluecard_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); bluecard_info_t *info = link->priv; dev_link_t **linkp; - int ret; /* Locate device structure */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) @@ -924,12 +924,6 @@ static void bluecard_detach(dev_link_t *link) if (link->state & DEV_CONFIG) bluecard_release(link); - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); - } - /* Unlink device structure, free bits */ *linkp = link->next; @@ -1070,16 +1064,8 @@ static int bluecard_resume(struct pcmcia_device *dev) static int bluecard_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - bluecard_info_t *info = link->priv; switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - bluecard_close(info); - bluecard_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; bluecard_config(link); @@ -1104,7 +1090,7 @@ static struct pcmcia_driver bluecard_driver = { }, .attach = bluecard_attach, .event = bluecard_event, - .detach = bluecard_detach, + .remove = bluecard_detach, .id_table = bluecard_ids, .suspend = bluecard_suspend, .resume = bluecard_resume, diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 1d524baa24a..02ce38e33d3 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -95,7 +95,7 @@ static int bt3c_event(event_t event, int priority, event_callback_args_t *args); static dev_info_t dev_info = "bt3c_cs"; static dev_link_t *bt3c_attach(void); -static void bt3c_detach(dev_link_t *); +static void bt3c_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list = NULL; @@ -700,7 +700,7 @@ static dev_link_t *bt3c_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - bt3c_detach(link); + bt3c_detach(link->handle); return NULL; } @@ -708,11 +708,11 @@ static dev_link_t *bt3c_attach(void) } -static void bt3c_detach(dev_link_t *link) +static void bt3c_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); bt3c_info_t *info = link->priv; dev_link_t **linkp; - int ret; /* Locate device structure */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) @@ -725,12 +725,6 @@ static void bt3c_detach(dev_link_t *link) if (link->state & DEV_CONFIG) bt3c_release(link); - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); - } - /* Unlink device structure, free bits */ *linkp = link->next; @@ -916,16 +910,8 @@ static int bt3c_resume(struct pcmcia_device *dev) static int bt3c_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - bt3c_info_t *info = link->priv; switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - bt3c_close(info); - bt3c_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; bt3c_config(link); @@ -948,7 +934,7 @@ static struct pcmcia_driver bt3c_driver = { }, .attach = bt3c_attach, .event = bt3c_event, - .detach = bt3c_detach, + .remove = bt3c_detach, .id_table = bt3c_ids, .suspend = bt3c_suspend, .resume = bt3c_resume, diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 1828ba6ca25..63221d383fd 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -91,7 +91,7 @@ static int btuart_event(event_t event, int priority, event_callback_args_t *args static dev_info_t dev_info = "btuart_cs"; static dev_link_t *btuart_attach(void); -static void btuart_detach(dev_link_t *); +static void btuart_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list = NULL; @@ -619,7 +619,7 @@ static dev_link_t *btuart_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - btuart_detach(link); + btuart_detach(link->handle); return NULL; } @@ -627,11 +627,11 @@ static dev_link_t *btuart_attach(void) } -static void btuart_detach(dev_link_t *link) +static void btuart_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); btuart_info_t *info = link->priv; dev_link_t **linkp; - int ret; /* Locate device structure */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) @@ -644,12 +644,6 @@ static void btuart_detach(dev_link_t *link) if (link->state & DEV_CONFIG) btuart_release(link); - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); - } - /* Unlink device structure, free bits */ *linkp = link->next; @@ -837,16 +831,8 @@ static int btuart_resume(struct pcmcia_device *dev) static int btuart_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - btuart_info_t *info = link->priv; switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - btuart_close(info); - btuart_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; btuart_config(link); @@ -869,7 +855,7 @@ static struct pcmcia_driver btuart_driver = { }, .attach = btuart_attach, .event = btuart_event, - .detach = btuart_detach, + .remove = btuart_detach, .id_table = btuart_ids, .suspend = btuart_suspend, .resume = btuart_resume, diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 9f9d3f91f45..2874d8722be 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -94,7 +94,7 @@ static int dtl1_event(event_t event, int priority, event_callback_args_t *args); static dev_info_t dev_info = "dtl1_cs"; static dev_link_t *dtl1_attach(void); -static void dtl1_detach(dev_link_t *); +static void dtl1_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list = NULL; @@ -598,7 +598,7 @@ static dev_link_t *dtl1_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - dtl1_detach(link); + dtl1_detach(link->handle); return NULL; } @@ -606,11 +606,11 @@ static dev_link_t *dtl1_attach(void) } -static void dtl1_detach(dev_link_t *link) +static void dtl1_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dtl1_info_t *info = link->priv; dev_link_t **linkp; - int ret; /* Locate device structure */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) @@ -623,12 +623,6 @@ static void dtl1_detach(dev_link_t *link) if (link->state & DEV_CONFIG) dtl1_release(link); - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); - } - /* Unlink device structure, free bits */ *linkp = link->next; @@ -788,16 +782,8 @@ static int dtl1_resume(struct pcmcia_device *dev) static int dtl1_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - dtl1_info_t *info = link->priv; switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - dtl1_close(info); - dtl1_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; dtl1_config(link); @@ -821,7 +807,7 @@ static struct pcmcia_driver dtl1_driver = { }, .attach = dtl1_attach, .event = dtl1_event, - .detach = dtl1_detach, + .remove = dtl1_detach, .id_table = dtl1_ids, .suspend = dtl1_suspend, .resume = dtl1_resume, -- cgit v1.2.3-70-g09d2