aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2013-02-12 16:19:37 -0500
committerGrant Likely <grant.likely@secretlab.ca>2013-02-13 05:05:58 -0500
commitcabb7d5b7896a4d307ea6ad6d3bd045810544151 (patch)
tree7c32c643c4b51eed352a050fc7c0b606b8c10382 /drivers/of
parentf7f951c29835622d6096530393a8322131059917 (diff)
of/selftest: Use selftest() macro throughout
Some of the selftests are open-coded. Others use the selftest() macro defined in drivers/of/selftest.c. The macro makes for cleaner selftest code, so refactor the of_parse_phandle_with_args() tests to use it. Cc: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/selftest.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c
index 9f62eb58dbc7..01b4174a3b46 100644
--- a/drivers/of/selftest.c
+++ b/drivers/of/selftest.c
@@ -2,7 +2,7 @@
2 * Self tests for device tree subsystem 2 * Self tests for device tree subsystem
3 */ 3 */
4 4
5#define pr_fmt(fmt) "### %s(): " fmt, __func__ 5#define pr_fmt(fmt) "### dt-test ### " fmt
6 6
7#include <linux/clk.h> 7#include <linux/clk.h>
8#include <linux/err.h> 8#include <linux/err.h>
@@ -16,19 +16,20 @@
16 16
17static bool selftest_passed = true; 17static bool selftest_passed = true;
18#define selftest(result, fmt, ...) { \ 18#define selftest(result, fmt, ...) { \
19 selftest_passed &= (result); \ 19 if (!(result)) { \
20 if (!(result)) \
21 pr_err("FAIL %s:%i " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \ 20 pr_err("FAIL %s:%i " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
21 selftest_passed = false; \
22 } else { \
23 pr_info("pass %s:%i\n", __FILE__, __LINE__); \
24 } \
22} 25}
23 26
24static void __init of_selftest_parse_phandle_with_args(void) 27static void __init of_selftest_parse_phandle_with_args(void)
25{ 28{
26 struct device_node *np; 29 struct device_node *np;
27 struct of_phandle_args args; 30 struct of_phandle_args args;
28 int rc, i; 31 int i, rc;
29 bool passed_all = true;
30 32
31 pr_info("start\n");
32 np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); 33 np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a");
33 if (!np) { 34 if (!np) {
34 pr_err("missing testcase data\n"); 35 pr_err("missing testcase data\n");
@@ -79,45 +80,35 @@ static void __init of_selftest_parse_phandle_with_args(void)
79 passed &= (args.args[0] == (i + 1)); 80 passed &= (args.args[0] == (i + 1));
80 break; 81 break;
81 case 7: 82 case 7:
82 passed &= (rc == -EINVAL); 83 passed &= (rc == -ENOENT);
83 break; 84 break;
84 default: 85 default:
85 passed = false; 86 passed = false;
86 } 87 }
87 88
88 if (!passed) { 89 selftest(passed, "index %i - data error on node %s rc=%i\n",
89 int j; 90 i, args.np->full_name, rc);
90 pr_err("index %i - data error on node %s rc=%i regs=[",
91 i, args.np->full_name, rc);
92 for (j = 0; j < args.args_count; j++)
93 printk(" %i", args.args[j]);
94 printk(" ]\n");
95
96 passed_all = false;
97 }
98 } 91 }
99 92
100 /* Check for missing list property */ 93 /* Check for missing list property */
101 rc = of_parse_phandle_with_args(np, "phandle-list-missing", 94 rc = of_parse_phandle_with_args(np, "phandle-list-missing",
102 "#phandle-cells", 0, &args); 95 "#phandle-cells", 0, &args);
103 passed_all &= (rc == -EINVAL); 96 selftest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc);
104 97
105 /* Check for missing cells property */ 98 /* Check for missing cells property */
106 rc = of_parse_phandle_with_args(np, "phandle-list", 99 rc = of_parse_phandle_with_args(np, "phandle-list",
107 "#phandle-cells-missing", 0, &args); 100 "#phandle-cells-missing", 0, &args);
108 passed_all &= (rc == -EINVAL); 101 selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
109 102
110 /* Check for bad phandle in list */ 103 /* Check for bad phandle in list */
111 rc = of_parse_phandle_with_args(np, "phandle-list-bad-phandle", 104 rc = of_parse_phandle_with_args(np, "phandle-list-bad-phandle",
112 "#phandle-cells", 0, &args); 105 "#phandle-cells", 0, &args);
113 passed_all &= (rc == -EINVAL); 106 selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
114 107
115 /* Check for incorrectly formed argument list */ 108 /* Check for incorrectly formed argument list */
116 rc = of_parse_phandle_with_args(np, "phandle-list-bad-args", 109 rc = of_parse_phandle_with_args(np, "phandle-list-bad-args",
117 "#phandle-cells", 1, &args); 110 "#phandle-cells", 1, &args);
118 passed_all &= (rc == -EINVAL); 111 selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
119
120 pr_info("end - %s\n", passed_all ? "PASS" : "FAIL");
121} 112}
122 113
123static void __init of_selftest_property_match_string(void) 114static void __init of_selftest_property_match_string(void)