mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
ALSA: firewire: motu: 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> Link: https://patch.msgid.link/20250830080351.25600-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
@@ -87,10 +87,9 @@ void snd_motu_command_dsp_message_parser_parse(const struct amdtp_stream *s,
|
||||
unsigned int data_block_quadlets = s->data_block_quadlets;
|
||||
struct msg_parser *parser = motu->message_parser;
|
||||
unsigned int interval = parser->interval;
|
||||
unsigned long flags;
|
||||
int i;
|
||||
|
||||
spin_lock_irqsave(&parser->lock, flags);
|
||||
guard(spinlock_irqsave)(&parser->lock);
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
__be32 *buffer = desc->ctx_payload;
|
||||
@@ -168,17 +167,13 @@ void snd_motu_command_dsp_message_parser_parse(const struct amdtp_stream *s,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&parser->lock, flags);
|
||||
}
|
||||
|
||||
void snd_motu_command_dsp_message_parser_copy_meter(struct snd_motu *motu,
|
||||
struct snd_firewire_motu_command_dsp_meter *meter)
|
||||
{
|
||||
struct msg_parser *parser = motu->message_parser;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&parser->lock, flags);
|
||||
guard(spinlock_irqsave)(&parser->lock);
|
||||
memcpy(meter, &parser->meter, sizeof(*meter));
|
||||
spin_unlock_irqrestore(&parser->lock, flags);
|
||||
}
|
||||
|
||||
@@ -100,18 +100,14 @@ static __poll_t hwdep_poll(struct snd_hwdep *hwdep, struct file *file,
|
||||
poll_table *wait)
|
||||
{
|
||||
struct snd_motu *motu = hwdep->private_data;
|
||||
__poll_t events;
|
||||
|
||||
poll_wait(file, &motu->hwdep_wait, wait);
|
||||
|
||||
spin_lock_irq(&motu->lock);
|
||||
guard(spinlock_irq)(&motu->lock);
|
||||
if (motu->dev_lock_changed || motu->msg || has_dsp_event(motu))
|
||||
events = EPOLLIN | EPOLLRDNORM;
|
||||
return EPOLLIN | EPOLLRDNORM;
|
||||
else
|
||||
events = 0;
|
||||
spin_unlock_irq(&motu->lock);
|
||||
|
||||
return events;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hwdep_get_info(struct snd_motu *motu, void __user *arg)
|
||||
@@ -135,48 +131,35 @@ static int hwdep_get_info(struct snd_motu *motu, void __user *arg)
|
||||
|
||||
static int hwdep_lock(struct snd_motu *motu)
|
||||
{
|
||||
int err;
|
||||
|
||||
spin_lock_irq(&motu->lock);
|
||||
guard(spinlock_irq)(&motu->lock);
|
||||
|
||||
if (motu->dev_lock_count == 0) {
|
||||
motu->dev_lock_count = -1;
|
||||
err = 0;
|
||||
return 0;
|
||||
} else {
|
||||
err = -EBUSY;
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
spin_unlock_irq(&motu->lock);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int hwdep_unlock(struct snd_motu *motu)
|
||||
{
|
||||
int err;
|
||||
|
||||
spin_lock_irq(&motu->lock);
|
||||
guard(spinlock_irq)(&motu->lock);
|
||||
|
||||
if (motu->dev_lock_count == -1) {
|
||||
motu->dev_lock_count = 0;
|
||||
err = 0;
|
||||
return 0;
|
||||
} else {
|
||||
err = -EBADFD;
|
||||
return -EBADFD;
|
||||
}
|
||||
|
||||
spin_unlock_irq(&motu->lock);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int hwdep_release(struct snd_hwdep *hwdep, struct file *file)
|
||||
{
|
||||
struct snd_motu *motu = hwdep->private_data;
|
||||
|
||||
spin_lock_irq(&motu->lock);
|
||||
guard(spinlock_irq)(&motu->lock);
|
||||
if (motu->dev_lock_count == -1)
|
||||
motu->dev_lock_count = 0;
|
||||
spin_unlock_irq(&motu->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_motu *motu = substrm->rmidi->private_data;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&motu->lock, flags);
|
||||
guard(spinlock_irqsave)(&motu->lock);
|
||||
|
||||
if (up)
|
||||
amdtp_motu_midi_trigger(&motu->tx_stream, substrm->number,
|
||||
@@ -57,16 +56,13 @@ static void midi_capture_trigger(struct snd_rawmidi_substream *substrm, int up)
|
||||
else
|
||||
amdtp_motu_midi_trigger(&motu->tx_stream, substrm->number,
|
||||
NULL);
|
||||
|
||||
spin_unlock_irqrestore(&motu->lock, flags);
|
||||
}
|
||||
|
||||
static void midi_playback_trigger(struct snd_rawmidi_substream *substrm, int up)
|
||||
{
|
||||
struct snd_motu *motu = substrm->rmidi->private_data;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&motu->lock, flags);
|
||||
guard(spinlock_irqsave)(&motu->lock);
|
||||
|
||||
if (up)
|
||||
amdtp_motu_midi_trigger(&motu->rx_stream, substrm->number,
|
||||
@@ -74,8 +70,6 @@ static void midi_playback_trigger(struct snd_rawmidi_substream *substrm, int up)
|
||||
else
|
||||
amdtp_motu_midi_trigger(&motu->rx_stream, substrm->number,
|
||||
NULL);
|
||||
|
||||
spin_unlock_irqrestore(&motu->lock, flags);
|
||||
}
|
||||
|
||||
static void set_midi_substream_names(struct snd_motu *motu,
|
||||
|
||||
@@ -150,10 +150,9 @@ void snd_motu_register_dsp_message_parser_parse(const struct amdtp_stream *s,
|
||||
struct msg_parser *parser = motu->message_parser;
|
||||
bool meter_pos_quirk = parser->meter_pos_quirk;
|
||||
unsigned int pos = parser->push_pos;
|
||||
unsigned long flags;
|
||||
int i;
|
||||
|
||||
spin_lock_irqsave(&parser->lock, flags);
|
||||
guard(spinlock_irqsave)(&parser->lock);
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
__be32 *buffer = desc->ctx_payload;
|
||||
@@ -363,30 +362,24 @@ void snd_motu_register_dsp_message_parser_parse(const struct amdtp_stream *s,
|
||||
|
||||
if (pos != parser->push_pos)
|
||||
wake_up(&motu->hwdep_wait);
|
||||
|
||||
spin_unlock_irqrestore(&parser->lock, flags);
|
||||
}
|
||||
|
||||
void snd_motu_register_dsp_message_parser_copy_meter(struct snd_motu *motu,
|
||||
struct snd_firewire_motu_register_dsp_meter *meter)
|
||||
{
|
||||
struct msg_parser *parser = motu->message_parser;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&parser->lock, flags);
|
||||
guard(spinlock_irqsave)(&parser->lock);
|
||||
memcpy(meter, &parser->meter, sizeof(*meter));
|
||||
spin_unlock_irqrestore(&parser->lock, flags);
|
||||
}
|
||||
|
||||
void snd_motu_register_dsp_message_parser_copy_parameter(struct snd_motu *motu,
|
||||
struct snd_firewire_motu_register_dsp_parameter *param)
|
||||
{
|
||||
struct msg_parser *parser = motu->message_parser;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&parser->lock, flags);
|
||||
guard(spinlock_irqsave)(&parser->lock);
|
||||
memcpy(param, &parser->param, sizeof(*param));
|
||||
spin_unlock_irqrestore(&parser->lock, flags);
|
||||
}
|
||||
|
||||
unsigned int snd_motu_register_dsp_message_parser_count_event(struct snd_motu *motu)
|
||||
@@ -403,12 +396,11 @@ bool snd_motu_register_dsp_message_parser_copy_event(struct snd_motu *motu, u32
|
||||
{
|
||||
struct msg_parser *parser = motu->message_parser;
|
||||
unsigned int pos = parser->pull_pos;
|
||||
unsigned long flags;
|
||||
|
||||
if (pos == parser->push_pos)
|
||||
return false;
|
||||
|
||||
spin_lock_irqsave(&parser->lock, flags);
|
||||
guard(spinlock_irqsave)(&parser->lock);
|
||||
|
||||
*event = parser->event_queue[pos];
|
||||
|
||||
@@ -417,7 +409,5 @@ bool snd_motu_register_dsp_message_parser_copy_event(struct snd_motu *motu, u32
|
||||
pos = 0;
|
||||
parser->pull_pos = pos;
|
||||
|
||||
spin_unlock_irqrestore(&parser->lock, flags);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -407,32 +407,23 @@ static void motu_lock_changed(struct snd_motu *motu)
|
||||
|
||||
int snd_motu_stream_lock_try(struct snd_motu *motu)
|
||||
{
|
||||
int err;
|
||||
guard(spinlock_irq)(&motu->lock);
|
||||
|
||||
spin_lock_irq(&motu->lock);
|
||||
|
||||
if (motu->dev_lock_count < 0) {
|
||||
err = -EBUSY;
|
||||
goto out;
|
||||
}
|
||||
if (motu->dev_lock_count < 0)
|
||||
return -EBUSY;
|
||||
|
||||
if (motu->dev_lock_count++ == 0)
|
||||
motu_lock_changed(motu);
|
||||
err = 0;
|
||||
out:
|
||||
spin_unlock_irq(&motu->lock);
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void snd_motu_stream_lock_release(struct snd_motu *motu)
|
||||
{
|
||||
spin_lock_irq(&motu->lock);
|
||||
guard(spinlock_irq)(&motu->lock);
|
||||
|
||||
if (WARN_ON(motu->dev_lock_count <= 0))
|
||||
goto out;
|
||||
return;
|
||||
|
||||
if (--motu->dev_lock_count == 0)
|
||||
motu_lock_changed(motu);
|
||||
out:
|
||||
spin_unlock_irq(&motu->lock);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ static void handle_message(struct fw_card *card, struct fw_request *request,
|
||||
{
|
||||
struct snd_motu *motu = callback_data;
|
||||
__be32 *buf = (__be32 *)data;
|
||||
unsigned long flags;
|
||||
|
||||
if (tcode != TCODE_WRITE_QUADLET_REQUEST) {
|
||||
fw_send_response(card, request, RCODE_COMPLETE);
|
||||
@@ -63,9 +62,9 @@ static void handle_message(struct fw_card *card, struct fw_request *request,
|
||||
return;
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&motu->lock, flags);
|
||||
motu->msg = be32_to_cpu(*buf);
|
||||
spin_unlock_irqrestore(&motu->lock, flags);
|
||||
scoped_guard(spinlock_irqsave, &motu->lock) {
|
||||
motu->msg = be32_to_cpu(*buf);
|
||||
}
|
||||
|
||||
fw_send_response(card, request, RCODE_COMPLETE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user