diff options
Diffstat (limited to 'sound/pci/ctxfi/ctamixer.c')
-rw-r--r-- | sound/pci/ctxfi/ctamixer.c | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/sound/pci/ctxfi/ctamixer.c b/sound/pci/ctxfi/ctamixer.c index 397900929aa6..bb4658592636 100644 --- a/sound/pci/ctxfi/ctamixer.c +++ b/sound/pci/ctxfi/ctamixer.c @@ -231,7 +231,6 @@ static int get_amixer_rsc(struct amixer_mgr *mgr, int err, i; unsigned int idx; struct amixer *amixer; - unsigned long flags; *ramixer = NULL; @@ -243,15 +242,15 @@ static int get_amixer_rsc(struct amixer_mgr *mgr, /* Check whether there are sufficient * amixer resources to meet request. */ err = 0; - spin_lock_irqsave(&mgr->mgr_lock, flags); - for (i = 0; i < desc->msr; i++) { - err = mgr_get_resource(&mgr->mgr, 1, &idx); - if (err) - break; + scoped_guard(spinlock_irqsave, &mgr->mgr_lock) { + for (i = 0; i < desc->msr; i++) { + err = mgr_get_resource(&mgr->mgr, 1, &idx); + if (err) + break; - amixer->idx[i] = idx; + amixer->idx[i] = idx; + } } - spin_unlock_irqrestore(&mgr->mgr_lock, flags); if (err) { dev_err(mgr->card->dev, "Can't meet AMIXER resource request!\n"); @@ -267,25 +266,23 @@ static int get_amixer_rsc(struct amixer_mgr *mgr, return 0; error: - spin_lock_irqsave(&mgr->mgr_lock, flags); - for (i--; i >= 0; i--) - mgr_put_resource(&mgr->mgr, 1, amixer->idx[i]); + scoped_guard(spinlock_irqsave, &mgr->mgr_lock) { + for (i--; i >= 0; i--) + mgr_put_resource(&mgr->mgr, 1, amixer->idx[i]); + } - spin_unlock_irqrestore(&mgr->mgr_lock, flags); kfree(amixer); return err; } static int put_amixer_rsc(struct amixer_mgr *mgr, struct amixer *amixer) { - unsigned long flags; int i; - spin_lock_irqsave(&mgr->mgr_lock, flags); - for (i = 0; i < amixer->rsc.msr; i++) - mgr_put_resource(&mgr->mgr, 1, amixer->idx[i]); - - spin_unlock_irqrestore(&mgr->mgr_lock, flags); + scoped_guard(spinlock_irqsave, &mgr->mgr_lock) { + for (i = 0; i < amixer->rsc.msr; i++) + mgr_put_resource(&mgr->mgr, 1, amixer->idx[i]); + } amixer_rsc_uninit(amixer); kfree(amixer); @@ -387,7 +384,6 @@ static int get_sum_rsc(struct sum_mgr *mgr, int err, i; unsigned int idx; struct sum *sum; - unsigned long flags; *rsum = NULL; @@ -398,15 +394,15 @@ static int get_sum_rsc(struct sum_mgr *mgr, /* Check whether there are sufficient sum resources to meet request. */ err = 0; - spin_lock_irqsave(&mgr->mgr_lock, flags); - for (i = 0; i < desc->msr; i++) { - err = mgr_get_resource(&mgr->mgr, 1, &idx); - if (err) - break; + scoped_guard(spinlock_irqsave, &mgr->mgr_lock) { + for (i = 0; i < desc->msr; i++) { + err = mgr_get_resource(&mgr->mgr, 1, &idx); + if (err) + break; - sum->idx[i] = idx; + sum->idx[i] = idx; + } } - spin_unlock_irqrestore(&mgr->mgr_lock, flags); if (err) { dev_err(mgr->card->dev, "Can't meet SUM resource request!\n"); @@ -422,25 +418,22 @@ static int get_sum_rsc(struct sum_mgr *mgr, return 0; error: - spin_lock_irqsave(&mgr->mgr_lock, flags); - for (i--; i >= 0; i--) - mgr_put_resource(&mgr->mgr, 1, sum->idx[i]); - - spin_unlock_irqrestore(&mgr->mgr_lock, flags); + scoped_guard(spinlock_irqsave, &mgr->mgr_lock) { + for (i--; i >= 0; i--) + mgr_put_resource(&mgr->mgr, 1, sum->idx[i]); + } kfree(sum); return err; } static int put_sum_rsc(struct sum_mgr *mgr, struct sum *sum) { - unsigned long flags; int i; - spin_lock_irqsave(&mgr->mgr_lock, flags); - for (i = 0; i < sum->rsc.msr; i++) - mgr_put_resource(&mgr->mgr, 1, sum->idx[i]); - - spin_unlock_irqrestore(&mgr->mgr_lock, flags); + scoped_guard(spinlock_irqsave, &mgr->mgr_lock) { + for (i = 0; i < sum->rsc.msr; i++) + mgr_put_resource(&mgr->mgr, 1, sum->idx[i]); + } sum_rsc_uninit(sum); kfree(sum); |