|
@@ -59,7 +59,6 @@ do { \
|
|
|
Data type declarations - Can be moded to a header file later
|
|
|
****************************************************************************/
|
|
|
|
|
|
-static struct snd_card *snd_cx25821_cards[SNDRV_CARDS];
|
|
|
static int devno;
|
|
|
|
|
|
struct cx25821_audio_buffer {
|
|
@@ -626,34 +625,6 @@ static DEFINE_PCI_DEVICE_TABLE(cx25821_audio_pci_tbl) = {
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, cx25821_audio_pci_tbl);
|
|
|
|
|
|
-/*
|
|
|
- * Not used in the function snd_cx25821_dev_free so removing
|
|
|
- * from the file.
|
|
|
- */
|
|
|
-/*
|
|
|
-static int snd_cx25821_free(struct cx25821_audio_dev *chip)
|
|
|
-{
|
|
|
- if (chip->irq >= 0)
|
|
|
- free_irq(chip->irq, chip);
|
|
|
-
|
|
|
- cx25821_dev_unregister(chip->dev);
|
|
|
- pci_disable_device(chip->pci);
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-*/
|
|
|
-
|
|
|
-/*
|
|
|
- * Component Destructor
|
|
|
- */
|
|
|
-static void snd_cx25821_dev_free(struct snd_card *card)
|
|
|
-{
|
|
|
- struct cx25821_audio_dev *chip = card->private_data;
|
|
|
-
|
|
|
- /* snd_cx25821_free(chip); */
|
|
|
- snd_card_free(chip->card);
|
|
|
-}
|
|
|
-
|
|
|
/*
|
|
|
* Alsa Constructor - Component probe
|
|
|
*/
|
|
@@ -685,7 +656,6 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev)
|
|
|
strcpy(card->driver, "cx25821");
|
|
|
|
|
|
/* Card "creation" */
|
|
|
- card->private_free = snd_cx25821_dev_free;
|
|
|
chip = card->private_data;
|
|
|
spin_lock_init(&chip->reg_lock);
|
|
|
|
|
@@ -729,8 +699,7 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev)
|
|
|
goto error;
|
|
|
}
|
|
|
|
|
|
- snd_cx25821_cards[devno] = card;
|
|
|
-
|
|
|
+ dev->card = card;
|
|
|
devno++;
|
|
|
return 0;
|
|
|
|
|
@@ -742,9 +711,31 @@ error:
|
|
|
/****************************************************************************
|
|
|
LINUX MODULE INIT
|
|
|
****************************************************************************/
|
|
|
+
|
|
|
+static int cx25821_alsa_exit_callback(struct device *dev, void *data)
|
|
|
+{
|
|
|
+ struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
|
|
|
+ struct cx25821_dev *cxdev = get_cx25821(v4l2_dev);
|
|
|
+
|
|
|
+ snd_card_free(cxdev->card);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
static void cx25821_audio_fini(void)
|
|
|
{
|
|
|
- snd_card_free(snd_cx25821_cards[0]);
|
|
|
+ struct device_driver *drv = driver_find("cx25821", &pci_bus_type);
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ ret = driver_for_each_device(drv, NULL, NULL, cx25821_alsa_exit_callback);
|
|
|
+}
|
|
|
+
|
|
|
+static int cx25821_alsa_init_callback(struct device *dev, void *data)
|
|
|
+{
|
|
|
+ struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
|
|
|
+ struct cx25821_dev *cxdev = get_cx25821(v4l2_dev);
|
|
|
+
|
|
|
+ cx25821_audio_initdev(cxdev);
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -756,29 +747,11 @@ static void cx25821_audio_fini(void)
|
|
|
*/
|
|
|
static int cx25821_alsa_init(void)
|
|
|
{
|
|
|
- struct cx25821_dev *dev = NULL;
|
|
|
- struct list_head *list;
|
|
|
+ struct device_driver *drv = driver_find("cx25821", &pci_bus_type);
|
|
|
|
|
|
- mutex_lock(&cx25821_devlist_mutex);
|
|
|
- list_for_each(list, &cx25821_devlist) {
|
|
|
- dev = list_entry(list, struct cx25821_dev, devlist);
|
|
|
- cx25821_audio_initdev(dev);
|
|
|
- }
|
|
|
- mutex_unlock(&cx25821_devlist_mutex);
|
|
|
-
|
|
|
- if (dev == NULL)
|
|
|
- pr_info("ERROR ALSA: no cx25821 cards found\n");
|
|
|
-
|
|
|
- return 0;
|
|
|
+ return driver_for_each_device(drv, NULL, NULL, cx25821_alsa_init_callback);
|
|
|
|
|
|
}
|
|
|
|
|
|
late_initcall(cx25821_alsa_init);
|
|
|
module_exit(cx25821_audio_fini);
|
|
|
-
|
|
|
-/* ----------------------------------------------------------- */
|
|
|
-/*
|
|
|
- * Local variables:
|
|
|
- * c-basic-offset: 8
|
|
|
- * End:
|
|
|
- */
|