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

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

sound: usb-audio: 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 149feef5
Loading
Loading
Loading
Loading
+5 −41
Original line number Original line Diff line number Diff line
@@ -44,7 +44,6 @@
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/string.h>
#include <linux/usb.h>
#include <linux/usb.h>
#include <linux/vmalloc.h>
#include <linux/moduleparam.h>
#include <linux/moduleparam.h>
#include <linux/mutex.h>
#include <linux/mutex.h>
#include <sound/core.h>
#include <sound/core.h>
@@ -735,41 +734,6 @@ static void snd_complete_sync_urb(struct urb *urb)
}
}




/* 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);
}

/* 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;
}


/*
/*
 * unlink active urbs.
 * unlink active urbs.
 */
 */
@@ -1449,7 +1413,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
	unsigned int channels, rate, format;
	unsigned int channels, rate, format;
	int ret, changed;
	int ret, changed;


	ret = snd_pcm_alloc_vmalloc_buffer(substream,
	ret = snd_pcm_lib_alloc_vmalloc_buffer(substream,
					       params_buffer_bytes(hw_params));
					       params_buffer_bytes(hw_params));
	if (ret < 0)
	if (ret < 0)
		return ret;
		return ret;
@@ -1507,7 +1471,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
	subs->period_bytes = 0;
	subs->period_bytes = 0;
	if (!subs->stream->chip->shutdown)
	if (!subs->stream->chip->shutdown)
		release_substream_urbs(subs, 0);
		release_substream_urbs(subs, 0);
	return snd_pcm_free_vmalloc_buffer(substream);
	return snd_pcm_lib_free_vmalloc_buffer(substream);
}
}


/*
/*
@@ -1973,7 +1937,7 @@ static struct snd_pcm_ops snd_usb_playback_ops = {
	.prepare =	snd_usb_pcm_prepare,
	.prepare =	snd_usb_pcm_prepare,
	.trigger =	snd_usb_pcm_playback_trigger,
	.trigger =	snd_usb_pcm_playback_trigger,
	.pointer =	snd_usb_pcm_pointer,
	.pointer =	snd_usb_pcm_pointer,
	.page =		snd_pcm_get_vmalloc_page,
	.page =		snd_pcm_lib_get_vmalloc_page,
};
};


static struct snd_pcm_ops snd_usb_capture_ops = {
static struct snd_pcm_ops snd_usb_capture_ops = {
@@ -1985,7 +1949,7 @@ static struct snd_pcm_ops snd_usb_capture_ops = {
	.prepare =	snd_usb_pcm_prepare,
	.prepare =	snd_usb_pcm_prepare,
	.trigger =	snd_usb_pcm_capture_trigger,
	.trigger =	snd_usb_pcm_capture_trigger,
	.pointer =	snd_usb_pcm_pointer,
	.pointer =	snd_usb_pcm_pointer,
	.page =		snd_pcm_get_vmalloc_page,
	.page =		snd_pcm_lib_get_vmalloc_page,
};
};