diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-11-17 11:14:11 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:28:39 -0500 |
commit | d29b761e6162d3b91079b25334270a2c36f6157d (patch) | |
tree | ec32368c58173039725dba4b6fa1b50d8b6aaab5 | |
parent | 99a0b7687ef991a577506a1974be146f02f18d74 (diff) |
[ALSA] wavefront - Use platform_device
Modules: Wavefront drivers
Rewrite the probe/remove with platform_device.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/isa/wavefront/wavefront.c | 267 |
1 files changed, 142 insertions, 125 deletions
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index 9e5b57163c0b..77a3012e5510 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/err.h> | ||
27 | #include <linux/platform_device.h> | ||
26 | #include <linux/pnp.h> | 28 | #include <linux/pnp.h> |
27 | #include <linux/moduleparam.h> | 29 | #include <linux/moduleparam.h> |
28 | #include <sound/core.h> | 30 | #include <sound/core.h> |
@@ -81,7 +83,6 @@ MODULE_PARM_DESC(fm_port, "FM port #."); | |||
81 | module_param_array(use_cs4232_midi, bool, NULL, 0444); | 83 | module_param_array(use_cs4232_midi, bool, NULL, 0444); |
82 | MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); | 84 | MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); |
83 | 85 | ||
84 | static struct snd_card *snd_wavefront_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; | ||
85 | 86 | ||
86 | #ifdef CONFIG_PNP | 87 | #ifdef CONFIG_PNP |
87 | 88 | ||
@@ -240,7 +241,7 @@ snd_wavefront_pnp (int dev, snd_wavefront_card_t *acard, struct pnp_card_link *c | |||
240 | cs4232_mpu_irq[dev] = pnp_irq(pdev, 0); | 241 | cs4232_mpu_irq[dev] = pnp_irq(pdev, 0); |
241 | } | 242 | } |
242 | 243 | ||
243 | snd_printk ("CS4232 MPU: port=0x%lx, irq=%i\n", | 244 | snd_printk (KERN_INFO "CS4232 MPU: port=0x%lx, irq=%i\n", |
244 | cs4232_mpu_port[dev], | 245 | cs4232_mpu_port[dev], |
245 | cs4232_mpu_irq[dev]); | 246 | cs4232_mpu_irq[dev]); |
246 | } | 247 | } |
@@ -315,7 +316,7 @@ snd_wavefront_new_fx (struct snd_card *card, | |||
315 | struct snd_hwdep *fx_processor; | 316 | struct snd_hwdep *fx_processor; |
316 | 317 | ||
317 | if (snd_wavefront_fx_start (&acard->wavefront)) { | 318 | if (snd_wavefront_fx_start (&acard->wavefront)) { |
318 | snd_printk ("cannot initialize YSS225 FX processor"); | 319 | snd_printk (KERN_ERR "cannot initialize YSS225 FX processor"); |
319 | return NULL; | 320 | return NULL; |
320 | } | 321 | } |
321 | 322 | ||
@@ -347,7 +348,7 @@ snd_wavefront_new_midi (struct snd_card *card, | |||
347 | first = 0; | 348 | first = 0; |
348 | acard->wavefront.midi.base = port; | 349 | acard->wavefront.midi.base = port; |
349 | if (snd_wavefront_midi_start (acard)) { | 350 | if (snd_wavefront_midi_start (acard)) { |
350 | snd_printk ("cannot initialize MIDI interface\n"); | 351 | snd_printk (KERN_ERR "cannot initialize MIDI interface\n"); |
351 | return NULL; | 352 | return NULL; |
352 | } | 353 | } |
353 | } | 354 | } |
@@ -385,42 +386,17 @@ snd_wavefront_free(struct snd_card *card) | |||
385 | } | 386 | } |
386 | } | 387 | } |
387 | 388 | ||
388 | static int __devinit | 389 | static struct snd_card *snd_wavefront_card_new(int dev) |
389 | snd_wavefront_probe (int dev, struct pnp_card_link *pcard, | ||
390 | const struct pnp_card_device_id *pid) | ||
391 | { | 390 | { |
392 | struct snd_card *card; | 391 | struct snd_card *card; |
393 | snd_wavefront_card_t *acard; | 392 | snd_wavefront_card_t *acard; |
394 | struct snd_cs4231 *chip; | ||
395 | struct snd_hwdep *wavefront_synth; | ||
396 | struct snd_rawmidi *ics2115_internal_rmidi = NULL; | ||
397 | struct snd_rawmidi *ics2115_external_rmidi = NULL; | ||
398 | struct snd_hwdep *fx_processor; | ||
399 | int hw_dev = 0, midi_dev = 0, err; | ||
400 | 393 | ||
401 | #ifdef CONFIG_PNP | 394 | card = snd_card_new (index[dev], id[dev], THIS_MODULE, |
402 | if (!isapnp[dev]) { | ||
403 | #endif | ||
404 | if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { | ||
405 | snd_printk("specify CS4232 port\n"); | ||
406 | return -EINVAL; | ||
407 | } | ||
408 | if (ics2115_port[dev] == SNDRV_AUTO_PORT) { | ||
409 | snd_printk("specify ICS2115 port\n"); | ||
410 | return -ENODEV; | ||
411 | } | ||
412 | #ifdef CONFIG_PNP | ||
413 | } | ||
414 | #endif | ||
415 | card = snd_card_new (index[dev], | ||
416 | id[dev], | ||
417 | THIS_MODULE, | ||
418 | sizeof(snd_wavefront_card_t)); | 395 | sizeof(snd_wavefront_card_t)); |
396 | if (card == NULL) | ||
397 | return NULL; | ||
419 | 398 | ||
420 | if (card == NULL) { | 399 | acard = card->private_data; |
421 | return -ENOMEM; | ||
422 | } | ||
423 | acard = (snd_wavefront_card_t *)card->private_data; | ||
424 | acard->wavefront.irq = -1; | 400 | acard->wavefront.irq = -1; |
425 | spin_lock_init(&acard->wavefront.irq_lock); | 401 | spin_lock_init(&acard->wavefront.irq_lock); |
426 | init_waitqueue_head(&acard->wavefront.interrupt_sleeper); | 402 | init_waitqueue_head(&acard->wavefront.interrupt_sleeper); |
@@ -428,18 +404,19 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, | |||
428 | spin_lock_init(&acard->wavefront.midi.virtual); | 404 | spin_lock_init(&acard->wavefront.midi.virtual); |
429 | card->private_free = snd_wavefront_free; | 405 | card->private_free = snd_wavefront_free; |
430 | 406 | ||
431 | #ifdef CONFIG_PNP | 407 | return card; |
432 | if (isapnp[dev]) { | 408 | } |
433 | if (snd_wavefront_pnp (dev, acard, pcard, pid) < 0) { | 409 | |
434 | if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { | 410 | static int __devinit |
435 | snd_printk ("isapnp detection failed\n"); | 411 | snd_wavefront_probe (struct snd_card *card, int dev) |
436 | snd_card_free (card); | 412 | { |
437 | return -ENODEV; | 413 | snd_wavefront_card_t *acard = card->private_data; |
438 | } | 414 | struct snd_cs4231 *chip; |
439 | } | 415 | struct snd_hwdep *wavefront_synth; |
440 | snd_card_set_dev(card, &pcard->card->dev); | 416 | struct snd_rawmidi *ics2115_internal_rmidi = NULL; |
441 | } | 417 | struct snd_rawmidi *ics2115_external_rmidi = NULL; |
442 | #endif /* CONFIG_PNP */ | 418 | struct snd_hwdep *fx_processor; |
419 | int hw_dev = 0, midi_dev = 0, err; | ||
443 | 420 | ||
444 | /* --------- PCM --------------- */ | 421 | /* --------- PCM --------------- */ |
445 | 422 | ||
@@ -450,19 +427,15 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, | |||
450 | dma1[dev], | 427 | dma1[dev], |
451 | dma2[dev], | 428 | dma2[dev], |
452 | CS4231_HW_DETECT, 0, &chip)) < 0) { | 429 | CS4231_HW_DETECT, 0, &chip)) < 0) { |
453 | snd_card_free(card); | 430 | snd_printk (KERN_ERR "can't allocate CS4231 device\n"); |
454 | snd_printk ("can't allocate CS4231 device\n"); | ||
455 | return err; | 431 | return err; |
456 | } | 432 | } |
457 | 433 | ||
458 | if ((err = snd_cs4231_pcm (chip, 0, NULL)) < 0) { | 434 | if ((err = snd_cs4231_pcm (chip, 0, NULL)) < 0) |
459 | snd_card_free(card); | ||
460 | return err; | 435 | return err; |
461 | } | 436 | |
462 | if ((err = snd_cs4231_timer (chip, 0, NULL)) < 0) { | 437 | if ((err = snd_cs4231_timer (chip, 0, NULL)) < 0) |
463 | snd_card_free(card); | ||
464 | return err; | 438 | return err; |
465 | } | ||
466 | 439 | ||
467 | /* ---------- OPL3 synth --------- */ | 440 | /* ---------- OPL3 synth --------- */ |
468 | 441 | ||
@@ -474,28 +447,26 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, | |||
474 | fm_port[dev] + 2, | 447 | fm_port[dev] + 2, |
475 | OPL3_HW_OPL3_CS, | 448 | OPL3_HW_OPL3_CS, |
476 | 0, &opl3)) < 0) { | 449 | 0, &opl3)) < 0) { |
477 | snd_printk ("can't allocate or detect OPL3 synth\n"); | 450 | snd_printk (KERN_ERR "can't allocate or detect OPL3 synth\n"); |
478 | snd_card_free(card); | ||
479 | return err; | 451 | return err; |
480 | } | 452 | } |
481 | 453 | ||
482 | if ((err = snd_opl3_hwdep_new(opl3, hw_dev, 1, NULL)) < 0) { | 454 | if ((err = snd_opl3_hwdep_new(opl3, hw_dev, 1, NULL)) < 0) |
483 | snd_card_free(card); | ||
484 | return err; | 455 | return err; |
485 | } | ||
486 | hw_dev++; | 456 | hw_dev++; |
487 | } | 457 | } |
488 | 458 | ||
489 | /* ------- ICS2115 Wavetable synth ------- */ | 459 | /* ------- ICS2115 Wavetable synth ------- */ |
490 | 460 | ||
491 | if ((acard->wavefront.res_base = request_region(ics2115_port[dev], 16, "ICS2115")) == NULL) { | 461 | if ((acard->wavefront.res_base = request_region(ics2115_port[dev], 16, |
492 | snd_printk("unable to grab ICS2115 i/o region 0x%lx-0x%lx\n", ics2115_port[dev], ics2115_port[dev] + 16 - 1); | 462 | "ICS2115")) == NULL) { |
493 | snd_card_free(card); | 463 | snd_printk(KERN_ERR "unable to grab ICS2115 i/o region 0x%lx-0x%lx\n", |
464 | ics2115_port[dev], ics2115_port[dev] + 16 - 1); | ||
494 | return -EBUSY; | 465 | return -EBUSY; |
495 | } | 466 | } |
496 | if (request_irq(ics2115_irq[dev], snd_wavefront_ics2115_interrupt, SA_INTERRUPT, "ICS2115", (void *)acard)) { | 467 | if (request_irq(ics2115_irq[dev], snd_wavefront_ics2115_interrupt, |
497 | snd_printk("unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]); | 468 | SA_INTERRUPT, "ICS2115", acard)) { |
498 | snd_card_free(card); | 469 | snd_printk(KERN_ERR "unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]); |
499 | return -EBUSY; | 470 | return -EBUSY; |
500 | } | 471 | } |
501 | 472 | ||
@@ -503,8 +474,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, | |||
503 | acard->wavefront.base = ics2115_port[dev]; | 474 | acard->wavefront.base = ics2115_port[dev]; |
504 | 475 | ||
505 | if ((wavefront_synth = snd_wavefront_new_synth (card, hw_dev, acard)) == NULL) { | 476 | if ((wavefront_synth = snd_wavefront_new_synth (card, hw_dev, acard)) == NULL) { |
506 | snd_printk ("can't create WaveFront synth device\n"); | 477 | snd_printk (KERN_ERR "can't create WaveFront synth device\n"); |
507 | snd_card_free(card); | ||
508 | return -ENOMEM; | 478 | return -ENOMEM; |
509 | } | 479 | } |
510 | 480 | ||
@@ -515,8 +485,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, | |||
515 | /* --------- Mixer ------------ */ | 485 | /* --------- Mixer ------------ */ |
516 | 486 | ||
517 | if ((err = snd_cs4231_mixer(chip)) < 0) { | 487 | if ((err = snd_cs4231_mixer(chip)) < 0) { |
518 | snd_printk ("can't allocate mixer device\n"); | 488 | snd_printk (KERN_ERR "can't allocate mixer device\n"); |
519 | snd_card_free(card); | ||
520 | return err; | 489 | return err; |
521 | } | 490 | } |
522 | 491 | ||
@@ -528,8 +497,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, | |||
528 | cs4232_mpu_irq[dev], | 497 | cs4232_mpu_irq[dev], |
529 | SA_INTERRUPT, | 498 | SA_INTERRUPT, |
530 | NULL)) < 0) { | 499 | NULL)) < 0) { |
531 | snd_printk ("can't allocate CS4232 MPU-401 device\n"); | 500 | snd_printk (KERN_ERR "can't allocate CS4232 MPU-401 device\n"); |
532 | snd_card_free(card); | ||
533 | return err; | 501 | return err; |
534 | } | 502 | } |
535 | midi_dev++; | 503 | midi_dev++; |
@@ -545,8 +513,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, | |||
545 | ics2115_port[dev], | 513 | ics2115_port[dev], |
546 | internal_mpu); | 514 | internal_mpu); |
547 | if (ics2115_internal_rmidi == NULL) { | 515 | if (ics2115_internal_rmidi == NULL) { |
548 | snd_printk ("can't setup ICS2115 internal MIDI device\n"); | 516 | snd_printk (KERN_ERR "can't setup ICS2115 internal MIDI device\n"); |
549 | snd_card_free(card); | ||
550 | return -ENOMEM; | 517 | return -ENOMEM; |
551 | } | 518 | } |
552 | midi_dev++; | 519 | midi_dev++; |
@@ -562,8 +529,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, | |||
562 | ics2115_port[dev], | 529 | ics2115_port[dev], |
563 | external_mpu); | 530 | external_mpu); |
564 | if (ics2115_external_rmidi == NULL) { | 531 | if (ics2115_external_rmidi == NULL) { |
565 | snd_printk ("can't setup ICS2115 external MIDI device\n"); | 532 | snd_printk (KERN_ERR "can't setup ICS2115 external MIDI device\n"); |
566 | snd_card_free(card); | ||
567 | return -ENOMEM; | 533 | return -ENOMEM; |
568 | } | 534 | } |
569 | midi_dev++; | 535 | midi_dev++; |
@@ -577,8 +543,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, | |||
577 | acard, | 543 | acard, |
578 | ics2115_port[dev]); | 544 | ics2115_port[dev]); |
579 | if (fx_processor == NULL) { | 545 | if (fx_processor == NULL) { |
580 | snd_printk ("can't setup FX device\n"); | 546 | snd_printk (KERN_ERR "can't setup FX device\n"); |
581 | snd_card_free(card); | ||
582 | return -ENOMEM; | 547 | return -ENOMEM; |
583 | } | 548 | } |
584 | 549 | ||
@@ -619,49 +584,97 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, | |||
619 | ics2115_port[dev], | 584 | ics2115_port[dev], |
620 | ics2115_irq[dev]); | 585 | ics2115_irq[dev]); |
621 | 586 | ||
622 | if ((err = snd_card_set_generic_dev(card)) < 0) { | 587 | return snd_card_register(card); |
623 | snd_card_free(card); | 588 | } |
624 | return err; | 589 | |
590 | static int __init snd_wavefront_nonpnp_probe(struct platform_device *pdev) | ||
591 | { | ||
592 | int dev = pdev->id; | ||
593 | struct snd_card *card; | ||
594 | int err; | ||
595 | |||
596 | if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { | ||
597 | snd_printk("specify CS4232 port\n"); | ||
598 | return -EINVAL; | ||
599 | } | ||
600 | if (ics2115_port[dev] == SNDRV_AUTO_PORT) { | ||
601 | snd_printk("specify ICS2115 port\n"); | ||
602 | return -ENODEV; | ||
625 | } | 603 | } |
626 | 604 | ||
627 | if ((err = snd_card_register(card)) < 0) { | 605 | card = snd_wavefront_card_new(dev); |
606 | if (! card) | ||
607 | return -ENOMEM; | ||
608 | snd_card_set_dev(card, &pdev->dev); | ||
609 | if ((err = snd_wavefront_probe(card, dev)) < 0) { | ||
628 | snd_card_free(card); | 610 | snd_card_free(card); |
629 | return err; | 611 | return err; |
630 | } | 612 | } |
631 | if (pcard) | 613 | |
632 | pnp_set_card_drvdata(pcard, card); | 614 | platform_set_drvdata(pdev, card); |
633 | else | ||
634 | snd_wavefront_legacy[dev] = card; | ||
635 | return 0; | 615 | return 0; |
636 | } | 616 | } |
617 | |||
618 | static int __devexit snd_wavefront_nonpnp_remove(struct platform_device *devptr) | ||
619 | { | ||
620 | snd_card_free(platform_get_drvdata(devptr)); | ||
621 | platform_set_drvdata(devptr, NULL); | ||
622 | return 0; | ||
623 | } | ||
624 | |||
625 | #define WAVEFRONT_DRIVER "snd_wavefront" | ||
626 | |||
627 | static struct platform_driver snd_wavefront_driver = { | ||
628 | .probe = snd_wavefront_nonpnp_probe, | ||
629 | .remove = __devexit_p(snd_wavefront_nonpnp_remove), | ||
630 | /* FIXME: suspend, resume */ | ||
631 | .driver = { | ||
632 | .name = WAVEFRONT_DRIVER | ||
633 | }, | ||
634 | }; | ||
635 | |||
637 | 636 | ||
638 | #ifdef CONFIG_PNP | 637 | #ifdef CONFIG_PNP |
639 | 638 | ||
640 | static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *card, | 639 | static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard, |
641 | const struct pnp_card_device_id *id) | 640 | const struct pnp_card_device_id *pid) |
642 | { | 641 | { |
643 | static int dev; | 642 | static int dev; |
644 | int res; | 643 | struct snd_card *card; |
645 | 644 | int res; | |
646 | for ( ; dev < SNDRV_CARDS; dev++) { | 645 | |
647 | if (!enable[dev] || !isapnp[dev]) | 646 | for ( ; dev < SNDRV_CARDS; dev++) { |
648 | continue; | 647 | if (enable[dev] && isapnp[dev]) |
649 | res = snd_wavefront_probe(dev, card, id); | 648 | break; |
650 | if (res < 0) | 649 | } |
651 | return res; | 650 | if (dev >= SNDRV_CARDS) |
652 | dev++; | 651 | return -ENODEV; |
653 | return 0; | 652 | |
654 | } | 653 | card = snd_wavefront_card_new(dev); |
655 | 654 | if (! card) | |
656 | return -ENODEV; | 655 | return -ENOMEM; |
656 | |||
657 | if (snd_wavefront_pnp (dev, card->private_data, pcard, pid) < 0) { | ||
658 | if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { | ||
659 | snd_printk (KERN_ERR "isapnp detection failed\n"); | ||
660 | snd_card_free (card); | ||
661 | return -ENODEV; | ||
662 | } | ||
663 | } | ||
664 | snd_card_set_dev(card, &pcard->card->dev); | ||
665 | |||
666 | if ((res = snd_wavefront_probe(card, dev)) < 0) | ||
667 | return res; | ||
668 | |||
669 | pnp_set_card_drvdata(pcard, card); | ||
670 | dev++; | ||
671 | return 0; | ||
657 | } | 672 | } |
658 | 673 | ||
659 | static void __devexit snd_wavefront_pnp_remove(struct pnp_card_link * pcard) | 674 | static void __devexit snd_wavefront_pnp_remove(struct pnp_card_link * pcard) |
660 | { | 675 | { |
661 | struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); | 676 | snd_card_free(pnp_get_card_drvdata(pcard)); |
662 | 677 | pnp_set_card_drvdata(pcard, NULL); | |
663 | snd_card_disconnect(card); | ||
664 | snd_card_free_in_thread(card); | ||
665 | } | 678 | } |
666 | 679 | ||
667 | static struct pnp_card_driver wavefront_pnpc_driver = { | 680 | static struct pnp_card_driver wavefront_pnpc_driver = { |
@@ -670,31 +683,40 @@ static struct pnp_card_driver wavefront_pnpc_driver = { | |||
670 | .id_table = snd_wavefront_pnpids, | 683 | .id_table = snd_wavefront_pnpids, |
671 | .probe = snd_wavefront_pnp_detect, | 684 | .probe = snd_wavefront_pnp_detect, |
672 | .remove = __devexit_p(snd_wavefront_pnp_remove), | 685 | .remove = __devexit_p(snd_wavefront_pnp_remove), |
686 | /* FIXME: suspend,resume */ | ||
673 | }; | 687 | }; |
674 | 688 | ||
675 | #endif /* CONFIG_PNP */ | 689 | #endif /* CONFIG_PNP */ |
676 | 690 | ||
677 | static int __init alsa_card_wavefront_init(void) | 691 | static int __init alsa_card_wavefront_init(void) |
678 | { | 692 | { |
679 | int cards = 0; | 693 | int i, err, cards = 0; |
680 | int dev; | 694 | |
681 | for (dev = 0; dev < SNDRV_CARDS; dev++) { | 695 | if ((err = platform_driver_register(&snd_wavefront_driver)) < 0) |
682 | if (!enable[dev]) | 696 | return err; |
683 | continue; | 697 | |
698 | for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { | ||
699 | struct platform_device *device; | ||
684 | #ifdef CONFIG_PNP | 700 | #ifdef CONFIG_PNP |
685 | if (isapnp[dev]) | 701 | if (isapnp[i]) |
686 | continue; | 702 | continue; |
687 | #endif | 703 | #endif |
688 | if (snd_wavefront_probe(dev, NULL, NULL) >= 0) | 704 | device = platform_device_register_simple(WAVEFRONT_DRIVER, |
689 | cards++; | 705 | i, NULL, 0); |
706 | if (IS_ERR(device)) { | ||
707 | platform_driver_unregister(&snd_wavefront_driver); | ||
708 | return PTR_ERR(device); | ||
709 | } | ||
710 | cards++; | ||
690 | } | 711 | } |
691 | #ifdef CONFIG_PNP | 712 | |
692 | cards += pnp_register_card_driver(&wavefront_pnpc_driver); | 713 | i = pnp_register_card_driver(&wavefront_pnpc_driver); |
693 | #endif | 714 | if (i > 0) |
715 | cards += i; | ||
716 | |||
694 | if (!cards) { | 717 | if (!cards) { |
695 | #ifdef CONFIG_PNP | ||
696 | pnp_unregister_card_driver(&wavefront_pnpc_driver); | 718 | pnp_unregister_card_driver(&wavefront_pnpc_driver); |
697 | #endif | 719 | platform_driver_unregister(&snd_wavefront_driver); |
698 | #ifdef MODULE | 720 | #ifdef MODULE |
699 | printk (KERN_ERR "No WaveFront cards found or devices busy\n"); | 721 | printk (KERN_ERR "No WaveFront cards found or devices busy\n"); |
700 | #endif | 722 | #endif |
@@ -705,13 +727,8 @@ static int __init alsa_card_wavefront_init(void) | |||
705 | 727 | ||
706 | static void __exit alsa_card_wavefront_exit(void) | 728 | static void __exit alsa_card_wavefront_exit(void) |
707 | { | 729 | { |
708 | int idx; | ||
709 | |||
710 | #ifdef CONFIG_PNP | ||
711 | pnp_unregister_card_driver(&wavefront_pnpc_driver); | 730 | pnp_unregister_card_driver(&wavefront_pnpc_driver); |
712 | #endif | 731 | platform_driver_unregister(&snd_wavefront_driver); |
713 | for (idx = 0; idx < SNDRV_CARDS; idx++) | ||
714 | snd_card_free(snd_wavefront_legacy[idx]); | ||
715 | } | 732 | } |
716 | 733 | ||
717 | module_init(alsa_card_wavefront_init) | 734 | module_init(alsa_card_wavefront_init) |