Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4649758rwb; Sat, 10 Dec 2022 12:25:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf7agjypQuHkg8A9d7+G1kk2+WFddNQ0HfTg9LUCuGEw5Pxv6E1ep4GUHZdbNJudYuqgWtWa X-Received: by 2002:a05:6402:50f:b0:46d:b458:8948 with SMTP id m15-20020a056402050f00b0046db4588948mr7771589edv.33.1670703923469; Sat, 10 Dec 2022 12:25:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670703923; cv=none; d=google.com; s=arc-20160816; b=zyqhSQXw19GtiCB3O2RoaYOn9q+kaWc3LiePBhY+IkadgX+O8kxNlwW9aD9SIkjKHZ Gx+7xLTug2by9E9uSTnGyq5D93SVDtgcnU8VkS5gqqLjn8J9mwOXw5Cj6DnthMcQ8JqG LwsL3SKTzKWTOv2zetMowixwo3QJ8ZIigIH/P94BL1LmkqYh1l4z56D3cmjzpggVcTVA wR6Q4GqfiEXoV8+TgImSyR3PP3C3vvk1s3BHiSy2ONVxvIQkfVckspc2n9NhVh4532EJ czQCVwqW8eTxdqZ15ARVRzY8VfB9IpEbhHo74pmmH7xZ80bn+X0dbuiIz0s1SAy7O/Iv VWSg== 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=z0h36/dLu6KUKERRu/XRRrIt/BaGU+EWwOVcIjPDcy8=; b=WvXZVChhYHpu8gEwkZr1r1xgFtWPJpSpiJ5lyVqLSJkOoDsMBszc+swOScp0dXD0wJ G5N3mIvPqm/rBjBtRMQn8ULA6Z0XqUbjyCFeD+6Y2Djj/dRBkSdN7fulLQlJaQhctVF7 fxzAnF5okLD6NkgXYe7xobbqEc1WGw46CroFmdMScMRJp+NnW84zj53nkhoKeBmcnxtD A+x+B3qLAywM26+C0hkE+Y0pe40Am/bC/zJODTJ0dpchnbSfNQyWwzJYTu9EI+RrSk+6 leEXdJhC62H0lEifbcDPqt3vJmdEmPFEhPcrgyxvWUMJxCBeLYJm34QBuj8cTBMDN+iJ /vrQ== 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 eh2-20020a0564020f8200b0045907cec72dsi3917607edb.320.2022.12.10.12.25.03; Sat, 10 Dec 2022 12:25:23 -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 S229628AbiLJSgt (ORCPT + 74 others); Sat, 10 Dec 2022 13:36:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiLJSgr (ORCPT ); Sat, 10 Dec 2022 13:36:47 -0500 Received: from smtp.smtpout.orange.fr (smtp-28.smtpout.orange.fr [80.12.242.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EB3417412 for ; Sat, 10 Dec 2022 10:36:46 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id 44iJpNwaA1SdM44iJpAGuk; Sat, 10 Dec 2022 19:36:44 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 10 Dec 2022 19:36:44 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Tony Huang , Li-hao Kuo , Ulf Hansson , Arnd Bergmann Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-mmc@vger.kernel.org Subject: [PATCH 1/3] mmc: sunlpus: Fix an error handling path in spmmc_drv_probe() Date: Sat, 10 Dec 2022 19:36:37 +0100 Message-Id: <7c686fecb11b4ec1f55cd7075dc7cfcdd9b445ba.1670697358.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 If an error occurs after successful clk_prepare_enable() call in the probe, the clk is not clk_disable_unprepare()'ed. Use devm_clk_get_enabled() instead of devm_clk_get() to fix, and simplify the probe and the remove function accordingly. Fixes: 4e268fed8b18 ("mmc: Add mmc driver for Sunplus SP7021") Signed-off-by: Christophe JAILLET --- This changes the order of resource releasing when the driver is removed, but it looks ok to me. --- drivers/mmc/host/sunplus-mmc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/mmc/host/sunplus-mmc.c b/drivers/mmc/host/sunplus-mmc.c index db5e0dcdfa7f..3e8856a82188 100644 --- a/drivers/mmc/host/sunplus-mmc.c +++ b/drivers/mmc/host/sunplus-mmc.c @@ -878,7 +878,7 @@ static int spmmc_drv_probe(struct platform_device *pdev) if (IS_ERR(host->base)) return PTR_ERR(host->base); - host->clk = devm_clk_get(&pdev->dev, NULL); + host->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(host->clk)) return dev_err_probe(&pdev->dev, PTR_ERR(host->clk), "clk get fail\n"); @@ -896,10 +896,6 @@ static int spmmc_drv_probe(struct platform_device *pdev) if (ret) return ret; - ret = clk_prepare_enable(host->clk); - if (ret) - return dev_err_probe(&pdev->dev, ret, "failed to enable clk\n"); - ret = mmc_of_parse(mmc); if (ret) goto probe_free_host; @@ -944,7 +940,6 @@ static int spmmc_drv_remove(struct platform_device *dev) mmc_remove_host(host->mmc); pm_runtime_get_sync(&dev->dev); - clk_disable_unprepare(host->clk); pm_runtime_put_noidle(&dev->dev); pm_runtime_disable(&dev->dev); platform_set_drvdata(dev, NULL); -- 2.34.1