Skip to content

Commit fd070e8

Browse files
andy-shevpmladek
authored andcommitted
test_printf: Refactor fwnode_pointer() to make it more readable
Converting fwnode_pointer() to use better swnode API allows to make code more readable. While at it, rename full_name to full_name_third to show exact relation in the hierarchy. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 66283a8 commit fd070e8

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

lib/test_printf.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -704,31 +704,29 @@ flags(void)
704704

705705
static void __init fwnode_pointer(void)
706706
{
707-
const struct software_node softnodes[] = {
708-
{ .name = "first", },
709-
{ .name = "second", .parent = &softnodes[0], },
710-
{ .name = "third", .parent = &softnodes[1], },
711-
{ NULL /* Guardian */ }
712-
};
713-
const char * const full_name = "first/second/third";
707+
const struct software_node first = { .name = "first" };
708+
const struct software_node second = { .name = "second", .parent = &first };
709+
const struct software_node third = { .name = "third", .parent = &second };
710+
const struct software_node *group[] = { &first, &second, &third, NULL };
714711
const char * const full_name_second = "first/second";
712+
const char * const full_name_third = "first/second/third";
715713
const char * const second_name = "second";
716714
const char * const third_name = "third";
717715
int rval;
718716

719-
rval = software_node_register_nodes(softnodes);
717+
rval = software_node_register_node_group(group);
720718
if (rval) {
721719
pr_warn("cannot register softnodes; rval %d\n", rval);
722720
return;
723721
}
724722

725-
test(full_name_second, "%pfw", software_node_fwnode(&softnodes[1]));
726-
test(full_name, "%pfw", software_node_fwnode(&softnodes[2]));
727-
test(full_name, "%pfwf", software_node_fwnode(&softnodes[2]));
728-
test(second_name, "%pfwP", software_node_fwnode(&softnodes[1]));
729-
test(third_name, "%pfwP", software_node_fwnode(&softnodes[2]));
723+
test(full_name_second, "%pfw", software_node_fwnode(&second));
724+
test(full_name_third, "%pfw", software_node_fwnode(&third));
725+
test(full_name_third, "%pfwf", software_node_fwnode(&third));
726+
test(second_name, "%pfwP", software_node_fwnode(&second));
727+
test(third_name, "%pfwP", software_node_fwnode(&third));
730728

731-
software_node_unregister_nodes(softnodes);
729+
software_node_unregister_node_group(group);
732730
}
733731

734732
static void __init fourcc_pointer(void)

0 commit comments

Comments
 (0)