diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2009-02-28 01:41:12 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-04-03 17:54:25 -0400 |
commit | 010f378e8c839a03f7741c95791a7b9980a9cdc2 (patch) | |
tree | 15ecdb5c88a7461c290e3b30943b34c98b3f5e5a | |
parent | 9a92fadcc6731de03d6bdcf8fbfce08533d13523 (diff) |
Staging: line6: fix checkpatch errors in playback.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/playback.c | 113 |
1 files changed, 57 insertions, 56 deletions
diff --git a/drivers/staging/line6/playback.c b/drivers/staging/line6/playback.c index 34cfbdbb15a2..acb06126a6a5 100644 --- a/drivers/staging/line6/playback.c +++ b/drivers/staging/line6/playback.c | |||
@@ -24,30 +24,31 @@ | |||
24 | /* | 24 | /* |
25 | Software stereo volume control. | 25 | Software stereo volume control. |
26 | */ | 26 | */ |
27 | static void change_volume(struct urb *urb_out, int volume[], int bytes_per_frame) | 27 | static void change_volume(struct urb *urb_out, int volume[], |
28 | int bytes_per_frame) | ||
28 | { | 29 | { |
29 | int chn = 0; | 30 | int chn = 0; |
30 | 31 | ||
31 | if(volume[0] == 256 && volume[1] == 256) | 32 | if (volume[0] == 256 && volume[1] == 256) |
32 | return; /* maximum volume - no change */ | 33 | return; /* maximum volume - no change */ |
33 | 34 | ||
34 | if(bytes_per_frame == 4) { | 35 | if (bytes_per_frame == 4) { |
35 | short *p, *buf_end; | 36 | short *p, *buf_end; |
36 | p = (short *)urb_out->transfer_buffer; | 37 | p = (short *)urb_out->transfer_buffer; |
37 | buf_end = p + urb_out->transfer_buffer_length / sizeof(*p); | 38 | buf_end = p + urb_out->transfer_buffer_length / sizeof(*p); |
38 | 39 | ||
39 | for(; p < buf_end; ++p) { | 40 | for (; p < buf_end; ++p) { |
40 | *p = (*p * volume[chn & 1]) >> 8; | 41 | *p = (*p * volume[chn & 1]) >> 8; |
41 | ++chn; | 42 | ++chn; |
42 | } | 43 | } |
43 | } | 44 | } else if (bytes_per_frame == 6) { |
44 | else if(bytes_per_frame == 6) { | ||
45 | unsigned char *p, *buf_end; | 45 | unsigned char *p, *buf_end; |
46 | p = (unsigned char *)urb_out->transfer_buffer; | 46 | p = (unsigned char *)urb_out->transfer_buffer; |
47 | buf_end = p + urb_out->transfer_buffer_length; | 47 | buf_end = p + urb_out->transfer_buffer_length; |
48 | 48 | ||
49 | for(; p < buf_end; p += 3) { | 49 | for (; p < buf_end; p += 3) { |
50 | int val = p[0] + (p[1] << 8) + ((signed char)p[2] << 16); | 50 | int val; |
51 | val = p[0] + (p[1] << 8) + ((signed char)p[2] << 16); | ||
51 | val = (val * volume[chn & 1]) >> 8; | 52 | val = (val * volume[chn & 1]) >> 8; |
52 | p[0] = val; | 53 | p[0] = val; |
53 | p[1] = val >> 8; | 54 | p[1] = val >> 8; |
@@ -75,7 +76,7 @@ static int submit_audio_out_urb(struct snd_pcm_substream *substream) | |||
75 | spin_lock_irqsave(&line6pcm->lock_audio_out, flags); | 76 | spin_lock_irqsave(&line6pcm->lock_audio_out, flags); |
76 | index = find_first_zero_bit(&line6pcm->active_urb_out, LINE6_ISO_BUFFERS); | 77 | index = find_first_zero_bit(&line6pcm->active_urb_out, LINE6_ISO_BUFFERS); |
77 | 78 | ||
78 | if(index < 0 || index >= LINE6_ISO_BUFFERS) { | 79 | if (index < 0 || index >= LINE6_ISO_BUFFERS) { |
79 | spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); | 80 | spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); |
80 | dev_err(s2m(substream), "no free URB found\n"); | 81 | dev_err(s2m(substream), "no free URB found\n"); |
81 | return -EINVAL; | 82 | return -EINVAL; |
@@ -84,7 +85,7 @@ static int submit_audio_out_urb(struct snd_pcm_substream *substream) | |||
84 | urb_out = line6pcm->urb_audio_out[index]; | 85 | urb_out = line6pcm->urb_audio_out[index]; |
85 | urb_size = 0; | 86 | urb_size = 0; |
86 | 87 | ||
87 | for(i = 0; i < LINE6_ISO_PACKETS; ++i) { | 88 | for (i = 0; i < LINE6_ISO_PACKETS; ++i) { |
88 | /* compute frame size for given sampling rate */ | 89 | /* compute frame size for given sampling rate */ |
89 | int n, fs; | 90 | int n, fs; |
90 | struct usb_iso_packet_descriptor *fout = &urb_out->iso_frame_desc[i]; | 91 | struct usb_iso_packet_descriptor *fout = &urb_out->iso_frame_desc[i]; |
@@ -99,12 +100,11 @@ static int submit_audio_out_urb(struct snd_pcm_substream *substream) | |||
99 | 100 | ||
100 | urb_frames = urb_size / bytes_per_frame; | 101 | urb_frames = urb_size / bytes_per_frame; |
101 | 102 | ||
102 | if(test_bit(BIT_PAUSE_PLAYBACK, &line6pcm->flags)) { | 103 | if (test_bit(BIT_PAUSE_PLAYBACK, &line6pcm->flags)) { |
103 | urb_out->transfer_buffer = line6pcm->wrap_out; | 104 | urb_out->transfer_buffer = line6pcm->wrap_out; |
104 | memset(line6pcm->wrap_out, 0, urb_size); | 105 | memset(line6pcm->wrap_out, 0, urb_size); |
105 | } | 106 | } else { |
106 | else { | 107 | if (line6pcm->pos_out + urb_frames > runtime->buffer_size) { |
107 | if(line6pcm->pos_out + urb_frames > runtime->buffer_size) { | ||
108 | /* | 108 | /* |
109 | The transferred area goes over buffer boundary, | 109 | The transferred area goes over buffer boundary, |
110 | copy the data to the temp buffer. | 110 | copy the data to the temp buffer. |
@@ -113,20 +113,18 @@ static int submit_audio_out_urb(struct snd_pcm_substream *substream) | |||
113 | len = runtime->buffer_size - line6pcm->pos_out; | 113 | len = runtime->buffer_size - line6pcm->pos_out; |
114 | urb_out->transfer_buffer = line6pcm->wrap_out; | 114 | urb_out->transfer_buffer = line6pcm->wrap_out; |
115 | 115 | ||
116 | if(len > 0) { | 116 | if (len > 0) { |
117 | memcpy(line6pcm->wrap_out, runtime->dma_area + line6pcm->pos_out * bytes_per_frame, len * bytes_per_frame); | 117 | memcpy(line6pcm->wrap_out, runtime->dma_area + line6pcm->pos_out * bytes_per_frame, len * bytes_per_frame); |
118 | memcpy(line6pcm->wrap_out + len * bytes_per_frame, runtime->dma_area, (urb_frames - len) * bytes_per_frame); | 118 | memcpy(line6pcm->wrap_out + len * bytes_per_frame, runtime->dma_area, (urb_frames - len) * bytes_per_frame); |
119 | } | 119 | } else |
120 | else | ||
121 | dev_err(s2m(substream), "driver bug: len = %d\n", len); /* this is somewhat paranoid */ | 120 | dev_err(s2m(substream), "driver bug: len = %d\n", len); /* this is somewhat paranoid */ |
122 | } | 121 | } else { |
123 | else { | ||
124 | /* set the buffer pointer */ | 122 | /* set the buffer pointer */ |
125 | urb_out->transfer_buffer = runtime->dma_area + line6pcm->pos_out * bytes_per_frame; | 123 | urb_out->transfer_buffer = runtime->dma_area + line6pcm->pos_out * bytes_per_frame; |
126 | } | 124 | } |
127 | } | 125 | } |
128 | 126 | ||
129 | if((line6pcm->pos_out += urb_frames) >= runtime->buffer_size) | 127 | if ((line6pcm->pos_out += urb_frames) >= runtime->buffer_size) |
130 | line6pcm->pos_out -= runtime->buffer_size; | 128 | line6pcm->pos_out -= runtime->buffer_size; |
131 | 129 | ||
132 | urb_out->transfer_buffer_length = urb_size; | 130 | urb_out->transfer_buffer_length = urb_size; |
@@ -134,13 +132,13 @@ static int submit_audio_out_urb(struct snd_pcm_substream *substream) | |||
134 | change_volume(urb_out, line6pcm->volume, bytes_per_frame); | 132 | change_volume(urb_out, line6pcm->volume, bytes_per_frame); |
135 | 133 | ||
136 | #if DO_DUMP_PCM_SEND | 134 | #if DO_DUMP_PCM_SEND |
137 | for(i = 0; i < LINE6_ISO_PACKETS; ++i) { | 135 | for (i = 0; i < LINE6_ISO_PACKETS; ++i) { |
138 | struct usb_iso_packet_descriptor *fout = &urb_out->iso_frame_desc[i]; | 136 | struct usb_iso_packet_descriptor *fout = &urb_out->iso_frame_desc[i]; |
139 | line6_write_hexdump(line6pcm->line6, 'P', urb_out->transfer_buffer + fout->offset, fout->length); | 137 | line6_write_hexdump(line6pcm->line6, 'P', urb_out->transfer_buffer + fout->offset, fout->length); |
140 | } | 138 | } |
141 | #endif | 139 | #endif |
142 | 140 | ||
143 | if(usb_submit_urb(urb_out, GFP_ATOMIC) == 0) | 141 | if (usb_submit_urb(urb_out, GFP_ATOMIC) == 0) |
144 | set_bit(index, &line6pcm->active_urb_out); | 142 | set_bit(index, &line6pcm->active_urb_out); |
145 | else | 143 | else |
146 | dev_err(s2m(substream), "URB out #%d submission failed\n", index); | 144 | dev_err(s2m(substream), "URB out #%d submission failed\n", index); |
@@ -156,9 +154,11 @@ static int submit_audio_out_all_urbs(struct snd_pcm_substream *substream) | |||
156 | { | 154 | { |
157 | int ret, i; | 155 | int ret, i; |
158 | 156 | ||
159 | for(i = 0; i < LINE6_ISO_BUFFERS; ++i) | 157 | for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { |
160 | if((ret = submit_audio_out_urb(substream)) < 0) | 158 | ret = submit_audio_out_urb(substream); |
159 | if (ret < 0) | ||
161 | return ret; | 160 | return ret; |
161 | } | ||
162 | 162 | ||
163 | return 0; | 163 | return 0; |
164 | } | 164 | } |
@@ -170,9 +170,9 @@ static void unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm) | |||
170 | { | 170 | { |
171 | unsigned int i; | 171 | unsigned int i; |
172 | 172 | ||
173 | for(i = LINE6_ISO_BUFFERS; i--;) { | 173 | for (i = LINE6_ISO_BUFFERS; i--;) { |
174 | if(test_bit(i, &line6pcm->active_urb_out)) { | 174 | if (test_bit(i, &line6pcm->active_urb_out)) { |
175 | if(!test_and_set_bit(i, &line6pcm->unlink_urb_out)) { | 175 | if (!test_and_set_bit(i, &line6pcm->unlink_urb_out)) { |
176 | struct urb *u = line6pcm->urb_audio_out[i]; | 176 | struct urb *u = line6pcm->urb_audio_out[i]; |
177 | usb_unlink_urb(u); | 177 | usb_unlink_urb(u); |
178 | } | 178 | } |
@@ -195,7 +195,7 @@ static void wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm) | |||
195 | if (test_bit(i, &line6pcm->active_urb_out)) | 195 | if (test_bit(i, &line6pcm->active_urb_out)) |
196 | alive++; | 196 | alive++; |
197 | } | 197 | } |
198 | if (! alive) | 198 | if (!alive) |
199 | break; | 199 | break; |
200 | set_current_state(TASK_UNINTERRUPTIBLE); | 200 | set_current_state(TASK_UNINTERRUPTIBLE); |
201 | schedule_timeout(1); | 201 | schedule_timeout(1); |
@@ -229,39 +229,39 @@ static void audio_out_callback(struct urb *urb) | |||
229 | struct snd_pcm_runtime *runtime = substream->runtime; | 229 | struct snd_pcm_runtime *runtime = substream->runtime; |
230 | 230 | ||
231 | /* find index of URB */ | 231 | /* find index of URB */ |
232 | for(index = LINE6_ISO_BUFFERS; index--;) | 232 | for (index = LINE6_ISO_BUFFERS; index--;) |
233 | if(urb == line6pcm->urb_audio_out[index]) | 233 | if (urb == line6pcm->urb_audio_out[index]) |
234 | break; | 234 | break; |
235 | 235 | ||
236 | if(index < 0) | 236 | if (index < 0) |
237 | return; /* URB has been unlinked asynchronously */ | 237 | return; /* URB has been unlinked asynchronously */ |
238 | 238 | ||
239 | for(i = LINE6_ISO_PACKETS; i--;) | 239 | for (i = LINE6_ISO_PACKETS; i--;) |
240 | length += urb->iso_frame_desc[i].length; | 240 | length += urb->iso_frame_desc[i].length; |
241 | 241 | ||
242 | spin_lock_irqsave(&line6pcm->lock_audio_out, flags); | 242 | spin_lock_irqsave(&line6pcm->lock_audio_out, flags); |
243 | line6pcm->pos_out_done += length / line6pcm->properties->bytes_per_frame; | 243 | line6pcm->pos_out_done += length / line6pcm->properties->bytes_per_frame; |
244 | 244 | ||
245 | if(line6pcm->pos_out_done >= runtime->buffer_size) | 245 | if (line6pcm->pos_out_done >= runtime->buffer_size) |
246 | line6pcm->pos_out_done -= runtime->buffer_size; | 246 | line6pcm->pos_out_done -= runtime->buffer_size; |
247 | 247 | ||
248 | clear_bit(index, &line6pcm->active_urb_out); | 248 | clear_bit(index, &line6pcm->active_urb_out); |
249 | 249 | ||
250 | for(i = LINE6_ISO_PACKETS; i--;) | 250 | for (i = LINE6_ISO_PACKETS; i--;) |
251 | if(urb->iso_frame_desc[i].status == -ESHUTDOWN) { | 251 | if (urb->iso_frame_desc[i].status == -ESHUTDOWN) { |
252 | shutdown = 1; | 252 | shutdown = 1; |
253 | break; | 253 | break; |
254 | } | 254 | } |
255 | 255 | ||
256 | if(test_bit(index, &line6pcm->unlink_urb_out)) | 256 | if (test_bit(index, &line6pcm->unlink_urb_out)) |
257 | shutdown = 1; | 257 | shutdown = 1; |
258 | 258 | ||
259 | spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); | 259 | spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); |
260 | 260 | ||
261 | if(!shutdown) { | 261 | if (!shutdown) { |
262 | submit_audio_out_urb(substream); | 262 | submit_audio_out_urb(substream); |
263 | 263 | ||
264 | if((line6pcm->bytes_out += length) >= line6pcm->period_out) { | 264 | if ((line6pcm->bytes_out += length) >= line6pcm->period_out) { |
265 | line6pcm->bytes_out -= line6pcm->period_out; | 265 | line6pcm->bytes_out -= line6pcm->period_out; |
266 | snd_pcm_period_elapsed(substream); | 266 | snd_pcm_period_elapsed(substream); |
267 | } | 267 | } |
@@ -275,8 +275,9 @@ static int snd_line6_playback_open(struct snd_pcm_substream *substream) | |||
275 | struct snd_pcm_runtime *runtime = substream->runtime; | 275 | struct snd_pcm_runtime *runtime = substream->runtime; |
276 | struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); | 276 | struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); |
277 | 277 | ||
278 | if((err = snd_pcm_hw_constraint_ratdens(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | 278 | err = snd_pcm_hw_constraint_ratdens(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, |
279 | (&line6pcm->properties->snd_line6_rates))) < 0) | 279 | (&line6pcm->properties->snd_line6_rates)); |
280 | if (err < 0) | ||
280 | return err; | 281 | return err; |
281 | 282 | ||
282 | runtime->hw = line6pcm->properties->snd_line6_playback_hw; | 283 | runtime->hw = line6pcm->properties->snd_line6_playback_hw; |
@@ -297,23 +298,25 @@ static int snd_line6_playback_hw_params(struct snd_pcm_substream *substream, str | |||
297 | 298 | ||
298 | /* -- Florian Demski [FD] */ | 299 | /* -- Florian Demski [FD] */ |
299 | /* don't ask me why, but this fixes the bug on my machine */ | 300 | /* don't ask me why, but this fixes the bug on my machine */ |
300 | if ( line6pcm == NULL ) { | 301 | if (line6pcm == NULL) { |
301 | if ( substream->pcm == NULL ) | 302 | if (substream->pcm == NULL) |
302 | return -ENOMEM; | 303 | return -ENOMEM; |
303 | if ( substream->pcm->private_data == NULL ) | 304 | if (substream->pcm->private_data == NULL) |
304 | return -ENOMEM; | 305 | return -ENOMEM; |
305 | substream->private_data = substream->pcm->private_data; | 306 | substream->private_data = substream->pcm->private_data; |
306 | line6pcm = snd_pcm_substream_chip( substream ); | 307 | line6pcm = snd_pcm_substream_chip(substream); |
307 | } | 308 | } |
308 | /* -- [FD] end */ | 309 | /* -- [FD] end */ |
309 | 310 | ||
310 | if((ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) | 311 | ret = snd_pcm_lib_malloc_pages(substream, |
312 | params_buffer_bytes(hw_params)); | ||
313 | if (ret < 0) | ||
311 | return ret; | 314 | return ret; |
312 | 315 | ||
313 | line6pcm->period_out = params_period_bytes(hw_params); | 316 | line6pcm->period_out = params_period_bytes(hw_params); |
314 | line6pcm->wrap_out = kmalloc(2 * LINE6_ISO_PACKET_SIZE_MAX, GFP_KERNEL); | 317 | line6pcm->wrap_out = kmalloc(2 * LINE6_ISO_PACKET_SIZE_MAX, GFP_KERNEL); |
315 | 318 | ||
316 | if(!line6pcm->wrap_out) { | 319 | if (!line6pcm->wrap_out) { |
317 | dev_err(s2m(substream), "cannot malloc wrap_out\n"); | 320 | dev_err(s2m(substream), "cannot malloc wrap_out\n"); |
318 | return -ENOMEM; | 321 | return -ENOMEM; |
319 | } | 322 | } |
@@ -327,10 +330,8 @@ static int snd_line6_playback_hw_free(struct snd_pcm_substream *substream) | |||
327 | struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); | 330 | struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); |
328 | unlink_wait_clear_audio_out_urbs(line6pcm); | 331 | unlink_wait_clear_audio_out_urbs(line6pcm); |
329 | 332 | ||
330 | if(line6pcm->wrap_out) { | 333 | kfree(line6pcm->wrap_out); |
331 | kfree(line6pcm->wrap_out); | 334 | line6pcm->wrap_out = NULL; |
332 | line6pcm->wrap_out = NULL; | ||
333 | } | ||
334 | 335 | ||
335 | return snd_pcm_lib_free_pages(substream); | 336 | return snd_pcm_lib_free_pages(substream); |
336 | } | 337 | } |
@@ -342,12 +343,12 @@ int snd_line6_playback_trigger(struct snd_pcm_substream *substream, int cmd) | |||
342 | int err; | 343 | int err; |
343 | line6pcm->count_out = 0; | 344 | line6pcm->count_out = 0; |
344 | 345 | ||
345 | switch(cmd) { | 346 | switch (cmd) { |
346 | case SNDRV_PCM_TRIGGER_START: | 347 | case SNDRV_PCM_TRIGGER_START: |
347 | if(!test_and_set_bit(BIT_RUNNING_PLAYBACK, &line6pcm->flags)) { | 348 | if (!test_and_set_bit(BIT_RUNNING_PLAYBACK, &line6pcm->flags)) { |
348 | err = submit_audio_out_all_urbs(substream); | 349 | err = submit_audio_out_all_urbs(substream); |
349 | 350 | ||
350 | if(err < 0) { | 351 | if (err < 0) { |
351 | clear_bit(BIT_RUNNING_PLAYBACK, &line6pcm->flags); | 352 | clear_bit(BIT_RUNNING_PLAYBACK, &line6pcm->flags); |
352 | return err; | 353 | return err; |
353 | } | 354 | } |
@@ -356,7 +357,7 @@ int snd_line6_playback_trigger(struct snd_pcm_substream *substream, int cmd) | |||
356 | break; | 357 | break; |
357 | 358 | ||
358 | case SNDRV_PCM_TRIGGER_STOP: | 359 | case SNDRV_PCM_TRIGGER_STOP: |
359 | if(test_and_clear_bit(BIT_RUNNING_PLAYBACK, &line6pcm->flags)) | 360 | if (test_and_clear_bit(BIT_RUNNING_PLAYBACK, &line6pcm->flags)) |
360 | unlink_audio_out_urbs(line6pcm); | 361 | unlink_audio_out_urbs(line6pcm); |
361 | 362 | ||
362 | break; | 363 | break; |
@@ -401,13 +402,13 @@ int create_audio_out_urbs(struct snd_line6_pcm *line6pcm) | |||
401 | int i; | 402 | int i; |
402 | 403 | ||
403 | /* create audio URBs and fill in constant values: */ | 404 | /* create audio URBs and fill in constant values: */ |
404 | for(i = 0; i < LINE6_ISO_BUFFERS; ++i) { | 405 | for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { |
405 | struct urb *urb; | 406 | struct urb *urb; |
406 | 407 | ||
407 | /* URB for audio out: */ | 408 | /* URB for audio out: */ |
408 | urb = line6pcm->urb_audio_out[i] = usb_alloc_urb(LINE6_ISO_PACKETS, GFP_KERNEL); | 409 | urb = line6pcm->urb_audio_out[i] = usb_alloc_urb(LINE6_ISO_PACKETS, GFP_KERNEL); |
409 | 410 | ||
410 | if(urb == NULL) { | 411 | if (urb == NULL) { |
411 | dev_err(line6pcm->line6->ifcdev, "Out of memory\n"); | 412 | dev_err(line6pcm->line6->ifcdev, "Out of memory\n"); |
412 | return -ENOMEM; | 413 | return -ENOMEM; |
413 | } | 414 | } |