mirror of https://github.com/torvalds/linux.git
ALSA: atiixp: 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-12-tiwai@suse.de
This commit is contained in:
parent
9608fe85ff
commit
5f7e725e02
|
|
@ -345,7 +345,6 @@ static int atiixp_build_dma_packets(struct atiixp *chip, struct atiixp_dma *dma,
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
u32 addr, desc_addr;
|
u32 addr, desc_addr;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
if (periods > ATI_MAX_DESCRIPTORS)
|
if (periods > ATI_MAX_DESCRIPTORS)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
@ -363,11 +362,11 @@ static int atiixp_build_dma_packets(struct atiixp *chip, struct atiixp_dma *dma,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* reset DMA before changing the descriptor table */
|
/* reset DMA before changing the descriptor table */
|
||||||
spin_lock_irqsave(&chip->reg_lock, flags);
|
scoped_guard(spinlock_irqsave, &chip->reg_lock) {
|
||||||
writel(0, chip->remap_addr + dma->ops->llp_offset);
|
writel(0, chip->remap_addr + dma->ops->llp_offset);
|
||||||
dma->ops->enable_dma(chip, 0);
|
dma->ops->enable_dma(chip, 0);
|
||||||
dma->ops->enable_dma(chip, 1);
|
dma->ops->enable_dma(chip, 1);
|
||||||
spin_unlock_irqrestore(&chip->reg_lock, flags);
|
}
|
||||||
|
|
||||||
/* fill the entries */
|
/* fill the entries */
|
||||||
addr = (u32)substream->runtime->dma_addr;
|
addr = (u32)substream->runtime->dma_addr;
|
||||||
|
|
@ -711,7 +710,7 @@ static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||||
!dma->ops->flush_dma))
|
!dma->ops->flush_dma))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
spin_lock(&chip->reg_lock);
|
guard(spinlock)(&chip->reg_lock);
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SNDRV_PCM_TRIGGER_START:
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
||||||
|
|
@ -745,7 +744,6 @@ static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||||
snd_atiixp_check_bus_busy(chip);
|
snd_atiixp_check_bus_busy(chip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock(&chip->reg_lock);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -859,7 +857,7 @@ static int snd_atiixp_spdif_prepare(struct snd_pcm_substream *substream)
|
||||||
{
|
{
|
||||||
struct atiixp *chip = snd_pcm_substream_chip(substream);
|
struct atiixp *chip = snd_pcm_substream_chip(substream);
|
||||||
|
|
||||||
spin_lock_irq(&chip->reg_lock);
|
guard(spinlock_irq)(&chip->reg_lock);
|
||||||
if (chip->spdif_over_aclink) {
|
if (chip->spdif_over_aclink) {
|
||||||
unsigned int data;
|
unsigned int data;
|
||||||
/* enable slots 10/11 */
|
/* enable slots 10/11 */
|
||||||
|
|
@ -877,7 +875,6 @@ static int snd_atiixp_spdif_prepare(struct snd_pcm_substream *substream)
|
||||||
atiixp_update(chip, CMD, ATI_REG_CMD_SPDF_CONFIG_MASK, 0);
|
atiixp_update(chip, CMD, ATI_REG_CMD_SPDF_CONFIG_MASK, 0);
|
||||||
atiixp_update(chip, CMD, ATI_REG_CMD_INTERLEAVE_SPDF, 0);
|
atiixp_update(chip, CMD, ATI_REG_CMD_INTERLEAVE_SPDF, 0);
|
||||||
}
|
}
|
||||||
spin_unlock_irq(&chip->reg_lock);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -887,7 +884,7 @@ static int snd_atiixp_playback_prepare(struct snd_pcm_substream *substream)
|
||||||
struct atiixp *chip = snd_pcm_substream_chip(substream);
|
struct atiixp *chip = snd_pcm_substream_chip(substream);
|
||||||
unsigned int data;
|
unsigned int data;
|
||||||
|
|
||||||
spin_lock_irq(&chip->reg_lock);
|
guard(spinlock_irq)(&chip->reg_lock);
|
||||||
data = atiixp_read(chip, OUT_DMA_SLOT) & ~ATI_REG_OUT_DMA_SLOT_MASK;
|
data = atiixp_read(chip, OUT_DMA_SLOT) & ~ATI_REG_OUT_DMA_SLOT_MASK;
|
||||||
switch (substream->runtime->channels) {
|
switch (substream->runtime->channels) {
|
||||||
case 8:
|
case 8:
|
||||||
|
|
@ -922,7 +919,6 @@ static int snd_atiixp_playback_prepare(struct snd_pcm_substream *substream)
|
||||||
atiixp_update(chip, 6CH_REORDER, ATI_REG_6CH_REORDER_EN,
|
atiixp_update(chip, 6CH_REORDER, ATI_REG_6CH_REORDER_EN,
|
||||||
substream->runtime->channels >= 6 ? ATI_REG_6CH_REORDER_EN: 0);
|
substream->runtime->channels >= 6 ? ATI_REG_6CH_REORDER_EN: 0);
|
||||||
|
|
||||||
spin_unlock_irq(&chip->reg_lock);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -931,11 +927,10 @@ static int snd_atiixp_capture_prepare(struct snd_pcm_substream *substream)
|
||||||
{
|
{
|
||||||
struct atiixp *chip = snd_pcm_substream_chip(substream);
|
struct atiixp *chip = snd_pcm_substream_chip(substream);
|
||||||
|
|
||||||
spin_lock_irq(&chip->reg_lock);
|
guard(spinlock_irq)(&chip->reg_lock);
|
||||||
atiixp_update(chip, CMD, ATI_REG_CMD_INTERLEAVE_IN,
|
atiixp_update(chip, CMD, ATI_REG_CMD_INTERLEAVE_IN,
|
||||||
substream->runtime->format == SNDRV_PCM_FORMAT_S16_LE ?
|
substream->runtime->format == SNDRV_PCM_FORMAT_S16_LE ?
|
||||||
ATI_REG_CMD_INTERLEAVE_IN : 0);
|
ATI_REG_CMD_INTERLEAVE_IN : 0);
|
||||||
spin_unlock_irq(&chip->reg_lock);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1043,9 +1038,9 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream,
|
||||||
runtime->private_data = dma;
|
runtime->private_data = dma;
|
||||||
|
|
||||||
/* enable DMA bits */
|
/* enable DMA bits */
|
||||||
spin_lock_irq(&chip->reg_lock);
|
scoped_guard(spinlock_irq, &chip->reg_lock) {
|
||||||
dma->ops->enable_dma(chip, 1);
|
dma->ops->enable_dma(chip, 1);
|
||||||
spin_unlock_irq(&chip->reg_lock);
|
}
|
||||||
dma->opened = 1;
|
dma->opened = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1058,9 +1053,9 @@ static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream,
|
||||||
/* disable DMA bits */
|
/* disable DMA bits */
|
||||||
if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
|
if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
spin_lock_irq(&chip->reg_lock);
|
scoped_guard(spinlock_irq, &chip->reg_lock) {
|
||||||
dma->ops->enable_dma(chip, 0);
|
dma->ops->enable_dma(chip, 0);
|
||||||
spin_unlock_irq(&chip->reg_lock);
|
}
|
||||||
dma->substream = NULL;
|
dma->substream = NULL;
|
||||||
dma->opened = 0;
|
dma->opened = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1348,10 +1343,9 @@ static irqreturn_t snd_atiixp_interrupt(int irq, void *dev_id)
|
||||||
if (status & CODEC_CHECK_BITS) {
|
if (status & CODEC_CHECK_BITS) {
|
||||||
unsigned int detected;
|
unsigned int detected;
|
||||||
detected = status & CODEC_CHECK_BITS;
|
detected = status & CODEC_CHECK_BITS;
|
||||||
spin_lock(&chip->reg_lock);
|
guard(spinlock)(&chip->reg_lock);
|
||||||
chip->codec_not_ready_bits |= detected;
|
chip->codec_not_ready_bits |= detected;
|
||||||
atiixp_update(chip, IER, detected, 0); /* disable the detected irqs */
|
atiixp_update(chip, IER, detected, 0); /* disable the detected irqs */
|
||||||
spin_unlock(&chip->reg_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ack */
|
/* ack */
|
||||||
|
|
|
||||||
|
|
@ -314,7 +314,6 @@ static int atiixp_build_dma_packets(struct atiixp_modem *chip,
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
u32 addr, desc_addr;
|
u32 addr, desc_addr;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
if (periods > ATI_MAX_DESCRIPTORS)
|
if (periods > ATI_MAX_DESCRIPTORS)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
@ -330,11 +329,11 @@ static int atiixp_build_dma_packets(struct atiixp_modem *chip,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* reset DMA before changing the descriptor table */
|
/* reset DMA before changing the descriptor table */
|
||||||
spin_lock_irqsave(&chip->reg_lock, flags);
|
scoped_guard(spinlock_irqsave, &chip->reg_lock) {
|
||||||
writel(0, chip->remap_addr + dma->ops->llp_offset);
|
writel(0, chip->remap_addr + dma->ops->llp_offset);
|
||||||
dma->ops->enable_dma(chip, 0);
|
dma->ops->enable_dma(chip, 0);
|
||||||
dma->ops->enable_dma(chip, 1);
|
dma->ops->enable_dma(chip, 1);
|
||||||
spin_unlock_irqrestore(&chip->reg_lock, flags);
|
}
|
||||||
|
|
||||||
/* fill the entries */
|
/* fill the entries */
|
||||||
addr = (u32)substream->runtime->dma_addr;
|
addr = (u32)substream->runtime->dma_addr;
|
||||||
|
|
@ -661,7 +660,7 @@ static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||||
!dma->ops->flush_dma))
|
!dma->ops->flush_dma))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
spin_lock(&chip->reg_lock);
|
guard(spinlock)(&chip->reg_lock);
|
||||||
switch(cmd) {
|
switch(cmd) {
|
||||||
case SNDRV_PCM_TRIGGER_START:
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
dma->ops->enable_transfer(chip, 1);
|
dma->ops->enable_transfer(chip, 1);
|
||||||
|
|
@ -682,7 +681,6 @@ static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||||
snd_atiixp_check_bus_busy(chip);
|
snd_atiixp_check_bus_busy(chip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock(&chip->reg_lock);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -753,13 +751,12 @@ static int snd_atiixp_playback_prepare(struct snd_pcm_substream *substream)
|
||||||
struct atiixp_modem *chip = snd_pcm_substream_chip(substream);
|
struct atiixp_modem *chip = snd_pcm_substream_chip(substream);
|
||||||
unsigned int data;
|
unsigned int data;
|
||||||
|
|
||||||
spin_lock_irq(&chip->reg_lock);
|
guard(spinlock_irq)(&chip->reg_lock);
|
||||||
/* set output threshold */
|
/* set output threshold */
|
||||||
data = atiixp_read(chip, MODEM_OUT_FIFO);
|
data = atiixp_read(chip, MODEM_OUT_FIFO);
|
||||||
data &= ~ATI_REG_MODEM_OUT1_DMA_THRESHOLD_MASK;
|
data &= ~ATI_REG_MODEM_OUT1_DMA_THRESHOLD_MASK;
|
||||||
data |= 0x04 << ATI_REG_MODEM_OUT1_DMA_THRESHOLD_SHIFT;
|
data |= 0x04 << ATI_REG_MODEM_OUT1_DMA_THRESHOLD_SHIFT;
|
||||||
atiixp_write(chip, MODEM_OUT_FIFO, data);
|
atiixp_write(chip, MODEM_OUT_FIFO, data);
|
||||||
spin_unlock_irq(&chip->reg_lock);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -864,9 +861,9 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream,
|
||||||
runtime->private_data = dma;
|
runtime->private_data = dma;
|
||||||
|
|
||||||
/* enable DMA bits */
|
/* enable DMA bits */
|
||||||
spin_lock_irq(&chip->reg_lock);
|
scoped_guard(spinlock_irq, &chip->reg_lock) {
|
||||||
dma->ops->enable_dma(chip, 1);
|
dma->ops->enable_dma(chip, 1);
|
||||||
spin_unlock_irq(&chip->reg_lock);
|
}
|
||||||
dma->opened = 1;
|
dma->opened = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -879,9 +876,9 @@ static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream,
|
||||||
/* disable DMA bits */
|
/* disable DMA bits */
|
||||||
if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
|
if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
spin_lock_irq(&chip->reg_lock);
|
scoped_guard(spinlock_irq, &chip->reg_lock) {
|
||||||
dma->ops->enable_dma(chip, 0);
|
dma->ops->enable_dma(chip, 0);
|
||||||
spin_unlock_irq(&chip->reg_lock);
|
}
|
||||||
dma->substream = NULL;
|
dma->substream = NULL;
|
||||||
dma->opened = 0;
|
dma->opened = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1013,10 +1010,9 @@ static irqreturn_t snd_atiixp_interrupt(int irq, void *dev_id)
|
||||||
if (status & CODEC_CHECK_BITS) {
|
if (status & CODEC_CHECK_BITS) {
|
||||||
unsigned int detected;
|
unsigned int detected;
|
||||||
detected = status & CODEC_CHECK_BITS;
|
detected = status & CODEC_CHECK_BITS;
|
||||||
spin_lock(&chip->reg_lock);
|
guard(spinlock)(&chip->reg_lock);
|
||||||
chip->codec_not_ready_bits |= detected;
|
chip->codec_not_ready_bits |= detected;
|
||||||
atiixp_update(chip, IER, detected, 0); /* disable the detected irqs */
|
atiixp_update(chip, IER, detected, 0); /* disable the detected irqs */
|
||||||
spin_unlock(&chip->reg_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ack */
|
/* ack */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue