diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2009-12-18 03:32:00 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-12-18 06:58:25 -0500 |
commit | 5b4b2a41a1a80f5560364b7ef001486cd8fb5230 (patch) | |
tree | 8fd89c9cfb6c50d4380b8f99f1c3669092bf4bf7 /sound/usb | |
parent | c55675e348d9630c1ca69a190529bed1108c649d (diff) |
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: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/ua101.c | 52 |
1 files changed, 7 insertions, 45 deletions
diff --git a/sound/usb/ua101.c b/sound/usb/ua101.c index ab9f8a2e1938..16dc7bd5e120 100644 --- a/sound/usb/ua101.c +++ b/sound/usb/ua101.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/usb.h> | 20 | #include <linux/usb.h> |
21 | #include <linux/usb/audio.h> | 21 | #include <linux/usb/audio.h> |
22 | #include <linux/vmalloc.h> | ||
23 | #include <sound/core.h> | 22 | #include <sound/core.h> |
24 | #include <sound/initval.h> | 23 | #include <sound/initval.h> |
25 | #include <sound/pcm.h> | 24 | #include <sound/pcm.h> |
@@ -145,42 +144,6 @@ static struct usb_driver ua101_driver; | |||
145 | static void abort_alsa_playback(struct ua101 *ua); | 144 | static void abort_alsa_playback(struct ua101 *ua); |
146 | static void abort_alsa_capture(struct ua101 *ua); | 145 | static void abort_alsa_capture(struct ua101 *ua); |
147 | 146 | ||
148 | /* allocate virtual buffer; may be called more than once */ | ||
149 | static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, | ||
150 | size_t size) | ||
151 | { | ||
152 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
153 | |||
154 | if (runtime->dma_area) { | ||
155 | if (runtime->dma_bytes >= size) | ||
156 | return 0; /* already large enough */ | ||
157 | vfree(runtime->dma_area); | ||
158 | } | ||
159 | runtime->dma_area = vmalloc_user(size); | ||
160 | if (!runtime->dma_area) | ||
161 | return -ENOMEM; | ||
162 | runtime->dma_bytes = size; | ||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | /* free virtual buffer; may be called more than once */ | ||
167 | static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) | ||
168 | { | ||
169 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
170 | |||
171 | vfree(runtime->dma_area); | ||
172 | runtime->dma_area = NULL; | ||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | /* get the physical page pointer at the given offset */ | ||
177 | static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, | ||
178 | unsigned long offset) | ||
179 | { | ||
180 | void *pageptr = subs->runtime->dma_area + offset; | ||
181 | return vmalloc_to_page(pageptr); | ||
182 | } | ||
183 | |||
184 | static const char *usb_error_string(int err) | 147 | static const char *usb_error_string(int err) |
185 | { | 148 | { |
186 | switch (err) { | 149 | switch (err) { |
@@ -791,8 +754,8 @@ static int capture_pcm_hw_params(struct snd_pcm_substream *substream, | |||
791 | if (err < 0) | 754 | if (err < 0) |
792 | return err; | 755 | return err; |
793 | 756 | ||
794 | return snd_pcm_alloc_vmalloc_buffer(substream, | 757 | return snd_pcm_lib_alloc_vmalloc_buffer(substream, |
795 | params_buffer_bytes(hw_params)); | 758 | params_buffer_bytes(hw_params)); |
796 | } | 759 | } |
797 | 760 | ||
798 | static int playback_pcm_hw_params(struct snd_pcm_substream *substream, | 761 | static int playback_pcm_hw_params(struct snd_pcm_substream *substream, |
@@ -809,14 +772,13 @@ static int playback_pcm_hw_params(struct snd_pcm_substream *substream, | |||
809 | if (err < 0) | 772 | if (err < 0) |
810 | return err; | 773 | return err; |
811 | 774 | ||
812 | return snd_pcm_alloc_vmalloc_buffer(substream, | 775 | return snd_pcm_lib_alloc_vmalloc_buffer(substream, |
813 | params_buffer_bytes(hw_params)); | 776 | params_buffer_bytes(hw_params)); |
814 | } | 777 | } |
815 | 778 | ||
816 | static int ua101_pcm_hw_free(struct snd_pcm_substream *substream) | 779 | static int ua101_pcm_hw_free(struct snd_pcm_substream *substream) |
817 | { | 780 | { |
818 | snd_pcm_free_vmalloc_buffer(substream); | 781 | return snd_pcm_lib_free_vmalloc_buffer(substream); |
819 | return 0; | ||
820 | } | 782 | } |
821 | 783 | ||
822 | static int capture_pcm_prepare(struct snd_pcm_substream *substream) | 784 | static int capture_pcm_prepare(struct snd_pcm_substream *substream) |
@@ -948,7 +910,7 @@ static struct snd_pcm_ops capture_pcm_ops = { | |||
948 | .prepare = capture_pcm_prepare, | 910 | .prepare = capture_pcm_prepare, |
949 | .trigger = capture_pcm_trigger, | 911 | .trigger = capture_pcm_trigger, |
950 | .pointer = capture_pcm_pointer, | 912 | .pointer = capture_pcm_pointer, |
951 | .page = snd_pcm_get_vmalloc_page, | 913 | .page = snd_pcm_lib_get_vmalloc_page, |
952 | }; | 914 | }; |
953 | 915 | ||
954 | static struct snd_pcm_ops playback_pcm_ops = { | 916 | static struct snd_pcm_ops playback_pcm_ops = { |
@@ -960,7 +922,7 @@ static struct snd_pcm_ops playback_pcm_ops = { | |||
960 | .prepare = playback_pcm_prepare, | 922 | .prepare = playback_pcm_prepare, |
961 | .trigger = playback_pcm_trigger, | 923 | .trigger = playback_pcm_trigger, |
962 | .pointer = playback_pcm_pointer, | 924 | .pointer = playback_pcm_pointer, |
963 | .page = snd_pcm_get_vmalloc_page, | 925 | .page = snd_pcm_lib_get_vmalloc_page, |
964 | }; | 926 | }; |
965 | 927 | ||
966 | static const struct uac_format_type_i_discrete_descriptor * | 928 | static const struct uac_format_type_i_discrete_descriptor * |