aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hisax/avma1_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/hisax/avma1_cs.c')
-rw-r--r--drivers/isdn/hisax/avma1_cs.c70
1 files changed, 11 insertions, 59 deletions
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index b6ea653f881e..969da40c4248 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -69,8 +69,6 @@ module_param(isdnprot, int, 0);
69 69
70static void avma1cs_config(dev_link_t *link); 70static void avma1cs_config(dev_link_t *link);
71static void avma1cs_release(dev_link_t *link); 71static void avma1cs_release(dev_link_t *link);
72static int avma1cs_event(event_t event, int priority,
73 event_callback_args_t *args);
74 72
75/* 73/*
76 The attach() and detach() entry points are used to create and destroy 74 The attach() and detach() entry points are used to create and destroy
@@ -78,16 +76,8 @@ static int avma1cs_event(event_t event, int priority,
78 needed to manage one actual PCMCIA card. 76 needed to manage one actual PCMCIA card.
79*/ 77*/
80 78
81static dev_link_t *avma1cs_attach(void);
82static void avma1cs_detach(struct pcmcia_device *p_dev); 79static void avma1cs_detach(struct pcmcia_device *p_dev);
83 80
84/*
85 The dev_info variable is the "key" that is used to match up this
86 device driver with appropriate cards, through the card configuration
87 database.
88*/
89
90static dev_info_t dev_info = "avma1_cs";
91 81
92/* 82/*
93 A linked list of "instances" of the skeleton device. Each actual 83 A linked list of "instances" of the skeleton device. Each actual
@@ -126,26 +116,24 @@ typedef struct local_info_t {
126 116
127======================================================================*/ 117======================================================================*/
128 118
129static dev_link_t *avma1cs_attach(void) 119static int avma1cs_attach(struct pcmcia_device *p_dev)
130{ 120{
131 client_reg_t client_reg;
132 dev_link_t *link; 121 dev_link_t *link;
133 local_info_t *local; 122 local_info_t *local;
134 int ret; 123
135
136 DEBUG(0, "avma1cs_attach()\n"); 124 DEBUG(0, "avma1cs_attach()\n");
137 125
138 /* Initialize the dev_link_t structure */ 126 /* Initialize the dev_link_t structure */
139 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 127 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
140 if (!link) 128 if (!link)
141 return NULL; 129 return -ENOMEM;
142 memset(link, 0, sizeof(struct dev_link_t)); 130 memset(link, 0, sizeof(struct dev_link_t));
143 131
144 /* Allocate space for private device-specific data */ 132 /* Allocate space for private device-specific data */
145 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 133 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
146 if (!local) { 134 if (!local) {
147 kfree(link); 135 kfree(link);
148 return NULL; 136 return -ENOMEM;
149 } 137 }
150 memset(local, 0, sizeof(local_info_t)); 138 memset(local, 0, sizeof(local_info_t));
151 link->priv = local; 139 link->priv = local;
@@ -170,19 +158,13 @@ static dev_link_t *avma1cs_attach(void)
170 link->conf.ConfigIndex = 1; 158 link->conf.ConfigIndex = 1;
171 link->conf.Present = PRESENT_OPTION; 159 link->conf.Present = PRESENT_OPTION;
172 160
173 /* Register with Card Services */ 161 link->handle = p_dev;
174 link->next = NULL; 162 p_dev->instance = link;
175 client_reg.dev_info = &dev_info; 163
176 client_reg.Version = 0x0210; 164 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
177 client_reg.event_callback_args.client_data = link; 165 avma1cs_config(link);
178 ret = pcmcia_register_client(&link->handle, &client_reg);
179 if (ret != 0) {
180 cs_error(link->handle, RegisterClient, ret);
181 avma1cs_detach(link->handle);
182 return NULL;
183 }
184 166
185 return link; 167 return 0;
186} /* avma1cs_attach */ 168} /* avma1cs_attach */
187 169
188/*====================================================================== 170/*======================================================================
@@ -430,35 +412,6 @@ static int avma1cs_resume(struct pcmcia_device *dev)
430 return 0; 412 return 0;
431} 413}
432 414
433/*======================================================================
434
435 The card status event handler. Mostly, this schedules other
436 stuff to run after an event is received. A CARD_REMOVAL event
437 also sets some flags to discourage the net drivers from trying
438 to talk to the card any more.
439
440 When a CARD_REMOVAL event is received, we immediately set a flag
441 to block future accesses to this device. All the functions that
442 actually access the device should check this flag to make sure
443 the card is still present.
444
445======================================================================*/
446
447static int avma1cs_event(event_t event, int priority,
448 event_callback_args_t *args)
449{
450 dev_link_t *link = args->client_data;
451
452 DEBUG(1, "avma1cs_event(0x%06x)\n", event);
453
454 switch (event) {
455 case CS_EVENT_CARD_INSERTION:
456 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
457 avma1cs_config(link);
458 break;
459 }
460 return 0;
461} /* avma1cs_event */
462 415
463static struct pcmcia_device_id avma1cs_ids[] = { 416static struct pcmcia_device_id avma1cs_ids[] = {
464 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN A", 0x95d42008, 0xadc9d4bb), 417 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN A", 0x95d42008, 0xadc9d4bb),
@@ -472,8 +425,7 @@ static struct pcmcia_driver avma1cs_driver = {
472 .drv = { 425 .drv = {
473 .name = "avma1_cs", 426 .name = "avma1_cs",
474 }, 427 },
475 .attach = avma1cs_attach, 428 .probe = avma1cs_attach,
476 .event = avma1cs_event,
477 .remove = avma1cs_detach, 429 .remove = avma1cs_detach,
478 .id_table = avma1cs_ids, 430 .id_table = avma1cs_ids,
479 .suspend = avma1cs_suspend, 431 .suspend = avma1cs_suspend,