mirror of https://github.com/torvalds/linux.git
ALSA: caiaq: 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> Link: https://patch.msgid.link/20250829150724.6886-10-tiwai@suse.de
This commit is contained in:
parent
cff7acfe0b
commit
95692e3c9f
|
|
@ -51,29 +51,24 @@ static void
|
||||||
activate_substream(struct snd_usb_caiaqdev *cdev,
|
activate_substream(struct snd_usb_caiaqdev *cdev,
|
||||||
struct snd_pcm_substream *sub)
|
struct snd_pcm_substream *sub)
|
||||||
{
|
{
|
||||||
spin_lock(&cdev->spinlock);
|
guard(spinlock)(&cdev->spinlock);
|
||||||
|
|
||||||
if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
||||||
cdev->sub_playback[sub->number] = sub;
|
cdev->sub_playback[sub->number] = sub;
|
||||||
else
|
else
|
||||||
cdev->sub_capture[sub->number] = sub;
|
cdev->sub_capture[sub->number] = sub;
|
||||||
|
|
||||||
spin_unlock(&cdev->spinlock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
deactivate_substream(struct snd_usb_caiaqdev *cdev,
|
deactivate_substream(struct snd_usb_caiaqdev *cdev,
|
||||||
struct snd_pcm_substream *sub)
|
struct snd_pcm_substream *sub)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
guard(spinlock_irqsave)(&cdev->spinlock);
|
||||||
spin_lock_irqsave(&cdev->spinlock, flags);
|
|
||||||
|
|
||||||
if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
||||||
cdev->sub_playback[sub->number] = NULL;
|
cdev->sub_playback[sub->number] = NULL;
|
||||||
else
|
else
|
||||||
cdev->sub_capture[sub->number] = NULL;
|
cdev->sub_capture[sub->number] = NULL;
|
||||||
|
|
||||||
spin_unlock_irqrestore(&cdev->spinlock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
@ -285,25 +280,18 @@ snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub)
|
||||||
{
|
{
|
||||||
int index = sub->number;
|
int index = sub->number;
|
||||||
struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub);
|
struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub);
|
||||||
snd_pcm_uframes_t ptr;
|
|
||||||
|
|
||||||
spin_lock(&cdev->spinlock);
|
guard(spinlock)(&cdev->spinlock);
|
||||||
|
|
||||||
if (cdev->input_panic || cdev->output_panic) {
|
if (cdev->input_panic || cdev->output_panic)
|
||||||
ptr = SNDRV_PCM_POS_XRUN;
|
return SNDRV_PCM_POS_XRUN;
|
||||||
goto unlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
||||||
ptr = bytes_to_frames(sub->runtime,
|
return bytes_to_frames(sub->runtime,
|
||||||
cdev->audio_out_buf_pos[index]);
|
cdev->audio_out_buf_pos[index]);
|
||||||
else
|
else
|
||||||
ptr = bytes_to_frames(sub->runtime,
|
return bytes_to_frames(sub->runtime,
|
||||||
cdev->audio_in_buf_pos[index]);
|
cdev->audio_in_buf_pos[index]);
|
||||||
|
|
||||||
unlock:
|
|
||||||
spin_unlock(&cdev->spinlock);
|
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* operators for both playback and capture */
|
/* operators for both playback and capture */
|
||||||
|
|
@ -601,7 +589,6 @@ static void read_completed(struct urb *urb)
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct urb *out = NULL;
|
struct urb *out = NULL;
|
||||||
int i, frame, len, send_it = 0, outframe = 0;
|
int i, frame, len, send_it = 0, outframe = 0;
|
||||||
unsigned long flags;
|
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
|
|
||||||
if (urb->status || !info)
|
if (urb->status || !info)
|
||||||
|
|
@ -638,10 +625,10 @@ static void read_completed(struct urb *urb)
|
||||||
offset += len;
|
offset += len;
|
||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
spin_lock_irqsave(&cdev->spinlock, flags);
|
scoped_guard(spinlock_irqsave, &cdev->spinlock) {
|
||||||
fill_out_urb(cdev, out, &out->iso_frame_desc[outframe]);
|
fill_out_urb(cdev, out, &out->iso_frame_desc[outframe]);
|
||||||
read_in_urb(cdev, urb, &urb->iso_frame_desc[frame]);
|
read_in_urb(cdev, urb, &urb->iso_frame_desc[frame]);
|
||||||
spin_unlock_irqrestore(&cdev->spinlock, flags);
|
}
|
||||||
check_for_elapsed_periods(cdev, cdev->sub_playback);
|
check_for_elapsed_periods(cdev, cdev->sub_playback);
|
||||||
check_for_elapsed_periods(cdev, cdev->sub_capture);
|
check_for_elapsed_periods(cdev, cdev->sub_capture);
|
||||||
send_it = 1;
|
send_it = 1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue