aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/qcom
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2016-02-11 07:17:17 -0500
committerMark Brown <broonie@kernel.org>2016-02-19 11:20:18 -0500
commit144a98835d2b4fc8a732628eaa5c98c573d58baf (patch)
tree373bee5843fba54568b20d5ffdb2a835237a6d4f /sound/soc/qcom
parent88a69d7b07747af08f737b160b27503b1400d3b6 (diff)
ASoC: qcom: use snd_dma_alloc/free* apis
There is no point in having local allocation functions when the driver can use snd_dma_alloc/free() apis. This patch replaces the local versions of the dma allocation apis with the snd_dma_alloc/free() apis. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Acked-by: Kenneth Westfield <kwestfie@codeaurora.org> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/qcom')
-rw-r--r--sound/soc/qcom/lpass-platform.c42
1 files changed, 6 insertions, 36 deletions
diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c
index 4aeb8e1a7160..ec2414dc089a 100644
--- a/sound/soc/qcom/lpass-platform.c
+++ b/sound/soc/qcom/lpass-platform.c
@@ -439,39 +439,6 @@ static irqreturn_t lpass_platform_lpaif_irq(int irq, void *data)
439 return IRQ_HANDLED; 439 return IRQ_HANDLED;
440} 440}
441 441
442static int lpass_platform_alloc_buffer(struct snd_pcm_substream *substream,
443 struct snd_soc_pcm_runtime *rt)
444{
445 struct snd_dma_buffer *buf = &substream->dma_buffer;
446 size_t size = lpass_platform_pcm_hardware.buffer_bytes_max;
447
448 buf->dev.type = SNDRV_DMA_TYPE_DEV;
449 buf->dev.dev = rt->platform->dev;
450 buf->private_data = NULL;
451 buf->area = dma_alloc_coherent(rt->platform->dev, size, &buf->addr,
452 GFP_KERNEL);
453 if (!buf->area) {
454 dev_err(rt->platform->dev, "%s: Could not allocate DMA buffer\n",
455 __func__);
456 return -ENOMEM;
457 }
458 buf->bytes = size;
459
460 return 0;
461}
462
463static void lpass_platform_free_buffer(struct snd_pcm_substream *substream,
464 struct snd_soc_pcm_runtime *rt)
465{
466 struct snd_dma_buffer *buf = &substream->dma_buffer;
467
468 if (buf->area) {
469 dma_free_coherent(rt->dev, buf->bytes, buf->area,
470 buf->addr);
471 }
472 buf->area = NULL;
473}
474
475static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime) 442static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime)
476{ 443{
477 struct snd_pcm *pcm = soc_runtime->pcm; 444 struct snd_pcm *pcm = soc_runtime->pcm;
@@ -483,6 +450,7 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime)
483 struct lpass_variant *v = drvdata->variant; 450 struct lpass_variant *v = drvdata->variant;
484 int ret; 451 int ret;
485 struct lpass_pcm_data *data; 452 struct lpass_pcm_data *data;
453 size_t size = lpass_platform_pcm_hardware.buffer_bytes_max;
486 454
487 data = devm_kzalloc(soc_runtime->dev, sizeof(*data), GFP_KERNEL); 455 data = devm_kzalloc(soc_runtime->dev, sizeof(*data), GFP_KERNEL);
488 if (!data) 456 if (!data)
@@ -499,7 +467,9 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime)
499 467
500 snd_soc_pcm_set_drvdata(soc_runtime, data); 468 snd_soc_pcm_set_drvdata(soc_runtime, data);
501 469
502 ret = lpass_platform_alloc_buffer(substream, soc_runtime); 470 ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
471 soc_runtime->platform->dev,
472 size, &substream->dma_buffer);
503 if (ret) 473 if (ret)
504 return ret; 474 return ret;
505 475
@@ -514,7 +484,7 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime)
514 return 0; 484 return 0;
515 485
516err_buf: 486err_buf:
517 lpass_platform_free_buffer(substream, soc_runtime); 487 snd_dma_free_pages(&substream->dma_buffer);
518 return ret; 488 return ret;
519} 489}
520 490
@@ -533,7 +503,7 @@ static void lpass_platform_pcm_free(struct snd_pcm *pcm)
533 if (v->free_dma_channel) 503 if (v->free_dma_channel)
534 v->free_dma_channel(drvdata, data->rdma_ch); 504 v->free_dma_channel(drvdata, data->rdma_ch);
535 505
536 lpass_platform_free_buffer(substream, soc_runtime); 506 snd_dma_free_pages(&substream->dma_buffer);
537} 507}
538 508
539static struct snd_soc_platform_driver lpass_platform_driver = { 509static struct snd_soc_platform_driver lpass_platform_driver = {