ALSA: es18xx: Use managed buffer allocation
authorTakashi Iwai <tiwai@suse.de>
Mon, 9 Dec 2019 09:48:45 +0000 (10:48 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 11 Dec 2019 06:25:00 +0000 (07:25 +0100)
Clean up the driver with the new managed buffer allocation API.
The hw_free callback became superfluous and got dropped.

Link: https://lore.kernel.org/r/20191209094943.14984-14-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/isa/es18xx.c

index 01ad15086c4a55969b17244f5857bbfcd6426115..1346447ffe01f91d3473a3c4048a5fb6c17c9c91 100644 (file)
@@ -434,7 +434,7 @@ static int snd_es18xx_playback_hw_params(struct snd_pcm_substream *substream,
                                         struct snd_pcm_hw_params *hw_params)
 {
        struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
-       int shift, err;
+       int shift;
 
        shift = 0;
        if (params_channels(hw_params) == 2)
@@ -453,16 +453,9 @@ static int snd_es18xx_playback_hw_params(struct snd_pcm_substream *substream,
        } else {
                chip->dma1_shift = shift;
        }
-       if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
-               return err;
        return 0;
 }
 
-static int snd_es18xx_pcm_hw_free(struct snd_pcm_substream *substream)
-{
-       return snd_pcm_lib_free_pages(substream);
-}
-
 static int snd_es18xx_playback1_prepare(struct snd_es18xx *chip,
                                        struct snd_pcm_substream *substream)
 {
@@ -543,7 +536,7 @@ static int snd_es18xx_capture_hw_params(struct snd_pcm_substream *substream,
                                        struct snd_pcm_hw_params *hw_params)
 {
        struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
-       int shift, err;
+       int shift;
 
        shift = 0;
        if ((chip->caps & ES18XX_DUPLEX_MONO) &&
@@ -557,8 +550,6 @@ static int snd_es18xx_capture_hw_params(struct snd_pcm_substream *substream,
        if (snd_pcm_format_width(params_format(hw_params)) == 16)
                shift++;
        chip->dma1_shift = shift;
-       if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
-               return err;
        return 0;
 }
 
@@ -915,7 +906,6 @@ static int snd_es18xx_playback_close(struct snd_pcm_substream *substream)
        else
                chip->playback_b_substream = NULL;
        
-       snd_pcm_lib_free_pages(substream);
        return 0;
 }
 
@@ -924,7 +914,6 @@ static int snd_es18xx_capture_close(struct snd_pcm_substream *substream)
         struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
 
         chip->capture_a_substream = NULL;
-       snd_pcm_lib_free_pages(substream);
         return 0;
 }
 
@@ -1656,7 +1645,6 @@ static const struct snd_pcm_ops snd_es18xx_playback_ops = {
        .close =        snd_es18xx_playback_close,
        .ioctl =        snd_pcm_lib_ioctl,
        .hw_params =    snd_es18xx_playback_hw_params,
-       .hw_free =      snd_es18xx_pcm_hw_free,
        .prepare =      snd_es18xx_playback_prepare,
        .trigger =      snd_es18xx_playback_trigger,
        .pointer =      snd_es18xx_playback_pointer,
@@ -1667,7 +1655,6 @@ static const struct snd_pcm_ops snd_es18xx_capture_ops = {
        .close =        snd_es18xx_capture_close,
        .ioctl =        snd_pcm_lib_ioctl,
        .hw_params =    snd_es18xx_capture_hw_params,
-       .hw_free =      snd_es18xx_pcm_hw_free,
        .prepare =      snd_es18xx_capture_prepare,
        .trigger =      snd_es18xx_capture_trigger,
        .pointer =      snd_es18xx_capture_pointer,
@@ -1701,10 +1688,9 @@ static int snd_es18xx_pcm(struct snd_card *card, int device)
        sprintf(pcm->name, "ESS AudioDrive ES%x", chip->version);
         chip->pcm = pcm;
 
-       snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
-                                             card->dev,
-                                             64*1024,
-                                             chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
+       snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev,
+                                      64*1024,
+                                      chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
        return 0;
 }