From: Takashi Iwai Date: Fri, 8 Nov 2019 09:46:35 +0000 (+0100) Subject: ASoC: rt5514-spi: Convert to the common vmalloc memalloc X-Git-Tag: 5.5-rc-smb3-fixes-part2~36^2~55 X-Git-Url: http://git.samba.org/samba.git/?p=sfrench%2Fcifs-2.6.git;a=commitdiff_plain;h=26105a6f05709ad7059c91e28005a5c75be24819 ASoC: rt5514-spi: Convert to the common vmalloc memalloc The recent change (*) in the ALSA memalloc core allows us to drop the special vmalloc-specific allocation and page handling. This patch coverts to the common code. (*) 1fe7f397cfe2: ALSA: memalloc: Add vmalloc buffer allocation support 7e8edae39fd1: ALSA: pcm: Handle special page mapping in the default mmap handler Since it requires the specific buffer type (SNDRV_DMA_TYPE_VMALLOC), it's set in the pcm_new ops now. Acked-by: Mark Brown Link: https://lore.kernel.org/r/20191108094641.20086-3-tiwai@suse.de Signed-off-by: Takashi Iwai --- diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 57ff5aee452d..f1b7b947ecbd 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -219,8 +219,7 @@ static int rt5514_spi_hw_params(struct snd_soc_component *component, u8 buf[8]; mutex_lock(&rt5514_dsp->dma_lock); - ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, - params_buffer_bytes(hw_params)); + ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); rt5514_dsp->substream = substream; rt5514_dsp->dma_offset = 0; @@ -246,7 +245,7 @@ static int rt5514_spi_hw_free(struct snd_soc_component *component, cancel_delayed_work_sync(&rt5514_dsp->copy_work); - return snd_pcm_lib_free_vmalloc_buffer(substream); + return snd_pcm_lib_free_pages(substream); } static snd_pcm_uframes_t rt5514_spi_pcm_pointer( @@ -260,12 +259,6 @@ static snd_pcm_uframes_t rt5514_spi_pcm_pointer( return bytes_to_frames(runtime, rt5514_dsp->dma_offset); } -static struct page *rt5514_spi_pcm_page(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - unsigned long offset) -{ - return snd_pcm_lib_get_vmalloc_page(substream, offset); -} static int rt5514_spi_pcm_probe(struct snd_soc_component *component) { @@ -298,6 +291,14 @@ static int rt5514_spi_pcm_probe(struct snd_soc_component *component) return 0; } +static int rt5514_spi_pcm_new(struct snd_soc_component *component, + struct snd_soc_pcm_runtime *rtd) +{ + snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0); + return 0; +} + static const struct snd_soc_component_driver rt5514_spi_component = { .name = DRV_NAME, .probe = rt5514_spi_pcm_probe, @@ -305,7 +306,7 @@ static const struct snd_soc_component_driver rt5514_spi_component = { .hw_params = rt5514_spi_hw_params, .hw_free = rt5514_spi_hw_free, .pointer = rt5514_spi_pcm_pointer, - .page = rt5514_spi_pcm_page, + .pcm_construct = rt5514_spi_pcm_new, }; /**