@@ -182,11 +182,10 @@ static void line6_buffer_release(struct snd_line6_pcm *line6pcm,
182182static int line6_stream_start (struct snd_line6_pcm * line6pcm , int direction ,
183183 int type )
184184{
185- unsigned long flags ;
186185 struct line6_pcm_stream * pstr = get_stream (line6pcm , direction );
187186 int ret = 0 ;
188187
189- spin_lock_irqsave ( & pstr -> lock , flags );
188+ guard ( spinlock_irqsave )( & pstr -> lock );
190189 if (!test_and_set_bit (type , & pstr -> running ) &&
191190 !(pstr -> active_urbs || pstr -> unlink_urbs )) {
192191 pstr -> count = 0 ;
@@ -199,29 +198,27 @@ static int line6_stream_start(struct snd_line6_pcm *line6pcm, int direction,
199198
200199 if (ret < 0 )
201200 clear_bit (type , & pstr -> running );
202- spin_unlock_irqrestore (& pstr -> lock , flags );
203201 return ret ;
204202}
205203
206204/* stop a PCM stream; this doesn't sync with the unlinked URBs */
207205static void line6_stream_stop (struct snd_line6_pcm * line6pcm , int direction ,
208206 int type )
209207{
210- unsigned long flags ;
211208 struct line6_pcm_stream * pstr = get_stream (line6pcm , direction );
212209
213- spin_lock_irqsave (& pstr -> lock , flags );
214- clear_bit (type , & pstr -> running );
215- if (!pstr -> running ) {
216- spin_unlock_irqrestore (& pstr -> lock , flags );
217- line6_unlink_audio_urbs (line6pcm , pstr );
218- spin_lock_irqsave (& pstr -> lock , flags );
219- if (direction == SNDRV_PCM_STREAM_CAPTURE ) {
220- line6pcm -> prev_fbuf = NULL ;
221- line6pcm -> prev_fsize = 0 ;
222- }
210+ scoped_guard (spinlock_irqsave , & pstr -> lock ) {
211+ clear_bit (type , & pstr -> running );
212+ if (pstr -> running )
213+ return ;
214+ }
215+
216+ line6_unlink_audio_urbs (line6pcm , pstr );
217+ if (direction == SNDRV_PCM_STREAM_CAPTURE ) {
218+ guard (spinlock_irqsave )(& pstr -> lock );
219+ line6pcm -> prev_fbuf = NULL ;
220+ line6pcm -> prev_fsize = 0 ;
223221 }
224- spin_unlock_irqrestore (& pstr -> lock , flags );
225222}
226223
227224/* common PCM trigger callback */
0 commit comments