saa7134-alsa: Only frees registered sound cards
[pandora-kernel.git] / drivers / media / video / saa7134 / saa7134-alsa.c
index 5bca2ab..11b0ef3 100644 (file)
@@ -172,7 +172,9 @@ static void saa7134_irq_alsa_done(struct saa7134_dev *dev,
                dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count,
                        dev->dmasound.bufsize, dev->dmasound.blocks);
                spin_unlock(&dev->slock);
+               snd_pcm_stream_lock(dev->dmasound.substream);
                snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN);
+               snd_pcm_stream_unlock(dev->dmasound.substream);
                return;
        }
 
@@ -669,7 +671,7 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
           byte, but it doesn't work. So I allocate the DMA using the
           V4L functions, and force ALSA to use that as the DMA area */
 
-       substream->runtime->dma_area = dev->dmasound.dma.vmalloc;
+       substream->runtime->dma_area = dev->dmasound.dma.vaddr;
        substream->runtime->dma_bytes = dev->dmasound.bufsize;
        substream->runtime->dma_addr = 0;
 
@@ -1080,7 +1082,7 @@ static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
        /* Card "creation" */
 
        card->private_free = snd_saa7134_free;
-       chip = (snd_card_saa7134_t *) card->private_data;
+       chip = card->private_data;
 
        spin_lock_init(&chip->lock);
        spin_lock_init(&chip->mixer_lock);
@@ -1143,6 +1145,8 @@ static int alsa_device_init(struct saa7134_dev *dev)
 
 static int alsa_device_exit(struct saa7134_dev *dev)
 {
+       if (!snd_saa7134_cards[dev->nr])
+               return 1;
 
        snd_card_free(snd_saa7134_cards[dev->nr]);
        snd_saa7134_cards[dev->nr] = NULL;
@@ -1192,7 +1196,8 @@ static void saa7134_alsa_exit(void)
        int idx;
 
        for (idx = 0; idx < SNDRV_CARDS; idx++) {
-               snd_card_free(snd_saa7134_cards[idx]);
+               if (snd_saa7134_cards[idx])
+                       snd_card_free(snd_saa7134_cards[idx]);
        }
 
        saa7134_dmasound_init = NULL;