Commit 4c93b0bc authored by Paolo Abeni's avatar Paolo Abeni
Browse files

Merge branch 'net-simplified-with-scoped-function'

Jinjie Ruan says:

====================
net: Simplified with scoped function

Simplify with scoped for each OF child loop, as well as dev_err_probe().

Changes in v4:
- Drop the fix patch and __free() patch.
- Rebased on the fix patch has been stripped out.
- Remove the extra parentheses.
- Ensure Signed-off-by: should always be last.
- Add Reviewed-by.
- Update the cover letter commit message.

Changes in v3:
- Sort the variables, longest first, shortest last.
- Add Reviewed-by.

Changes in v2:
- Subject prefix: next -> net-next.
- Split __free() from scoped for each OF child loop clean.
- Fix use of_node_put() instead of __free() for the 5th patch.
====================

Link: https://patch.msgid.link/20240830031325.2406672-1-ruanjinjie@huawei.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents c55f34a7 e8ac8974
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -4717,7 +4717,7 @@ static int ksz_parse_drive_strength(struct ksz_device *dev)
int ksz_switch_register(struct ksz_device *dev)
{
	const struct ksz_chip_data *info;
	struct device_node *port, *ports;
	struct device_node *ports;
	phy_interface_t interface;
	unsigned int port_num;
	int ret;
@@ -4803,12 +4803,11 @@ int ksz_switch_register(struct ksz_device *dev)
		if (!ports)
			ports = of_get_child_by_name(dev->dev->of_node, "ports");
		if (ports) {
			for_each_available_child_of_node(ports, port) {
			for_each_available_child_of_node_scoped(ports, port) {
				if (of_property_read_u32(port, "reg",
							 &port_num))
					continue;
				if (!(dev->port_mask & BIT(port_num))) {
					of_node_put(port);
					of_node_put(ports);
					return -EINVAL;
				}
+3 −5
Original line number Diff line number Diff line
@@ -1009,8 +1009,8 @@ static int rtl8366rb_setup_all_leds_off(struct realtek_priv *priv)

static int rtl8366rb_setup_leds(struct realtek_priv *priv)
{
	struct device_node *leds_np, *led_np;
	struct dsa_switch *ds = &priv->ds;
	struct device_node *leds_np;
	struct dsa_port *dp;
	int ret = 0;

@@ -1025,14 +1025,12 @@ static int rtl8366rb_setup_leds(struct realtek_priv *priv)
			continue;
		}

		for_each_child_of_node(leds_np, led_np) {
		for_each_child_of_node_scoped(leds_np, led_np) {
			ret = rtl8366rb_setup_led(priv, dp,
						  of_fwnode_handle(led_np));
			if (ret) {
				of_node_put(led_np);
			if (ret)
				break;
		}
		}

		of_node_put(leds_np);
		if (ret)
+2 −3
Original line number Diff line number Diff line
@@ -1300,9 +1300,9 @@ 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 device_node *ports_node;
	struct bcmasp_priv *priv;
	struct bcmasp_intf *intf;
	int ret = 0, count = 0;
@@ -1374,12 +1374,11 @@ static int bcmasp_probe(struct platform_device *pdev)
	}

	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;
		}
+2 −3
Original line number Diff line number Diff line
@@ -2802,7 +2802,7 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
static int mv643xx_eth_shared_of_probe(struct platform_device *pdev)
{
	struct mv643xx_eth_shared_platform_data *pd;
	struct device_node *pnp, *np = pdev->dev.of_node;
	struct device_node *np = pdev->dev.of_node;
	int ret;

	/* bail out if not registered from DT */
@@ -2816,10 +2816,9 @@ static int mv643xx_eth_shared_of_probe(struct platform_device *pdev)

	mv643xx_eth_property(np, "tx-checksum-limit", pd->tx_csum_limit);

	for_each_available_child_of_node(np, pnp) {
	for_each_available_child_of_node_scoped(np, pnp) {
		ret = mv643xx_eth_shared_of_add_port(pdev, pnp);
		if (ret) {
			of_node_put(pnp);
			mv643xx_eth_shared_of_remove();
			return ret;
		}
+2 −4
Original line number Diff line number Diff line
@@ -774,8 +774,8 @@ static int sun8i_dwmac_reset(struct stmmac_priv *priv)
static int get_ephy_nodes(struct stmmac_priv *priv)
{
	struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
	struct device_node *mdio_mux, *iphynode;
	struct device_node *mdio_internal;
	struct device_node *mdio_mux;
	int ret;

	mdio_mux = of_get_child_by_name(priv->device->of_node, "mdio-mux");
@@ -793,7 +793,7 @@ static int get_ephy_nodes(struct stmmac_priv *priv)
	}

	/* Seek for internal PHY */
	for_each_child_of_node(mdio_internal, iphynode) {
	for_each_child_of_node_scoped(mdio_internal, iphynode) {
		gmac->ephy_clk = of_clk_get(iphynode, 0);
		if (IS_ERR(gmac->ephy_clk))
			continue;
@@ -801,14 +801,12 @@ static int get_ephy_nodes(struct stmmac_priv *priv)
		if (IS_ERR(gmac->rst_ephy)) {
			ret = PTR_ERR(gmac->rst_ephy);
			if (ret == -EPROBE_DEFER) {
				of_node_put(iphynode);
				of_node_put(mdio_internal);
				return ret;
			}
			continue;
		}
		dev_info(priv->device, "Found internal PHY node\n");
		of_node_put(iphynode);
		of_node_put(mdio_internal);
		return 0;
	}
Loading