From patchwork Wed Aug 14 10:35:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1ACCC52D7B for ; Wed, 14 Aug 2024 10:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yHFYh1Cx+x4Cu70WZybitfJUp7k6hKw0CFTnTWoMGIs=; b=VoyFW08G5O9jZiWXp7dvntaiXp CChx+f3ro+KMK+eNBZhBhtQJtmJFhZ4blignNJmI29kBRTXvb/YvtUCxEIoEA7By+HpLi+J/CjLZW d2dyaGCc3e6P7w7C/bAS7uKxp9IeGVm0y9+mspTN3a5YGKuWz7J1RvI83HJ0gUBQx0RrBWH0+LJx3 A+A8d6nAGQO0GRNkVaKxMnyMsJC7lmAIkrW3XOVoKb240f4TtKMwI2IpPDfn7TdD5Fg24hu+52331 PNWv3McSAEfCnbF/llibfOCYdxmnCsqE5+F0BCcLfUnEWcdvZvxvFwQofMendY9Ipxw6wyWqsfTWV Lhx0r8FA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seBNQ-00000006dB5-1KKR; Wed, 14 Aug 2024 10:37:12 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seBMF-00000006cqM-1SIP for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 10:36:00 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-530e2548dfdso6881395e87.1 for ; Wed, 14 Aug 2024 03:35:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723631757; x=1724236557; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yHFYh1Cx+x4Cu70WZybitfJUp7k6hKw0CFTnTWoMGIs=; b=f5mBPzLDh7slb4IE4n+fW5yfOupL1m1bzFDi6vbMJIPk3Y2YOO8EtxkMlM/RErrunC uTi2HQjD4vYU+dJ4gPuU0dBkVemNeZMicFd/5jpy6FUF3N9JE3Rtu84YhSmFSOyec+5N lCCcIDFxjJ3AfPdzUWKPxb20Ll+qDKB+jlLGV2DvWRJEJ11CRlXT5cLtnrkMmBdEzOmA RZNdena5NbHct69dgN4OHSTq22rhJz6K5emFaCj6zWMZIlH1L1EroMIAeuigET6eFVUu ytSS8uKwYp3jKyfqF67HYWQ+cr5b0jLCC1yUR1T6LvpusQeGZ3UPDPq99IH37f8MkogC wTrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723631757; x=1724236557; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yHFYh1Cx+x4Cu70WZybitfJUp7k6hKw0CFTnTWoMGIs=; b=oR4KxFzYyfj+HyulVSDUpqfZblpzPsUaEl3DSqijB3DFEAbcHzF33GznxtCQkzZ0eI JlszTrq+L6bte+WXwGyFr8yDluoQJ/340Xa1F22Qm3aVF5XQL+XaeXahLgDITkpttPpm NUcz6xdW1/Lf6lB7+kpxmTKiGnX9Qojq71ixzj3eJQHL2mxA3+lD+2+bc1r2nlyLdu2W nBrySH5H0/9yFwGAFn3ueviC1hWNJ3XmmZnhc4xDKJtxA1ReR5YIGkY4FvDHPxMOUMoe /BYOP4OOgUE7MqlW8766kfucYOgrNGrMQ5ZFdfOCzHxYuiK8UwQepGhPzfhV6MxUdGPH Ug7g== X-Gm-Message-State: AOJu0Ywk5vD82aVA3uZYRrYhX1i4KCcQnHIMyWzJ721ZyLkk6HpMUXGi eGE2vYarTsWwow1VpO5A1xr9YtzB/amO+wGSD0Vxw6jhYH/FFVsKwNf0emTyE6E= X-Google-Smtp-Source: AGHT+IG969TFpPgU1+5jbbATSkjp3FOj4nyLgR0kdKAtRZ/slzlU8orv4hZlF4g3iItwYFiyM8i9Zw== X-Received: by 2002:a05:6512:10d5:b0:52c:d56f:b2cc with SMTP id 2adb3069b0e04-532edbcc0f5mr1485533e87.58.1723631757096; Wed, 14 Aug 2024 03:35:57 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded3dd4dsm15501835e9.29.2024.08.14.03.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 03:35:56 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 12:35:37 +0200 Subject: [PATCH 01/11] usb: dwc3: st: use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20240814-b4-cleanup-h-of-node-put-usb-v1-1-95481b9682bc@linaro.org> References: <20240814-b4-cleanup-h-of-node-put-usb-v1-0-95481b9682bc@linaro.org> In-Reply-To: <20240814-b4-cleanup-h-of-node-put-usb-v1-0-95481b9682bc@linaro.org> To: Patrice Chotard , Thinh Nguyen , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Michal Simek Cc: linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-msm@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3220; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=EFpd5/+dfOnJ8CRGGEqG1pEkOch4M8T0ltcfE8+XutU=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvIh/KTrLZD7u68/muOtkJgyWPEAQfePrGpnM9 QQAGl427iCJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZryIfwAKCRDBN2bmhouD 1zo4D/oCOGQPygqo0iW6HAtrAzZlIUOaNfwcp9iCj/Ano/8e5IrnUGFyuT7eMCpLXYpDrma27st DnqxrqJQ8RjjlTsb9TqjTs9CNh80OFAVvSi4sJmRZVfJbjXPp6zcO2X/ws1VvUhNYAQfh86Egy4 Rp+3kJrzjTKMSZxPgGGPQNhT7CFoEFtViM16h6JqCOgCzg/nN1FedbckC9IZ2Wz7wRbP/XV8QQ6 jyB5IyrboscOby2kvjZVXDcjZnFYqeCiNIp2xKxzh3++K4wU+py49dy+rI0wxtieuO1dFxHEU1K CO1q0FgG2e1q32wsr8tVFDX7NamjBQCFRKprLzATS2vJvtljz3VBq2pMr8lMwoC1JZ7w3BPTPgs XUjoiT0heBfbAFkM++5xexqBtarVug08K6eUMQwylhKiOe9ohfxkYKIZTWpvMbb+S07gItrAoWv UkQDT3LqXC88GJsXovIX4dzhF6moMmJTezJ9kXjFqAqJvDRKH0DN97YHAJzBgvzoW5qxijKeygY jSNFmJ6pXUrMcvs/db3Xijh3MP2wOpqE7I3VvVMTaZ5pJVIOvzE4XjODMfUqMDDrLQzSBuWz9lJ wFx7OSOPbUbZ92fyD0g12BeZlZ3RC61RBI88KT3P+kt/FtcWtui9H7XbQjMvviKXgHKTGUcgUB6 Bk0KetBjwiweuGw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_033559_423513_906CD3B3 X-CRM114-Status: GOOD ( 16.80 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Scoped/cleanup.h coding style expects variable declaration with initialization, so the of_get_compatible_child() call has to be moved earlier, before any goto jumps happen. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Patrice Chotard Acked-by: Thinh Nguyen --- This depends on my earlier fix: https://lore.kernel.org/all/20240814093957.37940-2-krzysztof.kozlowski@linaro.org/ --- drivers/usb/dwc3/dwc3-st.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c index c8c7cd0c1796..98f43d7082d7 100644 --- a/drivers/usb/dwc3/dwc3-st.c +++ b/drivers/usb/dwc3/dwc3-st.c @@ -14,6 +14,7 @@ * Inspired by dwc3-omap.c and dwc3-exynos.c. */ +#include #include #include #include @@ -197,7 +198,7 @@ static int st_dwc3_probe(struct platform_device *pdev) struct st_dwc3 *dwc3_data; struct resource *res; struct device *dev = &pdev->dev; - struct device_node *node = dev->of_node, *child; + struct device_node *node = dev->of_node; struct platform_device *child_pdev; struct regmap *regmap; int ret; @@ -227,6 +228,13 @@ static int st_dwc3_probe(struct platform_device *pdev) dev_vdbg(&pdev->dev, "glue-logic addr 0x%pK, syscfg-reg offset 0x%x\n", dwc3_data->glue_base, dwc3_data->syscfg_reg_off); + struct device_node *child __free(device_node) = of_get_compatible_child(node, + "snps,dwc3"); + if (!child) { + dev_err(&pdev->dev, "failed to find dwc3 core node\n"); + return -ENODEV; + } + dwc3_data->rstc_pwrdn = devm_reset_control_get_exclusive(dev, "powerdown"); if (IS_ERR(dwc3_data->rstc_pwrdn)) { @@ -248,18 +256,11 @@ static int st_dwc3_probe(struct platform_device *pdev) /* Manage SoftReset */ reset_control_deassert(dwc3_data->rstc_rst); - child = of_get_compatible_child(node, "snps,dwc3"); - if (!child) { - dev_err(&pdev->dev, "failed to find dwc3 core node\n"); - ret = -ENODEV; - goto err_node_put; - } - /* Allocate and initialize the core */ ret = of_platform_populate(node, NULL, NULL, dev); if (ret) { dev_err(dev, "failed to add dwc3 core\n"); - goto err_node_put; + goto undo_softreset; } child_pdev = of_find_device_by_node(child); @@ -270,7 +271,6 @@ static int st_dwc3_probe(struct platform_device *pdev) } dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev); - of_node_put(child); platform_device_put(child_pdev); /* @@ -282,8 +282,7 @@ static int st_dwc3_probe(struct platform_device *pdev) ret = st_dwc3_drd_init(dwc3_data); if (ret) { dev_err(dev, "drd initialisation failed\n"); - of_platform_depopulate(dev); - goto undo_softreset; + goto depopulate; } /* ST glue logic init */ @@ -294,8 +293,6 @@ static int st_dwc3_probe(struct platform_device *pdev) depopulate: of_platform_depopulate(dev); -err_node_put: - of_node_put(child); undo_softreset: reset_control_assert(dwc3_data->rstc_rst); undo_powerdown: