Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1402563pxj; Fri, 21 May 2021 13:23:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6vns2hIrMRBy7KMMHS3fAI0iyfilko40xH4SMVcHWcLk9e4hR+UhXub8yQQJBInu84ExE X-Received: by 2002:a50:d51a:: with SMTP id u26mr13114457edi.285.1621628594380; Fri, 21 May 2021 13:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621628594; cv=none; d=google.com; s=arc-20160816; b=cpalLliaDhnmZ74XvFuzfdW0x2tamLFA2bCOae+YQz6ybQNo8+0WnkkcWc8eBKZRNq YWPkk4iNn9kn7DVs+j9vML6i4VF2rRfmHm7p34s/Z2fRhr3p8PibvFalYmQfYGyfW4yA gLr3LtyZu7ON0HmRACp+YtqCBIVq6BJfutq7xHYvUAI/i+RX433mU8BeGQhRnrlbmBM/ 1WERLtRSubY58P3uW9dKXyw9y00yKoVDuax2+Fqlo8CO21sVGOubMJwv75C432u6FqUD lPvoE4e9BFSCeafbLURiKVcLhkph/lEn/KlnZ7+A8Wvo+AbkajiPX22cD7cTy7cwDnfL MS0g== 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=Juhu/2tfUID1WaufX4FPTEKsgd2o1fIY1kvSlkG742g=; b=t+oHHrqT2oZMX1zWdyaTrqWiysChAOrpPW5r/HPvb+7eKt3Z5iaSr/wVYG97EBZ2gx q+xhgaf4uuJ0A1AYxguSP7hQLQttdPnyKtbiZ0tvB0abtxl2NQQl6IWLDrkLr3aQrnrp Y2xIU1wfoVk4RrjAeLzczDImLHgzu+IZs5RmM/WJ66OanlV8/el2/Hx+tmWMAEyCzHQD Gs3doFfeW1ZFOWziYZkWiYd+kI6rgbHr1Yfy9zr0V8e7XLg8LQYrDtaz/ZafHvp7nDJr fAnsZgPAUaHTGcXLuU1nBgW5CTX68BOKnI1zddAYj2bxwtm8GzDX7LIt7DLA7z/XXHc+ wfxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e6si6922892edz.576.2021.05.21.13.22.51; Fri, 21 May 2021 13:23:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236233AbhEUQ5S (ORCPT + 99 others); Fri, 21 May 2021 12:57:18 -0400 Received: from smtp02.smtpout.orange.fr ([80.12.242.124]:59249 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236698AbhEUQ5R (ORCPT ); Fri, 21 May 2021 12:57:17 -0400 Received: from localhost.localdomain ([86.243.172.93]) by mwinf5d49 with ME id 7Uvr2500B21Fzsu03UvrPg; Fri, 21 May 2021 18:55:52 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 21 May 2021 18:55:52 +0200 X-ME-IP: 86.243.172.93 From: Christophe JAILLET To: balbi@kernel.org, gregkh@linuxfoundation.org, narmstrong@baylibre.com, khilman@baylibre.com, jbrunet@baylibre.com, martin.blumenstingl@googlemail.com Cc: linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] usb: dwc3: meson-g12a: Disable the regulator in the error handling path of the probe Date: Fri, 21 May 2021 18:55:50 +0200 Message-Id: <79df054046224bbb0716a8c5c2082650290eec86.1621616013.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If an error occurs after a successful 'regulator_enable()' call, 'regulator_disable()' must be called. Fix the error handling path of the probe accordingly. The remove function doesn't need to be fixed, because the 'regulator_disable()' call is already hidden in 'dwc3_meson_g12a_suspend()' which is called via 'pm_runtime_set_suspended()' in the remove function. Fixes: c99993376f72 ("usb: dwc3: Add Amlogic G12A DWC3 glue") Signed-off-by: Christophe JAILLET --- Please review carefully. I'm not that sure about: The remove function doesn't need to be fixed, because the 'regulator_disable()' call is already hidden in 'dwc3_meson_g12a_suspend()' which is called via 'pm_runtime_set_suspended()' in the remove function. This is more a guess than anything else! --- drivers/usb/dwc3/dwc3-meson-g12a.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c index bdf1f98dfad8..804957525130 100644 --- a/drivers/usb/dwc3/dwc3-meson-g12a.c +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c @@ -772,13 +772,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) ret = priv->drvdata->usb_init(priv); if (ret) - goto err_disable_clks; + goto err_disable_regulator; /* Init PHYs */ for (i = 0 ; i < PHY_COUNT ; ++i) { ret = phy_init(priv->phys[i]); if (ret) - goto err_disable_clks; + goto err_disable_regulator; } /* Set PHY Power */ @@ -816,6 +816,10 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) for (i = 0 ; i < PHY_COUNT ; ++i) phy_exit(priv->phys[i]); +err_disable_regulator: + if (priv->vbus) + regulator_disable(priv->vbus); + err_disable_clks: clk_bulk_disable_unprepare(priv->drvdata->num_clks, priv->drvdata->clks); -- 2.30.2