diff options
| author | Takashi Iwai <tiwai@suse.de> | 2025-08-29 17:42:37 +0300 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2025-09-01 14:52:38 +0300 |
| commit | fcee249f98d0b84d5d0222b47d30c93bbca08e17 (patch) | |
| tree | 4b96d57c7e78f3d2d23b944e5b92aa520bb49114 | |
| parent | 0a36f7d69dca0fd25ef66acda795b8b2b0228451 (diff) | |
| download | linux-fcee249f98d0b84d5d0222b47d30c93bbca08e17.tar.xz | |
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
| -rw-r--r-- | sound/pci/ac97/ac97_pcm.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/sound/pci/ac97/ac97_pcm.c b/sound/pci/ac97/ac97_pcm.c index fa14a562fe87..4715d88ff8f4 100644 --- a/sound/pci/ac97/ac97_pcm.c +++ b/sound/pci/ac97/ac97_pcm.c @@ -570,33 +570,31 @@ int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate, return err; } } - spin_lock_irq(&pcm->bus->bus_lock); - for (i = 3; i < 12; i++) { - if (!(slots & (1 << i))) - continue; - ok_flag = 0; - for (cidx = 0; cidx < 4; cidx++) { - if (bus->used_slots[pcm->stream][cidx] & (1 << i)) { - spin_unlock_irq(&pcm->bus->bus_lock); - err = -EBUSY; - goto error; + scoped_guard(spinlock_irq, &pcm->bus->bus_lock) { + for (i = 3; i < 12; i++) { + if (!(slots & (1 << i))) + continue; + ok_flag = 0; + for (cidx = 0; cidx < 4; cidx++) { + if (bus->used_slots[pcm->stream][cidx] & (1 << i)) { + err = -EBUSY; + goto error; + } + if (pcm->r[r].rslots[cidx] & (1 << i)) { + bus->used_slots[pcm->stream][cidx] |= (1 << i); + ok_flag++; + } } - 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; } } - 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++) { if (!(slots & (1 << i))) continue; @@ -664,7 +662,7 @@ int snd_ac97_pcm_close(struct ac97_pcm *pcm) #endif bus = pcm->bus; - spin_lock_irq(&pcm->bus->bus_lock); + guard(spinlock_irq)(&pcm->bus->bus_lock); for (i = 3; i < 12; i++) { if (!(slots & (1 << i))) continue; @@ -673,7 +671,6 @@ int snd_ac97_pcm_close(struct ac97_pcm *pcm) } pcm->aslots = 0; pcm->cur_dbl = 0; - spin_unlock_irq(&pcm->bus->bus_lock); return 0; } |
