mirror of https://github.com/torvalds/linux.git
ALSA: ac97: 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/20250829144342.4290-3-tiwai@suse.de
This commit is contained in:
parent
0a36f7d69d
commit
fcee249f98
|
|
@ -570,33 +570,31 @@ int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_lock_irq(&pcm->bus->bus_lock);
|
scoped_guard(spinlock_irq, &pcm->bus->bus_lock) {
|
||||||
for (i = 3; i < 12; i++) {
|
for (i = 3; i < 12; i++) {
|
||||||
if (!(slots & (1 << i)))
|
if (!(slots & (1 << i)))
|
||||||
continue;
|
continue;
|
||||||
ok_flag = 0;
|
ok_flag = 0;
|
||||||
for (cidx = 0; cidx < 4; cidx++) {
|
for (cidx = 0; cidx < 4; cidx++) {
|
||||||
if (bus->used_slots[pcm->stream][cidx] & (1 << i)) {
|
if (bus->used_slots[pcm->stream][cidx] & (1 << i)) {
|
||||||
spin_unlock_irq(&pcm->bus->bus_lock);
|
err = -EBUSY;
|
||||||
err = -EBUSY;
|
goto error;
|
||||||
|
}
|
||||||
|
if (pcm->r[r].rslots[cidx] & (1 << i)) {
|
||||||
|
bus->used_slots[pcm->stream][cidx] |= (1 << i);
|
||||||
|
ok_flag++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ok_flag) {
|
||||||
|
dev_err(bus->card->dev,
|
||||||
|
"cannot find configuration for AC97 slot %i\n",
|
||||||
|
i);
|
||||||
|
err = -EAGAIN;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (pcm->r[r].rslots[cidx] & (1 << i)) {
|
|
||||||
bus->used_slots[pcm->stream][cidx] |= (1 << i);
|
|
||||||
ok_flag++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!ok_flag) {
|
|
||||||
spin_unlock_irq(&pcm->bus->bus_lock);
|
|
||||||
dev_err(bus->card->dev,
|
|
||||||
"cannot find configuration for AC97 slot %i\n",
|
|
||||||
i);
|
|
||||||
err = -EAGAIN;
|
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
pcm->cur_dbl = r;
|
||||||
}
|
}
|
||||||
pcm->cur_dbl = r;
|
|
||||||
spin_unlock_irq(&pcm->bus->bus_lock);
|
|
||||||
for (i = 3; i < 12; i++) {
|
for (i = 3; i < 12; i++) {
|
||||||
if (!(slots & (1 << i)))
|
if (!(slots & (1 << i)))
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -664,7 +662,7 @@ int snd_ac97_pcm_close(struct ac97_pcm *pcm)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bus = pcm->bus;
|
bus = pcm->bus;
|
||||||
spin_lock_irq(&pcm->bus->bus_lock);
|
guard(spinlock_irq)(&pcm->bus->bus_lock);
|
||||||
for (i = 3; i < 12; i++) {
|
for (i = 3; i < 12; i++) {
|
||||||
if (!(slots & (1 << i)))
|
if (!(slots & (1 << i)))
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -673,7 +671,6 @@ int snd_ac97_pcm_close(struct ac97_pcm *pcm)
|
||||||
}
|
}
|
||||||
pcm->aslots = 0;
|
pcm->aslots = 0;
|
||||||
pcm->cur_dbl = 0;
|
pcm->cur_dbl = 0;
|
||||||
spin_unlock_irq(&pcm->bus->bus_lock);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue