diff options
author | Krzysztof Helt <krzysztof.h1@wp.pl> | 2010-05-09 14:35:44 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-05-10 03:48:59 -0400 |
commit | 396fa8272601c3d488cb8391c3962a7ee552afd0 (patch) | |
tree | 6ef9af15019a00f6a81243c458ca792247a07869 /sound/isa/es1688/es1688_lib.c | |
parent | 02a2ad40295fc8862457b469b3b698d8ece3c72a (diff) |
ALSA: es1688: allocate snd_es1688 structure as a part of snd_card structure
Allocate the snd_es1688 during the snd_card allocation.
This allows to remove the card pointer from the snd_es1688 structure.
Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/isa/es1688/es1688_lib.c')
-rw-r--r-- | sound/isa/es1688/es1688_lib.c | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index c76bb00c9d1..fdd440417bf 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c | |||
@@ -620,7 +620,6 @@ static int snd_es1688_free(struct snd_es1688 *chip) | |||
620 | disable_dma(chip->dma8); | 620 | disable_dma(chip->dma8); |
621 | free_dma(chip->dma8); | 621 | free_dma(chip->dma8); |
622 | } | 622 | } |
623 | kfree(chip); | ||
624 | return 0; | 623 | return 0; |
625 | } | 624 | } |
626 | 625 | ||
@@ -638,23 +637,20 @@ static const char *snd_es1688_chip_id(struct snd_es1688 *chip) | |||
638 | } | 637 | } |
639 | 638 | ||
640 | int snd_es1688_create(struct snd_card *card, | 639 | int snd_es1688_create(struct snd_card *card, |
640 | struct snd_es1688 *chip, | ||
641 | unsigned long port, | 641 | unsigned long port, |
642 | unsigned long mpu_port, | 642 | unsigned long mpu_port, |
643 | int irq, | 643 | int irq, |
644 | int mpu_irq, | 644 | int mpu_irq, |
645 | int dma8, | 645 | int dma8, |
646 | unsigned short hardware, | 646 | unsigned short hardware) |
647 | struct snd_es1688 **rchip) | ||
648 | { | 647 | { |
649 | static struct snd_device_ops ops = { | 648 | static struct snd_device_ops ops = { |
650 | .dev_free = snd_es1688_dev_free, | 649 | .dev_free = snd_es1688_dev_free, |
651 | }; | 650 | }; |
652 | 651 | ||
653 | struct snd_es1688 *chip; | ||
654 | int err; | 652 | int err; |
655 | 653 | ||
656 | *rchip = NULL; | ||
657 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | ||
658 | if (chip == NULL) | 654 | if (chip == NULL) |
659 | return -ENOMEM; | 655 | return -ENOMEM; |
660 | chip->irq = -1; | 656 | chip->irq = -1; |
@@ -662,25 +658,21 @@ int snd_es1688_create(struct snd_card *card, | |||
662 | 658 | ||
663 | if ((chip->res_port = request_region(port + 4, 12, "ES1688")) == NULL) { | 659 | if ((chip->res_port = request_region(port + 4, 12, "ES1688")) == NULL) { |
664 | snd_printk(KERN_ERR "es1688: can't grab port 0x%lx\n", port + 4); | 660 | snd_printk(KERN_ERR "es1688: can't grab port 0x%lx\n", port + 4); |
665 | snd_es1688_free(chip); | ||
666 | return -EBUSY; | 661 | return -EBUSY; |
667 | } | 662 | } |
668 | if (request_irq(irq, snd_es1688_interrupt, IRQF_DISABLED, "ES1688", (void *) chip)) { | 663 | if (request_irq(irq, snd_es1688_interrupt, IRQF_DISABLED, "ES1688", (void *) chip)) { |
669 | snd_printk(KERN_ERR "es1688: can't grab IRQ %d\n", irq); | 664 | snd_printk(KERN_ERR "es1688: can't grab IRQ %d\n", irq); |
670 | snd_es1688_free(chip); | ||
671 | return -EBUSY; | 665 | return -EBUSY; |
672 | } | 666 | } |
673 | chip->irq = irq; | 667 | chip->irq = irq; |
674 | if (request_dma(dma8, "ES1688")) { | 668 | if (request_dma(dma8, "ES1688")) { |
675 | snd_printk(KERN_ERR "es1688: can't grab DMA8 %d\n", dma8); | 669 | snd_printk(KERN_ERR "es1688: can't grab DMA8 %d\n", dma8); |
676 | snd_es1688_free(chip); | ||
677 | return -EBUSY; | 670 | return -EBUSY; |
678 | } | 671 | } |
679 | chip->dma8 = dma8; | 672 | chip->dma8 = dma8; |
680 | 673 | ||
681 | spin_lock_init(&chip->reg_lock); | 674 | spin_lock_init(&chip->reg_lock); |
682 | spin_lock_init(&chip->mixer_lock); | 675 | spin_lock_init(&chip->mixer_lock); |
683 | chip->card = card; | ||
684 | chip->port = port; | 676 | chip->port = port; |
685 | mpu_port &= ~0x000f; | 677 | mpu_port &= ~0x000f; |
686 | if (mpu_port < 0x300 || mpu_port > 0x330) | 678 | if (mpu_port < 0x300 || mpu_port > 0x330) |
@@ -689,23 +681,16 @@ int snd_es1688_create(struct snd_card *card, | |||
689 | chip->mpu_irq = mpu_irq; | 681 | chip->mpu_irq = mpu_irq; |
690 | chip->hardware = hardware; | 682 | chip->hardware = hardware; |
691 | 683 | ||
692 | if ((err = snd_es1688_probe(chip)) < 0) { | 684 | err = snd_es1688_probe(chip); |
693 | snd_es1688_free(chip); | 685 | if (err < 0) |
694 | return err; | 686 | return err; |
695 | } | ||
696 | if ((err = snd_es1688_init(chip, 1)) < 0) { | ||
697 | snd_es1688_free(chip); | ||
698 | return err; | ||
699 | } | ||
700 | 687 | ||
701 | /* Register device */ | 688 | err = snd_es1688_init(chip, 1); |
702 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { | 689 | if (err < 0) |
703 | snd_es1688_free(chip); | ||
704 | return err; | 690 | return err; |
705 | } | ||
706 | 691 | ||
707 | *rchip = chip; | 692 | /* Register device */ |
708 | return 0; | 693 | return snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); |
709 | } | 694 | } |
710 | 695 | ||
711 | static struct snd_pcm_ops snd_es1688_playback_ops = { | 696 | static struct snd_pcm_ops snd_es1688_playback_ops = { |
@@ -730,12 +715,14 @@ static struct snd_pcm_ops snd_es1688_capture_ops = { | |||
730 | .pointer = snd_es1688_capture_pointer, | 715 | .pointer = snd_es1688_capture_pointer, |
731 | }; | 716 | }; |
732 | 717 | ||
733 | int snd_es1688_pcm(struct snd_es1688 * chip, int device, struct snd_pcm ** rpcm) | 718 | int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, |
719 | int device, struct snd_pcm **rpcm) | ||
734 | { | 720 | { |
735 | struct snd_pcm *pcm; | 721 | struct snd_pcm *pcm; |
736 | int err; | 722 | int err; |
737 | 723 | ||
738 | if ((err = snd_pcm_new(chip->card, "ESx688", device, 1, 1, &pcm)) < 0) | 724 | err = snd_pcm_new(card, "ESx688", device, 1, 1, &pcm); |
725 | if (err < 0) | ||
739 | return err; | 726 | return err; |
740 | 727 | ||
741 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_es1688_playback_ops); | 728 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_es1688_playback_ops); |
@@ -1009,18 +996,15 @@ static unsigned char snd_es1688_init_table[][2] = { | |||
1009 | { ES1688_REC_DEV, 0x17 } | 996 | { ES1688_REC_DEV, 0x17 } |
1010 | }; | 997 | }; |
1011 | 998 | ||
1012 | int snd_es1688_mixer(struct snd_es1688 *chip) | 999 | int snd_es1688_mixer(struct snd_card *card, struct snd_es1688 *chip) |
1013 | { | 1000 | { |
1014 | struct snd_card *card; | ||
1015 | unsigned int idx; | 1001 | unsigned int idx; |
1016 | int err; | 1002 | int err; |
1017 | unsigned char reg, val; | 1003 | unsigned char reg, val; |
1018 | 1004 | ||
1019 | if (snd_BUG_ON(!chip || !chip->card)) | 1005 | if (snd_BUG_ON(!chip || !card)) |
1020 | return -EINVAL; | 1006 | return -EINVAL; |
1021 | 1007 | ||
1022 | card = chip->card; | ||
1023 | |||
1024 | strcpy(card->mixername, snd_es1688_chip_id(chip)); | 1008 | strcpy(card->mixername, snd_es1688_chip_id(chip)); |
1025 | 1009 | ||
1026 | for (idx = 0; idx < ARRAY_SIZE(snd_es1688_controls); idx++) { | 1010 | for (idx = 0; idx < ARRAY_SIZE(snd_es1688_controls); idx++) { |