aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/atmel_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/net/wireless/atmel_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/net/wireless/atmel_cs.c')
-rw-r--r--drivers/net/wireless/atmel_cs.c80
1 files changed, 16 insertions, 64 deletions
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 32f009709355..d6f4a5a3e55a 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -93,8 +93,6 @@ MODULE_SUPPORTED_DEVICE("Atmel at76c50x PCMCIA cards");
93 93
94static void atmel_config(dev_link_t *link); 94static void atmel_config(dev_link_t *link);
95static void atmel_release(dev_link_t *link); 95static void atmel_release(dev_link_t *link);
96static int atmel_event(event_t event, int priority,
97 event_callback_args_t *args);
98 96
99/* 97/*
100 The attach() and detach() entry points are used to create and destroy 98 The attach() and detach() entry points are used to create and destroy
@@ -102,7 +100,6 @@ static int atmel_event(event_t event, int priority,
102 needed to manage one actual PCMCIA card. 100 needed to manage one actual PCMCIA card.
103*/ 101*/
104 102
105static dev_link_t *atmel_attach(void);
106static void atmel_detach(struct pcmcia_device *p_dev); 103static void atmel_detach(struct pcmcia_device *p_dev);
107 104
108/* 105/*
@@ -113,14 +110,6 @@ static void atmel_detach(struct pcmcia_device *p_dev);
113*/ 110*/
114 111
115/* 112/*
116 The dev_info variable is the "key" that is used to match up this
117 device driver with appropriate cards, through the card configuration
118 database.
119*/
120
121static dev_info_t dev_info = "atmel_cs";
122
123/*
124 A linked list of "instances" of the atmelnet device. Each actual 113 A linked list of "instances" of the atmelnet device. Each actual
125 PCMCIA card corresponds to one device instance, and is described 114 PCMCIA card corresponds to one device instance, and is described
126 by one dev_link_t structure (defined in ds.h). 115 by one dev_link_t structure (defined in ds.h).
@@ -163,27 +152,25 @@ typedef struct local_info_t {
163 152
164 ======================================================================*/ 153 ======================================================================*/
165 154
166static dev_link_t *atmel_attach(void) 155static int atmel_attach(struct pcmcia_device *p_dev)
167{ 156{
168 client_reg_t client_reg;
169 dev_link_t *link; 157 dev_link_t *link;
170 local_info_t *local; 158 local_info_t *local;
171 int ret; 159
172
173 DEBUG(0, "atmel_attach()\n"); 160 DEBUG(0, "atmel_attach()\n");
174 161
175 /* Initialize the dev_link_t structure */ 162 /* Initialize the dev_link_t structure */
176 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); 163 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
177 if (!link) { 164 if (!link) {
178 printk(KERN_ERR "atmel_cs: no memory for new device\n"); 165 printk(KERN_ERR "atmel_cs: no memory for new device\n");
179 return NULL; 166 return -ENOMEM;
180 } 167 }
181 168
182 /* Interrupt setup */ 169 /* Interrupt setup */
183 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 170 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
184 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 171 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
185 link->irq.Handler = NULL; 172 link->irq.Handler = NULL;
186 173
187 /* 174 /*
188 General socket configuration defaults can go here. In this 175 General socket configuration defaults can go here. In this
189 client, we assume very little, and rely on the CIS for almost 176 client, we assume very little, and rely on the CIS for almost
@@ -194,29 +181,23 @@ static dev_link_t *atmel_attach(void)
194 link->conf.Attributes = 0; 181 link->conf.Attributes = 0;
195 link->conf.Vcc = 50; 182 link->conf.Vcc = 50;
196 link->conf.IntType = INT_MEMORY_AND_IO; 183 link->conf.IntType = INT_MEMORY_AND_IO;
197 184
198 /* Allocate space for private device-specific data */ 185 /* Allocate space for private device-specific data */
199 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 186 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
200 if (!local) { 187 if (!local) {
201 printk(KERN_ERR "atmel_cs: no memory for new device\n"); 188 printk(KERN_ERR "atmel_cs: no memory for new device\n");
202 kfree (link); 189 kfree (link);
203 return NULL; 190 return -ENOMEM;
204 } 191 }
205 link->priv = local; 192 link->priv = local;
206 193
207 /* Register with Card Services */ 194 link->handle = p_dev;
208 link->next = NULL; 195 p_dev->instance = link;
209 client_reg.dev_info = &dev_info; 196
210 client_reg.Version = 0x0210; 197 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
211 client_reg.event_callback_args.client_data = link; 198 atmel_config(link);
212 ret = pcmcia_register_client(&link->handle, &client_reg); 199
213 if (ret != 0) { 200 return 0;
214 cs_error(link->handle, RegisterClient, ret);
215 atmel_detach(link->handle);
216 return NULL;
217 }
218
219 return link;
220} /* atmel_attach */ 201} /* atmel_attach */
221 202
222/*====================================================================== 203/*======================================================================
@@ -485,34 +466,6 @@ static int atmel_resume(struct pcmcia_device *dev)
485 return 0; 466 return 0;
486} 467}
487 468
488/*======================================================================
489
490 The card status event handler. Mostly, this schedules other
491 stuff to run after an event is received.
492
493 When a CARD_REMOVAL event is received, we immediately set a
494 private flag to block future accesses to this device. All the
495 functions that actually access the device should check this flag
496 to make sure the card is still present.
497
498 ======================================================================*/
499
500static int atmel_event(event_t event, int priority,
501 event_callback_args_t *args)
502{
503 dev_link_t *link = args->client_data;
504
505 DEBUG(1, "atmel_event(0x%06x)\n", event);
506
507 switch (event) {
508 case CS_EVENT_CARD_INSERTION:
509 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
510 atmel_config(link);
511 break;
512 }
513 return 0;
514} /* atmel_event */
515
516/*====================================================================*/ 469/*====================================================================*/
517/* We use the driver_info field to store the correct firmware type for a card. */ 470/* We use the driver_info field to store the correct firmware type for a card. */
518 471
@@ -562,8 +515,7 @@ static struct pcmcia_driver atmel_driver = {
562 .drv = { 515 .drv = {
563 .name = "atmel_cs", 516 .name = "atmel_cs",
564 }, 517 },
565 .attach = atmel_attach, 518 .probe = atmel_attach,
566 .event = atmel_event,
567 .remove = atmel_detach, 519 .remove = atmel_detach,
568 .id_table = atmel_ids, 520 .id_table = atmel_ids,
569 .suspend = atmel_suspend, 521 .suspend = atmel_suspend,