aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/netwave_cs.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2005-11-14 15:25:51 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-01-05 18:03:24 -0500
commitf8cfa618dccbdc6dab5297f75779566a388a98fd (patch)
treeb91e0952038dafc6e03bf8b1d8948b1fdefec031 /drivers/net/wireless/netwave_cs.c
parentb463581154f3f3eecda27cae60df813fefcd84d3 (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/netwave_cs.c')
-rw-r--r--drivers/net/wireless/netwave_cs.c68
1 files changed, 12 insertions, 56 deletions
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index af9a32d8d22d..bf6271ee387a 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -166,8 +166,6 @@ static char *version =
166#define DEBUG(n, args...) 166#define DEBUG(n, args...)
167#endif 167#endif
168 168
169static dev_info_t dev_info = "netwave_cs";
170
171/*====================================================================*/ 169/*====================================================================*/
172 170
173/* Parameters that can be set with 'insmod' */ 171/* Parameters that can be set with 'insmod' */
@@ -195,11 +193,8 @@ module_param(mem_speed, int, 0);
195 193
196/* PCMCIA (Card Services) related functions */ 194/* PCMCIA (Card Services) related functions */
197static void netwave_release(dev_link_t *link); /* Card removal */ 195static void netwave_release(dev_link_t *link); /* Card removal */
198static int netwave_event(event_t event, int priority,
199 event_callback_args_t *args);
200static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card 196static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card
201 insertion */ 197 insertion */
202static dev_link_t *netwave_attach(void); /* Create instance */
203static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */ 198static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */
204 199
205/* Hardware configuration */ 200/* Hardware configuration */
@@ -383,20 +378,18 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev)
383 * configure the card at this point -- we wait until we receive a 378 * configure the card at this point -- we wait until we receive a
384 * card insertion event. 379 * card insertion event.
385 */ 380 */
386static dev_link_t *netwave_attach(void) 381static int netwave_attach(struct pcmcia_device *p_dev)
387{ 382{
388 client_reg_t client_reg;
389 dev_link_t *link; 383 dev_link_t *link;
390 struct net_device *dev; 384 struct net_device *dev;
391 netwave_private *priv; 385 netwave_private *priv;
392 int ret; 386
393
394 DEBUG(0, "netwave_attach()\n"); 387 DEBUG(0, "netwave_attach()\n");
395 388
396 /* Initialize the dev_link_t structure */ 389 /* Initialize the dev_link_t structure */
397 dev = alloc_etherdev(sizeof(netwave_private)); 390 dev = alloc_etherdev(sizeof(netwave_private));
398 if (!dev) 391 if (!dev)
399 return NULL; 392 return -ENOMEM;
400 priv = netdev_priv(dev); 393 priv = netdev_priv(dev);
401 link = &priv->link; 394 link = &priv->link;
402 link->priv = dev; 395 link->priv = dev;
@@ -438,20 +431,14 @@ static dev_link_t *netwave_attach(void)
438 dev->open = &netwave_open; 431 dev->open = &netwave_open;
439 dev->stop = &netwave_close; 432 dev->stop = &netwave_close;
440 link->irq.Instance = dev; 433 link->irq.Instance = dev;
441
442 /* Register with Card Services */
443 link->next = NULL;
444 client_reg.dev_info = &dev_info;
445 client_reg.Version = 0x0210;
446 client_reg.event_callback_args.client_data = link;
447 ret = pcmcia_register_client(&link->handle, &client_reg);
448 if (ret != 0) {
449 cs_error(link->handle, RegisterClient, ret);
450 netwave_detach(link->handle);
451 return NULL;
452 }
453 434
454 return link; 435 link->handle = p_dev;
436 p_dev->instance = link;
437
438 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
439 netwave_pcmcia_config( link);
440
441 return 0;
455} /* netwave_attach */ 442} /* netwave_attach */
456 443
457/* 444/*
@@ -935,36 +922,6 @@ static int netwave_resume(struct pcmcia_device *p_dev)
935 922
936 923
937/* 924/*
938 * Function netwave_event (event, priority, args)
939 *
940 * The card status event handler. Mostly, this schedules other
941 * stuff to run after an event is received. A CARD_REMOVAL event
942 * also sets some flags to discourage the net drivers from trying
943 * to talk to the card any more.
944 *
945 * When a CARD_REMOVAL event is received, we immediately set a flag
946 * to block future accesses to this device. All the functions that
947 * actually access the device should check this flag to make sure
948 * the card is still present.
949 *
950 */
951static int netwave_event(event_t event, int priority,
952 event_callback_args_t *args)
953{
954 dev_link_t *link = args->client_data;
955
956 DEBUG(1, "netwave_event(0x%06x)\n", event);
957
958 switch (event) {
959 case CS_EVENT_CARD_INSERTION:
960 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
961 netwave_pcmcia_config( link);
962 break;
963 }
964 return 0;
965} /* netwave_event */
966
967/*
968 * Function netwave_doreset (ioBase, ramBase) 925 * Function netwave_doreset (ioBase, ramBase)
969 * 926 *
970 * Proper hardware reset of the card. 927 * Proper hardware reset of the card.
@@ -1456,8 +1413,7 @@ static struct pcmcia_driver netwave_driver = {
1456 .drv = { 1413 .drv = {
1457 .name = "netwave_cs", 1414 .name = "netwave_cs",
1458 }, 1415 },
1459 .attach = netwave_attach, 1416 .probe = netwave_attach,
1460 .event = netwave_event,
1461 .remove = netwave_detach, 1417 .remove = netwave_detach,
1462 .id_table = netwave_ids, 1418 .id_table = netwave_ids,
1463 .suspend = netwave_suspend, 1419 .suspend = netwave_suspend,