Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <andriy.shevchenko@linux.intel.com>
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/3a33988fc042588cb00a0bfc5ad64e749cb0eb1f.1750248902.git.mazziesaccount@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Matti Vaittinen and committed by
Jakub Kicinski
64f37cd5 39983de5

+4 -13
+4 -13
drivers/net/ethernet/freescale/gianfar.c
··· 97 97 #include <linux/phy_fixed.h> 98 98 #include <linux/of.h> 99 99 #include <linux/of_net.h> 100 + #include <linux/property.h> 100 101 101 102 #include "gianfar.h" 102 103 ··· 572 571 return 0; 573 572 } 574 573 575 - static int gfar_of_group_count(struct device_node *np) 576 - { 577 - struct device_node *child; 578 - int num = 0; 579 - 580 - for_each_available_child_of_node(np, child) 581 - if (of_node_name_eq(child, "queue-group")) 582 - num++; 583 - 584 - return num; 585 - } 586 - 587 574 /* Reads the controller's registers to determine what interface 588 575 * connects it to the PHY. 589 576 */ ··· 643 654 num_rx_qs = 1; 644 655 } else { /* MQ_MG_MODE */ 645 656 /* get the actual number of supported groups */ 646 - unsigned int num_grps = gfar_of_group_count(np); 657 + unsigned int num_grps; 647 658 659 + num_grps = device_get_named_child_node_count(&ofdev->dev, 660 + "queue-group"); 648 661 if (num_grps == 0 || num_grps > MAXGROUPS) { 649 662 dev_err(&ofdev->dev, "Invalid # of int groups(%d)\n", 650 663 num_grps);