Skip to content

Commit

Permalink
ALSA: spi: Add check for clk_enable()
Browse files Browse the repository at this point in the history
As the potential failure of the clk_enable(),
it should be better to check it and return error
if fails.

Fixes: 3568459 ("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>
  • Loading branch information
JiangJias authored and tiwai committed Feb 28, 2022
1 parent a544684 commit ca1697e
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions sound/spi/at73c213.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ca1697e

Please sign in to comment.