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/airo_cs.c | 74 +++++------------------------ drivers/net/wireless/atmel_cs.c | 80 +++++++------------------------ drivers/net/wireless/hostap/hostap_cs.c | 55 +++++---------------- drivers/net/wireless/netwave_cs.c | 68 +++++--------------------- drivers/net/wireless/orinoco_cs.c | 58 ++++------------------- drivers/net/wireless/ray_cs.c | 68 ++++---------------------- drivers/net/wireless/spectrum_cs.c | 63 ++++--------------------- drivers/net/wireless/wavelan_cs.c | 84 ++++++--------------------------- drivers/net/wireless/wavelan_cs.p.h | 8 ---- drivers/net/wireless/wl3501_cs.c | 60 +++++------------------ 10 files changed, 108 insertions(+), 510 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index 88805a4c29f..a496460ce22 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c @@ -82,8 +82,6 @@ MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards"); static void airo_config(dev_link_t *link); static void airo_release(dev_link_t *link); -static int airo_event(event_t event, int priority, - event_callback_args_t *args); /* The attach() and detach() entry points are used to create and destroy @@ -91,7 +89,6 @@ static int airo_event(event_t event, int priority, needed to manage one actual PCMCIA card. */ -static dev_link_t *airo_attach(void); static void airo_detach(struct pcmcia_device *p_dev); /* @@ -101,14 +98,6 @@ static void airo_detach(struct pcmcia_device *p_dev); less on other parts of the kernel. */ -/* - 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 = "airo_cs"; - /* A linked list of "instances" of the aironet device. Each actual PCMCIA card corresponds to one device instance, and is described @@ -152,20 +141,18 @@ typedef struct local_info_t { ======================================================================*/ -static dev_link_t *airo_attach(void) +static int airo_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; local_info_t *local; - int ret; - + DEBUG(0, "airo_attach()\n"); /* Initialize the dev_link_t structure */ link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); if (!link) { printk(KERN_ERR "airo_cs: no memory for new device\n"); - return NULL; + return -ENOMEM; } /* Interrupt setup */ @@ -189,23 +176,17 @@ static dev_link_t *airo_attach(void) if (!local) { printk(KERN_ERR "airo_cs: no memory for new device\n"); kfree (link); - return NULL; + return -ENOMEM; } link->priv = local; - - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - airo_detach(link->handle); - return NULL; - } - - return link; + + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + airo_config(link); + + return 0; } /* airo_attach */ /*====================================================================== @@ -497,34 +478,6 @@ static int airo_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. - - When a CARD_REMOVAL event is received, we immediately set a - private 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 airo_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "airo_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - airo_config(link); - break; - } - return 0; -} /* airo_event */ - static struct pcmcia_device_id airo_ids[] = { PCMCIA_DEVICE_MANF_CARD(0x015f, 0x000a), PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0005), @@ -539,8 +492,7 @@ static struct pcmcia_driver airo_driver = { .drv = { .name = "airo_cs", }, - .attach = airo_attach, - .event = airo_event, + .probe = airo_attach, .remove = airo_detach, .id_table = airo_ids, .suspend = airo_suspend, diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index 32f00970935..d6f4a5a3e55 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c @@ -93,8 +93,6 @@ MODULE_SUPPORTED_DEVICE("Atmel at76c50x PCMCIA cards"); static void atmel_config(dev_link_t *link); static void atmel_release(dev_link_t *link); -static int atmel_event(event_t event, int priority, - event_callback_args_t *args); /* The attach() and detach() entry points are used to create and destroy @@ -102,7 +100,6 @@ static int atmel_event(event_t event, int priority, needed to manage one actual PCMCIA card. */ -static dev_link_t *atmel_attach(void); static void atmel_detach(struct pcmcia_device *p_dev); /* @@ -112,14 +109,6 @@ static void atmel_detach(struct pcmcia_device *p_dev); less on other parts of the kernel. */ -/* - 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 = "atmel_cs"; - /* A linked list of "instances" of the atmelnet device. Each actual PCMCIA card corresponds to one device instance, and is described @@ -163,27 +152,25 @@ typedef struct local_info_t { ======================================================================*/ -static dev_link_t *atmel_attach(void) +static int atmel_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; local_info_t *local; - int ret; - + DEBUG(0, "atmel_attach()\n"); /* Initialize the dev_link_t structure */ link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); if (!link) { printk(KERN_ERR "atmel_cs: no memory for new device\n"); - return NULL; + return -ENOMEM; } - + /* Interrupt setup */ link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Handler = NULL; - + /* General socket configuration defaults can go here. In this client, we assume very little, and rely on the CIS for almost @@ -194,29 +181,23 @@ static dev_link_t *atmel_attach(void) link->conf.Attributes = 0; link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; - + /* Allocate space for private device-specific data */ local = kzalloc(sizeof(local_info_t), GFP_KERNEL); if (!local) { printk(KERN_ERR "atmel_cs: no memory for new device\n"); kfree (link); - return NULL; + return -ENOMEM; } link->priv = local; - - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - atmel_detach(link->handle); - return NULL; - } - - return link; + + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + atmel_config(link); + + return 0; } /* atmel_attach */ /*====================================================================== @@ -485,34 +466,6 @@ static int atmel_resume(struct pcmcia_device *dev) return 0; } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. - - When a CARD_REMOVAL event is received, we immediately set a - private 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 atmel_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "atmel_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - atmel_config(link); - break; - } - return 0; -} /* atmel_event */ - /*====================================================================*/ /* We use the driver_info field to store the correct firmware type for a card. */ @@ -562,8 +515,7 @@ static struct pcmcia_driver atmel_driver = { .drv = { .name = "atmel_cs", }, - .attach = atmel_attach, - .event = atmel_event, + .probe = atmel_attach, .remove = atmel_detach, .id_table = atmel_ids, .suspend = atmel_suspend, diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index 195a5bf3d72..8bc0b528548 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c @@ -204,8 +204,7 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len) static void prism2_detach(struct pcmcia_device *p_dev); static void prism2_release(u_long arg); -static int prism2_event(event_t event, int priority, - event_callback_args_t *args); +static int prism2_config(dev_link_t *link); static int prism2_pccard_card_present(local_info_t *local) @@ -502,15 +501,13 @@ static struct prism2_helper_functions prism2_pccard_funcs = /* allocate local data and register with CardServices * initialize dev_link structure, but do not configure the card yet */ -static dev_link_t *prism2_attach(void) +static int prism2_attach(struct pcmcia_device *p_dev) { dev_link_t *link; - client_reg_t client_reg; - int ret; link = kmalloc(sizeof(dev_link_t), GFP_KERNEL); if (link == NULL) - return NULL; + return -ENOMEM; memset(link, 0, sizeof(dev_link_t)); @@ -518,18 +515,14 @@ static dev_link_t *prism2_attach(void) link->conf.Vcc = 33; link->conf.IntType = INT_MEMORY_AND_IO; - /* register with CardServices */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - prism2_detach(link->handle); - return NULL; - } - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + if (prism2_config(link)) + PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n"); + + return 0; } @@ -878,29 +871,6 @@ static int hostap_cs_resume(struct pcmcia_device *p_dev) return 0; } -static int prism2_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_INSERTION\n", dev_info); - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - if (prism2_config(link)) { - PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n"); - } - break; - - default: - PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n", - dev_info, event); - break; - } - return 0; -} - - static struct pcmcia_device_id hostap_cs_ids[] = { PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), @@ -959,10 +929,9 @@ static struct pcmcia_driver hostap_driver = { .drv = { .name = "hostap_cs", }, - .attach = prism2_attach, + .probe = prism2_attach, .remove = prism2_detach, .owner = THIS_MODULE, - .event = prism2_event, .id_table = hostap_cs_ids, .suspend = hostap_cs_suspend, .resume = hostap_cs_resume, diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index af9a32d8d22..bf6271ee387 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c @@ -166,8 +166,6 @@ static char *version = #define DEBUG(n, args...) #endif -static dev_info_t dev_info = "netwave_cs"; - /*====================================================================*/ /* Parameters that can be set with 'insmod' */ @@ -195,11 +193,8 @@ module_param(mem_speed, int, 0); /* PCMCIA (Card Services) related functions */ static void netwave_release(dev_link_t *link); /* Card removal */ -static int netwave_event(event_t event, int priority, - event_callback_args_t *args); static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card insertion */ -static dev_link_t *netwave_attach(void); /* Create instance */ static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */ /* Hardware configuration */ @@ -383,20 +378,18 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev) * configure the card at this point -- we wait until we receive a * card insertion event. */ -static dev_link_t *netwave_attach(void) +static int netwave_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; struct net_device *dev; netwave_private *priv; - int ret; - + DEBUG(0, "netwave_attach()\n"); - + /* Initialize the dev_link_t structure */ dev = alloc_etherdev(sizeof(netwave_private)); if (!dev) - return NULL; + return -ENOMEM; priv = netdev_priv(dev); link = &priv->link; link->priv = dev; @@ -438,20 +431,14 @@ static dev_link_t *netwave_attach(void) dev->open = &netwave_open; dev->stop = &netwave_close; link->irq.Instance = dev; - - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - netwave_detach(link->handle); - return NULL; - } - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + netwave_pcmcia_config( link); + + return 0; } /* netwave_attach */ /* @@ -934,36 +921,6 @@ static int netwave_resume(struct pcmcia_device *p_dev) } -/* - * Function netwave_event (event, priority, args) - * - * 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 netwave_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "netwave_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - netwave_pcmcia_config( link); - break; - } - return 0; -} /* netwave_event */ - /* * Function netwave_doreset (ioBase, ramBase) * @@ -1456,8 +1413,7 @@ static struct pcmcia_driver netwave_driver = { .drv = { .name = "netwave_cs", }, - .attach = netwave_attach, - .event = netwave_event, + .probe = netwave_attach, .remove = netwave_detach, .id_table = netwave_ids, .suspend = netwave_suspend, diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index bfeeef49f0b..b664708481c 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c @@ -42,17 +42,6 @@ static int ignore_cis_vcc; /* = 0 */ module_param(ignore_cis_vcc, int, 0); MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket"); -/********************************************************************/ -/* Magic constants */ -/********************************************************************/ - -/* - * 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 = DRIVER_NAME; - /********************************************************************/ /* Data structures */ /********************************************************************/ @@ -74,6 +63,7 @@ struct orinoco_pccard { /* Function prototypes */ /********************************************************************/ +static void orinoco_cs_config(dev_link_t *link); static void orinoco_cs_release(dev_link_t *link); static void orinoco_cs_detach(struct pcmcia_device *p_dev); @@ -113,19 +103,17 @@ orinoco_cs_hard_reset(struct orinoco_private *priv) * The dev_link structure is initialized, but we don't actually * configure the card at this point -- we wait until we receive a card * insertion event. */ -static dev_link_t * -orinoco_cs_attach(void) +static int +orinoco_cs_attach(struct pcmcia_device *p_dev) { struct net_device *dev; struct orinoco_private *priv; struct orinoco_pccard *card; dev_link_t *link; - client_reg_t client_reg; - int ret; dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset); if (! dev) - return NULL; + return -ENOMEM; priv = netdev_priv(dev); card = priv->card; @@ -150,18 +138,13 @@ orinoco_cs_attach(void) /* Register with Card Services */ link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; /* FIXME: what does this mean? */ - client_reg.event_callback_args.client_data = link; + link->handle = p_dev; + p_dev->instance = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - orinoco_cs_detach(link->handle); - return NULL; - } + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + orinoco_cs_config(link); - return link; + return 0; } /* orinoco_cs_attach */ /* @@ -521,26 +504,6 @@ static int orinoco_cs_resume(struct pcmcia_device *p_dev) } -/* - * The card status event handler. Mostly, this schedules other stuff - * to run after an event is received. - */ -static int -orinoco_cs_event(event_t event, int priority, - event_callback_args_t * args) -{ - dev_link_t *link = args->client_data; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - orinoco_cs_config(link); - break; - } - - return 0; -} /* orinoco_cs_event */ - /********************************************************************/ /* Module initialization */ /********************************************************************/ @@ -640,9 +603,8 @@ static struct pcmcia_driver orinoco_driver = { .drv = { .name = DRIVER_NAME, }, - .attach = orinoco_cs_attach, + .probe = orinoco_cs_attach, .remove = orinoco_cs_detach, - .event = orinoco_cs_event, .id_table = orinoco_cs_ids, .suspend = orinoco_cs_suspend, .resume = orinoco_cs_resume, 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, diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c index 1933250dad1..fee4be1ce81 100644 --- a/drivers/net/wireless/spectrum_cs.c +++ b/drivers/net/wireless/spectrum_cs.c @@ -56,17 +56,6 @@ static int ignore_cis_vcc; /* = 0 */ module_param(ignore_cis_vcc, int, 0); MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket"); -/********************************************************************/ -/* Magic constants */ -/********************************************************************/ - -/* - * 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 = DRIVER_NAME; - /********************************************************************/ /* Data structures */ /********************************************************************/ @@ -82,8 +71,8 @@ struct orinoco_pccard { /* Function prototypes */ /********************************************************************/ +static void spectrum_cs_config(dev_link_t *link); static void spectrum_cs_release(dev_link_t *link); -static void spectrum_cs_detach(struct pcmcia_device *p_dev); /********************************************************************/ /* Firmware downloader */ @@ -594,19 +583,17 @@ spectrum_cs_hard_reset(struct orinoco_private *priv) * The dev_link structure is initialized, but we don't actually * configure the card at this point -- we wait until we receive a card * insertion event. */ -static dev_link_t * -spectrum_cs_attach(void) +static int +spectrum_cs_attach(struct pcmcia_device *p_dev) { struct net_device *dev; struct orinoco_private *priv; struct orinoco_pccard *card; dev_link_t *link; - client_reg_t client_reg; - int ret; dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset); if (! dev) - return NULL; + return -ENOMEM; priv = netdev_priv(dev); card = priv->card; @@ -628,22 +615,13 @@ spectrum_cs_attach(void) link->conf.Attributes = 0; link->conf.IntType = INT_MEMORY_AND_IO; - /* Register with Card Services */ - /* FIXME: need a lock? */ - link->next = NULL; /* not needed */ + link->handle = p_dev; + p_dev->instance = link; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; /* FIXME: what does this mean? */ - client_reg.event_callback_args.client_data = link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + spectrum_cs_config(link); - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - spectrum_cs_detach(link->handle); - return NULL; - } - - return link; + return 0; } /* spectrum_cs_attach */ /* @@ -977,26 +955,6 @@ spectrum_cs_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. - */ -static int -spectrum_cs_event(event_t event, int priority, - event_callback_args_t * args) -{ - dev_link_t *link = args->client_data; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - spectrum_cs_config(link); - break; - - } - - return 0; -} /* spectrum_cs_event */ /********************************************************************/ /* Module initialization */ @@ -1021,11 +979,10 @@ static struct pcmcia_driver orinoco_driver = { .drv = { .name = DRIVER_NAME, }, - .attach = spectrum_cs_attach, + .probe = spectrum_cs_attach, .remove = spectrum_cs_detach, .suspend = spectrum_cs_suspend, .resume = spectrum_cs_resume, - .event = spectrum_cs_event, .id_table = spectrum_cs_ids, }; diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index 196e827fc84..7e2039f52c4 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c @@ -4594,14 +4594,12 @@ wavelan_close(struct net_device * dev) * configure the card at this point -- we wait until we receive a * card insertion event. */ -static dev_link_t * -wavelan_attach(void) +static int +wavelan_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; /* Register with cardmgr */ dev_link_t * link; /* Info for cardmgr */ struct net_device * dev; /* Interface generic data */ net_local * lp; /* Interface specific data */ - int ret; #ifdef DEBUG_CALLBACK_TRACE printk(KERN_DEBUG "-> wavelan_attach()\n"); @@ -4609,7 +4607,7 @@ wavelan_attach(void) /* Initialize the dev_link_t structure */ link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); - if (!link) return NULL; + if (!link) return -ENOMEM; /* The io structure describes IO port mapping */ link->io.NumPorts1 = 8; @@ -4633,7 +4631,7 @@ wavelan_attach(void) dev = alloc_etherdev(sizeof(net_local)); if (!dev) { kfree(link); - return NULL; + return -ENOMEM; } link->priv = link->irq.Instance = dev; @@ -4678,28 +4676,21 @@ wavelan_attach(void) /* Other specific data */ dev->mtu = WAVELAN_MTU; - /* Register with Card Services */ - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - -#ifdef DEBUG_CONFIG_INFO - printk(KERN_DEBUG "wavelan_attach(): almost done, calling pcmcia_register_client\n"); -#endif + link->handle = p_dev; + p_dev->instance = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if(ret != 0) - { - cs_error(link->handle, RegisterClient, ret); - wavelan_detach(link->handle); - return NULL; - } + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + if(wv_pcmcia_config(link) && + wv_hw_config(dev)) + wv_init_info(dev); + else + dev->irq = 0; #ifdef DEBUG_CALLBACK_TRACE printk(KERN_DEBUG "<- wavelan_attach()\n"); #endif - return link; + return 0; } /*------------------------------------------------------------------*/ @@ -4801,52 +4792,6 @@ static int wavelan_resume(struct pcmcia_device *p_dev) } -/*------------------------------------------------------------------*/ -/* - * 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. - */ -static int -wavelan_event(event_t event, /* The event received */ - int priority, - event_callback_args_t * args) -{ - dev_link_t * link = (dev_link_t *) args->client_data; - struct net_device * dev = (struct net_device *) link->priv; - -#ifdef DEBUG_CALLBACK_TRACE - printk(KERN_DEBUG "->wavelan_event(): %s\n", - ((event == CS_EVENT_REGISTRATION_COMPLETE)?"registration complete" : - ((event == CS_EVENT_CARD_REMOVAL) ? "card removal" : - ((event == CS_EVENT_CARD_INSERTION) ? "card insertion" : - ((event == CS_EVENT_PM_SUSPEND) ? "pm suspend" : - ((event == CS_EVENT_RESET_PHYSICAL) ? "physical reset" : - ((event == CS_EVENT_PM_RESUME) ? "pm resume" : - ((event == CS_EVENT_CARD_RESET) ? "card reset" : - "unknown")))))))); -#endif - - switch(event) - { - case CS_EVENT_CARD_INSERTION: - /* Reset and configure the card */ - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - if(wv_pcmcia_config(link) && - wv_hw_config(dev)) - wv_init_info(dev); - else - dev->irq = 0; - break; - } - -#ifdef DEBUG_CALLBACK_TRACE - printk(KERN_DEBUG "<-wavelan_event()\n"); -#endif - return 0; -} - static struct pcmcia_device_id wavelan_ids[] = { PCMCIA_DEVICE_PROD_ID12("AT&T","WaveLAN/PCMCIA", 0xe7c5affd, 0x1bc50975), PCMCIA_DEVICE_PROD_ID12("Digital", "RoamAbout/DS", 0x9999ab35, 0x00d05e06), @@ -4861,8 +4806,7 @@ static struct pcmcia_driver wavelan_driver = { .drv = { .name = "wavelan_cs", }, - .attach = wavelan_attach, - .event = wavelan_event, + .probe = wavelan_attach, .remove = wavelan_detach, .id_table = wavelan_ids, .suspend = wavelan_suspend, diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h index a1a19177c5c..f2d59756815 100644 --- a/drivers/net/wireless/wavelan_cs.p.h +++ b/drivers/net/wireless/wavelan_cs.p.h @@ -754,19 +754,11 @@ static void static int wavelan_open(struct net_device *), /* Open the device */ wavelan_close(struct net_device *); /* Close the device */ -static dev_link_t * - wavelan_attach(void); /* Create a new device */ static void wavelan_detach(struct pcmcia_device *p_dev); /* Destroy a removed device */ -static int - wavelan_event(event_t, /* Manage pcmcia events */ - int, - event_callback_args_t *); /**************************** VARIABLES ****************************/ -static dev_info_t dev_info = "wavelan_cs"; - /* * Parameters that can be set with 'insmod' * The exact syntax is 'insmod wavelan_cs.o =' diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 21e498fe7b1..48e10b0c7e7 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c @@ -105,7 +105,6 @@ module_param(pc_debug, int, 0); */ static void wl3501_config(dev_link_t *link); static void wl3501_release(dev_link_t *link); -static int wl3501_event(event_t event, int pri, event_callback_args_t *args); /* * The dev_info variable is the "key" that is used to match up this @@ -1954,18 +1953,16 @@ static const struct iw_handler_def wl3501_handler_def = { * The dev_link structure is initialized, but we don't actually configure the * card at this point -- we wait until we receive a card insertion event. */ -static dev_link_t *wl3501_attach(void) +static int wl3501_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; struct net_device *dev; struct wl3501_card *this; - int ret; /* Initialize the dev_link_t structure */ link = kzalloc(sizeof(*link), GFP_KERNEL); if (!link) - goto out; + return -ENOMEM; /* The io structure describes IO port mapping */ link->io.NumPorts1 = 16; @@ -2001,24 +1998,17 @@ static dev_link_t *wl3501_attach(void) netif_stop_queue(dev); link->priv = link->irq.Instance = dev; - /* Register with Card Services */ - link->next = wl3501_dev_list; - wl3501_dev_list = link; - client_reg.dev_info = &wl3501_dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret) { - cs_error(link->handle, RegisterClient, ret); - wl3501_detach(link->handle); - link = NULL; - } -out: - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + wl3501_config(link); + + return 0; out_link: kfree(link); link = NULL; - goto out; + return -ENOMEM; } #define CS_CHECK(fn, ret) \ @@ -2206,33 +2196,6 @@ static int wl3501_resume(struct pcmcia_device *p_dev) } -/** - * wl3501_event - The card status event handler - * @event - event - * @pri - priority - * @args - arguments for this event - * - * 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 wl3501_event(event_t event, int pri, event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - wl3501_config(link); - break; - } - return 0; -} - static struct pcmcia_device_id wl3501_ids[] = { PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001), PCMCIA_DEVICE_NULL @@ -2244,8 +2207,7 @@ static struct pcmcia_driver wl3501_driver = { .drv = { .name = "wl3501_cs", }, - .attach = wl3501_attach, - .event = wl3501_event, + .probe = wl3501_attach, .remove = wl3501_detach, .id_table = wl3501_ids, .suspend = wl3501_suspend, -- cgit v1.2.3