ALSA: arm: 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>pull/476/head
parent
56100eed4f
commit
2d7d8e0fa5
148
sound/arm/aaci.c
148
sound/arm/aaci.c
|
|
@ -210,45 +210,43 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock(&aacirun->lock);
|
scoped_guard(spinlock, &aacirun->lock) {
|
||||||
|
ptr = aacirun->ptr;
|
||||||
|
do {
|
||||||
|
unsigned int len = aacirun->fifo_bytes;
|
||||||
|
u32 val;
|
||||||
|
|
||||||
ptr = aacirun->ptr;
|
if (aacirun->bytes <= 0) {
|
||||||
do {
|
aacirun->bytes += aacirun->period;
|
||||||
unsigned int len = aacirun->fifo_bytes;
|
period_elapsed = true;
|
||||||
u32 val;
|
}
|
||||||
|
if (!(aacirun->cr & CR_EN))
|
||||||
|
break;
|
||||||
|
|
||||||
if (aacirun->bytes <= 0) {
|
val = readl(aacirun->base + AACI_SR);
|
||||||
aacirun->bytes += aacirun->period;
|
if (!(val & SR_RXHF))
|
||||||
period_elapsed = true;
|
break;
|
||||||
}
|
if (!(val & SR_RXFF))
|
||||||
if (!(aacirun->cr & CR_EN))
|
len >>= 1;
|
||||||
break;
|
|
||||||
|
|
||||||
val = readl(aacirun->base + AACI_SR);
|
aacirun->bytes -= len;
|
||||||
if (!(val & SR_RXHF))
|
|
||||||
break;
|
|
||||||
if (!(val & SR_RXFF))
|
|
||||||
len >>= 1;
|
|
||||||
|
|
||||||
aacirun->bytes -= len;
|
/* reading 16 bytes at a time */
|
||||||
|
for( ; len > 0; len -= 16) {
|
||||||
|
asm(
|
||||||
|
"ldmia %1, {r0, r1, r2, r3}\n\t"
|
||||||
|
"stmia %0!, {r0, r1, r2, r3}"
|
||||||
|
: "+r" (ptr)
|
||||||
|
: "r" (aacirun->fifo)
|
||||||
|
: "r0", "r1", "r2", "r3", "cc");
|
||||||
|
|
||||||
/* reading 16 bytes at a time */
|
if (ptr >= aacirun->end)
|
||||||
for( ; len > 0; len -= 16) {
|
ptr = aacirun->start;
|
||||||
asm(
|
}
|
||||||
"ldmia %1, {r0, r1, r2, r3}\n\t"
|
} while(1);
|
||||||
"stmia %0!, {r0, r1, r2, r3}"
|
|
||||||
: "+r" (ptr)
|
|
||||||
: "r" (aacirun->fifo)
|
|
||||||
: "r0", "r1", "r2", "r3", "cc");
|
|
||||||
|
|
||||||
if (ptr >= aacirun->end)
|
aacirun->ptr = ptr;
|
||||||
ptr = aacirun->start;
|
}
|
||||||
}
|
|
||||||
} while(1);
|
|
||||||
|
|
||||||
aacirun->ptr = ptr;
|
|
||||||
|
|
||||||
spin_unlock(&aacirun->lock);
|
|
||||||
|
|
||||||
if (period_elapsed)
|
if (period_elapsed)
|
||||||
snd_pcm_period_elapsed(aacirun->substream);
|
snd_pcm_period_elapsed(aacirun->substream);
|
||||||
|
|
@ -270,45 +268,43 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock(&aacirun->lock);
|
scoped_guard(spinlock, &aacirun->lock) {
|
||||||
|
ptr = aacirun->ptr;
|
||||||
|
do {
|
||||||
|
unsigned int len = aacirun->fifo_bytes;
|
||||||
|
u32 val;
|
||||||
|
|
||||||
ptr = aacirun->ptr;
|
if (aacirun->bytes <= 0) {
|
||||||
do {
|
aacirun->bytes += aacirun->period;
|
||||||
unsigned int len = aacirun->fifo_bytes;
|
period_elapsed = true;
|
||||||
u32 val;
|
}
|
||||||
|
if (!(aacirun->cr & CR_EN))
|
||||||
|
break;
|
||||||
|
|
||||||
if (aacirun->bytes <= 0) {
|
val = readl(aacirun->base + AACI_SR);
|
||||||
aacirun->bytes += aacirun->period;
|
if (!(val & SR_TXHE))
|
||||||
period_elapsed = true;
|
break;
|
||||||
}
|
if (!(val & SR_TXFE))
|
||||||
if (!(aacirun->cr & CR_EN))
|
len >>= 1;
|
||||||
break;
|
|
||||||
|
|
||||||
val = readl(aacirun->base + AACI_SR);
|
aacirun->bytes -= len;
|
||||||
if (!(val & SR_TXHE))
|
|
||||||
break;
|
|
||||||
if (!(val & SR_TXFE))
|
|
||||||
len >>= 1;
|
|
||||||
|
|
||||||
aacirun->bytes -= len;
|
/* writing 16 bytes at a time */
|
||||||
|
for ( ; len > 0; len -= 16) {
|
||||||
|
asm(
|
||||||
|
"ldmia %0!, {r0, r1, r2, r3}\n\t"
|
||||||
|
"stmia %1, {r0, r1, r2, r3}"
|
||||||
|
: "+r" (ptr)
|
||||||
|
: "r" (aacirun->fifo)
|
||||||
|
: "r0", "r1", "r2", "r3", "cc");
|
||||||
|
|
||||||
/* writing 16 bytes at a time */
|
if (ptr >= aacirun->end)
|
||||||
for ( ; len > 0; len -= 16) {
|
ptr = aacirun->start;
|
||||||
asm(
|
}
|
||||||
"ldmia %0!, {r0, r1, r2, r3}\n\t"
|
} while (1);
|
||||||
"stmia %1, {r0, r1, r2, r3}"
|
|
||||||
: "+r" (ptr)
|
|
||||||
: "r" (aacirun->fifo)
|
|
||||||
: "r0", "r1", "r2", "r3", "cc");
|
|
||||||
|
|
||||||
if (ptr >= aacirun->end)
|
aacirun->ptr = ptr;
|
||||||
ptr = aacirun->start;
|
}
|
||||||
}
|
|
||||||
} while (1);
|
|
||||||
|
|
||||||
aacirun->ptr = ptr;
|
|
||||||
|
|
||||||
spin_unlock(&aacirun->lock);
|
|
||||||
|
|
||||||
if (period_elapsed)
|
if (period_elapsed)
|
||||||
snd_pcm_period_elapsed(aacirun->substream);
|
snd_pcm_period_elapsed(aacirun->substream);
|
||||||
|
|
@ -577,10 +573,8 @@ static void aaci_pcm_playback_start(struct aaci_runtime *aacirun)
|
||||||
static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cmd)
|
static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||||
{
|
{
|
||||||
struct aaci_runtime *aacirun = substream->runtime->private_data;
|
struct aaci_runtime *aacirun = substream->runtime->private_data;
|
||||||
unsigned long flags;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&aacirun->lock, flags);
|
guard(spinlock_irqsave)(&aacirun->lock);
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SNDRV_PCM_TRIGGER_START:
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
|
|
@ -606,12 +600,10 @@ static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cm
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore(&aacirun->lock, flags);
|
return 0;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct snd_pcm_ops aaci_playback_ops = {
|
static const struct snd_pcm_ops aaci_playback_ops = {
|
||||||
|
|
@ -661,10 +653,8 @@ static void aaci_pcm_capture_start(struct aaci_runtime *aacirun)
|
||||||
static int aaci_pcm_capture_trigger(struct snd_pcm_substream *substream, int cmd)
|
static int aaci_pcm_capture_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||||
{
|
{
|
||||||
struct aaci_runtime *aacirun = substream->runtime->private_data;
|
struct aaci_runtime *aacirun = substream->runtime->private_data;
|
||||||
unsigned long flags;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&aacirun->lock, flags);
|
guard(spinlock_irqsave)(&aacirun->lock);
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SNDRV_PCM_TRIGGER_START:
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
|
|
@ -690,12 +680,10 @@ static int aaci_pcm_capture_trigger(struct snd_pcm_substream *substream, int cmd
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore(&aacirun->lock, flags);
|
return 0;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int aaci_pcm_capture_prepare(struct snd_pcm_substream *substream)
|
static int aaci_pcm_capture_prepare(struct snd_pcm_substream *substream)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue