aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn
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/isdn
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/isdn')
-rw-r--r--drivers/isdn/hardware/avm/avm_cs.c56
-rw-r--r--drivers/isdn/hisax/avma1_cs.c70
-rw-r--r--drivers/isdn/hisax/elsa_cs.c78
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c75
-rw-r--r--drivers/isdn/hisax/teles_cs.c67
5 files changed, 50 insertions, 296 deletions
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index 0a8c1da10b4b..2a2b03ff096b 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -53,8 +53,6 @@ MODULE_LICENSE("GPL");
53 53
54static void avmcs_config(dev_link_t *link); 54static void avmcs_config(dev_link_t *link);
55static void avmcs_release(dev_link_t *link); 55static void avmcs_release(dev_link_t *link);
56static int avmcs_event(event_t event, int priority,
57 event_callback_args_t *args);
58 56
59/* 57/*
60 The attach() and detach() entry points are used to create and destroy 58 The attach() and detach() entry points are used to create and destroy
@@ -62,18 +60,9 @@ static int avmcs_event(event_t event, int priority,
62 needed to manage one actual PCMCIA card. 60 needed to manage one actual PCMCIA card.
63*/ 61*/
64 62
65static dev_link_t *avmcs_attach(void);
66static void avmcs_detach(struct pcmcia_device *p_dev); 63static void avmcs_detach(struct pcmcia_device *p_dev);
67 64
68/* 65/*
69 The dev_info variable is the "key" that is used to match up this
70 device driver with appropriate cards, through the card configuration
71 database.
72*/
73
74static dev_info_t dev_info = "avm_cs";
75
76/*
77 A linked list of "instances" of the skeleton device. Each actual 66 A linked list of "instances" of the skeleton device. Each actual
78 PCMCIA card corresponds to one device instance, and is described 67 PCMCIA card corresponds to one device instance, and is described
79 by one dev_link_t structure (defined in ds.h). 68 by one dev_link_t structure (defined in ds.h).
@@ -110,13 +99,11 @@ typedef struct local_info_t {
110 99
111======================================================================*/ 100======================================================================*/
112 101
113static dev_link_t *avmcs_attach(void) 102static int avmcs_attach(struct pcmcia_device *p_dev)
114{ 103{
115 client_reg_t client_reg;
116 dev_link_t *link; 104 dev_link_t *link;
117 local_info_t *local; 105 local_info_t *local;
118 int ret; 106
119
120 /* Initialize the dev_link_t structure */ 107 /* Initialize the dev_link_t structure */
121 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 108 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
122 if (!link) 109 if (!link)
@@ -147,24 +134,19 @@ static dev_link_t *avmcs_attach(void)
147 goto err_kfree; 134 goto err_kfree;
148 memset(local, 0, sizeof(local_info_t)); 135 memset(local, 0, sizeof(local_info_t));
149 link->priv = local; 136 link->priv = local;
150 137
151 /* Register with Card Services */ 138 link->handle = p_dev;
152 link->next = NULL; 139 p_dev->instance = link;
153 client_reg.dev_info = &dev_info; 140
154 client_reg.Version = 0x0210; 141 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
155 client_reg.event_callback_args.client_data = link; 142 avmcs_config(link);
156 ret = pcmcia_register_client(&link->handle, &client_reg); 143
157 if (ret != 0) { 144 return 0;
158 cs_error(link->handle, RegisterClient, ret);
159 avmcs_detach(link->handle);
160 goto err;
161 }
162 return link;
163 145
164 err_kfree: 146 err_kfree:
165 kfree(link); 147 kfree(link);
166 err: 148 err:
167 return NULL; 149 return -EINVAL;
168} /* avmcs_attach */ 150} /* avmcs_attach */
169 151
170/*====================================================================== 152/*======================================================================
@@ -433,19 +415,6 @@ static int avmcs_resume(struct pcmcia_device *dev)
433 415
434======================================================================*/ 416======================================================================*/
435 417
436static int avmcs_event(event_t event, int priority,
437 event_callback_args_t *args)
438{
439 dev_link_t *link = args->client_data;
440
441 switch (event) {
442 case CS_EVENT_CARD_INSERTION:
443 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
444 avmcs_config(link);
445 break;
446 }
447 return 0;
448} /* avmcs_event */
449 418
450static struct pcmcia_device_id avmcs_ids[] = { 419static struct pcmcia_device_id avmcs_ids[] = {
451 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN-Controller B1", 0x95d42008, 0x845dc335), 420 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN-Controller B1", 0x95d42008, 0x845dc335),
@@ -460,8 +429,7 @@ static struct pcmcia_driver avmcs_driver = {
460 .drv = { 429 .drv = {
461 .name = "avm_cs", 430 .name = "avm_cs",
462 }, 431 },
463 .attach = avmcs_attach, 432 .probe = avmcs_attach,
464 .event = avmcs_event,
465 .remove = avmcs_detach, 433 .remove = avmcs_detach,
466 .id_table = avmcs_ids, 434 .id_table = avmcs_ids,
467 .suspend= avmcs_suspend, 435 .suspend= avmcs_suspend,
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,
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,
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index 814b32a9ef3b..6f5213a18a8d 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -97,8 +97,6 @@ module_param(protocol, int, 0);
97 97
98static void sedlbauer_config(dev_link_t *link); 98static void sedlbauer_config(dev_link_t *link);
99static void sedlbauer_release(dev_link_t *link); 99static void sedlbauer_release(dev_link_t *link);
100static int sedlbauer_event(event_t event, int priority,
101 event_callback_args_t *args);
102 100
103/* 101/*
104 The attach() and detach() entry points are used to create and destroy 102 The attach() and detach() entry points are used to create and destroy
@@ -106,7 +104,6 @@ static int sedlbauer_event(event_t event, int priority,
106 needed to manage one actual PCMCIA card. 104 needed to manage one actual PCMCIA card.
107*/ 105*/
108 106
109static dev_link_t *sedlbauer_attach(void);
110static void sedlbauer_detach(struct pcmcia_device *p_dev); 107static void sedlbauer_detach(struct pcmcia_device *p_dev);
111 108
112/* 109/*
@@ -117,24 +114,6 @@ static void sedlbauer_detach(struct pcmcia_device *p_dev);
117*/ 114*/
118 115
119/* 116/*
120 The dev_info variable is the "key" that is used to match up this
121 device driver with appropriate cards, through the card configuration
122 database.
123*/
124
125static dev_info_t dev_info = "sedlbauer_cs";
126
127/*
128 A linked list of "instances" of the sedlbauer device. Each actual
129 PCMCIA card corresponds to one device instance, and is described
130 by one dev_link_t structure (defined in ds.h).
131
132 You may not want to use a linked list for this -- for example, the
133 memory card driver uses an array of dev_link_t pointers, where minor
134 device numbers are used to derive the corresponding array index.
135*/
136
137/*
138 A driver needs to provide a dev_node_t structure for each device 117 A driver needs to provide a dev_node_t structure for each device
139 on a card. In some cases, there is only one device per card (for 118 on a card. In some cases, there is only one device per card (for
140 example, ethernet cards, modems). In other cases, there may be 119 example, ethernet cards, modems). In other cases, there may be
@@ -169,18 +148,16 @@ typedef struct local_info_t {
169 148
170======================================================================*/ 149======================================================================*/
171 150
172static dev_link_t *sedlbauer_attach(void) 151static int sedlbauer_attach(struct pcmcia_device *p_dev)
173{ 152{
174 local_info_t *local; 153 local_info_t *local;
175 dev_link_t *link; 154 dev_link_t *link;
176 client_reg_t client_reg;
177 int ret;
178 155
179 DEBUG(0, "sedlbauer_attach()\n"); 156 DEBUG(0, "sedlbauer_attach()\n");
180 157
181 /* Allocate space for private device-specific data */ 158 /* Allocate space for private device-specific data */
182 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 159 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
183 if (!local) return NULL; 160 if (!local) return -ENOMEM;
184 memset(local, 0, sizeof(local_info_t)); 161 memset(local, 0, sizeof(local_info_t));
185 local->cardnr = -1; 162 local->cardnr = -1;
186 link = &local->link; link->priv = local; 163 link = &local->link; link->priv = local;
@@ -210,19 +187,13 @@ static dev_link_t *sedlbauer_attach(void)
210 link->conf.Vcc = 50; 187 link->conf.Vcc = 50;
211 link->conf.IntType = INT_MEMORY_AND_IO; 188 link->conf.IntType = INT_MEMORY_AND_IO;
212 189
213 /* Register with Card Services */ 190 link->handle = p_dev;
214 link->next = NULL; 191 p_dev->instance = link;
215 client_reg.dev_info = &dev_info;
216 client_reg.Version = 0x0210;
217 client_reg.event_callback_args.client_data = link;
218 ret = pcmcia_register_client(&link->handle, &client_reg);
219 if (ret != CS_SUCCESS) {
220 cs_error(link->handle, RegisterClient, ret);
221 sedlbauer_detach(link->handle);
222 return NULL;
223 }
224 192
225 return link; 193 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
194 sedlbauer_config(link);
195
196 return 0;
226} /* sedlbauer_attach */ 197} /* sedlbauer_attach */
227 198
228/*====================================================================== 199/*======================================================================
@@ -541,33 +512,6 @@ static int sedlbauer_resume(struct pcmcia_device *p_dev)
541 return 0; 512 return 0;
542} 513}
543 514
544/*======================================================================
545
546 The card status event handler. Mostly, this schedules other
547 stuff to run after an event is received.
548
549 When a CARD_REMOVAL event is received, we immediately set a
550 private flag to block future accesses to this device. All the
551 functions that actually access the device should check this flag
552 to make sure the card is still present.
553
554======================================================================*/
555
556static int sedlbauer_event(event_t event, int priority,
557 event_callback_args_t *args)
558{
559 dev_link_t *link = args->client_data;
560
561 DEBUG(1, "sedlbauer_event(0x%06x)\n", event);
562
563 switch (event) {
564 case CS_EVENT_CARD_INSERTION:
565 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
566 sedlbauer_config(link);
567 break;
568 }
569 return 0;
570} /* sedlbauer_event */
571 515
572static struct pcmcia_device_id sedlbauer_ids[] = { 516static struct pcmcia_device_id sedlbauer_ids[] = {
573 PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "speed star II", "V 3.1", 0x81fb79f5, 0xf3612e1d, 0x6b95c78a), 517 PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "speed star II", "V 3.1", 0x81fb79f5, 0xf3612e1d, 0x6b95c78a),
@@ -586,8 +530,7 @@ static struct pcmcia_driver sedlbauer_driver = {
586 .drv = { 530 .drv = {
587 .name = "sedlbauer_cs", 531 .name = "sedlbauer_cs",
588 }, 532 },
589 .attach = sedlbauer_attach, 533 .probe = sedlbauer_attach,
590 .event = sedlbauer_event,
591 .remove = sedlbauer_detach, 534 .remove = sedlbauer_detach,
592 .id_table = sedlbauer_ids, 535 .id_table = sedlbauer_ids,
593 .suspend = sedlbauer_suspend, 536 .suspend = sedlbauer_suspend,
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index f956fceb9db2..4e5c14c7240e 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -77,8 +77,6 @@ module_param(protocol, int, 0);
77 77
78static void teles_cs_config(dev_link_t *link); 78static void teles_cs_config(dev_link_t *link);
79static void teles_cs_release(dev_link_t *link); 79static void teles_cs_release(dev_link_t *link);
80static int teles_cs_event(event_t event, int priority,
81 event_callback_args_t *args);
82 80
83/* 81/*
84 The attach() and detach() entry points are used to create and destroy 82 The attach() and detach() entry points are used to create and destroy
@@ -86,18 +84,9 @@ static int teles_cs_event(event_t event, int priority,
86 needed to manage one actual PCMCIA card. 84 needed to manage one actual PCMCIA card.
87*/ 85*/
88 86
89static dev_link_t *teles_attach(void);
90static void teles_detach(struct pcmcia_device *p_dev); 87static void teles_detach(struct pcmcia_device *p_dev);
91 88
92/* 89/*
93 The dev_info variable is the "key" that is used to match up this
94 device driver with appropriate cards, through the card configuration
95 database.
96*/
97
98static dev_info_t dev_info = "teles_cs";
99
100/*
101 A linked list of "instances" of the teles_cs device. Each actual 90 A linked list of "instances" of the teles_cs device. Each actual
102 PCMCIA card corresponds to one device instance, and is described 91 PCMCIA card corresponds to one device instance, and is described
103 by one dev_link_t structure (defined in ds.h). 92 by one dev_link_t structure (defined in ds.h).
@@ -141,18 +130,16 @@ typedef struct local_info_t {
141 130
142======================================================================*/ 131======================================================================*/
143 132
144static dev_link_t *teles_attach(void) 133static int teles_attach(struct pcmcia_device *p_dev)
145{ 134{
146 client_reg_t client_reg;
147 dev_link_t *link; 135 dev_link_t *link;
148 local_info_t *local; 136 local_info_t *local;
149 int ret;
150 137
151 DEBUG(0, "teles_attach()\n"); 138 DEBUG(0, "teles_attach()\n");
152 139
153 /* Allocate space for private device-specific data */ 140 /* Allocate space for private device-specific data */
154 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 141 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
155 if (!local) return NULL; 142 if (!local) return -ENOMEM;
156 memset(local, 0, sizeof(local_info_t)); 143 memset(local, 0, sizeof(local_info_t));
157 local->cardnr = -1; 144 local->cardnr = -1;
158 link = &local->link; link->priv = local; 145 link = &local->link; link->priv = local;
@@ -177,19 +164,13 @@ static dev_link_t *teles_attach(void)
177 link->conf.Vcc = 50; 164 link->conf.Vcc = 50;
178 link->conf.IntType = INT_MEMORY_AND_IO; 165 link->conf.IntType = INT_MEMORY_AND_IO;
179 166
180 /* Register with Card Services */ 167 link->handle = p_dev;
181 link->next = NULL; 168 p_dev->instance = link;
182 client_reg.dev_info = &dev_info;
183 client_reg.Version = 0x0210;
184 client_reg.event_callback_args.client_data = link;
185 ret = pcmcia_register_client(&link->handle, &client_reg);
186 if (ret != CS_SUCCESS) {
187 cs_error(link->handle, RegisterClient, ret);
188 teles_detach(link->handle);
189 return NULL;
190 }
191 169
192 return link; 170 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
171 teles_cs_config(link);
172
173 return 0;
193} /* teles_attach */ 174} /* teles_attach */
194 175
195/*====================================================================== 176/*======================================================================
@@ -428,35 +409,6 @@ static int teles_resume(struct pcmcia_device *p_dev)
428 return 0; 409 return 0;
429} 410}
430 411
431/*======================================================================
432
433 The card status event handler. Mostly, this schedules other
434 stuff to run after an event is received. A CARD_REMOVAL event
435 also sets some flags to discourage the net drivers from trying
436 to talk to the card any more.
437
438 When a CARD_REMOVAL event is received, we immediately set a flag
439 to block future accesses to this device. All the functions that
440 actually access the device should check this flag to make sure
441 the card is still present.
442
443======================================================================*/
444
445static int teles_cs_event(event_t event, int priority,
446 event_callback_args_t *args)
447{
448 dev_link_t *link = args->client_data;
449
450 DEBUG(1, "teles_cs_event(%d)\n", event);
451
452 switch (event) {
453 case CS_EVENT_CARD_INSERTION:
454 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
455 teles_cs_config(link);
456 break;
457 }
458 return 0;
459} /* teles_cs_event */
460 412
461static struct pcmcia_device_id teles_ids[] = { 413static struct pcmcia_device_id teles_ids[] = {
462 PCMCIA_DEVICE_PROD_ID12("TELES", "S0/PC", 0x67b50eae, 0xe9e70119), 414 PCMCIA_DEVICE_PROD_ID12("TELES", "S0/PC", 0x67b50eae, 0xe9e70119),
@@ -469,8 +421,7 @@ static struct pcmcia_driver teles_cs_driver = {
469 .drv = { 421 .drv = {
470 .name = "teles_cs", 422 .name = "teles_cs",
471 }, 423 },
472 .attach = teles_attach, 424 .probe = teles_attach,
473 .event = teles_cs_event,
474 .remove = teles_detach, 425 .remove = teles_detach,
475 .id_table = teles_ids, 426 .id_table = teles_ids,
476 .suspend = teles_suspend, 427 .suspend = teles_suspend,