[for-5.6,05/23] ASoC: meson: Use managed buffer allocation
diff mbox series

Message ID 20191210142614.19405-6-tiwai@suse.de
State Accepted
Commit bace3caa82e1f0b5b667e35b532534b9cbdc4338
Headers show
Series
  • ASoC: PCM API updates (part I)
Related show

Commit Message

Takashi Iwai Dec. 10, 2019, 2:25 p.m. UTC
Clean up the driver with the new managed buffer allocation API.
The superfluous snd_pcm_lib_malloc_pages() and
snd_pcm_lib_free_pages() calls are dropped.

Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/meson/axg-fifo.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Jerome Brunet Dec. 11, 2019, 9:49 a.m. UTC | #1
On Tue 10 Dec 2019 at 15:25, Takashi Iwai <tiwai@suse.de> wrote:

> Clean up the driver with the new managed buffer allocation API.
> The superfluous snd_pcm_lib_malloc_pages() and
> snd_pcm_lib_free_pages() calls are dropped.
>
> Cc: Jerome Brunet <jbrunet@baylibre.com>

Thanks Takashi !
Acked-by: Jerome Brunet <jbrunet@baylibre.com>

> Cc: Kevin Hilman <khilman@baylibre.com>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
>  sound/soc/meson/axg-fifo.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c
> index d6f3eefb8f09..772eda857019 100644
> --- a/sound/soc/meson/axg-fifo.c
> +++ b/sound/soc/meson/axg-fifo.c
> @@ -115,11 +115,6 @@ int axg_fifo_pcm_hw_params(struct snd_soc_component *component,
>  	struct axg_fifo *fifo = axg_fifo_data(ss);
>  	dma_addr_t end_ptr;
>  	unsigned int burst_num;
> -	int ret;
> -
> -	ret = snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(params));
> -	if (ret < 0)
> -		return ret;
>  
>  	/* Setup dma memory pointers */
>  	end_ptr = runtime->dma_addr + runtime->dma_bytes - AXG_FIFO_BURST;
> @@ -167,7 +162,7 @@ int axg_fifo_pcm_hw_free(struct snd_soc_component *component,
>  	regmap_update_bits(fifo->map, FIFO_CTRL0,
>  			   CTRL0_INT_EN(FIFO_INT_COUNT_REPEAT), 0);
>  
> -	return snd_pcm_lib_free_pages(ss);
> +	return 0;
>  }
>  EXPORT_SYMBOL_GPL(axg_fifo_pcm_hw_free);
>  
> @@ -287,9 +282,9 @@ int axg_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd, unsigned int type)
>  	struct snd_card *card = rtd->card->snd_card;
>  	size_t size = axg_fifo_hw.buffer_bytes_max;
>  
> -	snd_pcm_lib_preallocate_pages(rtd->pcm->streams[type].substream,
> -				      SNDRV_DMA_TYPE_DEV, card->dev,
> -				      size, size);
> +	snd_pcm_set_managed_buffer(rtd->pcm->streams[type].substream,
> +				   SNDRV_DMA_TYPE_DEV, card->dev,
> +				   size, size);
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(axg_fifo_pcm_new);

Patch
diff mbox series

diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c
index d6f3eefb8f09..772eda857019 100644
--- a/sound/soc/meson/axg-fifo.c
+++ b/sound/soc/meson/axg-fifo.c
@@ -115,11 +115,6 @@  int axg_fifo_pcm_hw_params(struct snd_soc_component *component,
 	struct axg_fifo *fifo = axg_fifo_data(ss);
 	dma_addr_t end_ptr;
 	unsigned int burst_num;
-	int ret;
-
-	ret = snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(params));
-	if (ret < 0)
-		return ret;
 
 	/* Setup dma memory pointers */
 	end_ptr = runtime->dma_addr + runtime->dma_bytes - AXG_FIFO_BURST;
@@ -167,7 +162,7 @@  int axg_fifo_pcm_hw_free(struct snd_soc_component *component,
 	regmap_update_bits(fifo->map, FIFO_CTRL0,
 			   CTRL0_INT_EN(FIFO_INT_COUNT_REPEAT), 0);
 
-	return snd_pcm_lib_free_pages(ss);
+	return 0;
 }
 EXPORT_SYMBOL_GPL(axg_fifo_pcm_hw_free);
 
@@ -287,9 +282,9 @@  int axg_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd, unsigned int type)
 	struct snd_card *card = rtd->card->snd_card;
 	size_t size = axg_fifo_hw.buffer_bytes_max;
 
-	snd_pcm_lib_preallocate_pages(rtd->pcm->streams[type].substream,
-				      SNDRV_DMA_TYPE_DEV, card->dev,
-				      size, size);
+	snd_pcm_set_managed_buffer(rtd->pcm->streams[type].substream,
+				   SNDRV_DMA_TYPE_DEV, card->dev,
+				   size, size);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(axg_fifo_pcm_new);