diff options
author | Rob Herring <robh@kernel.org> | 2017-06-01 16:50:55 -0400 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2017-07-18 18:09:18 -0400 |
commit | 0d638a07d3a1e98a7598eb2812a6236324e4c55f (patch) | |
tree | 5cca2869338b69318f5f758b0a6e8cb9ebaad69d /drivers/of/unittest.c | |
parent | b4032ff9af1c266ca671682117ba73e1ba89a259 (diff) |
of: Convert to using %pOF instead of full_name
Now that we have a custom printf format specifier, convert users of
full_name to use %pOF instead. This is preparation to remove storing
of the full path string for each node.
Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of/unittest.c')
-rw-r--r-- | drivers/of/unittest.c | 67 |
1 files changed, 39 insertions, 28 deletions
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 0107fc680335..0959e8cc8814 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c | |||
@@ -46,46 +46,54 @@ static struct unittest_results { | |||
46 | static void __init of_unittest_find_node_by_name(void) | 46 | static void __init of_unittest_find_node_by_name(void) |
47 | { | 47 | { |
48 | struct device_node *np; | 48 | struct device_node *np; |
49 | const char *options; | 49 | const char *options, *name; |
50 | 50 | ||
51 | np = of_find_node_by_path("/testcase-data"); | 51 | np = of_find_node_by_path("/testcase-data"); |
52 | unittest(np && !strcmp("/testcase-data", np->full_name), | 52 | name = kasprintf(GFP_KERNEL, "%pOF", np); |
53 | unittest(np && !strcmp("/testcase-data", name), | ||
53 | "find /testcase-data failed\n"); | 54 | "find /testcase-data failed\n"); |
54 | of_node_put(np); | 55 | of_node_put(np); |
56 | kfree(name); | ||
55 | 57 | ||
56 | /* Test if trailing '/' works */ | 58 | /* Test if trailing '/' works */ |
57 | np = of_find_node_by_path("/testcase-data/"); | 59 | np = of_find_node_by_path("/testcase-data/"); |
58 | unittest(!np, "trailing '/' on /testcase-data/ should fail\n"); | 60 | unittest(!np, "trailing '/' on /testcase-data/ should fail\n"); |
59 | 61 | ||
60 | np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); | 62 | np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); |
61 | unittest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", np->full_name), | 63 | name = kasprintf(GFP_KERNEL, "%pOF", np); |
64 | unittest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", name), | ||
62 | "find /testcase-data/phandle-tests/consumer-a failed\n"); | 65 | "find /testcase-data/phandle-tests/consumer-a failed\n"); |
63 | of_node_put(np); | 66 | of_node_put(np); |
67 | kfree(name); | ||
64 | 68 | ||
65 | np = of_find_node_by_path("testcase-alias"); | 69 | np = of_find_node_by_path("testcase-alias"); |
66 | unittest(np && !strcmp("/testcase-data", np->full_name), | 70 | name = kasprintf(GFP_KERNEL, "%pOF", np); |
71 | unittest(np && !strcmp("/testcase-data", name), | ||
67 | "find testcase-alias failed\n"); | 72 | "find testcase-alias failed\n"); |
68 | of_node_put(np); | 73 | of_node_put(np); |
74 | kfree(name); | ||
69 | 75 | ||
70 | /* Test if trailing '/' works on aliases */ | 76 | /* Test if trailing '/' works on aliases */ |
71 | np = of_find_node_by_path("testcase-alias/"); | 77 | np = of_find_node_by_path("testcase-alias/"); |
72 | unittest(!np, "trailing '/' on testcase-alias/ should fail\n"); | 78 | unittest(!np, "trailing '/' on testcase-alias/ should fail\n"); |
73 | 79 | ||
74 | np = of_find_node_by_path("testcase-alias/phandle-tests/consumer-a"); | 80 | np = of_find_node_by_path("testcase-alias/phandle-tests/consumer-a"); |
75 | unittest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", np->full_name), | 81 | name = kasprintf(GFP_KERNEL, "%pOF", np); |
82 | unittest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", name), | ||
76 | "find testcase-alias/phandle-tests/consumer-a failed\n"); | 83 | "find testcase-alias/phandle-tests/consumer-a failed\n"); |
77 | of_node_put(np); | 84 | of_node_put(np); |
85 | kfree(name); | ||
78 | 86 | ||
79 | np = of_find_node_by_path("/testcase-data/missing-path"); | 87 | np = of_find_node_by_path("/testcase-data/missing-path"); |
80 | unittest(!np, "non-existent path returned node %s\n", np->full_name); | 88 | unittest(!np, "non-existent path returned node %pOF\n", np); |
81 | of_node_put(np); | 89 | of_node_put(np); |
82 | 90 | ||
83 | np = of_find_node_by_path("missing-alias"); | 91 | np = of_find_node_by_path("missing-alias"); |
84 | unittest(!np, "non-existent alias returned node %s\n", np->full_name); | 92 | unittest(!np, "non-existent alias returned node %pOF\n", np); |
85 | of_node_put(np); | 93 | of_node_put(np); |
86 | 94 | ||
87 | np = of_find_node_by_path("testcase-alias/missing-path"); | 95 | np = of_find_node_by_path("testcase-alias/missing-path"); |
88 | unittest(!np, "non-existent alias with relative path returned node %s\n", np->full_name); | 96 | unittest(!np, "non-existent alias with relative path returned node %pOF\n", np); |
89 | of_node_put(np); | 97 | of_node_put(np); |
90 | 98 | ||
91 | np = of_find_node_opts_by_path("/testcase-data:testoption", &options); | 99 | np = of_find_node_opts_by_path("/testcase-data:testoption", &options); |
@@ -315,8 +323,8 @@ static void __init of_unittest_check_phandles(void) | |||
315 | 323 | ||
316 | hash_for_each_possible(phandle_ht, nh, node, np->phandle) { | 324 | hash_for_each_possible(phandle_ht, nh, node, np->phandle) { |
317 | if (nh->np->phandle == np->phandle) { | 325 | if (nh->np->phandle == np->phandle) { |
318 | pr_info("Duplicate phandle! %i used by %s and %s\n", | 326 | pr_info("Duplicate phandle! %i used by %pOF and %pOF\n", |
319 | np->phandle, nh->np->full_name, np->full_name); | 327 | np->phandle, nh->np, np); |
320 | dup_count++; | 328 | dup_count++; |
321 | break; | 329 | break; |
322 | } | 330 | } |
@@ -406,8 +414,8 @@ static void __init of_unittest_parse_phandle_with_args(void) | |||
406 | passed = false; | 414 | passed = false; |
407 | } | 415 | } |
408 | 416 | ||
409 | unittest(passed, "index %i - data error on node %s rc=%i\n", | 417 | unittest(passed, "index %i - data error on node %pOF rc=%i\n", |
410 | i, args.np->full_name, rc); | 418 | i, args.np, rc); |
411 | } | 419 | } |
412 | 420 | ||
413 | /* Check for missing list property */ | 421 | /* Check for missing list property */ |
@@ -590,7 +598,7 @@ static void __init of_unittest_changeset(void) | |||
590 | 598 | ||
591 | /* Make sure node names are constructed correctly */ | 599 | /* Make sure node names are constructed correctly */ |
592 | unittest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")), | 600 | unittest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")), |
593 | "'%s' not added\n", n21->full_name); | 601 | "'%pOF' not added\n", n21); |
594 | of_node_put(np); | 602 | of_node_put(np); |
595 | 603 | ||
596 | unittest(!of_changeset_revert(&chgset), "revert failed\n"); | 604 | unittest(!of_changeset_revert(&chgset), "revert failed\n"); |
@@ -621,8 +629,8 @@ static void __init of_unittest_parse_interrupts(void) | |||
621 | passed &= (args.args_count == 1); | 629 | passed &= (args.args_count == 1); |
622 | passed &= (args.args[0] == (i + 1)); | 630 | passed &= (args.args[0] == (i + 1)); |
623 | 631 | ||
624 | unittest(passed, "index %i - data error on node %s rc=%i\n", | 632 | unittest(passed, "index %i - data error on node %pOF rc=%i\n", |
625 | i, args.np->full_name, rc); | 633 | i, args.np, rc); |
626 | } | 634 | } |
627 | of_node_put(np); | 635 | of_node_put(np); |
628 | 636 | ||
@@ -667,8 +675,8 @@ static void __init of_unittest_parse_interrupts(void) | |||
667 | default: | 675 | default: |
668 | passed = false; | 676 | passed = false; |
669 | } | 677 | } |
670 | unittest(passed, "index %i - data error on node %s rc=%i\n", | 678 | unittest(passed, "index %i - data error on node %pOF rc=%i\n", |
671 | i, args.np->full_name, rc); | 679 | i, args.np, rc); |
672 | } | 680 | } |
673 | of_node_put(np); | 681 | of_node_put(np); |
674 | } | 682 | } |
@@ -737,8 +745,8 @@ static void __init of_unittest_parse_interrupts_extended(void) | |||
737 | passed = false; | 745 | passed = false; |
738 | } | 746 | } |
739 | 747 | ||
740 | unittest(passed, "index %i - data error on node %s rc=%i\n", | 748 | unittest(passed, "index %i - data error on node %pOF rc=%i\n", |
741 | i, args.np->full_name, rc); | 749 | i, args.np, rc); |
742 | } | 750 | } |
743 | of_node_put(np); | 751 | of_node_put(np); |
744 | } | 752 | } |
@@ -917,8 +925,11 @@ static int attach_node_and_children(struct device_node *np) | |||
917 | { | 925 | { |
918 | struct device_node *next, *dup, *child; | 926 | struct device_node *next, *dup, *child; |
919 | unsigned long flags; | 927 | unsigned long flags; |
928 | const char *full_name; | ||
920 | 929 | ||
921 | dup = of_find_node_by_path(np->full_name); | 930 | full_name = kasprintf(GFP_KERNEL, "%pOF", np); |
931 | dup = of_find_node_by_path(full_name); | ||
932 | kfree(full_name); | ||
922 | if (dup) { | 933 | if (dup) { |
923 | update_node_properties(np, dup); | 934 | update_node_properties(np, dup); |
924 | return 0; | 935 | return 0; |
@@ -1023,7 +1034,7 @@ static int unittest_probe(struct platform_device *pdev) | |||
1023 | 1034 | ||
1024 | } | 1035 | } |
1025 | 1036 | ||
1026 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); | 1037 | dev_dbg(dev, "%s for node @%pOF\n", __func__, np); |
1027 | 1038 | ||
1028 | of_platform_populate(np, NULL, NULL, &pdev->dev); | 1039 | of_platform_populate(np, NULL, NULL, &pdev->dev); |
1029 | 1040 | ||
@@ -1035,7 +1046,7 @@ static int unittest_remove(struct platform_device *pdev) | |||
1035 | struct device *dev = &pdev->dev; | 1046 | struct device *dev = &pdev->dev; |
1036 | struct device_node *np = dev->of_node; | 1047 | struct device_node *np = dev->of_node; |
1037 | 1048 | ||
1038 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); | 1049 | dev_dbg(dev, "%s for node @%pOF\n", __func__, np); |
1039 | return 0; | 1050 | return 0; |
1040 | } | 1051 | } |
1041 | 1052 | ||
@@ -1649,7 +1660,7 @@ static int unittest_i2c_bus_probe(struct platform_device *pdev) | |||
1649 | 1660 | ||
1650 | } | 1661 | } |
1651 | 1662 | ||
1652 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); | 1663 | dev_dbg(dev, "%s for node @%pOF\n", __func__, np); |
1653 | 1664 | ||
1654 | std = devm_kzalloc(dev, sizeof(*std), GFP_KERNEL); | 1665 | std = devm_kzalloc(dev, sizeof(*std), GFP_KERNEL); |
1655 | if (!std) { | 1666 | if (!std) { |
@@ -1687,7 +1698,7 @@ static int unittest_i2c_bus_remove(struct platform_device *pdev) | |||
1687 | struct device_node *np = dev->of_node; | 1698 | struct device_node *np = dev->of_node; |
1688 | struct unittest_i2c_bus_data *std = platform_get_drvdata(pdev); | 1699 | struct unittest_i2c_bus_data *std = platform_get_drvdata(pdev); |
1689 | 1700 | ||
1690 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); | 1701 | dev_dbg(dev, "%s for node @%pOF\n", __func__, np); |
1691 | i2c_del_adapter(&std->adap); | 1702 | i2c_del_adapter(&std->adap); |
1692 | 1703 | ||
1693 | return 0; | 1704 | return 0; |
@@ -1718,7 +1729,7 @@ static int unittest_i2c_dev_probe(struct i2c_client *client, | |||
1718 | return -EINVAL; | 1729 | return -EINVAL; |
1719 | } | 1730 | } |
1720 | 1731 | ||
1721 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); | 1732 | dev_dbg(dev, "%s for node @%pOF\n", __func__, np); |
1722 | 1733 | ||
1723 | return 0; | 1734 | return 0; |
1724 | }; | 1735 | }; |
@@ -1728,7 +1739,7 @@ static int unittest_i2c_dev_remove(struct i2c_client *client) | |||
1728 | struct device *dev = &client->dev; | 1739 | struct device *dev = &client->dev; |
1729 | struct device_node *np = client->dev.of_node; | 1740 | struct device_node *np = client->dev.of_node; |
1730 | 1741 | ||
1731 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); | 1742 | dev_dbg(dev, "%s for node @%pOF\n", __func__, np); |
1732 | return 0; | 1743 | return 0; |
1733 | } | 1744 | } |
1734 | 1745 | ||
@@ -1763,7 +1774,7 @@ static int unittest_i2c_mux_probe(struct i2c_client *client, | |||
1763 | struct i2c_mux_core *muxc; | 1774 | struct i2c_mux_core *muxc; |
1764 | u32 reg, max_reg; | 1775 | u32 reg, max_reg; |
1765 | 1776 | ||
1766 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); | 1777 | dev_dbg(dev, "%s for node @%pOF\n", __func__, np); |
1767 | 1778 | ||
1768 | if (!np) { | 1779 | if (!np) { |
1769 | dev_err(dev, "No OF node\n"); | 1780 | dev_err(dev, "No OF node\n"); |
@@ -1808,7 +1819,7 @@ static int unittest_i2c_mux_remove(struct i2c_client *client) | |||
1808 | struct device_node *np = client->dev.of_node; | 1819 | struct device_node *np = client->dev.of_node; |
1809 | struct i2c_mux_core *muxc = i2c_get_clientdata(client); | 1820 | struct i2c_mux_core *muxc = i2c_get_clientdata(client); |
1810 | 1821 | ||
1811 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); | 1822 | dev_dbg(dev, "%s for node @%pOF\n", __func__, np); |
1812 | i2c_mux_del_adapters(muxc); | 1823 | i2c_mux_del_adapters(muxc); |
1813 | return 0; | 1824 | return 0; |
1814 | } | 1825 | } |