From patchwork Fri May 5 17:15:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 90517 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp571765vqo; Fri, 5 May 2023 10:24:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51V+LDO+25uxg+xUAdtD9KXoVU9Gx4IvQ/60c4E1R7kG/GMQrLfCnWWKQhKVxo9xrMA1oD X-Received: by 2002:a05:6a00:2296:b0:63d:39a5:5bb9 with SMTP id f22-20020a056a00229600b0063d39a55bb9mr2622767pfe.7.1683307487372; Fri, 05 May 2023 10:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683307487; cv=none; d=google.com; s=arc-20160816; b=Q8sFEGVN2JzVftPLzG9IdZf1yciKA2UL05SCInlKtT4bQgdxxB9i529KKpFwBSLDIN 87Sj2mCGikkjKFUrtCPUxdsMnA5WGsfbhwi7HtnJXIU1FXiLZa9yRV0dwNcZpr/gmcjm N83zepHDHTQzaWrzjCncSn17PsvDBRaHquWPVbiUwsBkz6q7wceYDR2m0oi6bsgE85Kc 7KWFKOp38n57kUgeM5EUUi3/Y9JHli+Zw0wMdDLR+fS1/maxJo9Aieyy+rG3AtaRYzPn ojJhIEUjpAojj5Nu98FvO5sHcVFu+Kp7rHs+QlfpXSnMeH5CORheskXZ0YD0w4wgiR35 s2Eg== 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:dkim-signature; bh=gqu0tABTy71MEungb6mGeDyZBFgqwwfrDNcqSf4k2xI=; b=OpjfIKR94iJspHkbQ5uwo5kijl5wmyS0Wdk3i0fL6ETO44+JEiQmMBSxA0yI83cRF6 8iOdVuUKUYpUvUmQez1Q7jLI0ydnzbfg7Cm7tVILQaR0rO+lKdu911Z+IWhIQuPdVV6F a6qjGMtNHW+vJRDGXCx9qZay28i3B4oCFd6NgbgIoB+iWj8RSq9A94lZ6+BZHF2l22x3 QjDkLSy3jl8LgL47eT2C7koqO7xHkUb/RSST62dabiA0rG5Jxq7HccmInDSqXmiddPGJ b9etEvLY8xR7eIGpZozbVW+TI9MUumi1Inde5USCM6MCntgn9A8W13Fh4vH2OS1smzbc awng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=TXSZxQu4; 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 w7-20020a626207000000b00627e8781dbfsi2419104pfb.266.2023.05.05.10.24.32; Fri, 05 May 2023 10:24:47 -0700 (PDT) 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; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=TXSZxQu4; 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 S231326AbjEERPV (ORCPT + 99 others); Fri, 5 May 2023 13:15:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230492AbjEERPS (ORCPT ); Fri, 5 May 2023 13:15:18 -0400 Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF06E11629 for ; Fri, 5 May 2023 10:15:14 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id uz1Rp4Jh8unMHuz1Rp7Jtb; Fri, 05 May 2023 19:15:12 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1683306912; bh=gqu0tABTy71MEungb6mGeDyZBFgqwwfrDNcqSf4k2xI=; h=From:To:Cc:Subject:Date; b=TXSZxQu45vzltYYEBHgUMhaYMeqwXHk4BstUkPY4RcT0/b8hrNY8H+8gmre9bJ3Me xIaOMEm9eq0KW14VjJOxM+QTJGkQ82AyfYQ2CO9LMb0AGDAXjdinmZgbjFZOYLRoF3 xai208YBxS4oko0GiloT0Iy0WTs6zVOJS1kBGM+c5JVgz7qVmpe2Fr5ILkGgPEivdt Fq0qQDwDGozHs6ywi4wFgKFf9RlsinTfgVtOReWpc5Pnk79PvAgPZhHOUM23SnrmmQ H5mr0LWC3Ojjy/aIvbKiiRpOmcbi4VCjoqzDrcrkCkNOo3RTYwdKgY8sVjqgZcl6no 171QjEk5l4iQw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 05 May 2023 19:15:12 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: hminas@synopsys.com, gregkh@linuxfoundation.org, p.zabel@pengutronix.de, johnyoun@synopsys.com, felipe.balbi@linux.intel.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] usb: dwc2: Fix some error handling paths Date: Fri, 5 May 2023 19:15:08 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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?1765075832143924238?= X-GMAIL-MSGID: =?utf-8?q?1765075832143924238?= dwc2_driver_probe() calls dwc2_lowlevel_hw_init() which deassert some reset lines. Should an error happen in dwc2_lowlevel_hw_init() after calling reset_control_deassert() or in the probe after calling dwc2_lowlevel_hw_init(), the reset lines remain deasserted. Add some devm_add_action_or_reset() calls to re-assert the lines if needed. Update the remove function accordingly. This change is compile-tested only. Fixes: 83f8da562f8b ("usb: dwc2: Add reset control to dwc2") Signed-off-by: Christophe JAILLET Acked-by: Minas Harutyunyan --- drivers/usb/dwc2/platform.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index 5aee284018c0..5cf025511cce 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -203,6 +203,11 @@ int dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg) return ret; } +static void dwc2_reset_control_assert(void *data) +{ + reset_control_assert(data); +} + static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) { int i, ret; @@ -213,6 +218,10 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) "error getting reset control\n"); reset_control_deassert(hsotg->reset); + ret = devm_add_action_or_reset(hsotg->dev, dwc2_reset_control_assert, + hsotg->reset); + if (ret) + return ret; hsotg->reset_ecc = devm_reset_control_get_optional(hsotg->dev, "dwc2-ecc"); if (IS_ERR(hsotg->reset_ecc)) @@ -220,6 +229,10 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) "error getting reset control for ecc\n"); reset_control_deassert(hsotg->reset_ecc); + ret = devm_add_action_or_reset(hsotg->dev, dwc2_reset_control_assert, + hsotg->reset_ecc); + if (ret) + return ret; /* * Attempt to find a generic PHY, then look for an old style @@ -339,9 +352,6 @@ static int dwc2_driver_remove(struct platform_device *dev) if (hsotg->ll_hw_enabled) dwc2_lowlevel_hw_disable(hsotg); - reset_control_assert(hsotg->reset); - reset_control_assert(hsotg->reset_ecc); - return 0; }