From patchwork Fri May 21 16:55:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 12273395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EC02C4707A for ; Fri, 21 May 2021 17:03:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD34A613E4 for ; Fri, 21 May 2021 17:03:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD34A613E4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=wanadoo.fr Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=mnmispUwBL68NJaSbjmDTbamfVWpP2pf8dwLt6MQDs8=; b=PrICp1G8Xn8xKv5B/oQXNykzre 5A3y9MU7WwmdBpf94Sxo6HYCznSTNPBJ60KhXF1wUD5JqAIdWwyuG+MRVfAdZcPfg2ai1rhE0wQ1r 2YnGW5bzZo7CQi8MtKozZMXRK8//KbIFu1XXCZ+hJM3xG4VRgjpTGZMZtrunRJt0GAw7uaXMNCODy 8HoD2+c5JQGrGzJhTPL8RHjvHczajGV91Dkzlfvmoz0aRLQh0/8DQAJ7tnnqButpWWVTw57MgiNSf eKKRhW78f8zP3CX8EjPGxBjxrZcmWmzErcnzqD9SmmYSvmBK2RpPAuGi5Ud/jw/n+9fB9ABKnZxNl Gt4qfCwQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk8Yf-000OSs-I2; Fri, 21 May 2021 17:03:33 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk8Yd-000OSD-0u for linux-amlogic@desiato.infradead.org; Fri, 21 May 2021 17:03:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=Juhu/2tfUID1WaufX4FPTEKsgd2o1fIY1kvSlkG742g=; b=yZWUM80ZPEgRXrCOay9g8/Bcx5 1xGDs//o6khPxZRhQ+Y0PUQIFpdn7RTQjK1joYuDH+hzw6Al/vAB/LCGHJm7VE1myWZNh9W6K99+b StbVthW5SkKiBsZuI5l3tUM55fQXgWGZZPK1wuc9xcAuKG5xwns4o5xqEAHlL0jfAYnaEv5u6KWZM B/POD1FT+tURAyIAJr50vRi8mjiRd3eXlPwvtFnS6eOAeYngAyK3FzzMgMAdrpux1NVDPWILHynrr N6XqRhOThZDQ5IOx3irpOXJcftcEqfIy0WyIDKgRaydw+S445NFu9q6RTqRuCf5Z3BuEaHl4KD0D4 gk0xVUSw==; Received: from smtp02.smtpout.orange.fr ([80.12.242.124] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lk8YZ-00HIQB-SU for linux-amlogic@lists.infradead.org; Fri, 21 May 2021 17:03:29 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210521_100328_219296_82CF0A2E X-CRM114-Status: GOOD ( 11.72 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.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 Reviewed-by: Martin Blumenstingl Acked-by: Neil Armstrong --- 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);