From patchwork Mon Aug 26 10:07:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13777609 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 B1361C5321E for ; Mon, 26 Aug 2024 10:14:16 +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=ASWJ1lNjHUuMpa6qAsr3Tj5tgry0xzTBJeveJBPNnU4=; b=tN8h77RRKDopjBI+lheWC5wMNH CVijhkUfk19QecSxLEdB2mGgfNJW/D2MJSa3cchXAzNkBNlIRSsMfOP/ouNIAPwuXleQcQixy+Laa yVCGk6yFTWCb0QmR52YhV3x83LXrRv4wcd6noJ3je6a0UnQzIw70Nv4fEGfR0KXvs0KXY1NMc0PzE ZoXXYksE9chOceFBTRYjTb9TwLIemRyc+e7w/kjGYxLR4twzslnIqDutuLGmFsCleP9qL+VEokKeI xtcpErGvZmTmQlY18I4Ar66mhg8E/DqMjVfp3A56RSqpuSSMAchqVfCMOFfnfobQ+x6pDVXp++eMa LfiSi6Hg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siWjc-00000006sEy-32Xb; Mon, 26 Aug 2024 10:14:04 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siWdX-00000006qhe-0sDW for linux-arm-kernel@bombadil.infradead.org; Mon, 26 Aug 2024 10:07:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=ASWJ1lNjHUuMpa6qAsr3Tj5tgry0xzTBJeveJBPNnU4=; b=aTsT/SzrmSsEcFZBOTZgTZmx7F RS92Rc6H1GW+LHYr+Q7m6ubpsFd8SJjn71ztosB7s1bXt//8lIZQCAr2YJ8rddFs3Jdap/esBV3b5 xpXWauxoz+5x8rH+Sy7x7P4tvOZm4yIqxuE3l0evxjUlVcjKWgJo3gKQRKOQ2opmDPq5lUIKAxp1d o/JFVhcylvKIcEXv8O6EhD7ZtSQ5jZWcWtSl2gaNAXjgHtTmlTJoVzo2pC0MWJjyWPHM1M7epRY8G +cpxsUBk65Hf9z+BZHU308bA2Ed0y+7actA1HH+2K5WAI44X6Fn8cESn4dNn6gCCnJ0gcjDhho+Nk WdjXnH0g==; Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siWdS-0000000Ad9J-42Je for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 10:07:45 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42802e90140so1841995e9.0 for ; Mon, 26 Aug 2024 03:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724666861; x=1725271661; 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=ASWJ1lNjHUuMpa6qAsr3Tj5tgry0xzTBJeveJBPNnU4=; b=ioKbMr+/cwkHYkM2SSwYqDP4bTIldLjQha7nBrRB9iqrzFpwJyB1JWquvn56QFTrxo KKCQiJotcoP2ynp8xWlqYnCiKRWv37MyB5ju9hclmFX3ZR38pkMCxKwY53q4xFHk8XBr z77MdViri0Ubs65X/Q30G41l6yZWDoZx+ENVk5BJS1A6c4PKfNzEyDua0lduXF/TjwAK e5AFAY7ePFb4QqPc66vhIHS78tjZqxvayf6iJ0Dpkat+a52MYqWAzngwbuVHDSx1dV+2 BJBY7eMXZ0+6EMO7m8tSQqhpd2DXN3Nd62/sDqZzkNqrnxqtLkFuRE+bgtvHW5moiHh9 seWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724666861; x=1725271661; 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=ASWJ1lNjHUuMpa6qAsr3Tj5tgry0xzTBJeveJBPNnU4=; b=J3uIR2VyLLznfbd4KZprTvQ/XNf0xO7560qvqXZp3YRH6G0N3OIb1wxdWtjBrqjERg 71XwK1FADSfTKGWynl+f2gftGHWFcZKb03Mxq8of4PiVTtAikm9oSCuLMlR2G5LvvMEo OlPevm4Pz+Sq88DDhkCmcT4y/arqcX8MPwVVwKItwBwNauYDTPnk5EHFbGvzdetTXP1G /dgEcsEX2vqZ7A1Q5rObhT+9fKCMJj2uPX6Mwt4paSEUpZ8Dmztc9tlTwGKYMc9EQ9s6 Btwd8jX1HSP77eVUvNmrV5p2dI222rwkGP0+KIe6uUbrq+zmTfbmgUxz+B+lRog1LntE fGOg== X-Forwarded-Encrypted: i=1; AJvYcCUcpH77VQL0Yd87yLwtegMp2+9VwyX7t9xwL3HRSyT5Q7Urcu9l3plqT1KObo5HGuVIo05c3ThG3h/f2ASWz0bX@lists.infradead.org X-Gm-Message-State: AOJu0YzOi2O3Scza00t7MfLNdP9XY8xjyjVyeGvfmqBqyPAecaVXjAZh YVRhaMjKiHQ1cNpjPyi699QSJlcQjI6Qc4qpfGrVAT4JqwNIP6CBeswmearjerhEVzdJGWONi0g G X-Google-Smtp-Source: AGHT+IGnpO6+krf9to/NrSDs8QxwhaBThYRXrUT2BYv5yO/i1nNfdR3qX52BrU7X1WNRyqqZ2hzEKw== X-Received: by 2002:a05:600c:5104:b0:428:f17:6baf with SMTP id 5b1f17b1804b1-42acca104f1mr43496065e9.5.1724666861335; Mon, 26 Aug 2024 03:07:41 -0700 (PDT) Received: from [127.0.1.1] ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37308110009sm10324821f8f.18.2024.08.26.03.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 03:07:40 -0700 (PDT) From: Krzysztof Kozlowski Date: Mon, 26 Aug 2024 12:07:22 +0200 Subject: [PATCH 06/11] phy: mediatek: xsphy: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240826-phy-of-node-scope-v1-6-5b4d82582644@linaro.org> References: <20240826-phy-of-node-scope-v1-0-5b4d82582644@linaro.org> In-Reply-To: <20240826-phy-of-node-scope-v1-0-5b4d82582644@linaro.org> To: Vinod Koul , Kishon Vijay Abraham I , Ray Jui , Scott Branden , Broadcom internal kernel review list , Chunfeng Yun , Matthias Brugger , AngeloGioacchino Del Regno Cc: linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2728; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=leD8tF3yHCNMBo9vM9LVLXB5PNba9al/SNWQPAQYPNY=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmzFPdbq398dEPwi9VsOu0ZYKL/TxY+EchqiwUv jtz4Z1F6wOJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZsxT3QAKCRDBN2bmhouD 189TD/0QjWxZ8926h1MFxLw4xEdxSn6C7GFD7UWOUoHho2maLGHAP0d69x+ozFtJlztBohHkqbW kRJNDsp6wHEfcnBupn8tIBsDZbC/np6CT6l8qW64k9CaatbGcD95BsD5LuC31pzpc2WoGPir634 eHuXAc3970XdG9x+sJYhyyS9ONcHPmJcdpPfbtGTzffmsUYWdcnK8iC51dhESPWiVyWfWWkGVy0 ZxagVj/Y77BiwaPv3B0bMQDHjnEj6N7dhh/umLiwgY1pusksIG121C1vbM5R8kzYtunZVtemQ43 uMldHhstgo4Ev3VynweUyowv4pAA0rkxxP8dT0bzB0fjubttMbnwlAB+K+MAppBWGDIepsgfK5H gPdIcCGNbt3ILpIrCRUcqz2Qpiluzlq5KTjQugyQMsnQYyUXg4KgbOJuWsmI3R4hCY4II4e7WOt eQiyP1d/13zdBKlf55/XR+G9EPieqO0UIQ+NgK7lFiD8fZtYJXKeg2E70iWo+YGSyHe+BlOKFVw jbt6ll62mrjY0N0sH3DKkrgdIAbmNJ4AdM4U6uX3FMYf43kEh+eS8SLmk7s5NaAUdZLazZpY7ME sOLGuytbfXbqflrjDXbwOmne4MXE6W5NI1XcgkZCed4ImXGKbfDdUMvVGEelI5QojoNJBOhf35q irWNDnlCOCWDxrA== 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-20240826_110743_246732_BA0C0B3B X-CRM114-Status: GOOD ( 15.09 ) 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 Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/phy/mediatek/phy-mtk-xsphy.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/phy/mediatek/phy-mtk-xsphy.c b/drivers/phy/mediatek/phy-mtk-xsphy.c index 064fd0941727..7c248f5cfca5 100644 --- a/drivers/phy/mediatek/phy-mtk-xsphy.c +++ b/drivers/phy/mediatek/phy-mtk-xsphy.c @@ -432,12 +432,11 @@ static int mtk_xsphy_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; - struct device_node *child_np; struct phy_provider *provider; struct resource *glb_res; struct mtk_xsphy *xsphy; struct resource res; - int port, retval; + int port; xsphy = devm_kzalloc(dev, sizeof(*xsphy), GFP_KERNEL); if (!xsphy) @@ -471,37 +470,34 @@ static int mtk_xsphy_probe(struct platform_device *pdev) device_property_read_u32(dev, "mediatek,src-coef", &xsphy->src_coef); port = 0; - for_each_child_of_node(np, child_np) { + for_each_child_of_node_scoped(np, child_np) { struct xsphy_instance *inst; struct phy *phy; + int retval; inst = devm_kzalloc(dev, sizeof(*inst), GFP_KERNEL); - if (!inst) { - retval = -ENOMEM; - goto put_child; - } + if (!inst) + return -ENOMEM; xsphy->phys[port] = inst; phy = devm_phy_create(dev, child_np, &mtk_xsphy_ops); if (IS_ERR(phy)) { dev_err(dev, "failed to create phy\n"); - retval = PTR_ERR(phy); - goto put_child; + return PTR_ERR(phy); } retval = of_address_to_resource(child_np, 0, &res); if (retval) { dev_err(dev, "failed to get address resource(id-%d)\n", port); - goto put_child; + return retval; } inst->port_base = devm_ioremap_resource(&phy->dev, &res); if (IS_ERR(inst->port_base)) { dev_err(dev, "failed to remap phy regs\n"); - retval = PTR_ERR(inst->port_base); - goto put_child; + return PTR_ERR(inst->port_base); } inst->phy = phy; @@ -512,17 +508,12 @@ static int mtk_xsphy_probe(struct platform_device *pdev) inst->ref_clk = devm_clk_get(&phy->dev, "ref"); if (IS_ERR(inst->ref_clk)) { dev_err(dev, "failed to get ref_clk(id-%d)\n", port); - retval = PTR_ERR(inst->ref_clk); - goto put_child; + return PTR_ERR(inst->ref_clk); } } provider = devm_of_phy_provider_register(dev, mtk_phy_xlate); return PTR_ERR_OR_ZERO(provider); - -put_child: - of_node_put(child_np); - return retval; } static struct platform_driver mtk_xsphy_driver = {