aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hisax/sedlbauer_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/sedlbauer_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/sedlbauer_cs.c')
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c75
1 files changed, 9 insertions, 66 deletions
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,