From patchwork Sat Dec 10 18:36:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 32084 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1450050wrr; Sat, 10 Dec 2022 10:38:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf7xvRPR5fBJbnOUv6tYqByb3JxBNMoPM0mmJ4gC26JJOiPSQXQVciuozKzJfyWVl0abFVvq X-Received: by 2002:a17:907:cf48:b0:7aa:ee98:b812 with SMTP id uv8-20020a170907cf4800b007aaee98b812mr2501624ejc.19.1670697531715; Sat, 10 Dec 2022 10:38:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670697531; cv=none; d=google.com; s=arc-20160816; b=xDq3e++HDIY4JJfUaXU1edLM83AH+sugfuLNHGM+xb/bgZLHBZ3UUQemDtXIfQFe69 cKh/OL5iqWmGncm7rwJFXDoSxqrN9sr/qH24wUxM6HYhusSbfmvwcsxkam5KwFUdTJ3W 8Q4QAcAAh9Oe5OoVBBrRGb1y8eRKw7nlcfGrWhD6UF8325VLRbquEcZn+l2/iAE4A32V 64pequ0sPC6MYSk8uP3ixPRilm+hnSG8bmP8woQkTHVo24CPeS9ulBlg/nRNd5e8YsNG wPabTon7BWqtQqIE4gyAzszeAMnkN7ZzpX7+7uNWBvh1tJYcgobJZaHP0wM+84AN0Wy+ zE5A== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb31-20020a170907961f00b0078e063fc787si3063182ejc.433.2022.12.10.10.38.28; Sat, 10 Dec 2022 10:38:51 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751853334797682829?= X-GMAIL-MSGID: =?utf-8?q?1751853334797682829?= 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);