Skip to content

Commit

Permalink
ASoC: nuc900: No need to track the dma buffer in the driver state struct
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lars-Peter Clausen authored and Mark Brown committed Mar 16, 2015
1 parent c517d83 commit fa41181
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 29 deletions.
3 changes: 0 additions & 3 deletions sound/soc/nuc900/nuc900-audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@
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;
Expand Down
31 changes: 5 additions & 26 deletions sound/soc/nuc900/nuc900-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit fa41181

Please sign in to comment.