diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2009-02-28 01:39:22 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-04-03 17:54:25 -0400 |
commit | 6efc5667ef588df7156e1c481383f8dbff4fa409 (patch) | |
tree | b0a899b257176fa2fae8d200eae5a7d4bb0e060b | |
parent | a49e483835823ab97028f396531d83b6668734cf (diff) |
Staging: line6: fix checkpatch errors in capture.c
2 errors left, but they are minor.
Lots of warnings also fixed up.
Cc: Markus Grabner <grabner@icg.tugraz.at>
Cc: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/line6/capture.c | 94 |
1 files changed, 49 insertions, 45 deletions
diff --git a/drivers/staging/line6/capture.c b/drivers/staging/line6/capture.c index d6c1d1a70459..8393e25a10b1 100644 --- a/drivers/staging/line6/capture.c +++ b/drivers/staging/line6/capture.c | |||
@@ -35,7 +35,7 @@ static int submit_audio_in_urb(struct snd_pcm_substream *substream) | |||
35 | spin_lock_irqsave(&line6pcm->lock_audio_in, flags); | 35 | spin_lock_irqsave(&line6pcm->lock_audio_in, flags); |
36 | index = find_first_zero_bit(&line6pcm->active_urb_in, LINE6_ISO_BUFFERS); | 36 | index = find_first_zero_bit(&line6pcm->active_urb_in, LINE6_ISO_BUFFERS); |
37 | 37 | ||
38 | if(index < 0 || index >= LINE6_ISO_BUFFERS) { | 38 | if (index < 0 || index >= LINE6_ISO_BUFFERS) { |
39 | spin_unlock_irqrestore(&line6pcm->lock_audio_in, flags); | 39 | spin_unlock_irqrestore(&line6pcm->lock_audio_in, flags); |
40 | dev_err(s2m(substream), "no free URB found\n"); | 40 | dev_err(s2m(substream), "no free URB found\n"); |
41 | return -EINVAL; | 41 | return -EINVAL; |
@@ -44,7 +44,7 @@ static int submit_audio_in_urb(struct snd_pcm_substream *substream) | |||
44 | urb_in = line6pcm->urb_audio_in[index]; | 44 | urb_in = line6pcm->urb_audio_in[index]; |
45 | urb_size = 0; | 45 | urb_size = 0; |
46 | 46 | ||
47 | for(i = 0; i < LINE6_ISO_PACKETS; ++i) { | 47 | for (i = 0; i < LINE6_ISO_PACKETS; ++i) { |
48 | struct usb_iso_packet_descriptor *fin = &urb_in->iso_frame_desc[i]; | 48 | struct usb_iso_packet_descriptor *fin = &urb_in->iso_frame_desc[i]; |
49 | fin->offset = urb_size; | 49 | fin->offset = urb_size; |
50 | fin->length = line6pcm->max_packet_size; | 50 | fin->length = line6pcm->max_packet_size; |
@@ -55,7 +55,7 @@ static int submit_audio_in_urb(struct snd_pcm_substream *substream) | |||
55 | urb_in->transfer_buffer_length = urb_size; | 55 | urb_in->transfer_buffer_length = urb_size; |
56 | urb_in->context = substream; | 56 | urb_in->context = substream; |
57 | 57 | ||
58 | if(usb_submit_urb(urb_in, GFP_ATOMIC) == 0) | 58 | if (usb_submit_urb(urb_in, GFP_ATOMIC) == 0) |
59 | set_bit(index, &line6pcm->active_urb_in); | 59 | set_bit(index, &line6pcm->active_urb_in); |
60 | else | 60 | else |
61 | dev_err(s2m(substream), "URB in #%d submission failed\n", index); | 61 | dev_err(s2m(substream), "URB in #%d submission failed\n", index); |
@@ -71,9 +71,11 @@ static int submit_audio_in_all_urbs(struct snd_pcm_substream *substream) | |||
71 | { | 71 | { |
72 | int ret, i; | 72 | int ret, i; |
73 | 73 | ||
74 | for(i = 0; i < LINE6_ISO_BUFFERS; ++i) | 74 | for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { |
75 | if((ret = submit_audio_in_urb(substream)) < 0) | 75 | ret = submit_audio_in_urb(substream); |
76 | if (ret < 0) | ||
76 | return ret; | 77 | return ret; |
78 | } | ||
77 | 79 | ||
78 | return 0; | 80 | return 0; |
79 | } | 81 | } |
@@ -85,9 +87,9 @@ static void unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm) | |||
85 | { | 87 | { |
86 | unsigned int i; | 88 | unsigned int i; |
87 | 89 | ||
88 | for(i = LINE6_ISO_BUFFERS; i--;) { | 90 | for (i = LINE6_ISO_BUFFERS; i--;) { |
89 | if(test_bit(i, &line6pcm->active_urb_in)) { | 91 | if (test_bit(i, &line6pcm->active_urb_in)) { |
90 | if(!test_and_set_bit(i, &line6pcm->unlink_urb_in)) { | 92 | if (!test_and_set_bit(i, &line6pcm->unlink_urb_in)) { |
91 | struct urb *u = line6pcm->urb_audio_in[i]; | 93 | struct urb *u = line6pcm->urb_audio_in[i]; |
92 | usb_unlink_urb(u); | 94 | usb_unlink_urb(u); |
93 | } | 95 | } |
@@ -96,7 +98,8 @@ static void unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm) | |||
96 | } | 98 | } |
97 | 99 | ||
98 | /* | 100 | /* |
99 | Wait until unlinking of all currently active capture URBs has been finished. | 101 | Wait until unlinking of all currently active capture URBs has been |
102 | finished. | ||
100 | */ | 103 | */ |
101 | static void wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm) | 104 | static void wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm) |
102 | { | 105 | { |
@@ -110,7 +113,7 @@ static void wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm) | |||
110 | if (test_bit(i, &line6pcm->active_urb_in)) | 113 | if (test_bit(i, &line6pcm->active_urb_in)) |
111 | alive++; | 114 | alive++; |
112 | } | 115 | } |
113 | if (! alive) | 116 | if (!alive) |
114 | break; | 117 | break; |
115 | set_current_state(TASK_UNINTERRUPTIBLE); | 118 | set_current_state(TASK_UNINTERRUPTIBLE); |
116 | schedule_timeout(1); | 119 | schedule_timeout(1); |
@@ -146,12 +149,12 @@ static void audio_in_callback(struct urb *urb) | |||
146 | struct snd_pcm_runtime *runtime = substream->runtime; | 149 | struct snd_pcm_runtime *runtime = substream->runtime; |
147 | 150 | ||
148 | /* find index of URB */ | 151 | /* find index of URB */ |
149 | for(index = 0; index < LINE6_ISO_BUFFERS; ++index) | 152 | for (index = 0; index < LINE6_ISO_BUFFERS; ++index) |
150 | if(urb == line6pcm->urb_audio_in[index]) | 153 | if (urb == line6pcm->urb_audio_in[index]) |
151 | break; | 154 | break; |
152 | 155 | ||
153 | #if DO_DUMP_PCM_RECEIVE | 156 | #if DO_DUMP_PCM_RECEIVE |
154 | for(i = 0; i < LINE6_ISO_PACKETS; ++i) { | 157 | for (i = 0; i < LINE6_ISO_PACKETS; ++i) { |
155 | struct usb_iso_packet_descriptor *fout = &urb->iso_frame_desc[i]; | 158 | struct usb_iso_packet_descriptor *fout = &urb->iso_frame_desc[i]; |
156 | line6_write_hexdump(line6pcm->line6, 'C', urb->transfer_buffer + fout->offset, fout->length); | 159 | line6_write_hexdump(line6pcm->line6, 'C', urb->transfer_buffer + fout->offset, fout->length); |
157 | } | 160 | } |
@@ -159,12 +162,12 @@ static void audio_in_callback(struct urb *urb) | |||
159 | 162 | ||
160 | spin_lock_irqsave(&line6pcm->lock_audio_in, flags); | 163 | spin_lock_irqsave(&line6pcm->lock_audio_in, flags); |
161 | 164 | ||
162 | for(i = 0; i < LINE6_ISO_PACKETS; ++i) { | 165 | for (i = 0; i < LINE6_ISO_PACKETS; ++i) { |
163 | char *fbuf; | 166 | char *fbuf; |
164 | int fsize; | 167 | int fsize; |
165 | struct usb_iso_packet_descriptor *fin = &urb->iso_frame_desc[i]; | 168 | struct usb_iso_packet_descriptor *fin = &urb->iso_frame_desc[i]; |
166 | 169 | ||
167 | if(fin->status == -18) { | 170 | if (fin->status == -18) { |
168 | shutdown = 1; | 171 | shutdown = 1; |
169 | break; | 172 | break; |
170 | } | 173 | } |
@@ -173,10 +176,10 @@ static void audio_in_callback(struct urb *urb) | |||
173 | fsize = fin->actual_length; | 176 | fsize = fin->actual_length; |
174 | length += fsize; | 177 | length += fsize; |
175 | 178 | ||
176 | if(fsize > 0) { | 179 | if (fsize > 0) { |
177 | frames = fsize / bytes_per_frame; | 180 | frames = fsize / bytes_per_frame; |
178 | 181 | ||
179 | if(line6pcm->pos_in_done + frames > runtime->buffer_size) { | 182 | if (line6pcm->pos_in_done + frames > runtime->buffer_size) { |
180 | /* | 183 | /* |
181 | The transferred area goes over buffer boundary, | 184 | The transferred area goes over buffer boundary, |
182 | copy two separate chunks. | 185 | copy two separate chunks. |
@@ -184,34 +187,32 @@ static void audio_in_callback(struct urb *urb) | |||
184 | int len; | 187 | int len; |
185 | len = runtime->buffer_size - line6pcm->pos_in_done; | 188 | len = runtime->buffer_size - line6pcm->pos_in_done; |
186 | 189 | ||
187 | if(len > 0) { | 190 | if (len > 0) { |
188 | memcpy(runtime->dma_area + line6pcm->pos_in_done * bytes_per_frame, fbuf, len * bytes_per_frame); | 191 | memcpy(runtime->dma_area + line6pcm->pos_in_done * bytes_per_frame, fbuf, len * bytes_per_frame); |
189 | memcpy(runtime->dma_area, fbuf + len * bytes_per_frame, (frames - len) * bytes_per_frame); | 192 | memcpy(runtime->dma_area, fbuf + len * bytes_per_frame, (frames - len) * bytes_per_frame); |
190 | } | 193 | } else |
191 | else | ||
192 | dev_err(s2m(substream), "driver bug: len = %d\n", len); /* this is somewhat paranoid */ | 194 | dev_err(s2m(substream), "driver bug: len = %d\n", len); /* this is somewhat paranoid */ |
193 | } | 195 | } else { |
194 | else { | ||
195 | /* copy single chunk */ | 196 | /* copy single chunk */ |
196 | memcpy(runtime->dma_area + line6pcm->pos_in_done * bytes_per_frame, fbuf, fsize * bytes_per_frame); | 197 | memcpy(runtime->dma_area + line6pcm->pos_in_done * bytes_per_frame, fbuf, fsize * bytes_per_frame); |
197 | } | 198 | } |
198 | 199 | ||
199 | if((line6pcm->pos_in_done += frames) >= runtime->buffer_size) | 200 | if ((line6pcm->pos_in_done += frames) >= runtime->buffer_size) |
200 | line6pcm->pos_in_done -= runtime->buffer_size; | 201 | line6pcm->pos_in_done -= runtime->buffer_size; |
201 | } | 202 | } |
202 | } | 203 | } |
203 | 204 | ||
204 | clear_bit(index, &line6pcm->active_urb_in); | 205 | clear_bit(index, &line6pcm->active_urb_in); |
205 | 206 | ||
206 | if(test_bit(index, &line6pcm->unlink_urb_in)) | 207 | if (test_bit(index, &line6pcm->unlink_urb_in)) |
207 | shutdown = 1; | 208 | shutdown = 1; |
208 | 209 | ||
209 | spin_unlock_irqrestore(&line6pcm->lock_audio_in, flags); | 210 | spin_unlock_irqrestore(&line6pcm->lock_audio_in, flags); |
210 | 211 | ||
211 | if(!shutdown) { | 212 | if (!shutdown) { |
212 | submit_audio_in_urb(substream); | 213 | submit_audio_in_urb(substream); |
213 | 214 | ||
214 | if((line6pcm->bytes_in += length) >= line6pcm->period_in) { | 215 | if ((line6pcm->bytes_in += length) >= line6pcm->period_in) { |
215 | line6pcm->bytes_in -= line6pcm->period_in; | 216 | line6pcm->bytes_in -= line6pcm->period_in; |
216 | snd_pcm_period_elapsed(substream); | 217 | snd_pcm_period_elapsed(substream); |
217 | } | 218 | } |
@@ -225,8 +226,10 @@ static int snd_line6_capture_open(struct snd_pcm_substream *substream) | |||
225 | struct snd_pcm_runtime *runtime = substream->runtime; | 226 | struct snd_pcm_runtime *runtime = substream->runtime; |
226 | struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); | 227 | struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); |
227 | 228 | ||
228 | if((err = snd_pcm_hw_constraint_ratdens(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | 229 | err = snd_pcm_hw_constraint_ratdens(runtime, 0, |
229 | (&line6pcm->properties->snd_line6_rates))) < 0) | 230 | SNDRV_PCM_HW_PARAM_RATE, |
231 | (&line6pcm->properties->snd_line6_rates)); | ||
232 | if (err < 0) | ||
230 | return err; | 233 | return err; |
231 | 234 | ||
232 | runtime->hw = line6pcm->properties->snd_line6_capture_hw; | 235 | runtime->hw = line6pcm->properties->snd_line6_capture_hw; |
@@ -240,30 +243,33 @@ static int snd_line6_capture_close(struct snd_pcm_substream *substream) | |||
240 | } | 243 | } |
241 | 244 | ||
242 | /* hw_params capture callback */ | 245 | /* hw_params capture callback */ |
243 | static int snd_line6_capture_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) | 246 | static int snd_line6_capture_hw_params(struct snd_pcm_substream *substream, |
247 | struct snd_pcm_hw_params *hw_params) | ||
244 | { | 248 | { |
245 | int ret; | 249 | int ret; |
246 | struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); | 250 | struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); |
247 | 251 | ||
248 | /* -- Florian Demski [FD] */ | 252 | /* -- Florian Demski [FD] */ |
249 | /* don't ask me why, but this fixes the bug on my machine */ | 253 | /* don't ask me why, but this fixes the bug on my machine */ |
250 | if ( line6pcm == NULL ) { | 254 | if (line6pcm == NULL) { |
251 | if ( substream->pcm == NULL ) | 255 | if (substream->pcm == NULL) |
252 | return -ENOMEM; | 256 | return -ENOMEM; |
253 | if ( substream->pcm->private_data == NULL ) | 257 | if (substream->pcm->private_data == NULL) |
254 | return -ENOMEM; | 258 | return -ENOMEM; |
255 | substream->private_data = substream->pcm->private_data; | 259 | substream->private_data = substream->pcm->private_data; |
256 | line6pcm = snd_pcm_substream_chip( substream ); | 260 | line6pcm = snd_pcm_substream_chip(substream); |
257 | } | 261 | } |
258 | /* -- [FD] end */ | 262 | /* -- [FD] end */ |
259 | 263 | ||
260 | if((ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) | 264 | ret = snd_pcm_lib_malloc_pages(substream, |
265 | params_buffer_bytes(hw_params)); | ||
266 | if (ret < 0) | ||
261 | return ret; | 267 | return ret; |
262 | 268 | ||
263 | line6pcm->period_in = params_period_bytes(hw_params); | 269 | line6pcm->period_in = params_period_bytes(hw_params); |
264 | line6pcm->buffer_in = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * LINE6_ISO_PACKET_SIZE_MAX, GFP_KERNEL); | 270 | line6pcm->buffer_in = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * LINE6_ISO_PACKET_SIZE_MAX, GFP_KERNEL); |
265 | 271 | ||
266 | if(!line6pcm->buffer_in) { | 272 | if (!line6pcm->buffer_in) { |
267 | dev_err(s2m(substream), "cannot malloc buffer_in\n"); | 273 | dev_err(s2m(substream), "cannot malloc buffer_in\n"); |
268 | return -ENOMEM; | 274 | return -ENOMEM; |
269 | } | 275 | } |
@@ -277,10 +283,8 @@ static int snd_line6_capture_hw_free(struct snd_pcm_substream *substream) | |||
277 | struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); | 283 | struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); |
278 | unlink_wait_clear_audio_in_urbs(line6pcm); | 284 | unlink_wait_clear_audio_in_urbs(line6pcm); |
279 | 285 | ||
280 | if(line6pcm->buffer_in) { | 286 | kfree(line6pcm->buffer_in); |
281 | kfree(line6pcm->buffer_in); | 287 | line6pcm->buffer_in = NULL; |
282 | line6pcm->buffer_in = NULL; | ||
283 | } | ||
284 | 288 | ||
285 | return snd_pcm_lib_free_pages(substream); | 289 | return snd_pcm_lib_free_pages(substream); |
286 | } | 290 | } |
@@ -292,12 +296,12 @@ int snd_line6_capture_trigger(struct snd_pcm_substream *substream, int cmd) | |||
292 | int err; | 296 | int err; |
293 | line6pcm->count_in = 0; | 297 | line6pcm->count_in = 0; |
294 | 298 | ||
295 | switch(cmd) { | 299 | switch (cmd) { |
296 | case SNDRV_PCM_TRIGGER_START: | 300 | case SNDRV_PCM_TRIGGER_START: |
297 | if(!test_and_set_bit(BIT_RUNNING_CAPTURE, &line6pcm->flags)) { | 301 | if (!test_and_set_bit(BIT_RUNNING_CAPTURE, &line6pcm->flags)) { |
298 | err = submit_audio_in_all_urbs(substream); | 302 | err = submit_audio_in_all_urbs(substream); |
299 | 303 | ||
300 | if(err < 0) { | 304 | if (err < 0) { |
301 | clear_bit(BIT_RUNNING_CAPTURE, &line6pcm->flags); | 305 | clear_bit(BIT_RUNNING_CAPTURE, &line6pcm->flags); |
302 | return err; | 306 | return err; |
303 | } | 307 | } |
@@ -306,7 +310,7 @@ int snd_line6_capture_trigger(struct snd_pcm_substream *substream, int cmd) | |||
306 | break; | 310 | break; |
307 | 311 | ||
308 | case SNDRV_PCM_TRIGGER_STOP: | 312 | case SNDRV_PCM_TRIGGER_STOP: |
309 | if(test_and_clear_bit(BIT_RUNNING_CAPTURE, &line6pcm->flags)) | 313 | if (test_and_clear_bit(BIT_RUNNING_CAPTURE, &line6pcm->flags)) |
310 | unlink_audio_in_urbs(line6pcm); | 314 | unlink_audio_in_urbs(line6pcm); |
311 | 315 | ||
312 | break; | 316 | break; |
@@ -343,13 +347,13 @@ int create_audio_in_urbs(struct snd_line6_pcm *line6pcm) | |||
343 | int i; | 347 | int i; |
344 | 348 | ||
345 | /* create audio URBs and fill in constant values: */ | 349 | /* create audio URBs and fill in constant values: */ |
346 | for(i = 0; i < LINE6_ISO_BUFFERS; ++i) { | 350 | for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { |
347 | struct urb *urb; | 351 | struct urb *urb; |
348 | 352 | ||
349 | /* URB for audio in: */ | 353 | /* URB for audio in: */ |
350 | urb = line6pcm->urb_audio_in[i] = usb_alloc_urb(LINE6_ISO_PACKETS, GFP_KERNEL); | 354 | urb = line6pcm->urb_audio_in[i] = usb_alloc_urb(LINE6_ISO_PACKETS, GFP_KERNEL); |
351 | 355 | ||
352 | if(urb == NULL) { | 356 | if (urb == NULL) { |
353 | dev_err(line6pcm->line6->ifcdev, "Out of memory\n"); | 357 | dev_err(line6pcm->line6->ifcdev, "Out of memory\n"); |
354 | return -ENOMEM; | 358 | return -ENOMEM; |
355 | } | 359 | } |