ASoC: nuc900: No need to track the dma buffer in the driver state struct
authorLars-Peter Clausen <lars@metafoo.de>
Sun, 15 Mar 2015 11:15:24 +0000 (12:15 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 16 Mar 2015 11:40:52 +0000 (11:40 +0000)
The DMA buffer and address can be accessed through the snd_pcm_runtime.
There is no need to manually track them in the driver's state struct.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/nuc900/nuc900-audio.h
sound/soc/nuc900/nuc900-pcm.c

index 59f7e8ed1a6898937e3472016bce5e4bdc11e3de..d0b725705914a1e8935a1276250193c8439a60d9 100644 (file)
 struct nuc900_audio {
        void __iomem *mmio;
        spinlock_t lock;
-       dma_addr_t dma_addr[2];
-       unsigned long buffersize[2];
        unsigned long irq_num;
-       struct snd_pcm_substream *substream;
        struct resource *res;
        struct clk *clk;
        struct device *dev;
index b809fa909e4d6d6f91a78bdf5e9cda0e7f9c2fa8..5ae5ca15b6d6bf109b20a236f69f1b6a2900bd7a 100644 (file)
@@ -42,29 +42,10 @@ static const struct snd_pcm_hardware nuc900_pcm_hardware = {
 static int nuc900_dma_hw_params(struct snd_pcm_substream *substream,
        struct snd_pcm_hw_params *params)
 {
-       struct snd_pcm_runtime *runtime = substream->runtime;
-       struct nuc900_audio *nuc900_audio = runtime->private_data;
-       unsigned long flags;
-       int ret = 0;
-
-       ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
-       if (ret < 0)
-               return ret;
-
-       spin_lock_irqsave(&nuc900_audio->lock, flags);
-
-       nuc900_audio->substream = substream;
-       nuc900_audio->dma_addr[substream->stream] = runtime->dma_addr;
-       nuc900_audio->buffersize[substream->stream] =
-                                               params_buffer_bytes(params);
-
-       spin_unlock_irqrestore(&nuc900_audio->lock, flags);
-
-       return ret;
+       return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
 }
 
-static void nuc900_update_dma_register(struct snd_pcm_substream *substream,
-                               dma_addr_t dma_addr, size_t count)
+static void nuc900_update_dma_register(struct snd_pcm_substream *substream)
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct nuc900_audio *nuc900_audio = runtime->private_data;
@@ -78,8 +59,8 @@ static void nuc900_update_dma_register(struct snd_pcm_substream *substream,
                mmio_len = nuc900_audio->mmio + ACTL_RDST_LENGTH;
        }
 
-       AUDIO_WRITE(mmio_addr, dma_addr);
-       AUDIO_WRITE(mmio_len, count);
+       AUDIO_WRITE(mmio_addr, runtime->dma_addr);
+       AUDIO_WRITE(mmio_len, runtime->dma_bytes);
 }
 
 static void nuc900_dma_start(struct snd_pcm_substream *substream)
@@ -170,9 +151,7 @@ static int nuc900_dma_prepare(struct snd_pcm_substream *substream)
 
        spin_lock_irqsave(&nuc900_audio->lock, flags);
 
-       nuc900_update_dma_register(substream,
-                               nuc900_audio->dma_addr[substream->stream],
-                               nuc900_audio->buffersize[substream->stream]);
+       nuc900_update_dma_register(substream);
 
        val = AUDIO_READ(nuc900_audio->mmio + ACTL_RESET);