Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b4b2a41 authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Takashi Iwai
Browse files

sound: ua101: use vmalloc buffer helper functions



Remove this duplicate of snd_pcm_alloc_vmalloc_buffer and use the
equivalent core functions instead.

Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent c55675e3
Loading
Loading
Loading
Loading
+7 −45
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/usb.h>
#include <linux/usb.h>
#include <linux/usb/audio.h>
#include <linux/usb/audio.h>
#include <linux/vmalloc.h>
#include <sound/core.h>
#include <sound/core.h>
#include <sound/initval.h>
#include <sound/initval.h>
#include <sound/pcm.h>
#include <sound/pcm.h>
@@ -145,42 +144,6 @@ static struct usb_driver ua101_driver;
static void abort_alsa_playback(struct ua101 *ua);
static void abort_alsa_playback(struct ua101 *ua);
static void abort_alsa_capture(struct ua101 *ua);
static void abort_alsa_capture(struct ua101 *ua);


/* allocate virtual buffer; may be called more than once */
static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs,
					size_t size)
{
	struct snd_pcm_runtime *runtime = subs->runtime;

	if (runtime->dma_area) {
		if (runtime->dma_bytes >= size)
			return 0; /* already large enough */
		vfree(runtime->dma_area);
	}
	runtime->dma_area = vmalloc_user(size);
	if (!runtime->dma_area)
		return -ENOMEM;
	runtime->dma_bytes = size;
	return 0;
}

/* free virtual buffer; may be called more than once */
static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs)
{
	struct snd_pcm_runtime *runtime = subs->runtime;

	vfree(runtime->dma_area);
	runtime->dma_area = NULL;
	return 0;
}

/* get the physical page pointer at the given offset */
static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs,
					     unsigned long offset)
{
	void *pageptr = subs->runtime->dma_area + offset;
	return vmalloc_to_page(pageptr);
}

static const char *usb_error_string(int err)
static const char *usb_error_string(int err)
{
{
	switch (err) {
	switch (err) {
@@ -791,7 +754,7 @@ static int capture_pcm_hw_params(struct snd_pcm_substream *substream,
	if (err < 0)
	if (err < 0)
		return err;
		return err;


	return snd_pcm_alloc_vmalloc_buffer(substream,
	return snd_pcm_lib_alloc_vmalloc_buffer(substream,
						params_buffer_bytes(hw_params));
						params_buffer_bytes(hw_params));
}
}


@@ -809,14 +772,13 @@ static int playback_pcm_hw_params(struct snd_pcm_substream *substream,
	if (err < 0)
	if (err < 0)
		return err;
		return err;


	return snd_pcm_alloc_vmalloc_buffer(substream,
	return snd_pcm_lib_alloc_vmalloc_buffer(substream,
						params_buffer_bytes(hw_params));
						params_buffer_bytes(hw_params));
}
}


static int ua101_pcm_hw_free(struct snd_pcm_substream *substream)
static int ua101_pcm_hw_free(struct snd_pcm_substream *substream)
{
{
	snd_pcm_free_vmalloc_buffer(substream);
	return snd_pcm_lib_free_vmalloc_buffer(substream);
	return 0;
}
}


static int capture_pcm_prepare(struct snd_pcm_substream *substream)
static int capture_pcm_prepare(struct snd_pcm_substream *substream)
@@ -948,7 +910,7 @@ static struct snd_pcm_ops capture_pcm_ops = {
	.prepare = capture_pcm_prepare,
	.prepare = capture_pcm_prepare,
	.trigger = capture_pcm_trigger,
	.trigger = capture_pcm_trigger,
	.pointer = capture_pcm_pointer,
	.pointer = capture_pcm_pointer,
	.page = snd_pcm_get_vmalloc_page,
	.page = snd_pcm_lib_get_vmalloc_page,
};
};


static struct snd_pcm_ops playback_pcm_ops = {
static struct snd_pcm_ops playback_pcm_ops = {
@@ -960,7 +922,7 @@ static struct snd_pcm_ops playback_pcm_ops = {
	.prepare = playback_pcm_prepare,
	.prepare = playback_pcm_prepare,
	.trigger = playback_pcm_trigger,
	.trigger = playback_pcm_trigger,
	.pointer = playback_pcm_pointer,
	.pointer = playback_pcm_pointer,
	.page = snd_pcm_get_vmalloc_page,
	.page = snd_pcm_lib_get_vmalloc_page,
};
};


static const struct uac_format_type_i_discrete_descriptor *
static const struct uac_format_type_i_discrete_descriptor *