mirror of https://github.com/torvalds/linux.git
ALSA: parisc: 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>
This commit is contained in:
parent
b10b93d193
commit
f1998e16b2
|
|
@ -140,32 +140,25 @@ harmony_enable_interrupts(struct snd_harmony *h)
|
||||||
static void
|
static void
|
||||||
harmony_mute(struct snd_harmony *h)
|
harmony_mute(struct snd_harmony *h)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
guard(spinlock_irqsave)(&h->mixer_lock);
|
||||||
|
|
||||||
spin_lock_irqsave(&h->mixer_lock, flags);
|
|
||||||
harmony_wait_for_control(h);
|
harmony_wait_for_control(h);
|
||||||
harmony_write(h, HARMONY_GAINCTL, HARMONY_GAIN_SILENCE);
|
harmony_write(h, HARMONY_GAINCTL, HARMONY_GAIN_SILENCE);
|
||||||
spin_unlock_irqrestore(&h->mixer_lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
harmony_unmute(struct snd_harmony *h)
|
harmony_unmute(struct snd_harmony *h)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
guard(spinlock_irqsave)(&h->mixer_lock);
|
||||||
|
|
||||||
spin_lock_irqsave(&h->mixer_lock, flags);
|
|
||||||
harmony_wait_for_control(h);
|
harmony_wait_for_control(h);
|
||||||
harmony_write(h, HARMONY_GAINCTL, h->st.gain);
|
harmony_write(h, HARMONY_GAINCTL, h->st.gain);
|
||||||
spin_unlock_irqrestore(&h->mixer_lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
harmony_set_control(struct snd_harmony *h)
|
harmony_set_control(struct snd_harmony *h)
|
||||||
{
|
{
|
||||||
u32 ctrl;
|
u32 ctrl;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&h->lock, flags);
|
guard(spinlock_irqsave)(&h->lock);
|
||||||
|
|
||||||
ctrl = (HARMONY_CNTL_C |
|
ctrl = (HARMONY_CNTL_C |
|
||||||
(h->st.format << 6) |
|
(h->st.format << 6) |
|
||||||
|
|
@ -174,8 +167,6 @@ harmony_set_control(struct snd_harmony *h)
|
||||||
|
|
||||||
harmony_wait_for_control(h);
|
harmony_wait_for_control(h);
|
||||||
harmony_write(h, HARMONY_CNTL, ctrl);
|
harmony_write(h, HARMONY_CNTL, ctrl);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&h->lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static irqreturn_t
|
static irqreturn_t
|
||||||
|
|
@ -184,53 +175,53 @@ snd_harmony_interrupt(int irq, void *dev)
|
||||||
u32 dstatus;
|
u32 dstatus;
|
||||||
struct snd_harmony *h = dev;
|
struct snd_harmony *h = dev;
|
||||||
|
|
||||||
spin_lock(&h->lock);
|
scoped_guard(spinlock, &h->lock) {
|
||||||
harmony_disable_interrupts(h);
|
harmony_disable_interrupts(h);
|
||||||
harmony_wait_for_control(h);
|
harmony_wait_for_control(h);
|
||||||
dstatus = harmony_read(h, HARMONY_DSTATUS);
|
dstatus = harmony_read(h, HARMONY_DSTATUS);
|
||||||
spin_unlock(&h->lock);
|
}
|
||||||
|
|
||||||
if (dstatus & HARMONY_DSTATUS_PN) {
|
if (dstatus & HARMONY_DSTATUS_PN) {
|
||||||
if (h->psubs && h->st.playing) {
|
if (h->psubs && h->st.playing) {
|
||||||
spin_lock(&h->lock);
|
scoped_guard(spinlock, &h->lock) {
|
||||||
h->pbuf.buf += h->pbuf.count; /* PAGE_SIZE */
|
h->pbuf.buf += h->pbuf.count; /* PAGE_SIZE */
|
||||||
h->pbuf.buf %= h->pbuf.size; /* MAX_BUFS*PAGE_SIZE */
|
h->pbuf.buf %= h->pbuf.size; /* MAX_BUFS*PAGE_SIZE */
|
||||||
|
|
||||||
harmony_write(h, HARMONY_PNXTADD,
|
harmony_write(h, HARMONY_PNXTADD,
|
||||||
h->pbuf.addr + h->pbuf.buf);
|
h->pbuf.addr + h->pbuf.buf);
|
||||||
h->stats.play_intr++;
|
h->stats.play_intr++;
|
||||||
spin_unlock(&h->lock);
|
}
|
||||||
snd_pcm_period_elapsed(h->psubs);
|
snd_pcm_period_elapsed(h->psubs);
|
||||||
} else {
|
} else {
|
||||||
spin_lock(&h->lock);
|
scoped_guard(spinlock, &h->lock) {
|
||||||
harmony_write(h, HARMONY_PNXTADD, h->sdma.addr);
|
harmony_write(h, HARMONY_PNXTADD, h->sdma.addr);
|
||||||
h->stats.silence_intr++;
|
h->stats.silence_intr++;
|
||||||
spin_unlock(&h->lock);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dstatus & HARMONY_DSTATUS_RN) {
|
if (dstatus & HARMONY_DSTATUS_RN) {
|
||||||
if (h->csubs && h->st.capturing) {
|
if (h->csubs && h->st.capturing) {
|
||||||
spin_lock(&h->lock);
|
scoped_guard(spinlock, &h->lock) {
|
||||||
h->cbuf.buf += h->cbuf.count;
|
h->cbuf.buf += h->cbuf.count;
|
||||||
h->cbuf.buf %= h->cbuf.size;
|
h->cbuf.buf %= h->cbuf.size;
|
||||||
|
|
||||||
harmony_write(h, HARMONY_RNXTADD,
|
harmony_write(h, HARMONY_RNXTADD,
|
||||||
h->cbuf.addr + h->cbuf.buf);
|
h->cbuf.addr + h->cbuf.buf);
|
||||||
h->stats.rec_intr++;
|
h->stats.rec_intr++;
|
||||||
spin_unlock(&h->lock);
|
}
|
||||||
snd_pcm_period_elapsed(h->csubs);
|
snd_pcm_period_elapsed(h->csubs);
|
||||||
} else {
|
} else {
|
||||||
spin_lock(&h->lock);
|
scoped_guard(spinlock, &h->lock) {
|
||||||
harmony_write(h, HARMONY_RNXTADD, h->gdma.addr);
|
harmony_write(h, HARMONY_RNXTADD, h->gdma.addr);
|
||||||
h->stats.graveyard_intr++;
|
h->stats.graveyard_intr++;
|
||||||
spin_unlock(&h->lock);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock(&h->lock);
|
scoped_guard(spinlock, &h->lock) {
|
||||||
harmony_enable_interrupts(h);
|
harmony_enable_interrupts(h);
|
||||||
spin_unlock(&h->lock);
|
}
|
||||||
|
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
@ -297,7 +288,7 @@ snd_harmony_playback_trigger(struct snd_pcm_substream *ss, int cmd)
|
||||||
if (h->st.capturing)
|
if (h->st.capturing)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
spin_lock(&h->lock);
|
guard(spinlock)(&h->lock);
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SNDRV_PCM_TRIGGER_START:
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
h->st.playing = 1;
|
h->st.playing = 1;
|
||||||
|
|
@ -316,11 +307,9 @@ snd_harmony_playback_trigger(struct snd_pcm_substream *ss, int cmd)
|
||||||
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
||||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||||
default:
|
default:
|
||||||
spin_unlock(&h->lock);
|
|
||||||
snd_BUG();
|
snd_BUG();
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
spin_unlock(&h->lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -333,7 +322,7 @@ snd_harmony_capture_trigger(struct snd_pcm_substream *ss, int cmd)
|
||||||
if (h->st.playing)
|
if (h->st.playing)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
spin_lock(&h->lock);
|
guard(spinlock)(&h->lock);
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SNDRV_PCM_TRIGGER_START:
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
h->st.capturing = 1;
|
h->st.capturing = 1;
|
||||||
|
|
@ -352,11 +341,9 @@ snd_harmony_capture_trigger(struct snd_pcm_substream *ss, int cmd)
|
||||||
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
||||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||||
default:
|
default:
|
||||||
spin_unlock(&h->lock);
|
|
||||||
snd_BUG();
|
snd_BUG();
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
spin_unlock(&h->lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -674,7 +661,7 @@ snd_harmony_volume_get(struct snd_kcontrol *kc,
|
||||||
int invert = (kc->private_value >> 24) & 0xff;
|
int invert = (kc->private_value >> 24) & 0xff;
|
||||||
int left, right;
|
int left, right;
|
||||||
|
|
||||||
spin_lock_irq(&h->mixer_lock);
|
guard(spinlock_irq)(&h->mixer_lock);
|
||||||
|
|
||||||
left = (h->st.gain >> shift_left) & mask;
|
left = (h->st.gain >> shift_left) & mask;
|
||||||
right = (h->st.gain >> shift_right) & mask;
|
right = (h->st.gain >> shift_right) & mask;
|
||||||
|
|
@ -687,8 +674,6 @@ snd_harmony_volume_get(struct snd_kcontrol *kc,
|
||||||
if (shift_left != shift_right)
|
if (shift_left != shift_right)
|
||||||
ucontrol->value.integer.value[1] = right;
|
ucontrol->value.integer.value[1] = right;
|
||||||
|
|
||||||
spin_unlock_irq(&h->mixer_lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -704,7 +689,7 @@ snd_harmony_volume_put(struct snd_kcontrol *kc,
|
||||||
int left, right;
|
int left, right;
|
||||||
int old_gain = h->st.gain;
|
int old_gain = h->st.gain;
|
||||||
|
|
||||||
spin_lock_irq(&h->mixer_lock);
|
guard(spinlock_irq)(&h->mixer_lock);
|
||||||
|
|
||||||
left = ucontrol->value.integer.value[0] & mask;
|
left = ucontrol->value.integer.value[0] & mask;
|
||||||
if (invert)
|
if (invert)
|
||||||
|
|
@ -722,8 +707,6 @@ snd_harmony_volume_put(struct snd_kcontrol *kc,
|
||||||
|
|
||||||
snd_harmony_set_new_gain(h);
|
snd_harmony_set_new_gain(h);
|
||||||
|
|
||||||
spin_unlock_irq(&h->mixer_lock);
|
|
||||||
|
|
||||||
return h->st.gain != old_gain;
|
return h->st.gain != old_gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -743,13 +726,11 @@ snd_harmony_captureroute_get(struct snd_kcontrol *kc,
|
||||||
struct snd_harmony *h = snd_kcontrol_chip(kc);
|
struct snd_harmony *h = snd_kcontrol_chip(kc);
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
spin_lock_irq(&h->mixer_lock);
|
guard(spinlock_irq)(&h->mixer_lock);
|
||||||
|
|
||||||
value = (h->st.gain >> HARMONY_GAIN_IS_SHIFT) & 1;
|
value = (h->st.gain >> HARMONY_GAIN_IS_SHIFT) & 1;
|
||||||
ucontrol->value.enumerated.item[0] = value;
|
ucontrol->value.enumerated.item[0] = value;
|
||||||
|
|
||||||
spin_unlock_irq(&h->mixer_lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -761,7 +742,7 @@ snd_harmony_captureroute_put(struct snd_kcontrol *kc,
|
||||||
int value;
|
int value;
|
||||||
int old_gain = h->st.gain;
|
int old_gain = h->st.gain;
|
||||||
|
|
||||||
spin_lock_irq(&h->mixer_lock);
|
guard(spinlock_irq)(&h->mixer_lock);
|
||||||
|
|
||||||
value = ucontrol->value.enumerated.item[0] & 1;
|
value = ucontrol->value.enumerated.item[0] & 1;
|
||||||
h->st.gain &= ~HARMONY_GAIN_IS_MASK;
|
h->st.gain &= ~HARMONY_GAIN_IS_MASK;
|
||||||
|
|
@ -769,8 +750,6 @@ snd_harmony_captureroute_put(struct snd_kcontrol *kc,
|
||||||
|
|
||||||
snd_harmony_set_new_gain(h);
|
snd_harmony_set_new_gain(h);
|
||||||
|
|
||||||
spin_unlock_irq(&h->mixer_lock);
|
|
||||||
|
|
||||||
return h->st.gain != old_gain;
|
return h->st.gain != old_gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue