sound: sgio2audio: use vmalloc buffer helper functions
Remove this duplicate of snd_pcm_alloc_vmalloc_buffer and use the equivalent core functions instead. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
d20fb5dc07
commit
6cedf8696d
1 changed files with 6 additions and 25 deletions
|
@ -26,7 +26,6 @@
|
|||
#include <linux/delay.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/gfp.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
@ -603,25 +602,14 @@ static int snd_sgio2audio_pcm_close(struct snd_pcm_substream *substream)
|
|||
static int snd_sgio2audio_pcm_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *hw_params)
|
||||
{
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
int size = params_buffer_bytes(hw_params);
|
||||
|
||||
/* alloc virtual 'dma' area */
|
||||
if (runtime->dma_area)
|
||||
vfree(runtime->dma_area);
|
||||
runtime->dma_area = vmalloc_user(size);
|
||||
if (runtime->dma_area == NULL)
|
||||
return -ENOMEM;
|
||||
runtime->dma_bytes = size;
|
||||
return 0;
|
||||
return snd_pcm_lib_alloc_vmalloc_buffer(substream,
|
||||
params_buffer_bytes(hw_params));
|
||||
}
|
||||
|
||||
/* hw_free callback */
|
||||
static int snd_sgio2audio_pcm_hw_free(struct snd_pcm_substream *substream)
|
||||
{
|
||||
vfree(substream->runtime->dma_area);
|
||||
substream->runtime->dma_area = NULL;
|
||||
return 0;
|
||||
return snd_pcm_lib_free_vmalloc_buffer(substream);
|
||||
}
|
||||
|
||||
/* prepare callback */
|
||||
|
@ -692,13 +680,6 @@ snd_sgio2audio_pcm_pointer(struct snd_pcm_substream *substream)
|
|||
chip->channel[chan->idx].pos);
|
||||
}
|
||||
|
||||
/* get the physical page pointer on the given offset */
|
||||
static struct page *snd_sgio2audio_page(struct snd_pcm_substream *substream,
|
||||
unsigned long offset)
|
||||
{
|
||||
return vmalloc_to_page(substream->runtime->dma_area + offset);
|
||||
}
|
||||
|
||||
/* operators */
|
||||
static struct snd_pcm_ops snd_sgio2audio_playback1_ops = {
|
||||
.open = snd_sgio2audio_playback1_open,
|
||||
|
@ -709,7 +690,7 @@ static struct snd_pcm_ops snd_sgio2audio_playback1_ops = {
|
|||
.prepare = snd_sgio2audio_pcm_prepare,
|
||||
.trigger = snd_sgio2audio_pcm_trigger,
|
||||
.pointer = snd_sgio2audio_pcm_pointer,
|
||||
.page = snd_sgio2audio_page,
|
||||
.page = snd_pcm_lib_get_vmalloc_page,
|
||||
};
|
||||
|
||||
static struct snd_pcm_ops snd_sgio2audio_playback2_ops = {
|
||||
|
@ -721,7 +702,7 @@ static struct snd_pcm_ops snd_sgio2audio_playback2_ops = {
|
|||
.prepare = snd_sgio2audio_pcm_prepare,
|
||||
.trigger = snd_sgio2audio_pcm_trigger,
|
||||
.pointer = snd_sgio2audio_pcm_pointer,
|
||||
.page = snd_sgio2audio_page,
|
||||
.page = snd_pcm_lib_get_vmalloc_page,
|
||||
};
|
||||
|
||||
static struct snd_pcm_ops snd_sgio2audio_capture_ops = {
|
||||
|
@ -733,7 +714,7 @@ static struct snd_pcm_ops snd_sgio2audio_capture_ops = {
|
|||
.prepare = snd_sgio2audio_pcm_prepare,
|
||||
.trigger = snd_sgio2audio_pcm_trigger,
|
||||
.pointer = snd_sgio2audio_pcm_pointer,
|
||||
.page = snd_sgio2audio_page,
|
||||
.page = snd_pcm_lib_get_vmalloc_page,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue