netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Rosen Penev <rosenp@gmail.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>, "Andrew Lunn" <andrew@lunn.ch>,
	"Shannon Nelson" <shannon.nelson@amd.com>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Breno Leitao" <leitao@debian.org>,
	"Jeff Johnson" <quic_jjohnson@quicinc.com>,
	"Christian Marangi" <ansuelsmth@gmail.com>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCHv6 net-next 7/7] net: ibm: emac: use of_find_matching_node
Date: Sat, 12 Oct 2024 14:21:37 +0100	[thread overview]
Message-ID: <20241012132137.GF77519@kernel.org> (raw)
In-Reply-To: <20241011195622.6349-8-rosenp@gmail.com>

On Fri, Oct 11, 2024 at 12:56:22PM -0700, Rosen Penev wrote:
> Cleaner than using of_find_all_nodes and then of_match_node.
> 
> Also modified EMAC_BOOT_LIST_SIZE check to run before of_node_get to
> avoid having to call of_node_put on failure.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  drivers/net/ethernet/ibm/emac/core.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
> index faa483790b29..5265616400c2 100644
> --- a/drivers/net/ethernet/ibm/emac/core.c
> +++ b/drivers/net/ethernet/ibm/emac/core.c
> @@ -3253,21 +3253,17 @@ static void __init emac_make_bootlist(void)
>  	int cell_indices[EMAC_BOOT_LIST_SIZE];
>  
>  	/* Collect EMACs */
> -	while((np = of_find_all_nodes(np)) != NULL) {
> +	while((np = of_find_matching_node(np, emac_match))) {
>  		u32 idx;
>  
> -		if (of_match_node(emac_match, np) == NULL)
> -			continue;
>  		if (of_property_read_bool(np, "unused"))
>  			continue;
>  		if (of_property_read_u32(np, "cell-index", &idx))
>  			continue;
>  		cell_indices[i] = idx;
> -		emac_boot_list[i++] = of_node_get(np);
> -		if (i >= EMAC_BOOT_LIST_SIZE) {
> -			of_node_put(np);
> +		if (i >= EMAC_BOOT_LIST_SIZE)
>  			break;
> -		}
> +		emac_boot_list[i++] = of_node_get(np);

Reading the Kernel doc for of_find_matching_node() it seems
that of_node_put() needs to called each time it (and thus
of_find_matching_node() returns a np. But that doesn't seem
to be the case here. Am I mistaken?


>  	}
>  	max = i;
>  
> -- 
> 2.47.0
> 

  reply	other threads:[~2024-10-12 13:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11 19:56 [PATCHv6 net-next 0/7] ibm: emac: more cleanups Rosen Penev
2024-10-11 19:56 ` [PATCHv6 net-next 1/7] net: ibm: emac: use netif_receive_skb_list Rosen Penev
2024-10-12 13:22   ` Simon Horman
2024-10-11 19:56 ` [PATCHv6 net-next 2/7] net: ibm: emac: remove custom init/exit functions Rosen Penev
2024-10-12 12:59   ` Simon Horman
2024-10-11 19:56 ` [PATCHv6 net-next 3/7] net: ibm: emac: use devm_platform_ioremap_resource Rosen Penev
2024-10-12 13:23   ` Simon Horman
2024-10-11 19:56 ` [PATCHv6 net-next 4/7] net: ibm: emac: use platform_get_irq Rosen Penev
2024-10-12 13:23   ` Simon Horman
2024-10-11 19:56 ` [PATCHv6 net-next 5/7] net: ibm: emac: use devm for mutex_init Rosen Penev
2024-10-12 12:43   ` Simon Horman
2024-10-11 19:56 ` [PATCHv6 net-next 6/7] net: ibm: emac: generate random MAC if not found Rosen Penev
2024-10-12 13:16   ` Simon Horman
2024-10-15 19:44     ` Rosen Penev
2024-10-16  7:36       ` Simon Horman
2024-10-11 19:56 ` [PATCHv6 net-next 7/7] net: ibm: emac: use of_find_matching_node Rosen Penev
2024-10-12 13:21   ` Simon Horman [this message]
2024-10-15 19:45     ` Rosen Penev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241012132137.GF77519@kernel.org \
    --to=horms@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=quic_jjohnson@quicinc.com \
    --cc=rosenp@gmail.com \
    --cc=shannon.nelson@amd.com \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).