mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
ASoC: fsl: mpc5200_psc_ac97: Use guard() for mutex locks
Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20260615093824.115751-12-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
caed9fb2e4
commit
8a2d7e4631
|
|
@ -31,14 +31,13 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
|
|||
int status;
|
||||
unsigned int val;
|
||||
|
||||
mutex_lock(&psc_dma->mutex);
|
||||
guard(mutex)(&psc_dma->mutex);
|
||||
|
||||
/* Wait for command send status zero = ready */
|
||||
status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) &
|
||||
MPC52xx_PSC_SR_CMDSEND), 100, 0);
|
||||
if (status == 0) {
|
||||
pr_err("timeout on ac97 bus (rdy)\n");
|
||||
mutex_unlock(&psc_dma->mutex);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
|
@ -54,19 +53,16 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
|
|||
if (status == 0) {
|
||||
pr_err("timeout on ac97 read (val) %x\n",
|
||||
in_be16(&psc_dma->psc_regs->sr_csr.status));
|
||||
mutex_unlock(&psc_dma->mutex);
|
||||
return -ENODEV;
|
||||
}
|
||||
/* Get the data */
|
||||
val = in_be32(&psc_dma->psc_regs->ac97_data);
|
||||
if (((val >> 24) & 0x7f) != reg) {
|
||||
pr_err("reg echo error on ac97 read\n");
|
||||
mutex_unlock(&psc_dma->mutex);
|
||||
return -ENODEV;
|
||||
}
|
||||
val = (val >> 8) & 0xffff;
|
||||
|
||||
mutex_unlock(&psc_dma->mutex);
|
||||
return (unsigned short) val;
|
||||
}
|
||||
|
||||
|
|
@ -75,52 +71,46 @@ static void psc_ac97_write(struct snd_ac97 *ac97,
|
|||
{
|
||||
int status;
|
||||
|
||||
mutex_lock(&psc_dma->mutex);
|
||||
guard(mutex)(&psc_dma->mutex);
|
||||
|
||||
/* Wait for command status zero = ready */
|
||||
status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) &
|
||||
MPC52xx_PSC_SR_CMDSEND), 100, 0);
|
||||
if (status == 0) {
|
||||
pr_err("timeout on ac97 bus (write)\n");
|
||||
goto out;
|
||||
return;
|
||||
}
|
||||
/* Write data */
|
||||
out_be32(&psc_dma->psc_regs->ac97_cmd,
|
||||
((reg & 0x7f) << 24) | (val << 8));
|
||||
|
||||
out:
|
||||
mutex_unlock(&psc_dma->mutex);
|
||||
}
|
||||
|
||||
static void psc_ac97_warm_reset(struct snd_ac97 *ac97)
|
||||
{
|
||||
struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs;
|
||||
|
||||
mutex_lock(&psc_dma->mutex);
|
||||
guard(mutex)(&psc_dma->mutex);
|
||||
|
||||
out_be32(®s->sicr, psc_dma->sicr | MPC52xx_PSC_SICR_AWR);
|
||||
udelay(3);
|
||||
out_be32(®s->sicr, psc_dma->sicr);
|
||||
|
||||
mutex_unlock(&psc_dma->mutex);
|
||||
}
|
||||
|
||||
static void psc_ac97_cold_reset(struct snd_ac97 *ac97)
|
||||
{
|
||||
struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs;
|
||||
|
||||
mutex_lock(&psc_dma->mutex);
|
||||
dev_dbg(psc_dma->dev, "cold reset\n");
|
||||
scoped_guard(mutex, &psc_dma->mutex) {
|
||||
dev_dbg(psc_dma->dev, "cold reset\n");
|
||||
|
||||
mpc5200_psc_ac97_gpio_reset(psc_dma->id);
|
||||
mpc5200_psc_ac97_gpio_reset(psc_dma->id);
|
||||
|
||||
/* Notify the PSC that a reset has occurred */
|
||||
out_be32(®s->sicr, psc_dma->sicr | MPC52xx_PSC_SICR_ACRB);
|
||||
/* Notify the PSC that a reset has occurred */
|
||||
out_be32(®s->sicr, psc_dma->sicr | MPC52xx_PSC_SICR_ACRB);
|
||||
|
||||
/* Re-enable RX and TX */
|
||||
out_8(®s->command, MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE);
|
||||
|
||||
mutex_unlock(&psc_dma->mutex);
|
||||
/* Re-enable RX and TX */
|
||||
out_8(®s->command, MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE);
|
||||
}
|
||||
|
||||
usleep_range(1000, 2000);
|
||||
psc_ac97_warm_reset(ac97);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user