From patchwork Sat Jun 20 21:00:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 6651721 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E6397C05AC for ; Sat, 20 Jun 2015 21:01:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A27220707 for ; Sat, 20 Jun 2015 21:01:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id E603A2069E for ; Sat, 20 Jun 2015 21:01:09 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7FDE826068D; Sat, 20 Jun 2015 23:01:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,SUBJ_OBFU_PUNCT_MANY,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 338F3260526; Sat, 20 Jun 2015 23:01:00 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4317B260557; Sat, 20 Jun 2015 23:00:59 +0200 (CEST) Received: from mail-qk0-f178.google.com (mail-qk0-f178.google.com [209.85.220.178]) by alsa0.perex.cz (Postfix) with ESMTP id 16FD026051B for ; Sat, 20 Jun 2015 23:00:52 +0200 (CEST) Received: by qkbp125 with SMTP id p125so75282294qkb.2 for ; Sat, 20 Jun 2015 14:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=b58fsZ4GAvcV/vldUp7RwBQ0oqDkXpwgKDsvWu9q7JY=; b=xyL7fB8OicNMBQIbDLZpHfEz79xRPys7KIACGKc2cOaVb44sRyctikqUr+8u+GHhdn wIL5OXMo14r/mkPsbC1Pelp+X1kWhNAI7/ZDdWKFF+msm7K6LpO8lwRWpQAdVFj/kxKH 0AXvoRExWmVygx6F4mKjit8p00yQ8sFJzZ0IYCBRsGe9WDzr25D4lneh7Pr5WHRN3qEZ aeSHVtgyOAzrmWx5SLWnGjliaKj8Lzfg84/R1iwWBJjn6MiQs2t//C6DdphBvoqiFIbe rhaBlAyfHHtK5byu7iJv0M+9jciWroxfTs6ZC+GbP7jN0/xD3AHtP/A2h5+uGWDxqtWb M7Iw== X-Received: by 10.55.25.207 with SMTP id 76mr47538037qkz.82.1434834051096; Sat, 20 Jun 2015 14:00:51 -0700 (PDT) Received: from localhost.localdomain ([189.101.187.123]) by mx.google.com with ESMTPSA id w67sm7892625qgw.41.2015.06.20.14.00.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 20 Jun 2015 14:00:50 -0700 (PDT) From: Fabio Estevam To: broonie@kernel.org Date: Sat, 20 Jun 2015 18:00:13 -0300 Message-Id: <1434834013-23088-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: nicoleotsuka@gmail.com, Fabio Estevam , alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH v2] ASoC: fsl: fsl_asrc: Check for clk_prepare_enable() error X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabio Estevam clk_prepare_enable() may fail, so we should better check its return value and propagate it in the case of error. Signed-off-by: Fabio Estevam Acked-by: Nicolin Chen --- Changes since v1: - Also handle the error for asrck_clk[i] as suggested by Nicolin sound/soc/fsl/fsl_asrc.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index c068494..9f087d4 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -931,14 +931,29 @@ static int fsl_asrc_probe(struct platform_device *pdev) static int fsl_asrc_runtime_resume(struct device *dev) { struct fsl_asrc *asrc_priv = dev_get_drvdata(dev); - int i; + int i, ret; - clk_prepare_enable(asrc_priv->mem_clk); - clk_prepare_enable(asrc_priv->ipg_clk); - for (i = 0; i < ASRC_CLK_MAX_NUM; i++) - clk_prepare_enable(asrc_priv->asrck_clk[i]); + ret = clk_prepare_enable(asrc_priv->mem_clk); + if (ret) + return ret; + ret = clk_prepare_enable(asrc_priv->ipg_clk); + if (ret) + goto disable_mem_clk; + for (i = 0; i < ASRC_CLK_MAX_NUM; i++) { + ret = clk_prepare_enable(asrc_priv->asrck_clk[i]); + if (ret) + goto disable_asrck_clk; + } return 0; + +disable_asrck_clk: + for (i--; i >= 0; i--) + clk_disable_unprepare(asrc_priv->asrck_clk[i]); + clk_disable_unprepare(asrc_priv->ipg_clk); +disable_mem_clk: + clk_disable_unprepare(asrc_priv->mem_clk); + return ret; } static int fsl_asrc_runtime_suspend(struct device *dev)