aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hisax/elsa_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/hisax/elsa_cs.c')
-rw-r--r--drivers/isdn/hisax/elsa_cs.c78
1 files changed, 9 insertions, 69 deletions
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index a0c5bad7bc6b..062fb8f0739f 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -96,8 +96,6 @@ module_param(protocol, int, 0);
96 96
97static void elsa_cs_config(dev_link_t *link); 97static void elsa_cs_config(dev_link_t *link);
98static void elsa_cs_release(dev_link_t *link); 98static void elsa_cs_release(dev_link_t *link);
99static int elsa_cs_event(event_t event, int priority,
100 event_callback_args_t *args);
101 99
102/* 100/*
103 The attach() and detach() entry points are used to create and destroy 101 The attach() and detach() entry points are used to create and destroy
@@ -105,28 +103,9 @@ static int elsa_cs_event(event_t event, int priority,
105 needed to manage one actual PCMCIA card. 103 needed to manage one actual PCMCIA card.
106*/ 104*/
107 105
108static dev_link_t *elsa_cs_attach(void);
109static void elsa_cs_detach(struct pcmcia_device *p_dev); 106static void elsa_cs_detach(struct pcmcia_device *p_dev);
110 107
111/* 108/*
112 The dev_info variable is the "key" that is used to match up this
113 device driver with appropriate cards, through the card configuration
114 database.
115*/
116
117static dev_info_t dev_info = "elsa_cs";
118
119/*
120 A linked list of "instances" of the elsa_cs device. Each actual
121 PCMCIA card corresponds to one device instance, and is described
122 by one dev_link_t structure (defined in ds.h).
123
124 You may not want to use a linked list for this -- for example, the
125 memory card driver uses an array of dev_link_t pointers, where minor
126 device numbers are used to derive the corresponding array index.
127*/
128
129/*
130 A driver needs to provide a dev_node_t structure for each device 109 A driver needs to provide a dev_node_t structure for each device
131 on a card. In some cases, there is only one device per card (for 110 on a card. In some cases, there is only one device per card (for
132 example, ethernet cards, modems). In other cases, there may be 111 example, ethernet cards, modems). In other cases, there may be
@@ -160,18 +139,16 @@ typedef struct local_info_t {
160 139
161======================================================================*/ 140======================================================================*/
162 141
163static dev_link_t *elsa_cs_attach(void) 142static int elsa_cs_attach(struct pcmcia_device *p_dev)
164{ 143{
165 client_reg_t client_reg;
166 dev_link_t *link; 144 dev_link_t *link;
167 local_info_t *local; 145 local_info_t *local;
168 int ret;
169 146
170 DEBUG(0, "elsa_cs_attach()\n"); 147 DEBUG(0, "elsa_cs_attach()\n");
171 148
172 /* Allocate space for private device-specific data */ 149 /* Allocate space for private device-specific data */
173 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 150 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
174 if (!local) return NULL; 151 if (!local) return -ENOMEM;
175 memset(local, 0, sizeof(local_info_t)); 152 memset(local, 0, sizeof(local_info_t));
176 local->cardnr = -1; 153 local->cardnr = -1;
177 link = &local->link; link->priv = local; 154 link = &local->link; link->priv = local;
@@ -196,19 +173,13 @@ static dev_link_t *elsa_cs_attach(void)
196 link->conf.Vcc = 50; 173 link->conf.Vcc = 50;
197 link->conf.IntType = INT_MEMORY_AND_IO; 174 link->conf.IntType = INT_MEMORY_AND_IO;
198 175
199 /* Register with Card Services */ 176 link->handle = p_dev;
200 link->next = NULL; 177 p_dev->instance = link;
201 client_reg.dev_info = &dev_info;
202 client_reg.Version = 0x0210;
203 client_reg.event_callback_args.client_data = link;
204 ret = pcmcia_register_client(&link->handle, &client_reg);
205 if (ret != CS_SUCCESS) {
206 cs_error(link->handle, RegisterClient, ret);
207 elsa_cs_detach(link->handle);
208 return NULL;
209 }
210 178
211 return link; 179 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
180 elsa_cs_config(link);
181
182 return 0;
212} /* elsa_cs_attach */ 183} /* elsa_cs_attach */
213 184
214/*====================================================================== 185/*======================================================================
@@ -447,36 +418,6 @@ static int elsa_resume(struct pcmcia_device *p_dev)
447 return 0; 418 return 0;
448} 419}
449 420
450/*======================================================================
451
452 The card status event handler. Mostly, this schedules other
453 stuff to run after an event is received. A CARD_REMOVAL event
454 also sets some flags to discourage the net drivers from trying
455 to talk to the card any more.
456
457 When a CARD_REMOVAL event is received, we immediately set a flag
458 to block future accesses to this device. All the functions that
459 actually access the device should check this flag to make sure
460 the card is still present.
461
462======================================================================*/
463
464static int elsa_cs_event(event_t event, int priority,
465 event_callback_args_t *args)
466{
467 dev_link_t *link = args->client_data;
468
469 DEBUG(1, "elsa_cs_event(%d)\n", event);
470
471 switch (event) {
472 case CS_EVENT_CARD_INSERTION:
473 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
474 elsa_cs_config(link);
475 break;
476 }
477 return 0;
478} /* elsa_cs_event */
479
480static struct pcmcia_device_id elsa_ids[] = { 421static struct pcmcia_device_id elsa_ids[] = {
481 PCMCIA_DEVICE_PROD_ID12("ELSA AG (Aachen, Germany)", "MicroLink ISDN/MC ", 0x983de2c4, 0x333ba257), 422 PCMCIA_DEVICE_PROD_ID12("ELSA AG (Aachen, Germany)", "MicroLink ISDN/MC ", 0x983de2c4, 0x333ba257),
482 PCMCIA_DEVICE_PROD_ID12("ELSA GmbH, Aachen", "MicroLink ISDN/MC ", 0x639e5718, 0x333ba257), 423 PCMCIA_DEVICE_PROD_ID12("ELSA GmbH, Aachen", "MicroLink ISDN/MC ", 0x639e5718, 0x333ba257),
@@ -489,8 +430,7 @@ static struct pcmcia_driver elsa_cs_driver = {
489 .drv = { 430 .drv = {
490 .name = "elsa_cs", 431 .name = "elsa_cs",
491 }, 432 },
492 .attach = elsa_cs_attach, 433 .probe = elsa_cs_attach,
493 .event = elsa_cs_event,
494 .remove = elsa_cs_detach, 434 .remove = elsa_cs_detach,
495 .id_table = elsa_ids, 435 .id_table = elsa_ids,
496 .suspend = elsa_suspend, 436 .suspend = elsa_suspend,