Skip to content

Commit

Permalink
sound: pdaudiocf: use vmalloc buffer helper functions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cladisch authored and tiwai committed Dec 18, 2009
1 parent 681b84e commit d20fb5d
Showing 1 changed file with 4 additions and 47 deletions.
51 changes: 4 additions & 47 deletions sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,56 +21,12 @@
*/

#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/delay.h>
#include <sound/core.h>
#include <sound/asoundef.h>
#include "pdaudiocf.h"


/*
* we use a vmalloc'ed (sg-)buffer
*/

/* get the physical page pointer on 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);
}

/*
* hw_params callback
* NOTE: this may be called not only once per pcm open!
*/
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 enough large */
vfree(runtime->dma_area);
}
runtime->dma_area = vmalloc_32_user(size);
if (! runtime->dma_area)
return -ENOMEM;
runtime->dma_bytes = size;
return 0;
}

/*
* hw_free callback
* NOTE: this may be called not only once per pcm open!
*/
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;
}

/*
* clear the SRAM contents
*/
Expand Down Expand Up @@ -147,15 +103,16 @@ static int pdacf_pcm_trigger(struct snd_pcm_substream *subs, int cmd)
static int pdacf_pcm_hw_params(struct snd_pcm_substream *subs,
struct snd_pcm_hw_params *hw_params)
{
return snd_pcm_alloc_vmalloc_buffer(subs, params_buffer_bytes(hw_params));
return snd_pcm_lib_alloc_vmalloc_32_buffer
(subs, params_buffer_bytes(hw_params));
}

/*
* pdacf_pcm_hw_free - hw_free callback for playback and capture
*/
static int pdacf_pcm_hw_free(struct snd_pcm_substream *subs)
{
return snd_pcm_free_vmalloc_buffer(subs);
return snd_pcm_lib_free_vmalloc_buffer(subs);
}

/*
Expand Down Expand Up @@ -319,7 +276,7 @@ static struct snd_pcm_ops pdacf_pcm_capture_ops = {
.prepare = pdacf_pcm_prepare,
.trigger = pdacf_pcm_trigger,
.pointer = pdacf_pcm_capture_pointer,
.page = snd_pcm_get_vmalloc_page,
.page = snd_pcm_lib_get_vmalloc_page,
};


Expand Down

0 comments on commit d20fb5d

Please sign in to comment.