Skip to content

Commit ca1697e

Browse files
JiangJiastiwai
authored andcommitted
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: 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>
1 parent a544684 commit ca1697e

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

sound/spi/at73c213.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ static int snd_at73c213_pcm_open(struct snd_pcm_substream *substream)
218218
runtime->hw = snd_at73c213_playback_hw;
219219
chip->substream = substream;
220220

221-
clk_enable(chip->ssc->clk);
221+
err = clk_enable(chip->ssc->clk);
222+
if (err)
223+
return err;
222224

223225
return 0;
224226
}
@@ -776,7 +778,9 @@ static int snd_at73c213_chip_init(struct snd_at73c213 *chip)
776778
goto out;
777779

778780
/* Enable DAC master clock. */
779-
clk_enable(chip->board->dac_clk);
781+
retval = clk_enable(chip->board->dac_clk);
782+
if (retval)
783+
goto out;
780784

781785
/* Initialize at73c213 on SPI bus. */
782786
retval = snd_at73c213_write_reg(chip, DAC_RST, 0x04);
@@ -889,7 +893,9 @@ static int snd_at73c213_dev_init(struct snd_card *card,
889893
chip->card = card;
890894
chip->irq = -1;
891895

892-
clk_enable(chip->ssc->clk);
896+
retval = clk_enable(chip->ssc->clk);
897+
if (retval)
898+
return retval;
893899

894900
retval = request_irq(irq, snd_at73c213_interrupt, 0, "at73c213", chip);
895901
if (retval) {
@@ -1008,7 +1014,9 @@ static int snd_at73c213_remove(struct spi_device *spi)
10081014
int retval;
10091015

10101016
/* Stop playback. */
1011-
clk_enable(chip->ssc->clk);
1017+
retval = clk_enable(chip->ssc->clk);
1018+
if (retval)
1019+
goto out;
10121020
ssc_writel(chip->ssc->regs, CR, SSC_BIT(CR_TXDIS));
10131021
clk_disable(chip->ssc->clk);
10141022

@@ -1088,9 +1096,16 @@ static int snd_at73c213_resume(struct device *dev)
10881096
{
10891097
struct snd_card *card = dev_get_drvdata(dev);
10901098
struct snd_at73c213 *chip = card->private_data;
1099+
int retval;
10911100

1092-
clk_enable(chip->board->dac_clk);
1093-
clk_enable(chip->ssc->clk);
1101+
retval = clk_enable(chip->board->dac_clk);
1102+
if (retval)
1103+
return retval;
1104+
retval = clk_enable(chip->ssc->clk);
1105+
if (retval) {
1106+
clk_disable(chip->board->dac_clk);
1107+
return retval;
1108+
}
10941109
ssc_writel(chip->ssc->regs, CR, SSC_BIT(CR_TXEN));
10951110

10961111
return 0;

0 commit comments

Comments
 (0)