aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pcmcia/vx/vxpocket.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pcmcia/vx/vxpocket.c')
-rw-r--r--sound/pcmcia/vx/vxpocket.c94
1 files changed, 31 insertions, 63 deletions
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c
index 66900d20a42f..7e0cda2b6ef9 100644
--- a/sound/pcmcia/vx/vxpocket.c
+++ b/sound/pcmcia/vx/vxpocket.c
@@ -59,15 +59,9 @@ static unsigned int card_alloc;
59 59
60/* 60/*
61 */ 61 */
62static void vxpocket_release(dev_link_t *link) 62static void vxpocket_release(struct pcmcia_device *link)
63{ 63{
64 if (link->state & DEV_CONFIG) { 64 pcmcia_disable_device(link);
65 /* release cs resources */
66 pcmcia_release_configuration(link->handle);
67 pcmcia_release_io(link->handle, &link->io);
68 pcmcia_release_irq(link->handle, &link->irq);
69 link->state &= ~DEV_CONFIG;
70 }
71} 65}
72 66
73/* 67/*
@@ -132,9 +126,9 @@ static struct snd_vx_hardware vxp440_hw = {
132/* 126/*
133 * create vxpocket instance 127 * create vxpocket instance
134 */ 128 */
135static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl) 129static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl,
130 struct pcmcia_device *link)
136{ 131{
137 dev_link_t *link; /* Info for cardmgr */
138 struct vx_core *chip; 132 struct vx_core *chip;
139 struct snd_vxpocket *vxp; 133 struct snd_vxpocket *vxp;
140 static struct snd_device_ops ops = { 134 static struct snd_device_ops ops = {
@@ -154,7 +148,7 @@ static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl)
154 148
155 vxp = (struct snd_vxpocket *)chip; 149 vxp = (struct snd_vxpocket *)chip;
156 150
157 link = &vxp->link; 151 vxp->p_dev = link;
158 link->priv = chip; 152 link->priv = chip;
159 153
160 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 154 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
@@ -167,7 +161,6 @@ static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl)
167 link->irq.Instance = chip; 161 link->irq.Instance = chip;
168 162
169 link->conf.Attributes = CONF_ENABLE_IRQ; 163 link->conf.Attributes = CONF_ENABLE_IRQ;
170 link->conf.Vcc = 50;
171 link->conf.IntType = INT_MEMORY_AND_IO; 164 link->conf.IntType = INT_MEMORY_AND_IO;
172 link->conf.ConfigIndex = 1; 165 link->conf.ConfigIndex = 1;
173 link->conf.Present = PRESENT_OPTION; 166 link->conf.Present = PRESENT_OPTION;
@@ -215,9 +208,8 @@ static int snd_vxpocket_assign_resources(struct vx_core *chip, int port, int irq
215#define CS_CHECK(fn, ret) \ 208#define CS_CHECK(fn, ret) \
216do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 209do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
217 210
218static void vxpocket_config(dev_link_t *link) 211static int vxpocket_config(struct pcmcia_device *link)
219{ 212{
220 client_handle_t handle = link->handle;
221 struct vx_core *chip = link->priv; 213 struct vx_core *chip = link->priv;
222 struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; 214 struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
223 tuple_t tuple; 215 tuple_t tuple;
@@ -229,24 +221,24 @@ static void vxpocket_config(dev_link_t *link)
229 parse = kmalloc(sizeof(*parse), GFP_KERNEL); 221 parse = kmalloc(sizeof(*parse), GFP_KERNEL);
230 if (! parse) { 222 if (! parse) {
231 snd_printk(KERN_ERR "vx: cannot allocate\n"); 223 snd_printk(KERN_ERR "vx: cannot allocate\n");
232 return; 224 return -ENOMEM;
233 } 225 }
234 tuple.Attributes = 0; 226 tuple.Attributes = 0;
235 tuple.TupleData = (cisdata_t *)buf; 227 tuple.TupleData = (cisdata_t *)buf;
236 tuple.TupleDataMax = sizeof(buf); 228 tuple.TupleDataMax = sizeof(buf);
237 tuple.TupleOffset = 0; 229 tuple.TupleOffset = 0;
238 tuple.DesiredTuple = CISTPL_CONFIG; 230 tuple.DesiredTuple = CISTPL_CONFIG;
239 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 231 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
240 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 232 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
241 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, parse)); 233 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse));
242 link->conf.ConfigBase = parse->config.base; 234 link->conf.ConfigBase = parse->config.base;
243 link->conf.Present = parse->config.rmask[0]; 235 link->conf.Present = parse->config.rmask[0];
244 236
245 /* redefine hardware record according to the VERSION1 string */ 237 /* redefine hardware record according to the VERSION1 string */
246 tuple.DesiredTuple = CISTPL_VERS_1; 238 tuple.DesiredTuple = CISTPL_VERS_1;
247 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 239 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
248 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 240 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
249 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, parse)); 241 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse));
250 if (! strcmp(parse->version_1.str + parse->version_1.ofs[1], "VX-POCKET")) { 242 if (! strcmp(parse->version_1.str + parse->version_1.ofs[1], "VX-POCKET")) {
251 snd_printdd("VX-pocket is detected\n"); 243 snd_printdd("VX-pocket is detected\n");
252 } else { 244 } else {
@@ -257,67 +249,50 @@ static void vxpocket_config(dev_link_t *link)
257 strcpy(chip->card->driver, vxp440_hw.name); 249 strcpy(chip->card->driver, vxp440_hw.name);
258 } 250 }
259 251
260 /* Configure card */ 252 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
261 link->state |= DEV_CONFIG; 253 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
262 254 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
263 CS_CHECK(RequestIO, pcmcia_request_io(handle, &link->io));
264 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
265 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
266 255
267 chip->dev = &handle_to_dev(link->handle); 256 chip->dev = &handle_to_dev(link);
268 snd_card_set_dev(chip->card, chip->dev); 257 snd_card_set_dev(chip->card, chip->dev);
269 258
270 if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0) 259 if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0)
271 goto failed; 260 goto failed;
272 261
273 link->dev = &vxp->node; 262 link->dev_node = &vxp->node;
274 link->state &= ~DEV_CONFIG_PENDING;
275 kfree(parse); 263 kfree(parse);
276 return; 264 return 9;
277 265
278cs_failed: 266cs_failed:
279 cs_error(link->handle, last_fn, last_ret); 267 cs_error(link, last_fn, last_ret);
280failed: 268failed:
281 pcmcia_release_configuration(link->handle); 269 pcmcia_disable_device(link);
282 pcmcia_release_io(link->handle, &link->io);
283 pcmcia_release_irq(link->handle, &link->irq);
284 link->state &= ~DEV_CONFIG;
285 kfree(parse); 270 kfree(parse);
271 return -ENODEV;
286} 272}
287 273
288#ifdef CONFIG_PM 274#ifdef CONFIG_PM
289 275
290static int vxp_suspend(struct pcmcia_device *dev) 276static int vxp_suspend(struct pcmcia_device *link)
291{ 277{
292 dev_link_t *link = dev_to_instance(dev);
293 struct vx_core *chip = link->priv; 278 struct vx_core *chip = link->priv;
294 279
295 snd_printdd(KERN_DEBUG "SUSPEND\n"); 280 snd_printdd(KERN_DEBUG "SUSPEND\n");
296 link->state |= DEV_SUSPEND;
297 if (chip) { 281 if (chip) {
298 snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n"); 282 snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n");
299 snd_vx_suspend(chip, PMSG_SUSPEND); 283 snd_vx_suspend(chip, PMSG_SUSPEND);
300 } 284 }
301 snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n");
302 if (link->state & DEV_CONFIG)
303 pcmcia_release_configuration(link->handle);
304 285
305 return 0; 286 return 0;
306} 287}
307 288
308static int vxp_resume(struct pcmcia_device *dev) 289static int vxp_resume(struct pcmcia_device *link)
309{ 290{
310 dev_link_t *link = dev_to_instance(dev);
311 struct vx_core *chip = link->priv; 291 struct vx_core *chip = link->priv;
312 292
313 snd_printdd(KERN_DEBUG "RESUME\n"); 293 snd_printdd(KERN_DEBUG "RESUME\n");
314 link->state &= ~DEV_SUSPEND; 294 if (pcmcia_dev_present(link)) {
315
316 snd_printdd(KERN_DEBUG "CARD_RESET\n");
317 if (DEV_OK(link)) {
318 //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; 295 //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
319 snd_printdd(KERN_DEBUG "requestconfig...\n");
320 pcmcia_request_configuration(link->handle, &link->conf);
321 if (chip) { 296 if (chip) {
322 snd_printdd(KERN_DEBUG "calling snd_vx_resume\n"); 297 snd_printdd(KERN_DEBUG "calling snd_vx_resume\n");
323 snd_vx_resume(chip); 298 snd_vx_resume(chip);
@@ -333,7 +308,7 @@ static int vxp_resume(struct pcmcia_device *dev)
333 308
334/* 309/*
335 */ 310 */
336static int vxpocket_attach(struct pcmcia_device *p_dev) 311static int vxpocket_probe(struct pcmcia_device *p_dev)
337{ 312{
338 struct snd_card *card; 313 struct snd_card *card;
339 struct snd_vxpocket *vxp; 314 struct snd_vxpocket *vxp;
@@ -358,7 +333,7 @@ static int vxpocket_attach(struct pcmcia_device *p_dev)
358 return -ENOMEM; 333 return -ENOMEM;
359 } 334 }
360 335
361 vxp = snd_vxpocket_new(card, ibl[i]); 336 vxp = snd_vxpocket_new(card, ibl[i], p_dev);
362 if (! vxp) { 337 if (! vxp) {
363 snd_card_free(card); 338 snd_card_free(card);
364 return -ENODEV; 339 return -ENODEV;
@@ -368,20 +343,13 @@ static int vxpocket_attach(struct pcmcia_device *p_dev)
368 vxp->index = i; 343 vxp->index = i;
369 card_alloc |= 1 << i; 344 card_alloc |= 1 << i;
370 345
371 /* Chain drivers */ 346 vxp->p_dev = p_dev;
372 vxp->link.next = NULL;
373
374 vxp->link.handle = p_dev;
375 vxp->link.state |= DEV_PRESENT | DEV_CONFIG_PENDING;
376 p_dev->instance = &vxp->link;
377 vxpocket_config(&vxp->link);
378 347
379 return 0; 348 return vxpocket_config(p_dev);
380} 349}
381 350
382static void vxpocket_detach(struct pcmcia_device *p_dev) 351static void vxpocket_detach(struct pcmcia_device *link)
383{ 352{
384 dev_link_t *link = dev_to_instance(p_dev);
385 struct snd_vxpocket *vxp; 353 struct snd_vxpocket *vxp;
386 struct vx_core *chip; 354 struct vx_core *chip;
387 355
@@ -413,7 +381,7 @@ static struct pcmcia_driver vxp_cs_driver = {
413 .drv = { 381 .drv = {
414 .name = "snd-vxpocket", 382 .name = "snd-vxpocket",
415 }, 383 },
416 .probe = vxpocket_attach, 384 .probe = vxpocket_probe,
417 .remove = vxpocket_detach, 385 .remove = vxpocket_detach,
418 .id_table = vxp_ids, 386 .id_table = vxp_ids,
419#ifdef CONFIG_PM 387#ifdef CONFIG_PM