From 37b9b9a5078aa2efe2131d7b0084ebd4192fb1f5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:35 +0100 Subject: [PATCH] ALSA: atmel: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-4-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/atmel/ac97c.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index eef7ec7..44507e4 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -159,12 +159,6 @@ static int atmel_ac97c_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); - int retval; - - retval = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (retval < 0) - return retval; /* Set restrictions to params. */ mutex_lock(&opened_mutex); @@ -172,19 +166,13 @@ static int atmel_ac97c_playback_hw_params(struct snd_pcm_substream *substream, chip->cur_format = params_format(hw_params); mutex_unlock(&opened_mutex); - return retval; + return 0; } static int atmel_ac97c_capture_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); - int retval; - - retval = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (retval < 0) - return retval; /* Set restrictions to params. */ mutex_lock(&opened_mutex); @@ -192,7 +180,7 @@ static int atmel_ac97c_capture_hw_params(struct snd_pcm_substream *substream, chip->cur_format = params_format(hw_params); mutex_unlock(&opened_mutex); - return retval; + return 0; } static int atmel_ac97c_playback_prepare(struct snd_pcm_substream *substream) @@ -461,7 +449,6 @@ static const struct snd_pcm_ops atmel_ac97_playback_ops = { .close = atmel_ac97c_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = atmel_ac97c_playback_hw_params, - .hw_free = snd_pcm_lib_free_pages, .prepare = atmel_ac97c_playback_prepare, .trigger = atmel_ac97c_playback_trigger, .pointer = atmel_ac97c_playback_pointer, @@ -472,7 +459,6 @@ static const struct snd_pcm_ops atmel_ac97_capture_ops = { .close = atmel_ac97c_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = atmel_ac97c_capture_hw_params, - .hw_free = snd_pcm_lib_free_pages, .prepare = atmel_ac97c_capture_prepare, .trigger = atmel_ac97c_capture_trigger, .pointer = atmel_ac97c_capture_pointer, @@ -600,7 +586,7 @@ static int atmel_ac97c_pcm_new(struct atmel_ac97c *chip) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &atmel_ac97_capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &atmel_ac97_playback_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pdev->dev, hw.periods_min * hw.period_bytes_min, hw.buffer_bytes_max); -- 2.7.4