ALSA: spi: Add check for clk_enable()

As the potential failure of the clk_enable(),
it should be better to check it and return error
if fails.

Fixes: 3568459a51 ("ALSA: at73c213: manage SSC clock")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20220228022839.3547266-1-jiasheng@iscas.ac.cn
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Jiasheng Jiang 2022-02-28 10:28:39 +08:00 committed by Takashi Iwai
parent a544684b79
commit ca1697eb09
1 changed files with 21 additions and 6 deletions

View File

@ -218,7 +218,9 @@ static int snd_at73c213_pcm_open(struct snd_pcm_substream *substream)
runtime->hw = snd_at73c213_playback_hw;
chip->substream = substream;
clk_enable(chip->ssc->clk);
err = clk_enable(chip->ssc->clk);
if (err)
return err;
return 0;
}
@ -776,7 +778,9 @@ static int snd_at73c213_chip_init(struct snd_at73c213 *chip)
goto out;
/* Enable DAC master clock. */
clk_enable(chip->board->dac_clk);
retval = clk_enable(chip->board->dac_clk);
if (retval)
goto out;
/* Initialize at73c213 on SPI bus. */
retval = snd_at73c213_write_reg(chip, DAC_RST, 0x04);
@ -889,7 +893,9 @@ static int snd_at73c213_dev_init(struct snd_card *card,
chip->card = card;
chip->irq = -1;
clk_enable(chip->ssc->clk);
retval = clk_enable(chip->ssc->clk);
if (retval)
return retval;
retval = request_irq(irq, snd_at73c213_interrupt, 0, "at73c213", chip);
if (retval) {
@ -1008,7 +1014,9 @@ static int snd_at73c213_remove(struct spi_device *spi)
int retval;
/* Stop playback. */
clk_enable(chip->ssc->clk);
retval = clk_enable(chip->ssc->clk);
if (retval)
goto out;
ssc_writel(chip->ssc->regs, CR, SSC_BIT(CR_TXDIS));
clk_disable(chip->ssc->clk);
@ -1088,9 +1096,16 @@ static int snd_at73c213_resume(struct device *dev)
{
struct snd_card *card = dev_get_drvdata(dev);
struct snd_at73c213 *chip = card->private_data;
int retval;
clk_enable(chip->board->dac_clk);
clk_enable(chip->ssc->clk);
retval = clk_enable(chip->board->dac_clk);
if (retval)
return retval;
retval = clk_enable(chip->ssc->clk);
if (retval) {
clk_disable(chip->board->dac_clk);
return retval;
}
ssc_writel(chip->ssc->regs, CR, SSC_BIT(CR_TXEN));
return 0;