From patchwork Tue Apr 4 07:25:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 78885 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2841099vqo; Tue, 4 Apr 2023 00:39:37 -0700 (PDT) X-Google-Smtp-Source: AKy350YU4aOUaaJ0UIkO274bgseCScKGzFS6OJEhiFqKTBxixa5kDWJBRDqfdQWq97iMN9nxjQ24 X-Received: by 2002:a17:90b:20a:b0:236:a3c2:168a with SMTP id fy10-20020a17090b020a00b00236a3c2168amr1908544pjb.33.1680593977335; Tue, 04 Apr 2023 00:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680593977; cv=none; d=google.com; s=arc-20160816; b=wfIOL5zVocFSvCc52z1LK+B3MB1yQNetqjFASHGiWRSZ3j89qJQWEjW7zdVquwjzhL eQcVeVR0J5VPSTpFhSmLVhBp7C02yXDqVtdwHPYHBIXW+YV3syBVtlY98JTjkttmbcJS rW03eGKbCyQ9d1aIy71WpVYhI3vtHjNQyH7itGggqq5lS9I7FLZJS+Yuih9NM2BuT2DG Uu200d5kPfAL+CQjSfoH7RpzDg8AVH/RxEbP9XEqMmWwDwN3YND//Qe/u+peVQRt7pnl yQI1ta6FD4sLWb9SFyUj0M3FrVKd+Y4EyZfJBL7EgGNFt/fkyskE0J/E5QwC4MPuQU3A BYjA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cV8OWD7OXQ0zszfqYBmseBZDR0qFxLw8HxJ4GRLIGkU=; b=Oo7d3lD3c0WV2D+13u6is8NuiJKk+/vW9eZtJ0HLy7PvIWJUJzMDSFGC26u7VoCoOq pCFRjhn4mhfQL15JZd/FEva2LDUUbK6JSsVqjMZwIJGLIOf6XCOXlc8DNdRG5/eGPqtx rrkJT+sJekz5d6tkcog+ng9eqzkEFVXIZ9VbNYAnLmWGO33FDh18PO+cMWBz9BviMhoV MXzjYvJMpA2/Bx908jd3GLC1ybtOUgeV4cYFjcbsq1hAHb9gEFgOKg8xuFODWTpu76Fn Hy8g5CI4IPMi5ng5nYxszZnYhgomxro3i+4y8gJTOBEaAuh1QL9MvMrjXTnDHiaGnAFX VqAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BA5wBplk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nk18-20020a17090b195200b0023750b6960csi9377532pjb.156.2023.04.04.00.39.24; Tue, 04 Apr 2023 00:39:37 -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=@kernel.org header.s=k20201202 header.b=BA5wBplk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234069AbjDDH0l (ORCPT + 99 others); Tue, 4 Apr 2023 03:26:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233856AbjDDHZz (ORCPT ); Tue, 4 Apr 2023 03:25:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04B1D2D61; Tue, 4 Apr 2023 00:25:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 132C862F82; Tue, 4 Apr 2023 07:25:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFC4DC433A8; Tue, 4 Apr 2023 07:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680593146; bh=HINqrMhuBbCk5a4TBRf+k04vnEVW5aw69FWQnx8oXE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BA5wBplkdvTnvUblKDN26vtxTjyUXx3UY46V6kZYI4sZ4f35gBEdBuSGcuE5QDXXV 5VUXLChmEMEkJZdXQbM4IyVEEMfGihUe8LrENefnHJX3fk0kDeKuqVYnPHN4p91fpJ N2FdALEwDNYWe2CMEKgEOebARbVQBftFRuWCF8WCL7RoGVUwCKGzrw7y9xpeDq/mXt jm052DjYXEB3k0Cy6g3YKMN+Q+RZAIjhASNc1KT9vbsvHjBZszeBwR9NQbrC3duKUe jPs6XZfJ/emNY58jxxqbRznhD+4VVQXgYtHgUal5Kv+4GX49kp8YzBLiJ/ZOkV3otV S7Fww25u7SdvA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pjb3V-0004xk-A2; Tue, 04 Apr 2023 09:26:13 +0200 From: Johan Hovold To: Thinh Nguyen Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 08/11] USB: dwc3: clean up core init error handling Date: Tue, 4 Apr 2023 09:25:21 +0200 Message-Id: <20230404072524.19014-9-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404072524.19014-1-johan+linaro@kernel.org> References: <20230404072524.19014-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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?1762230510177077672?= X-GMAIL-MSGID: =?utf-8?q?1762230510177077672?= Clean up the core init error handling by using descriptive names for the error labels and releasing resourcing in reverse order consistently. Signed-off-by: Johan Hovold Acked-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 15405f1f7aef..c499ef026500 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1008,7 +1008,7 @@ static int dwc3_core_init(struct dwc3 *dwc) ret = dwc3_phy_setup(dwc); if (ret) - goto err0; + return ret; if (!dwc->ulpi_ready) { ret = dwc3_core_ulpi_init(dwc); @@ -1017,7 +1017,7 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc3_core_soft_reset(dwc); ret = -EPROBE_DEFER; } - goto err0; + return ret; } dwc->ulpi_ready = true; } @@ -1025,7 +1025,7 @@ static int dwc3_core_init(struct dwc3 *dwc) if (!dwc->phys_ready) { ret = dwc3_core_get_phy(dwc); if (ret) - goto err0a; + goto err_exit_ulpi; dwc->phys_ready = true; } @@ -1042,7 +1042,7 @@ static int dwc3_core_init(struct dwc3 *dwc) ret = dwc3_core_soft_reset(dwc); if (ret) - goto err1; + goto err_exit_usb3_phy; if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD && !DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) { @@ -1077,16 +1077,16 @@ static int dwc3_core_init(struct dwc3 *dwc) usb_phy_set_suspend(dwc->usb3_phy, 0); ret = phy_power_on(dwc->usb2_generic_phy); if (ret < 0) - goto err2; + goto err_suspend_usb3_phy; ret = phy_power_on(dwc->usb3_generic_phy); if (ret < 0) - goto err3; + goto err_power_off_usb2_phy; ret = dwc3_event_buffers_setup(dwc); if (ret) { dev_err(dwc->dev, "failed to setup event buffers\n"); - goto err4; + goto err_power_off_usb3_phy; } /* @@ -1203,27 +1203,23 @@ static int dwc3_core_init(struct dwc3 *dwc) return 0; -err4: +err_power_off_usb3_phy: phy_power_off(dwc->usb3_generic_phy); - -err3: +err_power_off_usb2_phy: phy_power_off(dwc->usb2_generic_phy); - -err2: - usb_phy_set_suspend(dwc->usb2_phy, 1); +err_suspend_usb3_phy: usb_phy_set_suspend(dwc->usb3_phy, 1); - -err1: + usb_phy_set_suspend(dwc->usb2_phy, 1); +err_exit_usb3_phy: phy_exit(dwc->usb3_generic_phy); err_exit_usb2_phy: phy_exit(dwc->usb2_generic_phy); err_shutdown_usb3_phy: usb_phy_shutdown(dwc->usb3_phy); usb_phy_shutdown(dwc->usb2_phy); -err0a: +err_exit_ulpi: dwc3_ulpi_exit(dwc); -err0: return ret; }