linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net-next: gianfar: Use device_get_named_child_node_count()
@ 2025-06-17 10:58 Matti Vaittinen
  2025-06-17 11:47 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Matti Vaittinen @ 2025-06-17 10:58 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Claudiu Manoil, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, netdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2231 bytes --]

We can avoid open-coding the loop construct which counts firmware child
nodes with a specific name by using the newly added
device_get_named_child_node_count().

The gianfar driver has such open-coded loop. Replace it with the
device_get_child_node_count_named().

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
Previously sent as part of the BD79124 ADC series:
https://lore.kernel.org/all/95b6015cd5f6fcce535982118543d47504ed609f.1742225817.git.mazziesaccount@gmail.com/

All dependencies should be in net-next now.

Compile tested only!

 drivers/net/ethernet/freescale/gianfar.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index bcbcad613512..7c0f049f0938 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -97,6 +97,7 @@
 #include <linux/phy_fixed.h>
 #include <linux/of.h>
 #include <linux/of_net.h>
+#include <linux/property.h>
 
 #include "gianfar.h"
 
@@ -571,18 +572,6 @@ static int gfar_parse_group(struct device_node *np,
 	return 0;
 }
 
-static int gfar_of_group_count(struct device_node *np)
-{
-	struct device_node *child;
-	int num = 0;
-
-	for_each_available_child_of_node(np, child)
-		if (of_node_name_eq(child, "queue-group"))
-			num++;
-
-	return num;
-}
-
 /* Reads the controller's registers to determine what interface
  * connects it to the PHY.
  */
@@ -654,8 +643,10 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
 		num_rx_qs = 1;
 	} else { /* MQ_MG_MODE */
 		/* get the actual number of supported groups */
-		unsigned int num_grps = gfar_of_group_count(np);
+		unsigned int num_grps;
 
+		num_grps = device_get_named_child_node_count(&ofdev->dev,
+							     "queue-group");
 		if (num_grps == 0 || num_grps > MAXGROUPS) {
 			dev_err(&ofdev->dev, "Invalid # of int groups(%d)\n",
 				num_grps);

base-commit: 3b5b1c428260152e47c9584bc176f358b87ca82d
-- 
2.49.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net-next: gianfar: Use device_get_named_child_node_count()
  2025-06-17 10:58 [PATCH] net-next: gianfar: Use device_get_named_child_node_count() Matti Vaittinen
@ 2025-06-17 11:47 ` Andy Shevchenko
  2025-06-18 10:42   ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2025-06-17 11:47 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Matti Vaittinen, Claudiu Manoil, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, netdev,
	linux-kernel

On Tue, Jun 17, 2025 at 01:58:26PM +0300, Matti Vaittinen wrote:
> We can avoid open-coding the loop construct which counts firmware child
> nodes with a specific name by using the newly added
> device_get_named_child_node_count().
> 
> The gianfar driver has such open-coded loop. Replace it with the
> device_get_child_node_count_named().

Just a side note: The net-next is assumed to be in the square brackets, so when
you format patch, use something like

	git format-patch --subject-prefix="PATCH, net-next" ...

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net-next: gianfar: Use device_get_named_child_node_count()
  2025-06-17 11:47 ` Andy Shevchenko
@ 2025-06-18 10:42   ` Simon Horman
  2025-06-18 12:20     ` Matti Vaittinen
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Horman @ 2025-06-18 10:42 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Matti Vaittinen, Matti Vaittinen, Claudiu Manoil, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev, linux-kernel

On Tue, Jun 17, 2025 at 02:47:10PM +0300, Andy Shevchenko wrote:
> On Tue, Jun 17, 2025 at 01:58:26PM +0300, Matti Vaittinen wrote:
> > We can avoid open-coding the loop construct which counts firmware child
> > nodes with a specific name by using the newly added
> > device_get_named_child_node_count().
> > 
> > The gianfar driver has such open-coded loop. Replace it with the
> > device_get_child_node_count_named().
> 
> Just a side note: The net-next is assumed to be in the square brackets, so when
> you format patch, use something like
> 
> 	git format-patch --subject-prefix="PATCH, net-next" ...

Hi Matti,

It looks like this patch has been marked as Changes Requested in patchwork.
I assume because of Andy's comment above.

Could you address that and submit a v2?

  Subject: [PATCH net-next v2] ...

Otherwise, this looks good to me.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net-next: gianfar: Use device_get_named_child_node_count()
  2025-06-18 10:42   ` Simon Horman
@ 2025-06-18 12:20     ` Matti Vaittinen
  0 siblings, 0 replies; 4+ messages in thread
From: Matti Vaittinen @ 2025-06-18 12:20 UTC (permalink / raw)
  To: Simon Horman, Andy Shevchenko
  Cc: Matti Vaittinen, Claudiu Manoil, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel

On 18/06/2025 13:42, Simon Horman wrote:
> On Tue, Jun 17, 2025 at 02:47:10PM +0300, Andy Shevchenko wrote:
>> On Tue, Jun 17, 2025 at 01:58:26PM +0300, Matti Vaittinen wrote:
>>> We can avoid open-coding the loop construct which counts firmware child
>>> nodes with a specific name by using the newly added
>>> device_get_named_child_node_count().
>>>
>>> The gianfar driver has such open-coded loop. Replace it with the
>>> device_get_child_node_count_named().
>>
>> Just a side note: The net-next is assumed to be in the square brackets, so when
>> you format patch, use something like
>>
>> 	git format-patch --subject-prefix="PATCH, net-next" ...
> 
> Hi Matti,
> 
> It looks like this patch has been marked as Changes Requested in patchwork.

Thanks for the heads-up. I don't really follow the patchwork.

> I assume because of Andy's comment above.
> 
> Could you address that and submit a v2?

Right. I'll re-spin with different subject.

Yours,
	-- Matti

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-06-18 12:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 10:58 [PATCH] net-next: gianfar: Use device_get_named_child_node_count() Matti Vaittinen
2025-06-17 11:47 ` Andy Shevchenko
2025-06-18 10:42   ` Simon Horman
2025-06-18 12:20     ` Matti Vaittinen

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).