Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350816
b: refs/heads/master
c: cabb7d5
h: refs/heads/master
v: v3
  • Loading branch information
Grant Likely committed Feb 13, 2013
1 parent bb606af commit fcd08f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f7f951c29835622d6096530393a8322131059917
refs/heads/master: cabb7d5b7896a4d307ea6ad6d3bd045810544151
37 changes: 14 additions & 23 deletions trunk/drivers/of/selftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Self tests for device tree subsystem
*/

#define pr_fmt(fmt) "### %s(): " fmt, __func__
#define pr_fmt(fmt) "### dt-test ### " fmt

#include <linux/clk.h>
#include <linux/err.h>
Expand All @@ -16,19 +16,20 @@

static bool selftest_passed = true;
#define selftest(result, fmt, ...) { \
selftest_passed &= (result); \
if (!(result)) \
if (!(result)) { \
pr_err("FAIL %s:%i " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
selftest_passed = false; \
} else { \
pr_info("pass %s:%i\n", __FILE__, __LINE__); \
} \
}

static void __init of_selftest_parse_phandle_with_args(void)
{
struct device_node *np;
struct of_phandle_args args;
int rc, i;
bool passed_all = true;
int i, rc;

pr_info("start\n");
np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a");
if (!np) {
pr_err("missing testcase data\n");
Expand Down Expand Up @@ -79,45 +80,35 @@ static void __init of_selftest_parse_phandle_with_args(void)
passed &= (args.args[0] == (i + 1));
break;
case 7:
passed &= (rc == -EINVAL);
passed &= (rc == -ENOENT);
break;
default:
passed = false;
}

if (!passed) {
int j;
pr_err("index %i - data error on node %s rc=%i regs=[",
i, args.np->full_name, rc);
for (j = 0; j < args.args_count; j++)
printk(" %i", args.args[j]);
printk(" ]\n");

passed_all = false;
}
selftest(passed, "index %i - data error on node %s rc=%i\n",
i, args.np->full_name, rc);
}

/* Check for missing list property */
rc = of_parse_phandle_with_args(np, "phandle-list-missing",
"#phandle-cells", 0, &args);
passed_all &= (rc == -EINVAL);
selftest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc);

/* Check for missing cells property */
rc = of_parse_phandle_with_args(np, "phandle-list",
"#phandle-cells-missing", 0, &args);
passed_all &= (rc == -EINVAL);
selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);

/* Check for bad phandle in list */
rc = of_parse_phandle_with_args(np, "phandle-list-bad-phandle",
"#phandle-cells", 0, &args);
passed_all &= (rc == -EINVAL);
selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);

/* Check for incorrectly formed argument list */
rc = of_parse_phandle_with_args(np, "phandle-list-bad-args",
"#phandle-cells", 1, &args);
passed_all &= (rc == -EINVAL);

pr_info("end - %s\n", passed_all ? "PASS" : "FAIL");
selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
}

static void __init of_selftest_property_match_string(void)
Expand Down

0 comments on commit fcd08f5

Please sign in to comment.