From patchwork Wed Aug 28 03:23:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13780431 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F42A15534D; Wed, 28 Aug 2024 03:16:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724814968; cv=none; b=Au9pucp8t+O76tSTmh759rAMICJ01Pq40VzC1Jt+EUoBaouCVQ2vsSW/jaiUyn2H7pjYTisg6ZWEuv/BVeDiFB6PXs+9ZVI11N2f3JzJ4+nV7B953zFvRowE+Y+SSKfqaISJBtc7IIR0nqzWLM67caN2uEauaCjYj91cRscbILM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724814968; c=relaxed/simple; bh=ZL9bRw9rf/2bxgkx0yf1jyPjHJuCRsugEq2KZaHuCfU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oSstGn97nFnYxhu1hZxdRHAZoI4NIy/GOyVP0q0ziVZ1yal60R/hCGfojYnLJyA5s32XK6UuvLW+6GpKNEe7HGbwhVOZHBTe01yv/gWxYXnoAEHd2OWmW2UbYT5nvGe0IKjfpXBrkNOt573opA1AidbRHccAxW0XBo2gBVmCX2k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4WtqJ95f2Hz1xwMn; Wed, 28 Aug 2024 11:14:01 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 49EC4140135; Wed, 28 Aug 2024 11:15:59 +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; Wed, 28 Aug 2024 11:15:58 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH net-next v2 07/13] net: mdio: mux-mmioreg: Simplified with scoped function Date: Wed, 28 Aug 2024 11:23:37 +0800 Message-ID: <20240828032343.1218749-8-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240828032343.1218749-1-ruanjinjie@huawei.com> References: <20240828032343.1218749-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh500013.china.huawei.com (7.202.181.146) X-Patchwork-Delegate: kuba@kernel.org Avoids the need for manual cleanup of_node_put() in early exits from the loop by using for_each_available_child_of_node_scoped(). Signed-off-by: Jinjie Ruan Reviewed-by: Jonathan Cameron --- v2: - Split into 2 patches. --- drivers/net/mdio/mdio-mux-mmioreg.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/mdio/mdio-mux-mmioreg.c b/drivers/net/mdio/mdio-mux-mmioreg.c index de08419d0c98..4d87e61fec7b 100644 --- a/drivers/net/mdio/mdio-mux-mmioreg.c +++ b/drivers/net/mdio/mdio-mux-mmioreg.c @@ -96,7 +96,7 @@ static int mdio_mux_mmioreg_switch_fn(int current_child, int desired_child, static int mdio_mux_mmioreg_probe(struct platform_device *pdev) { - struct device_node *np2, *np = pdev->dev.of_node; + struct device_node *np = pdev->dev.of_node; struct mdio_mux_mmioreg_state *s; struct resource res; const __be32 *iprop; @@ -139,20 +139,18 @@ static int mdio_mux_mmioreg_probe(struct platform_device *pdev) * Verify that the 'reg' property of each child MDIO bus does not * set any bits outside of the 'mask'. */ - for_each_available_child_of_node(np, np2) { + for_each_available_child_of_node_scoped(np, np2) { u64 reg; if (of_property_read_reg(np2, 0, ®, NULL)) { dev_err(&pdev->dev, "mdio-mux child node %pOF is " "missing a 'reg' property\n", np2); - of_node_put(np2); return -ENODEV; } if ((u32)reg & ~s->mask) { dev_err(&pdev->dev, "mdio-mux child node %pOF has " "a 'reg' value with unmasked bits\n", np2); - of_node_put(np2); return -ENODEV; } }