ALSA: usx2y: Use managed buffer allocation
authorTakashi Iwai <tiwai@suse.de>
Mon, 9 Dec 2019 09:49:41 +0000 (10:49 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 11 Dec 2019 06:25:24 +0000 (07:25 +0100)
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.

Link: https://lore.kernel.org/r/20191209094943.14984-70-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/usx2y/usbusx2yaudio.c
sound/usb/usx2y/usx2yhwdeppcm.c

index 25a0939..7eb9805 100644 (file)
@@ -764,14 +764,6 @@ static int snd_usX2Y_pcm_hw_params(struct snd_pcm_substream *substream,
                }
        }
 
-       err = snd_pcm_lib_malloc_pages(substream,
-                                      params_buffer_bytes(hw_params));
-       if (err < 0) {
-               snd_printk(KERN_ERR "snd_pcm_lib_malloc_pages(%p, %i) returned %i\n",
-                          substream, params_buffer_bytes(hw_params), err);
-               goto error;
-       }
-
  error:
        mutex_unlock(&usX2Y(card)->pcm_mutex);
        return err;
@@ -806,7 +798,7 @@ static int snd_usX2Y_pcm_hw_free(struct snd_pcm_substream *substream)
                }
        }
        mutex_unlock(&subs->usX2Y->pcm_mutex);
-       return snd_pcm_lib_free_pages(substream);
+       return 0;
 }
 /*
  * prepare callback
@@ -968,16 +960,16 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint,
        sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->pcm_devs);
 
        if (playback_endpoint) {
-               snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
-                                             SNDRV_DMA_TYPE_CONTINUOUS,
-                                             NULL,
-                                             64*1024, 128*1024);
+               snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
+                                          SNDRV_DMA_TYPE_CONTINUOUS,
+                                          NULL,
+                                          64*1024, 128*1024);
        }
 
-       snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
-                                     SNDRV_DMA_TYPE_CONTINUOUS,
-                                     NULL,
-                                     64*1024, 128*1024);
+       snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
+                                  SNDRV_DMA_TYPE_CONTINUOUS,
+                                  NULL,
+                                  64*1024, 128*1024);
        usX2Y(card)->pcm_devs++;
 
        return 0;
index 997493e..419d9f0 100644 (file)
@@ -376,7 +376,7 @@ static int snd_usX2Y_usbpcm_hw_free(struct snd_pcm_substream *substream)
                }
        }
        mutex_unlock(&subs->usX2Y->pcm_mutex);
-       return snd_pcm_lib_free_pages(substream);
+       return 0;
 }
 
 static void usX2Y_usbpcm_subs_startup(struct snd_usX2Y_substream *subs)
@@ -726,14 +726,14 @@ int usX2Y_hwdep_pcm_new(struct snd_card *card)
        pcm->info_flags = 0;
 
        sprintf(pcm->name, NAME_ALLCAPS" hwdep Audio");
-       snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
-                                     SNDRV_DMA_TYPE_CONTINUOUS,
-                                     NULL,
-                                     64*1024, 128*1024);
-       snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
-                                     SNDRV_DMA_TYPE_CONTINUOUS,
-                                     NULL,
-                                     64*1024, 128*1024);
+       snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
+                                  SNDRV_DMA_TYPE_CONTINUOUS,
+                                  NULL,
+                                  64*1024, 128*1024);
+       snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
+                                  SNDRV_DMA_TYPE_CONTINUOUS,
+                                  NULL,
+                                  64*1024, 128*1024);
 
        return 0;
 }