From patchwork Sat Feb 18 13:19:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9581067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0D0A1604A4 for ; Sat, 18 Feb 2017 13:27:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F294528236 for ; Sat, 18 Feb 2017 13:27:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E78D3283EC; Sat, 18 Feb 2017 13:27:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1EFD328236 for ; Sat, 18 Feb 2017 13:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SavSKMAtCJr0ARYssb5/npo4s1PYJfSg/j9Y2DXzMv8=; b=VCtLUjWhZ8InPO o/LGFUfnMOXrnWtLgQ59jx6SHoSommBTktnI1b38E6y8JmMrwAb6bDMp7fUW14+/DO/EnJWWFCCGv rVVvClTwY0ssBES9Vs59lZHtScdTL5carHj4r0z2L2f0j/xhxuP9Z6U+LZKHUGxnonGUdUDNFnLTO uwQ+qDqky7JKcdgFHV5X6zKsGFyek/Op+S5q2pR8jjXOYe7vmIHF0EbiwT4Ptttr1KWE8T4I21UMk ++koiQmDEGYKzrnicX7CkDdO2t7G3KIqwlPKLAP3duCJ8BYmGB0/w4IL5mJeG0wwbi+pwJlfxKFzd s68Wuhg+aqThP9LEI1wQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cf52V-000150-ET; Sat, 18 Feb 2017 13:27:03 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cf52O-0000tb-DU for linux-amlogic@lists.infradead.org; Sat, 18 Feb 2017 13:26:59 +0000 Received: by mail-wm0-x242.google.com with SMTP id r18so6864164wmd.3 for ; Sat, 18 Feb 2017 05:26:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=DKaHBB5bI6uGQNlN/eT4ej+TR69lZkICob+L/9+J5DQ=; b=kB1ERD11/n57KWnWMniU+A/sYcwlknyodNNJ+NpZ4BLWmxe8Rv0/p12g27W6hDsPr3 kWN5gMUGF/yPaCFrR1wMh3aEt1mBAKgjzFl9hXl/+QaSj8lFRY08YrpA427W5zJmAm5/ yM53KZ1PzOtYNp9/SBbu1D8lU4XRG62SGZGobak78o9OildotAFmkozGlSYwW5R7ULX1 0xvSpM3braP2t/HSf4eSkP/3avr/aIYuuUe6WfXepS8+FRss+Bx+4PS/VwrITTyJFk9j pvCwe0SKVbWLy2D3iI7q6Si+JcShe5w1cWOYvLvdY17uQcr4q7bzMqQ8m25lOrTgwJYk 0/+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=DKaHBB5bI6uGQNlN/eT4ej+TR69lZkICob+L/9+J5DQ=; b=TNxP/NqivB98SBN27Tcm/XzL/m8TUiZMKEbOf3nANp2FYiCDNEgl65GqMZv2RYZXJ1 dxEX1bqIYlhlKVR4TkWZSPDP4VzbM0y1dbIn0agIBi29xJ6tX0+iyqJFMAbC6ys/T4qm fNAMvDnbYJW3qBY+qTkN4SkYhx9GUZKj8YqE3zofrbQSQ+k0xjOPGVK6tIPiqSZWChdU OSAnJUFFivQ8AiHdHSnFKJ62pZH+Yjejyuz4lHHPnr9r7/4v6Z/a+GauuGZcuDFUVBZn wm8Db8XZNmhqzIKO5G7lIibE1Kpdwy2P7/AB4YoKbPpy5pY6iQzP8p8M1K3iFMOA+YQ8 at3g== X-Gm-Message-State: AMke39ndF7GwHS8F2HE0XXpjhRpMKn+fxAPiBbnU+kc8tOBrb5pseV3yJhAKWYjRCJFLKg== X-Received: by 10.28.49.70 with SMTP id x67mr9365536wmx.69.1487424399226; Sat, 18 Feb 2017 05:26:39 -0800 (PST) Received: from ?IPv6:2003:c6:ebdc:4000:7c19:f774:dabe:f95d? (p200300C6EBDC40007C19F774DABEF95D.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:7c19:f774:dabe:f95d]) by smtp.googlemail.com with ESMTPSA id r19sm16904214wrr.44.2017.02.18.05.26.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Feb 2017 05:26:38 -0800 (PST) Subject: [PATCH v3 6/10] mmc: meson-gx: fix error path in meson_mmc_clk_init / meson_mmc_probe To: Ulf Hansson , Kevin Hilman References: <583f6496-68a9-b8e1-6b25-1f073f819a3c@gmail.com> From: Heiner Kallweit Message-ID: <8419d592-1338-d7eb-3a75-342b64897922@gmail.com> Date: Sat, 18 Feb 2017 14:19:32 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <583f6496-68a9-b8e1-6b25-1f073f819a3c@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170218_052656_694756_E8A3B526 X-CRM114-Status: UNSURE ( 8.03 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, =?UTF-8?Q?Micha=c5=82_Zegan?= , "linux-mmc@vger.kernel.org" Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The condition should be "if (ret)" as the disable/unprepare is supposed to be executed if the previous command fails. In addition adjust the error path in probe to properly deal with the case that cfg_div_clk can be registered successfully but enable/prepare fails. In this case we shouldn't call clk_disable_unprepare. Reported-by: Michał Zegan Signed-off-by: Heiner Kallweit Reviewed-by: Michał Zegan Acked-by: Kevin Hilman --- v2: - extended commit message v3: - adjust error path in probe --- drivers/mmc/host/meson-gx-mmc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 68e76fa8..002e4aac 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -321,7 +321,7 @@ static int meson_mmc_clk_init(struct meson_host *host) host->mmc->f_min = clk_round_rate(host->cfg_div_clk, 400000); ret = meson_mmc_clk_set(host, host->mmc->f_min); - if (!ret) + if (ret) clk_disable_unprepare(host->cfg_div_clk); return ret; @@ -771,7 +771,7 @@ static int meson_mmc_probe(struct platform_device *pdev) meson_mmc_irq_thread, IRQF_SHARED, DRIVER_NAME, host); if (ret) - goto free_host; + goto err_div_clk; mmc->max_blk_count = CMD_CFG_LENGTH_MASK; mmc->max_req_size = mmc->max_blk_count * mmc->max_blk_size; @@ -784,7 +784,7 @@ static int meson_mmc_probe(struct platform_device *pdev) if (host->bounce_buf == NULL) { dev_err(host->dev, "Unable to map allocate DMA bounce buffer.\n"); ret = -ENOMEM; - goto free_host; + goto err_div_clk; } mmc->ops = &meson_mmc_ops; @@ -792,8 +792,9 @@ static int meson_mmc_probe(struct platform_device *pdev) return 0; -free_host: +err_div_clk: clk_disable_unprepare(host->cfg_div_clk); +free_host: clk_disable_unprepare(host->core_clk); mmc_free_host(mmc); return ret;