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/pcmcia/xirc2ps_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/pcmcia/xirc2ps_cs.c')
-rw-r--r-- | drivers/net/pcmcia/xirc2ps_cs.c | 67 |
1 files changed, 10 insertions, 57 deletions
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index 8c8cc40bbb7d..049c34b37067 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c | |||
@@ -292,8 +292,6 @@ static void mii_wr(kio_addr_t ioaddr, u_char phyaddr, u_char phyreg, | |||
292 | static int has_ce2_string(dev_link_t * link); | 292 | static int has_ce2_string(dev_link_t * link); |
293 | static void xirc2ps_config(dev_link_t * link); | 293 | static void xirc2ps_config(dev_link_t * link); |
294 | static void xirc2ps_release(dev_link_t * link); | 294 | static void xirc2ps_release(dev_link_t * link); |
295 | static int xirc2ps_event(event_t event, int priority, | ||
296 | event_callback_args_t * args); | ||
297 | 295 | ||
298 | /**************** | 296 | /**************** |
299 | * The attach() and detach() entry points are used to create and destroy | 297 | * The attach() and detach() entry points are used to create and destroy |
@@ -301,7 +299,6 @@ static int xirc2ps_event(event_t event, int priority, | |||
301 | * needed to manage one actual PCMCIA card. | 299 | * needed to manage one actual PCMCIA card. |
302 | */ | 300 | */ |
303 | 301 | ||
304 | static dev_link_t *xirc2ps_attach(void); | ||
305 | static void xirc2ps_detach(struct pcmcia_device *p_dev); | 302 | static void xirc2ps_detach(struct pcmcia_device *p_dev); |
306 | 303 | ||
307 | /**************** | 304 | /**************** |
@@ -313,14 +310,6 @@ static void xirc2ps_detach(struct pcmcia_device *p_dev); | |||
313 | 310 | ||
314 | static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id, struct pt_regs *regs); | 311 | static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id, struct pt_regs *regs); |
315 | 312 | ||
316 | /* | ||
317 | * The dev_info variable is the "key" that is used to match up this | ||
318 | * device driver with appropriate cards, through the card configuration | ||
319 | * database. | ||
320 | */ | ||
321 | |||
322 | static dev_info_t dev_info = "xirc2ps_cs"; | ||
323 | |||
324 | /**************** | 313 | /**************** |
325 | * A linked list of "instances" of the device. Each actual | 314 | * A linked list of "instances" of the device. Each actual |
326 | * PCMCIA card corresponds to one device instance, and is described | 315 | * PCMCIA card corresponds to one device instance, and is described |
@@ -563,21 +552,19 @@ mii_wr(kio_addr_t ioaddr, u_char phyaddr, u_char phyreg, unsigned data, int len) | |||
563 | * card insertion event. | 552 | * card insertion event. |
564 | */ | 553 | */ |
565 | 554 | ||
566 | static dev_link_t * | 555 | static int |
567 | xirc2ps_attach(void) | 556 | xirc2ps_attach(struct pcmcia_device *p_dev) |
568 | { | 557 | { |
569 | client_reg_t client_reg; | ||
570 | dev_link_t *link; | 558 | dev_link_t *link; |
571 | struct net_device *dev; | 559 | struct net_device *dev; |
572 | local_info_t *local; | 560 | local_info_t *local; |
573 | int err; | ||
574 | 561 | ||
575 | DEBUG(0, "attach()\n"); | 562 | DEBUG(0, "attach()\n"); |
576 | 563 | ||
577 | /* Allocate the device structure */ | 564 | /* Allocate the device structure */ |
578 | dev = alloc_etherdev(sizeof(local_info_t)); | 565 | dev = alloc_etherdev(sizeof(local_info_t)); |
579 | if (!dev) | 566 | if (!dev) |
580 | return NULL; | 567 | return -ENOMEM; |
581 | local = netdev_priv(dev); | 568 | local = netdev_priv(dev); |
582 | link = &local->link; | 569 | link = &local->link; |
583 | link->priv = dev; | 570 | link->priv = dev; |
@@ -606,18 +593,13 @@ xirc2ps_attach(void) | |||
606 | dev->watchdog_timeo = TX_TIMEOUT; | 593 | dev->watchdog_timeo = TX_TIMEOUT; |
607 | #endif | 594 | #endif |
608 | 595 | ||
609 | /* Register with Card Services */ | 596 | link->handle = p_dev; |
610 | link->next = NULL; | 597 | p_dev->instance = link; |
611 | client_reg.dev_info = &dev_info; | 598 | |
612 | client_reg.Version = 0x0210; | 599 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; |
613 | client_reg.event_callback_args.client_data = link; | 600 | xirc2ps_config(link); |
614 | if ((err = pcmcia_register_client(&link->handle, &client_reg))) { | ||
615 | cs_error(link->handle, RegisterClient, err); | ||
616 | xirc2ps_detach(link->handle); | ||
617 | return NULL; | ||
618 | } | ||
619 | 601 | ||
620 | return link; | 602 | return 0; |
621 | } /* xirc2ps_attach */ | 603 | } /* xirc2ps_attach */ |
622 | 604 | ||
623 | /**************** | 605 | /**************** |
@@ -1162,34 +1144,6 @@ static int xirc2ps_resume(struct pcmcia_device *p_dev) | |||
1162 | return 0; | 1144 | return 0; |
1163 | } | 1145 | } |
1164 | 1146 | ||
1165 | /**************** | ||
1166 | * The card status event handler. Mostly, this schedules other | ||
1167 | * stuff to run after an event is received. A CARD_REMOVAL event | ||
1168 | * also sets some flags to discourage the net drivers from trying | ||
1169 | * to talk to the card any more. | ||
1170 | * | ||
1171 | * When a CARD_REMOVAL event is received, we immediately set a flag | ||
1172 | * to block future accesses to this device. All the functions that | ||
1173 | * actually access the device should check this flag to make sure | ||
1174 | * the card is still present. | ||
1175 | */ | ||
1176 | |||
1177 | static int | ||
1178 | xirc2ps_event(event_t event, int priority, | ||
1179 | event_callback_args_t * args) | ||
1180 | { | ||
1181 | dev_link_t *link = args->client_data; | ||
1182 | |||
1183 | DEBUG(0, "event(%d)\n", (int)event); | ||
1184 | |||
1185 | switch (event) { | ||
1186 | case CS_EVENT_CARD_INSERTION: | ||
1187 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
1188 | xirc2ps_config(link); | ||
1189 | break; | ||
1190 | } | ||
1191 | return 0; | ||
1192 | } /* xirc2ps_event */ | ||
1193 | 1147 | ||
1194 | /*====================================================================*/ | 1148 | /*====================================================================*/ |
1195 | 1149 | ||
@@ -1981,8 +1935,7 @@ static struct pcmcia_driver xirc2ps_cs_driver = { | |||
1981 | .drv = { | 1935 | .drv = { |
1982 | .name = "xirc2ps_cs", | 1936 | .name = "xirc2ps_cs", |
1983 | }, | 1937 | }, |
1984 | .attach = xirc2ps_attach, | 1938 | .probe = xirc2ps_attach, |
1985 | .event = xirc2ps_event, | ||
1986 | .remove = xirc2ps_detach, | 1939 | .remove = xirc2ps_detach, |
1987 | .id_table = xirc2ps_ids, | 1940 | .id_table = xirc2ps_ids, |
1988 | .suspend = xirc2ps_suspend, | 1941 | .suspend = xirc2ps_suspend, |