aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/cx25821/cx25821-alsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/pci/cx25821/cx25821-alsa.c')
-rw-r--r--drivers/media/pci/cx25821/cx25821-alsa.c79
1 files changed, 26 insertions, 53 deletions
diff --git a/drivers/media/pci/cx25821/cx25821-alsa.c b/drivers/media/pci/cx25821/cx25821-alsa.c
index b3cac75a4891..81361c26c54e 100644
--- a/drivers/media/pci/cx25821/cx25821-alsa.c
+++ b/drivers/media/pci/cx25821/cx25821-alsa.c
@@ -59,7 +59,6 @@ do { \
59 Data type declarations - Can be moded to a header file later 59 Data type declarations - Can be moded to a header file later
60 ****************************************************************************/ 60 ****************************************************************************/
61 61
62static struct snd_card *snd_cx25821_cards[SNDRV_CARDS];
63static int devno; 62static int devno;
64 63
65struct cx25821_audio_buffer { 64struct cx25821_audio_buffer {
@@ -627,34 +626,6 @@ static DEFINE_PCI_DEVICE_TABLE(cx25821_audio_pci_tbl) = {
627MODULE_DEVICE_TABLE(pci, cx25821_audio_pci_tbl); 626MODULE_DEVICE_TABLE(pci, cx25821_audio_pci_tbl);
628 627
629/* 628/*
630 * Not used in the function snd_cx25821_dev_free so removing
631 * from the file.
632 */
633/*
634static int snd_cx25821_free(struct cx25821_audio_dev *chip)
635{
636 if (chip->irq >= 0)
637 free_irq(chip->irq, chip);
638
639 cx25821_dev_unregister(chip->dev);
640 pci_disable_device(chip->pci);
641
642 return 0;
643}
644*/
645
646/*
647 * Component Destructor
648 */
649static void snd_cx25821_dev_free(struct snd_card *card)
650{
651 struct cx25821_audio_dev *chip = card->private_data;
652
653 /* snd_cx25821_free(chip); */
654 snd_card_free(chip->card);
655}
656
657/*
658 * Alsa Constructor - Component probe 629 * Alsa Constructor - Component probe
659 */ 630 */
660static int cx25821_audio_initdev(struct cx25821_dev *dev) 631static int cx25821_audio_initdev(struct cx25821_dev *dev)
@@ -685,7 +656,6 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev)
685 strcpy(card->driver, "cx25821"); 656 strcpy(card->driver, "cx25821");
686 657
687 /* Card "creation" */ 658 /* Card "creation" */
688 card->private_free = snd_cx25821_dev_free;
689 chip = card->private_data; 659 chip = card->private_data;
690 spin_lock_init(&chip->reg_lock); 660 spin_lock_init(&chip->reg_lock);
691 661
@@ -729,8 +699,7 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev)
729 goto error; 699 goto error;
730 } 700 }
731 701
732 snd_cx25821_cards[devno] = card; 702 dev->card = card;
733
734 devno++; 703 devno++;
735 return 0; 704 return 0;
736 705
@@ -742,9 +711,31 @@ error:
742/**************************************************************************** 711/****************************************************************************
743 LINUX MODULE INIT 712 LINUX MODULE INIT
744 ****************************************************************************/ 713 ****************************************************************************/
714
715static int cx25821_alsa_exit_callback(struct device *dev, void *data)
716{
717 struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
718 struct cx25821_dev *cxdev = get_cx25821(v4l2_dev);
719
720 snd_card_free(cxdev->card);
721 return 0;
722}
723
745static void cx25821_audio_fini(void) 724static void cx25821_audio_fini(void)
746{ 725{
747 snd_card_free(snd_cx25821_cards[0]); 726 struct device_driver *drv = driver_find("cx25821", &pci_bus_type);
727 int ret;
728
729 ret = driver_for_each_device(drv, NULL, NULL, cx25821_alsa_exit_callback);
730}
731
732static int cx25821_alsa_init_callback(struct device *dev, void *data)
733{
734 struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
735 struct cx25821_dev *cxdev = get_cx25821(v4l2_dev);
736
737 cx25821_audio_initdev(cxdev);
738 return 0;
748} 739}
749 740
750/* 741/*
@@ -756,29 +747,11 @@ static void cx25821_audio_fini(void)
756 */ 747 */
757static int cx25821_alsa_init(void) 748static int cx25821_alsa_init(void)
758{ 749{
759 struct cx25821_dev *dev = NULL; 750 struct device_driver *drv = driver_find("cx25821", &pci_bus_type);
760 struct list_head *list;
761 751
762 mutex_lock(&cx25821_devlist_mutex); 752 return driver_for_each_device(drv, NULL, NULL, cx25821_alsa_init_callback);
763 list_for_each(list, &cx25821_devlist) {
764 dev = list_entry(list, struct cx25821_dev, devlist);
765 cx25821_audio_initdev(dev);
766 }
767 mutex_unlock(&cx25821_devlist_mutex);
768
769 if (dev == NULL)
770 pr_info("ERROR ALSA: no cx25821 cards found\n");
771
772 return 0;
773 753
774} 754}
775 755
776late_initcall(cx25821_alsa_init); 756late_initcall(cx25821_alsa_init);
777module_exit(cx25821_audio_fini); 757module_exit(cx25821_audio_fini);
778
779/* ----------------------------------------------------------- */
780/*
781 * Local variables:
782 * c-basic-offset: 8
783 * End:
784 */