mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-11 17:10:13 +00:00
ALSA: firewire: bebob: Use guard() for spin locks
Clean up the code using guard() for spin locks. Merely code refactoring, and no behavior change. Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20250828132802.9032-12-tiwai@suse.de
This commit is contained in:
parent
6061b4accb
commit
9c2ca41d57
@ -53,18 +53,14 @@ static __poll_t
|
||||
hwdep_poll(struct snd_hwdep *hwdep, struct file *file, poll_table *wait)
|
||||
{
|
||||
struct snd_bebob *bebob = hwdep->private_data;
|
||||
__poll_t events;
|
||||
|
||||
poll_wait(file, &bebob->hwdep_wait, wait);
|
||||
|
||||
spin_lock_irq(&bebob->lock);
|
||||
guard(spinlock_irq)(&bebob->lock);
|
||||
if (bebob->dev_lock_changed)
|
||||
events = EPOLLIN | EPOLLRDNORM;
|
||||
return EPOLLIN | EPOLLRDNORM;
|
||||
else
|
||||
events = 0;
|
||||
spin_unlock_irq(&bebob->lock);
|
||||
|
||||
return events;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -90,39 +86,27 @@ hwdep_get_info(struct snd_bebob *bebob, void __user *arg)
|
||||
static int
|
||||
hwdep_lock(struct snd_bebob *bebob)
|
||||
{
|
||||
int err;
|
||||
|
||||
spin_lock_irq(&bebob->lock);
|
||||
guard(spinlock_irq)(&bebob->lock);
|
||||
|
||||
if (bebob->dev_lock_count == 0) {
|
||||
bebob->dev_lock_count = -1;
|
||||
err = 0;
|
||||
return 0;
|
||||
} else {
|
||||
err = -EBUSY;
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
spin_unlock_irq(&bebob->lock);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int
|
||||
hwdep_unlock(struct snd_bebob *bebob)
|
||||
{
|
||||
int err;
|
||||
|
||||
spin_lock_irq(&bebob->lock);
|
||||
guard(spinlock_irq)(&bebob->lock);
|
||||
|
||||
if (bebob->dev_lock_count == -1) {
|
||||
bebob->dev_lock_count = 0;
|
||||
err = 0;
|
||||
return 0;
|
||||
} else {
|
||||
err = -EBADFD;
|
||||
return -EBADFD;
|
||||
}
|
||||
|
||||
spin_unlock_irq(&bebob->lock);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -130,10 +114,9 @@ hwdep_release(struct snd_hwdep *hwdep, struct file *file)
|
||||
{
|
||||
struct snd_bebob *bebob = hwdep->private_data;
|
||||
|
||||
spin_lock_irq(&bebob->lock);
|
||||
guard(spinlock_irq)(&bebob->lock);
|
||||
if (bebob->dev_lock_count == -1)
|
||||
bebob->dev_lock_count = 0;
|
||||
spin_unlock_irq(&bebob->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -47,9 +47,8 @@ static int midi_close(struct snd_rawmidi_substream *substream)
|
||||
static void midi_capture_trigger(struct snd_rawmidi_substream *substrm, int up)
|
||||
{
|
||||
struct snd_bebob *bebob = substrm->rmidi->private_data;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&bebob->lock, flags);
|
||||
guard(spinlock_irqsave)(&bebob->lock);
|
||||
|
||||
if (up)
|
||||
amdtp_am824_midi_trigger(&bebob->tx_stream,
|
||||
@ -57,16 +56,13 @@ static void midi_capture_trigger(struct snd_rawmidi_substream *substrm, int up)
|
||||
else
|
||||
amdtp_am824_midi_trigger(&bebob->tx_stream,
|
||||
substrm->number, NULL);
|
||||
|
||||
spin_unlock_irqrestore(&bebob->lock, flags);
|
||||
}
|
||||
|
||||
static void midi_playback_trigger(struct snd_rawmidi_substream *substrm, int up)
|
||||
{
|
||||
struct snd_bebob *bebob = substrm->rmidi->private_data;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&bebob->lock, flags);
|
||||
guard(spinlock_irqsave)(&bebob->lock);
|
||||
|
||||
if (up)
|
||||
amdtp_am824_midi_trigger(&bebob->rx_stream,
|
||||
@ -74,8 +70,6 @@ static void midi_playback_trigger(struct snd_rawmidi_substream *substrm, int up)
|
||||
else
|
||||
amdtp_am824_midi_trigger(&bebob->rx_stream,
|
||||
substrm->number, NULL);
|
||||
|
||||
spin_unlock_irqrestore(&bebob->lock, flags);
|
||||
}
|
||||
|
||||
static void set_midi_substream_names(struct snd_bebob *bebob,
|
||||
|
||||
@ -964,33 +964,24 @@ void snd_bebob_stream_lock_changed(struct snd_bebob *bebob)
|
||||
|
||||
int snd_bebob_stream_lock_try(struct snd_bebob *bebob)
|
||||
{
|
||||
int err;
|
||||
|
||||
spin_lock_irq(&bebob->lock);
|
||||
guard(spinlock_irq)(&bebob->lock);
|
||||
|
||||
/* user land lock this */
|
||||
if (bebob->dev_lock_count < 0) {
|
||||
err = -EBUSY;
|
||||
goto end;
|
||||
}
|
||||
if (bebob->dev_lock_count < 0)
|
||||
return -EBUSY;
|
||||
|
||||
/* this is the first time */
|
||||
if (bebob->dev_lock_count++ == 0)
|
||||
snd_bebob_stream_lock_changed(bebob);
|
||||
err = 0;
|
||||
end:
|
||||
spin_unlock_irq(&bebob->lock);
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void snd_bebob_stream_lock_release(struct snd_bebob *bebob)
|
||||
{
|
||||
spin_lock_irq(&bebob->lock);
|
||||
guard(spinlock_irq)(&bebob->lock);
|
||||
|
||||
if (WARN_ON(bebob->dev_lock_count <= 0))
|
||||
goto end;
|
||||
return;
|
||||
if (--bebob->dev_lock_count == 0)
|
||||
snd_bebob_stream_lock_changed(bebob);
|
||||
end:
|
||||
spin_unlock_irq(&bebob->lock);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user