diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2005-11-14 15:25:51 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-01-05 18:03:24 -0500 |
commit | f8cfa618dccbdc6dab5297f75779566a388a98fd (patch) | |
tree | b91e0952038dafc6e03bf8b1d8948b1fdefec031 /drivers/net/wireless/wavelan_cs.c | |
parent | b463581154f3f3eecda27cae60df813fefcd84d3 (diff) |
[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 <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/wireless/wavelan_cs.c')
-rw-r--r-- | drivers/net/wireless/wavelan_cs.c | 84 |
1 files changed, 14 insertions, 70 deletions
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index 196e827fc846..7e2039f52c49 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) | |||
4594 | * configure the card at this point -- we wait until we receive a | 4594 | * configure the card at this point -- we wait until we receive a |
4595 | * card insertion event. | 4595 | * card insertion event. |
4596 | */ | 4596 | */ |
4597 | static dev_link_t * | 4597 | static int |
4598 | wavelan_attach(void) | 4598 | wavelan_attach(struct pcmcia_device *p_dev) |
4599 | { | 4599 | { |
4600 | client_reg_t client_reg; /* Register with cardmgr */ | ||
4601 | dev_link_t * link; /* Info for cardmgr */ | 4600 | dev_link_t * link; /* Info for cardmgr */ |
4602 | struct net_device * dev; /* Interface generic data */ | 4601 | struct net_device * dev; /* Interface generic data */ |
4603 | net_local * lp; /* Interface specific data */ | 4602 | net_local * lp; /* Interface specific data */ |
4604 | int ret; | ||
4605 | 4603 | ||
4606 | #ifdef DEBUG_CALLBACK_TRACE | 4604 | #ifdef DEBUG_CALLBACK_TRACE |
4607 | printk(KERN_DEBUG "-> wavelan_attach()\n"); | 4605 | printk(KERN_DEBUG "-> wavelan_attach()\n"); |
@@ -4609,7 +4607,7 @@ wavelan_attach(void) | |||
4609 | 4607 | ||
4610 | /* Initialize the dev_link_t structure */ | 4608 | /* Initialize the dev_link_t structure */ |
4611 | link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); | 4609 | link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); |
4612 | if (!link) return NULL; | 4610 | if (!link) return -ENOMEM; |
4613 | 4611 | ||
4614 | /* The io structure describes IO port mapping */ | 4612 | /* The io structure describes IO port mapping */ |
4615 | link->io.NumPorts1 = 8; | 4613 | link->io.NumPorts1 = 8; |
@@ -4633,7 +4631,7 @@ wavelan_attach(void) | |||
4633 | dev = alloc_etherdev(sizeof(net_local)); | 4631 | dev = alloc_etherdev(sizeof(net_local)); |
4634 | if (!dev) { | 4632 | if (!dev) { |
4635 | kfree(link); | 4633 | kfree(link); |
4636 | return NULL; | 4634 | return -ENOMEM; |
4637 | } | 4635 | } |
4638 | link->priv = link->irq.Instance = dev; | 4636 | link->priv = link->irq.Instance = dev; |
4639 | 4637 | ||
@@ -4678,28 +4676,21 @@ wavelan_attach(void) | |||
4678 | /* Other specific data */ | 4676 | /* Other specific data */ |
4679 | dev->mtu = WAVELAN_MTU; | 4677 | dev->mtu = WAVELAN_MTU; |
4680 | 4678 | ||
4681 | /* Register with Card Services */ | 4679 | link->handle = p_dev; |
4682 | client_reg.dev_info = &dev_info; | 4680 | p_dev->instance = link; |
4683 | client_reg.Version = 0x0210; | ||
4684 | client_reg.event_callback_args.client_data = link; | ||
4685 | |||
4686 | #ifdef DEBUG_CONFIG_INFO | ||
4687 | printk(KERN_DEBUG "wavelan_attach(): almost done, calling pcmcia_register_client\n"); | ||
4688 | #endif | ||
4689 | 4681 | ||
4690 | ret = pcmcia_register_client(&link->handle, &client_reg); | 4682 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; |
4691 | if(ret != 0) | 4683 | if(wv_pcmcia_config(link) && |
4692 | { | 4684 | wv_hw_config(dev)) |
4693 | cs_error(link->handle, RegisterClient, ret); | 4685 | wv_init_info(dev); |
4694 | wavelan_detach(link->handle); | 4686 | else |
4695 | return NULL; | 4687 | dev->irq = 0; |
4696 | } | ||
4697 | 4688 | ||
4698 | #ifdef DEBUG_CALLBACK_TRACE | 4689 | #ifdef DEBUG_CALLBACK_TRACE |
4699 | printk(KERN_DEBUG "<- wavelan_attach()\n"); | 4690 | printk(KERN_DEBUG "<- wavelan_attach()\n"); |
4700 | #endif | 4691 | #endif |
4701 | 4692 | ||
4702 | return link; | 4693 | return 0; |
4703 | } | 4694 | } |
4704 | 4695 | ||
4705 | /*------------------------------------------------------------------*/ | 4696 | /*------------------------------------------------------------------*/ |
@@ -4801,52 +4792,6 @@ static int wavelan_resume(struct pcmcia_device *p_dev) | |||
4801 | } | 4792 | } |
4802 | 4793 | ||
4803 | 4794 | ||
4804 | /*------------------------------------------------------------------*/ | ||
4805 | /* | ||
4806 | * The card status event handler. Mostly, this schedules other stuff | ||
4807 | * to run after an event is received. A CARD_REMOVAL event also sets | ||
4808 | * some flags to discourage the net drivers from trying to talk to the | ||
4809 | * card any more. | ||
4810 | */ | ||
4811 | static int | ||
4812 | wavelan_event(event_t event, /* The event received */ | ||
4813 | int priority, | ||
4814 | event_callback_args_t * args) | ||
4815 | { | ||
4816 | dev_link_t * link = (dev_link_t *) args->client_data; | ||
4817 | struct net_device * dev = (struct net_device *) link->priv; | ||
4818 | |||
4819 | #ifdef DEBUG_CALLBACK_TRACE | ||
4820 | printk(KERN_DEBUG "->wavelan_event(): %s\n", | ||
4821 | ((event == CS_EVENT_REGISTRATION_COMPLETE)?"registration complete" : | ||
4822 | ((event == CS_EVENT_CARD_REMOVAL) ? "card removal" : | ||
4823 | ((event == CS_EVENT_CARD_INSERTION) ? "card insertion" : | ||
4824 | ((event == CS_EVENT_PM_SUSPEND) ? "pm suspend" : | ||
4825 | ((event == CS_EVENT_RESET_PHYSICAL) ? "physical reset" : | ||
4826 | ((event == CS_EVENT_PM_RESUME) ? "pm resume" : | ||
4827 | ((event == CS_EVENT_CARD_RESET) ? "card reset" : | ||
4828 | "unknown")))))))); | ||
4829 | #endif | ||
4830 | |||
4831 | switch(event) | ||
4832 | { | ||
4833 | case CS_EVENT_CARD_INSERTION: | ||
4834 | /* Reset and configure the card */ | ||
4835 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
4836 | if(wv_pcmcia_config(link) && | ||
4837 | wv_hw_config(dev)) | ||
4838 | wv_init_info(dev); | ||
4839 | else | ||
4840 | dev->irq = 0; | ||
4841 | break; | ||
4842 | } | ||
4843 | |||
4844 | #ifdef DEBUG_CALLBACK_TRACE | ||
4845 | printk(KERN_DEBUG "<-wavelan_event()\n"); | ||
4846 | #endif | ||
4847 | return 0; | ||
4848 | } | ||
4849 | |||
4850 | static struct pcmcia_device_id wavelan_ids[] = { | 4795 | static struct pcmcia_device_id wavelan_ids[] = { |
4851 | PCMCIA_DEVICE_PROD_ID12("AT&T","WaveLAN/PCMCIA", 0xe7c5affd, 0x1bc50975), | 4796 | PCMCIA_DEVICE_PROD_ID12("AT&T","WaveLAN/PCMCIA", 0xe7c5affd, 0x1bc50975), |
4852 | PCMCIA_DEVICE_PROD_ID12("Digital", "RoamAbout/DS", 0x9999ab35, 0x00d05e06), | 4797 | PCMCIA_DEVICE_PROD_ID12("Digital", "RoamAbout/DS", 0x9999ab35, 0x00d05e06), |
@@ -4861,8 +4806,7 @@ static struct pcmcia_driver wavelan_driver = { | |||
4861 | .drv = { | 4806 | .drv = { |
4862 | .name = "wavelan_cs", | 4807 | .name = "wavelan_cs", |
4863 | }, | 4808 | }, |
4864 | .attach = wavelan_attach, | 4809 | .probe = wavelan_attach, |
4865 | .event = wavelan_event, | ||
4866 | .remove = wavelan_detach, | 4810 | .remove = wavelan_detach, |
4867 | .id_table = wavelan_ids, | 4811 | .id_table = wavelan_ids, |
4868 | .suspend = wavelan_suspend, | 4812 | .suspend = wavelan_suspend, |