From f8cfa618dccbdc6dab5297f75779566a388a98fd Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 14 Nov 2005 21:25:51 +0100 Subject: [PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback Unify the EVENT_CARD_INSERTION and "attach" callbacks to one unified probe() callback. As all in-kernel drivers are changed to this new callback, there will be no temporary backwards-compatibility. Inside a probe() function, each driver _must_ set struct pcmcia_device *p_dev->instance and instance->handle correctly. With these patches, the basic driver interface for 16-bit PCMCIA drivers now has the classic four callbacks known also from other buses: int (*probe) (struct pcmcia_device *dev); void (*remove) (struct pcmcia_device *dev); int (*suspend) (struct pcmcia_device *dev); int (*resume) (struct pcmcia_device *dev); Signed-off-by: Dominik Brodowski --- drivers/net/wireless/ray_cs.c | 68 +++++++------------------------------------ 1 file changed, 10 insertions(+), 58 deletions(-) (limited to 'drivers/net/wireless/ray_cs.c') diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index 33a89e29212..319180ca7e7 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c @@ -92,8 +92,6 @@ module_param(pc_debug, int, 0); /** Prototypes based on PCMCIA skeleton driver *******************************/ static void ray_config(dev_link_t *link); static void ray_release(dev_link_t *link); -static int ray_event(event_t event, int priority, event_callback_args_t *args); -static dev_link_t *ray_attach(void); static void ray_detach(struct pcmcia_device *p_dev); /***** Prototypes indicated by device structure ******************************/ @@ -192,12 +190,6 @@ static int bc; static char *phy_addr = NULL; -/* The dev_info variable is the "key" that is used to match up this - device driver with appropriate cards, through the card configuration - database. -*/ -static dev_info_t dev_info = "ray_cs"; - /* A linked list of "instances" of the ray device. Each actual PCMCIA card corresponds to one device instance, and is described by one dev_link_t structure (defined in ds.h). @@ -314,12 +306,10 @@ static char rcsid[] = "Raylink/WebGear wireless LAN - Corey stop = &ray_dev_close; netif_stop_queue(dev); - /* Register with Card Services */ - link->next = dev_list; - dev_list = link; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; + init_timer(&local->timer); - DEBUG(2,"ray_cs ray_attach calling pcmcia_register_client(...)\n"); + link->handle = p_dev; + p_dev->instance = link; - init_timer(&local->timer); + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + ray_config(link); - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - printk("ray_cs ray_attach RegisterClient unhappy - detaching\n"); - cs_error(link->handle, RegisterClient, ret); - ray_detach(link->handle); - return NULL; - } - DEBUG(2,"ray_cs ray_attach ending\n"); - return link; + return 0; fail_alloc_dev: kfree(link); - return NULL; + return -ENOMEM; } /* ray_attach */ /*============================================================================= This deletes a driver "instance". The device is de-registered @@ -924,32 +903,6 @@ static int ray_resume(struct pcmcia_device *p_dev) return 0; } -/*============================================================================= - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the net drivers from trying - to talk to the card any more. - - When a CARD_REMOVAL event is received, we immediately set a flag - to block future accesses to this device. All the functions that - actually access the device should check this flag to make sure - the card is still present. -=============================================================================*/ -static int ray_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - DEBUG(1, "ray_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - ray_config(link); - break; - } - return 0; - DEBUG(2,"ray_event ending\n"); -} /* ray_event */ /*===========================================================================*/ int ray_dev_init(struct net_device *dev) { @@ -2945,8 +2898,7 @@ static struct pcmcia_driver ray_driver = { .drv = { .name = "ray_cs", }, - .attach = ray_attach, - .event = ray_event, + .probe = ray_attach, .remove = ray_detach, .id_table = ray_ids, .suspend = ray_suspend, -- cgit v1.2.3