Skip to content

Commit 3f4a929

Browse files
M-VaittinenNipaLocal
authored andcommitted
net: gianfar: Use device_get_named_child_node_count()
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 <[email protected]> Signed-off-by: Matti Vaittinen <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent bea7d74 commit 3f4a929

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

drivers/net/ethernet/freescale/gianfar.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
#include <linux/phy_fixed.h>
9898
#include <linux/of.h>
9999
#include <linux/of_net.h>
100+
#include <linux/property.h>
100101

101102
#include "gianfar.h"
102103

@@ -571,18 +572,6 @@ static int gfar_parse_group(struct device_node *np,
571572
return 0;
572573
}
573574

574-
static int gfar_of_group_count(struct device_node *np)
575-
{
576-
struct device_node *child;
577-
int num = 0;
578-
579-
for_each_available_child_of_node(np, child)
580-
if (of_node_name_eq(child, "queue-group"))
581-
num++;
582-
583-
return num;
584-
}
585-
586575
/* Reads the controller's registers to determine what interface
587576
* connects it to the PHY.
588577
*/
@@ -654,8 +643,10 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
654643
num_rx_qs = 1;
655644
} else { /* MQ_MG_MODE */
656645
/* get the actual number of supported groups */
657-
unsigned int num_grps = gfar_of_group_count(np);
646+
unsigned int num_grps;
658647

648+
num_grps = device_get_named_child_node_count(&ofdev->dev,
649+
"queue-group");
659650
if (num_grps == 0 || num_grps > MAXGROUPS) {
660651
dev_err(&ofdev->dev, "Invalid # of int groups(%d)\n",
661652
num_grps);

0 commit comments

Comments
 (0)