Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ALSA: line6: Use guard() for spin locks

Clean up the code using guard() for spin locks.

Merely code refactoring, and no behavior change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

+29 -43
+1 -5
sound/usb/line6/capture.c
··· 145 145 static void audio_in_callback(struct urb *urb) 146 146 { 147 147 int i, index, length = 0, shutdown = 0; 148 - unsigned long flags; 149 - 150 148 struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context; 151 149 152 150 line6pcm->in.last_frame = urb->start_frame; ··· 154 156 if (urb == line6pcm->in.urbs[index]) 155 157 break; 156 158 157 - spin_lock_irqsave(&line6pcm->in.lock, flags); 159 + guard(spinlock_irqsave)(&line6pcm->in.lock); 158 160 159 161 for (i = 0; i < LINE6_ISO_PACKETS; ++i) { 160 162 char *fbuf; ··· 209 211 test_bit(LINE6_STREAM_PCM, &line6pcm->in.running)) 210 212 line6_capture_check_period(line6pcm, length); 211 213 } 212 - 213 - spin_unlock_irqrestore(&line6pcm->in.lock, flags); 214 214 } 215 215 216 216 /* open capture callback */
+14 -15
sound/usb/line6/driver.c
··· 286 286 { 287 287 struct usb_line6 *line6 = (struct usb_line6 *)urb->context; 288 288 struct midi_buffer *mb = &line6->line6midi->midibuf_in; 289 - unsigned long flags; 290 289 int done; 291 290 292 291 if (urb->status == -ESHUTDOWN) 293 292 return; 294 293 295 294 if (line6->properties->capabilities & LINE6_CAP_CONTROL_MIDI) { 296 - spin_lock_irqsave(&line6->line6midi->lock, flags); 297 - done = 298 - line6_midibuf_write(mb, urb->transfer_buffer, urb->actual_length); 295 + scoped_guard(spinlock_irqsave, &line6->line6midi->lock) { 296 + done = 297 + line6_midibuf_write(mb, urb->transfer_buffer, urb->actual_length); 299 298 300 - if (done < urb->actual_length) { 301 - line6_midibuf_ignore(mb, done); 302 - dev_dbg(line6->ifcdev, "%d %d buffer overflow - message skipped\n", 303 - done, urb->actual_length); 299 + if (done < urb->actual_length) { 300 + line6_midibuf_ignore(mb, done); 301 + dev_dbg(line6->ifcdev, "%d %d buffer overflow - message skipped\n", 302 + done, urb->actual_length); 303 + } 304 304 } 305 - spin_unlock_irqrestore(&line6->line6midi->lock, flags); 306 305 307 306 for (;;) { 308 - spin_lock_irqsave(&line6->line6midi->lock, flags); 309 - done = 310 - line6_midibuf_read(mb, line6->buffer_message, 311 - LINE6_MIDI_MESSAGE_MAXLEN, 312 - LINE6_MIDIBUF_READ_RX); 313 - spin_unlock_irqrestore(&line6->line6midi->lock, flags); 307 + scoped_guard(spinlock_irqsave, &line6->line6midi->lock) { 308 + done = 309 + line6_midibuf_read(mb, line6->buffer_message, 310 + LINE6_MIDI_MESSAGE_MAXLEN, 311 + LINE6_MIDIBUF_READ_RX); 312 + } 314 313 315 314 if (done <= 0) 316 315 break;
+2 -8
sound/usb/line6/midi.c
··· 72 72 */ 73 73 static void midi_sent(struct urb *urb) 74 74 { 75 - unsigned long flags; 76 75 int status; 77 76 int num; 78 77 struct usb_line6 *line6 = (struct usb_line6 *)urb->context; ··· 83 84 if (status == -ESHUTDOWN) 84 85 return; 85 86 86 - spin_lock_irqsave(&line6->line6midi->lock, flags); 87 + guard(spinlock_irqsave)(&line6->line6midi->lock); 87 88 num = --line6->line6midi->num_active_send_urbs; 88 89 89 90 if (num == 0) { ··· 93 94 94 95 if (num == 0) 95 96 wake_up(&line6->line6midi->send_wait); 96 - 97 - spin_unlock_irqrestore(&line6->line6midi->lock, flags); 98 97 } 99 98 100 99 /* ··· 155 158 static void line6_midi_output_trigger(struct snd_rawmidi_substream *substream, 156 159 int up) 157 160 { 158 - unsigned long flags; 159 161 struct usb_line6 *line6 = 160 162 line6_rawmidi_substream_midi(substream)->line6; 161 163 162 164 line6->line6midi->substream_transmit = substream; 163 - spin_lock_irqsave(&line6->line6midi->lock, flags); 165 + guard(spinlock_irqsave)(&line6->line6midi->lock); 164 166 165 167 if (line6->line6midi->num_active_send_urbs == 0) 166 168 line6_midi_transmit(substream); 167 - 168 - spin_unlock_irqrestore(&line6->line6midi->lock, flags); 169 169 } 170 170 171 171 static void line6_midi_output_drain(struct snd_rawmidi_substream *substream)
+12 -15
sound/usb/line6/pcm.c
··· 182 182 static int line6_stream_start(struct snd_line6_pcm *line6pcm, int direction, 183 183 int type) 184 184 { 185 - unsigned long flags; 186 185 struct line6_pcm_stream *pstr = get_stream(line6pcm, direction); 187 186 int ret = 0; 188 187 189 - spin_lock_irqsave(&pstr->lock, flags); 188 + guard(spinlock_irqsave)(&pstr->lock); 190 189 if (!test_and_set_bit(type, &pstr->running) && 191 190 !(pstr->active_urbs || pstr->unlink_urbs)) { 192 191 pstr->count = 0; ··· 198 199 199 200 if (ret < 0) 200 201 clear_bit(type, &pstr->running); 201 - spin_unlock_irqrestore(&pstr->lock, flags); 202 202 return ret; 203 203 } 204 204 ··· 205 207 static void line6_stream_stop(struct snd_line6_pcm *line6pcm, int direction, 206 208 int type) 207 209 { 208 - unsigned long flags; 209 210 struct line6_pcm_stream *pstr = get_stream(line6pcm, direction); 210 211 211 - spin_lock_irqsave(&pstr->lock, flags); 212 - clear_bit(type, &pstr->running); 213 - if (!pstr->running) { 214 - spin_unlock_irqrestore(&pstr->lock, flags); 215 - line6_unlink_audio_urbs(line6pcm, pstr); 216 - spin_lock_irqsave(&pstr->lock, flags); 217 - if (direction == SNDRV_PCM_STREAM_CAPTURE) { 218 - line6pcm->prev_fbuf = NULL; 219 - line6pcm->prev_fsize = 0; 220 - } 212 + scoped_guard(spinlock_irqsave, &pstr->lock) { 213 + clear_bit(type, &pstr->running); 214 + if (pstr->running) 215 + return; 221 216 } 222 - spin_unlock_irqrestore(&pstr->lock, flags); 217 + 218 + line6_unlink_audio_urbs(line6pcm, pstr); 219 + if (direction == SNDRV_PCM_STREAM_CAPTURE) { 220 + guard(spinlock_irqsave)(&pstr->lock); 221 + line6pcm->prev_fbuf = NULL; 222 + line6pcm->prev_fsize = 0; 223 + } 223 224 } 224 225 225 226 /* common PCM trigger callback */