Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2579216pxm; Mon, 28 Feb 2022 01:48:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHY+jS2ElCj4bnQL1QcSFk29LLMzarpVOhcZvnzsivaoUbXJAUDL9zUztHyYF0RRsUIWBf X-Received: by 2002:a05:6a00:14ce:b0:4ec:aa7a:53c7 with SMTP id w14-20020a056a0014ce00b004ecaa7a53c7mr20633967pfu.62.1646041733037; Mon, 28 Feb 2022 01:48:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646041733; cv=none; d=google.com; s=arc-20160816; b=YxKiE2XtjkbZZlQonvn7TGNkUIW45AlxUG0YJzrZmVxMZ59gv9HYgzf572nXU8nJcf iM1jYoGBj1O3EbQSSnUWl27q9apM62CBygwxkuBpvs1Y5nzlq8/X/AJUhWL2FY3GMZ/0 GkIrZBdegSq47CoXH1gtwdHWsUsISnqX4qlMXCjHwuHBqp/J5z4ZQv0LjbKWGE8zQTE+ PSYCrLPzABxK3l7AteS1/W++x8vuF1/RrKz9/3p7/s2ijDj3HOFp5sFgXMeZoxZuT8Os 9XGhadrvePdW8CJNHbwq0FjldahzIVg/ESzhbVOFtl4srO9i74Dl7276vxQzA0QTxHpm fmEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=SOU0lusjtcYdSlw3zTVrGhMRBaULBgUrHF8aRKG4FmA=; b=bcFca3IKZkC5+iFXRQ197cqsOfOxGoOjCQwV5HYsNylvnZmX9y5sNMoVpsny1fWue2 ZzS97INL+GLxoQgJHmnZ7VvB+UvDrPYcOiFY7jIsxIOxU/3HBHdOPosDLwA98BaZO8Id /MJqMW1OiwFRln5Tp7zefnbtN45Dbxmwkg0nCxwUYi4/NY3pWkGqtdMIcrR7VVkK8HNA SP3jd23pvs28E0eGfAnA3X7cyQevI/IcAkBlP77rAJRNOFMCU6E3sDcx4g4r1VhE1H4L hAqGBTQTL4XEZdGIXpdV3LnM4MPmM5diKQThMPenwJKvKUxz5KbaJc8CequXBYl3TAKl xHVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c9-20020a634e09000000b0037835828227si7717208pgb.398.2022.02.28.01.48.38; Mon, 28 Feb 2022 01:48:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232486AbiB1C3a (ORCPT + 99 others); Sun, 27 Feb 2022 21:29:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbiB1C3a (ORCPT ); Sun, 27 Feb 2022 21:29:30 -0500 Received: from cstnet.cn (smtp23.cstnet.cn [159.226.251.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5419A5C64A for ; Sun, 27 Feb 2022 18:28:51 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.126]) by APP-03 (Coremail) with SMTP id rQCowAAHD8NYMxxiopZpAQ--.55928S2; Mon, 28 Feb 2022 10:28:41 +0800 (CST) From: Jiasheng Jiang To: perex@perex.cz, tiwai@suse.com Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] ALSA: spi: Add check for clk_enable() Date: Mon, 28 Feb 2022 10:28:39 +0800 Message-Id: <20220228022839.3547266-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: rQCowAAHD8NYMxxiopZpAQ--.55928S2 X-Coremail-Antispam: 1UD129KBjvJXoW7CF1rWry5Ar4fXFW7tr1rXrb_yoW8tw4Dpa 97JFyrt3ykJasa9F4ayr48XFy3Jr40kFZxXwn2gw1xZw1Syw4qkay8JrnYya90kryDG3W3 Wr4xtFyUC3yUAr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUyC14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr 1j6rxdM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxAIw28IcxkI7VAK I48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7 xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xII jxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw2 0EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF 7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x0JUywZ7UUUUU= X-Originating-IP: [124.16.138.126] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As the potential failure of the clk_enable(), it should be better to check it and return error if fails. Fixes: 3568459a5113 ("ALSA: at73c213: manage SSC clock") Signed-off-by: Jiasheng Jiang --- sound/spi/at73c213.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c index 76c0e37a838c..8a2da6b1012e 100644 --- a/sound/spi/at73c213.c +++ b/sound/spi/at73c213.c @@ -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; -- 2.25.1