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

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

index cfbb8ca..0bb5a0f 100644 (file)
@@ -378,7 +378,6 @@ static int snd_als300_playback_close(struct snd_pcm_substream *substream)
        data = substream->runtime->private_data;
        kfree(data);
        chip->playback_substream = NULL;
-       snd_pcm_lib_free_pages(substream);
        return 0;
 }
 
@@ -407,22 +406,9 @@ static int snd_als300_capture_close(struct snd_pcm_substream *substream)
        data = substream->runtime->private_data;
        kfree(data);
        chip->capture_substream = NULL;
-       snd_pcm_lib_free_pages(substream);
        return 0;
 }
 
-static int snd_als300_pcm_hw_params(struct snd_pcm_substream *substream,
-                                   struct snd_pcm_hw_params *hw_params)
-{
-       return snd_pcm_lib_malloc_pages(substream,
-                                       params_buffer_bytes(hw_params));
-}
-
-static int snd_als300_pcm_hw_free(struct snd_pcm_substream *substream)
-{
-       return snd_pcm_lib_free_pages(substream);
-}
-
 static int snd_als300_playback_prepare(struct snd_pcm_substream *substream)
 {
        u32 tmp;
@@ -554,8 +540,6 @@ static const struct snd_pcm_ops snd_als300_playback_ops = {
        .open =         snd_als300_playback_open,
        .close =        snd_als300_playback_close,
        .ioctl =        snd_pcm_lib_ioctl,
-       .hw_params =    snd_als300_pcm_hw_params,
-       .hw_free =      snd_als300_pcm_hw_free,
        .prepare =      snd_als300_playback_prepare,
        .trigger =      snd_als300_trigger,
        .pointer =      snd_als300_pointer,
@@ -565,8 +549,6 @@ static const struct snd_pcm_ops snd_als300_capture_ops = {
        .open =         snd_als300_capture_open,
        .close =        snd_als300_capture_close,
        .ioctl =        snd_pcm_lib_ioctl,
-       .hw_params =    snd_als300_pcm_hw_params,
-       .hw_free =      snd_als300_pcm_hw_free,
        .prepare =      snd_als300_capture_prepare,
        .trigger =      snd_als300_trigger,
        .pointer =      snd_als300_pointer,
@@ -591,9 +573,8 @@ static int snd_als300_new_pcm(struct snd_als300 *chip)
                                &snd_als300_capture_ops);
 
        /* pre-allocation of buffers */
-       snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
-                                             &chip->pci->dev,
-                                             64*1024, 64*1024);
+       snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
+                                      64*1024, 64*1024);
        return 0;
 }