From patchwork Sat Mar 4 12:25:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9603937 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 E42D2602B4 for ; Sat, 4 Mar 2017 12:39:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4DAC2843F for ; Sat, 4 Mar 2017 12:39:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9CDD2854F; Sat, 4 Mar 2017 12:39:13 +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 83EC72843F for ; Sat, 4 Mar 2017 12:39:13 +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=PgJGbc85vUs3ObuKrOjN5b7YsjXWoKuCtYtz9w/wbL4=; b=B3oaLub3zWoR0M RD1jdOIqmAtIhPWAVC3eP/KhY2AXkOybjdMZQbE1bXe+ZcPWbw1WG51aUEVfvn28ORLmZSQDngrd/ eEhM5hkej+m9hoWRXtWZNFJpUeN3w8LgcnH8+/LywPQfp8mEMerzR4EcCzcRb393BSmTom+LQR8xG QvjMF1oWXUxLrRgD3ydrVnzdJY85CgFO6VDhAAdcCy/xselUgpHLOBg1UaFKf9Tiia/WlnYQg+Cs9 7sp4YFPHJB0ehzA+3Bj/n/JrDrdn6jHF8vgikRQWQBUyN9k3+2puJAnpyVwj/5KYK1U3WU05b0mwP TgKnMPE3U/Bs/RI2k9aQ==; 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 1ck8xn-0007Kv-Q6; Sat, 04 Mar 2017 12:39:07 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ck8xN-0006qj-Vq for linux-amlogic@lists.infradead.org; Sat, 04 Mar 2017 12:38:44 +0000 Received: by mail-wr0-x242.google.com with SMTP id l37so16201813wrc.3 for ; Sat, 04 Mar 2017 04:38:21 -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=tusTuPmXOJn/o04gCX7Jh1gsLuZ/tJSmIa4MAGpbvrA=; b=dCCv/RvIHuRWkL+wdaiBW9j0xqFVSlOTulppsYkHCPFGyUwbMELlom24HErm4MXO5E z4Bu46Q+TZZK3/iozzFv/oGsQ43mx2cO7Dg4L4DMZ4XbcT5pLnGr9V4Q1Acw/Q51CYTG MsqCBm27GVCTkK7Skr3mr4uBCsXSEWPEeSnGpLF07L1F7ImJiqePjtD6H8jPN4R/Cn2n 7wATPYW7wUph2iiiPp/9gWiyxSMqCDU9PuEDCkichaD9dlX0vgE4iHz4jIAaMO3rHbjt rqyAXt8tM8YaNnOArCbSuFL0UvydjyuqtI0iQS6VO7iC7o8bB2vc0XcNm0DRUtn7Qu0V Yhiw== 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=tusTuPmXOJn/o04gCX7Jh1gsLuZ/tJSmIa4MAGpbvrA=; b=UHoIkB2hOx+T86CtEx/ML5dSKrKNMtNNeE5YffusqTxZoQBw/wl4vrlbB1UE9mIRrZ CzhsGWNVUfnFw/HYqZYsSAORBpoAPn0SelFA77IzCalj+5fsccxOunOQkEXOpBMolhml /zm8BuBtIYDNlbDdhTjCWvSQ484VQaXp5eIoEy6nfdxqrTsCtOFboH8glz9NjEUW7tEc pg2O4Fugj1g21fITUXnm9YR8GoEu2PmgtNln12QZ7hWSXZPuhTFH+f6/C9AJRnEnQ7Zg lsjZPbK1R4tg8vym8ugxyWnSwbIxRgaNLhC7mrSwca2iEjx2sDCaSDcakywOkFEOpxVY r9Aw== X-Gm-Message-State: AMke39nXXhcTnZQydiHRUrxO0kCCpB9y4C5I0kzQaXXCDKltyTlvTX6T72dMTjrVfRAoPA== X-Received: by 10.223.170.210 with SMTP id i18mr7431406wrc.114.1488631100257; Sat, 04 Mar 2017 04:38:20 -0800 (PST) Received: from ?IPv6:2003:c6:ebdc:4000:98cd:c51c:6f4e:443? (p200300C6EBDC400098CDC51C6F4E0443.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:98cd:c51c:6f4e:443]) by smtp.googlemail.com with ESMTPSA id q4sm19093881wrc.35.2017.03.04.04.38.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Mar 2017 04:38:19 -0800 (PST) Subject: [PATCH v5 6/10] mmc: meson-gx: fix error path in meson_mmc_clk_init / meson_mmc_probe To: Ulf Hansson , Kevin Hilman References: From: Heiner Kallweit Message-ID: <5291f703-af62-b9a5-3f5e-f0f8a2d6248e@gmail.com> Date: Sat, 4 Mar 2017 13:25:14 +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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170304_043842_205789_9D47796F X-CRM114-Status: UNSURE ( 8.46 ) 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, "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 Acked-by: Kevin Hilman --- v2: - extended commit message v3: - adjust error path in probe v4: - added acked-by v5: - no changes --- 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;