diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2009-12-18 03:31:31 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-12-18 06:58:14 -0500 |
commit | c55675e348d9630c1ca69a190529bed1108c649d (patch) | |
tree | d5429d11c35220bf0442ada0213e9676b716cfea /sound/usb | |
parent | 149feef54bf543448dd4ec5820ef8ae178021c3a (diff) |
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: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/usbaudio.c | 46 |
1 files changed, 5 insertions, 41 deletions
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index af8869a8a79..31b63ea098b 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -44,7 +44,6 @@ | |||
44 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
45 | #include <linux/string.h> | 45 | #include <linux/string.h> |
46 | #include <linux/usb.h> | 46 | #include <linux/usb.h> |
47 | #include <linux/vmalloc.h> | ||
48 | #include <linux/moduleparam.h> | 47 | #include <linux/moduleparam.h> |
49 | #include <linux/mutex.h> | 48 | #include <linux/mutex.h> |
50 | #include <sound/core.h> | 49 | #include <sound/core.h> |
@@ -735,41 +734,6 @@ static void snd_complete_sync_urb(struct urb *urb) | |||
735 | } | 734 | } |
736 | 735 | ||
737 | 736 | ||
738 | /* get the physical page pointer at the given offset */ | ||
739 | static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, | ||
740 | unsigned long offset) | ||
741 | { | ||
742 | void *pageptr = subs->runtime->dma_area + offset; | ||
743 | return vmalloc_to_page(pageptr); | ||
744 | } | ||
745 | |||
746 | /* allocate virtual buffer; may be called more than once */ | ||
747 | static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) | ||
748 | { | ||
749 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
750 | if (runtime->dma_area) { | ||
751 | if (runtime->dma_bytes >= size) | ||
752 | return 0; /* already large enough */ | ||
753 | vfree(runtime->dma_area); | ||
754 | } | ||
755 | runtime->dma_area = vmalloc_user(size); | ||
756 | if (!runtime->dma_area) | ||
757 | return -ENOMEM; | ||
758 | runtime->dma_bytes = size; | ||
759 | return 0; | ||
760 | } | ||
761 | |||
762 | /* free virtual buffer; may be called more than once */ | ||
763 | static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) | ||
764 | { | ||
765 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
766 | |||
767 | vfree(runtime->dma_area); | ||
768 | runtime->dma_area = NULL; | ||
769 | return 0; | ||
770 | } | ||
771 | |||
772 | |||
773 | /* | 737 | /* |
774 | * unlink active urbs. | 738 | * unlink active urbs. |
775 | */ | 739 | */ |
@@ -1449,8 +1413,8 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream, | |||
1449 | unsigned int channels, rate, format; | 1413 | unsigned int channels, rate, format; |
1450 | int ret, changed; | 1414 | int ret, changed; |
1451 | 1415 | ||
1452 | ret = snd_pcm_alloc_vmalloc_buffer(substream, | 1416 | ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, |
1453 | params_buffer_bytes(hw_params)); | 1417 | params_buffer_bytes(hw_params)); |
1454 | if (ret < 0) | 1418 | if (ret < 0) |
1455 | return ret; | 1419 | return ret; |
1456 | 1420 | ||
@@ -1507,7 +1471,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) | |||
1507 | subs->period_bytes = 0; | 1471 | subs->period_bytes = 0; |
1508 | if (!subs->stream->chip->shutdown) | 1472 | if (!subs->stream->chip->shutdown) |
1509 | release_substream_urbs(subs, 0); | 1473 | release_substream_urbs(subs, 0); |
1510 | return snd_pcm_free_vmalloc_buffer(substream); | 1474 | return snd_pcm_lib_free_vmalloc_buffer(substream); |
1511 | } | 1475 | } |
1512 | 1476 | ||
1513 | /* | 1477 | /* |
@@ -1973,7 +1937,7 @@ static struct snd_pcm_ops snd_usb_playback_ops = { | |||
1973 | .prepare = snd_usb_pcm_prepare, | 1937 | .prepare = snd_usb_pcm_prepare, |
1974 | .trigger = snd_usb_pcm_playback_trigger, | 1938 | .trigger = snd_usb_pcm_playback_trigger, |
1975 | .pointer = snd_usb_pcm_pointer, | 1939 | .pointer = snd_usb_pcm_pointer, |
1976 | .page = snd_pcm_get_vmalloc_page, | 1940 | .page = snd_pcm_lib_get_vmalloc_page, |
1977 | }; | 1941 | }; |
1978 | 1942 | ||
1979 | static struct snd_pcm_ops snd_usb_capture_ops = { | 1943 | static struct snd_pcm_ops snd_usb_capture_ops = { |
@@ -1985,7 +1949,7 @@ static struct snd_pcm_ops snd_usb_capture_ops = { | |||
1985 | .prepare = snd_usb_pcm_prepare, | 1949 | .prepare = snd_usb_pcm_prepare, |
1986 | .trigger = snd_usb_pcm_capture_trigger, | 1950 | .trigger = snd_usb_pcm_capture_trigger, |
1987 | .pointer = snd_usb_pcm_pointer, | 1951 | .pointer = snd_usb_pcm_pointer, |
1988 | .page = snd_pcm_get_vmalloc_page, | 1952 | .page = snd_pcm_lib_get_vmalloc_page, |
1989 | }; | 1953 | }; |
1990 | 1954 | ||
1991 | 1955 | ||