From patchwork Tue Aug 27 07:52:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13779063 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 0FB78C52D6F for ; Tue, 27 Aug 2024 07:50:55 +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:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: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:List-Owner; bh=BRww7gmNvrWSHEsuA33TCPhTBw0gJVL7xyCwZ2ndj0s=; b=u7inss6NdYZcW7aPsewWaSPn3N Nms1eGnY8AyAPgLjT0qOtMA6ZA696Xny/R0HYIPiiKnfNT+toMTdCuXow1uhay6NlAHrC9gZLH/zQ GvrICOqyGd4ua9TTmNn8q0xamyzxpvj9x67aywnB+tcdgS9HZp+4lKs1d/ogVgBq19GQAvzT3Q8rm DV8+FAtx5ov+QFGP04/u8mMDIjOjvRf2IM78uz/08zmu8EUbeY2t9cRNbzFopKJKgad4YE0NMpw+4 1A8vwd2MR9y0JS6rr0UPMY037EUr9ix6fWTejyRD/L8fiZhUGqXcyGsO5GJ4GKtSjfCoOnRHgL+fB VD8KxW7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siqyS-0000000AIH0-083o; Tue, 27 Aug 2024 07:50:44 +0000 Received: from szxga04-in.huawei.com ([45.249.212.190]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siqsZ-0000000AGhs-2UYs for linux-arm-kernel@lists.infradead.org; Tue, 27 Aug 2024 07:44:41 +0000 Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WtKFJ03pPz20mhj; Tue, 27 Aug 2024 15:39:48 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 19E411400F4; Tue, 27 Aug 2024 15:44:36 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 27 Aug 2024 15:44:35 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH -next 7/7] net: bcmasp: Simplify with scoped for each OF child loop Date: Tue, 27 Aug 2024 15:52:19 +0800 Message-ID: <20240827075219.3793198-8-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827075219.3793198-1-ruanjinjie@huawei.com> References: <20240827075219.3793198-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemh500013.china.huawei.com (7.202.181.146) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240827_004440_207596_255F8A4E X-CRM114-Status: GOOD ( 11.49 ) 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_available_child_of_node_scoped() and __free() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan --- drivers/net/ethernet/broadcom/asp2/bcmasp.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c index 20c6529ec135..73e767aada2f 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c @@ -1300,7 +1300,6 @@ static void bcmasp_remove_intfs(struct bcmasp_priv *priv) static int bcmasp_probe(struct platform_device *pdev) { - struct device_node *ports_node, *intf_node; const struct bcmasp_plat_data *pdata; struct device *dev = &pdev->dev; struct bcmasp_priv *priv; @@ -1367,21 +1366,20 @@ static int bcmasp_probe(struct platform_device *pdev) bcmasp_core_init(priv); bcmasp_core_init_filters(priv); - ports_node = of_find_node_by_name(dev->of_node, "ethernet-ports"); + struct device_node *ports_node __free(device_node) = + of_find_node_by_name(dev->of_node, "ethernet-ports"); if (!ports_node) { dev_warn(dev, "No ports found\n"); return -EINVAL; } i = 0; - for_each_available_child_of_node(ports_node, intf_node) { + for_each_available_child_of_node_scoped(ports_node, intf_node) { intf = bcmasp_interface_create(priv, intf_node, i); if (!intf) { - dev_err(dev, "Cannot create eth interface %d\n", i); bcmasp_remove_intfs(priv); - of_node_put(intf_node); - ret = -ENOMEM; - goto of_put_exit; + return dev_err_probe(dev, -ENOMEM, + "Cannot create eth interface %d\n", i); } list_add_tail(&intf->list, &priv->intfs); i++; @@ -1407,16 +1405,14 @@ static int bcmasp_probe(struct platform_device *pdev) "failed to register net_device: %d\n", ret); priv->destroy_wol(priv); bcmasp_remove_intfs(priv); - goto of_put_exit; + return ret; } count++; } dev_info(dev, "Initialized %d port(s)\n", count); -of_put_exit: - of_node_put(ports_node); - return ret; + return 0; } static void bcmasp_remove(struct platform_device *pdev)