aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hisax/teles_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/isdn/hisax/teles_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/isdn/hisax/teles_cs.c')
-rw-r--r--drivers/isdn/hisax/teles_cs.c67
1 files changed, 9 insertions, 58 deletions
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,