diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-20 11:04:46 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-20 11:04:46 -0800 |
commit | b3cdda2b4f541439ca4205793040aa2e1c852e3b (patch) | |
tree | 12f4249a75ba4348b6674c0d46581d959d1dc5c0 /drivers/of/selftest.c | |
parent | 3aad3f03b2b6d2d977b985c49274cdb78a1593e5 (diff) | |
parent | 02bbde7849e68e193cefaa1885fe0df0f03c9fcd (diff) | |
download | blackbird-op-linux-b3cdda2b4f541439ca4205793040aa2e1c852e3b.tar.gz blackbird-op-linux-b3cdda2b4f541439ca4205793040aa2e1c852e3b.zip |
Merge tag 'dt-for-linus' of git://git.secretlab.ca/git/linux
Pull device tree changes from Grant Likely:
"All around device tree changes destined for v3.8. Aside from the
documentation updates the highlights in this branch include:
- Kbuild changes for using CPP with .dts files
- locking fix from preempt_rt patchset
- include DT alias names in device uevent
- Selftest bugfixes and improvements
- New function for counting phandles stanzas in a property
- constify argument to of_node_full_name()
- Various bug fixes
This tree did also contain a commit to use platform_device_add instead
of open-coding the device add code, but it caused problems with amba
devices and needed to be reverted."
* tag 'dt-for-linus' of git://git.secretlab.ca/git/linux: (23 commits)
Revert "of: use platform_device_add"
kbuild: limit dtc+cpp include path
gpio: Make of_count_named_gpios() use new of_count_phandle_with_args()
of: Create function for counting number of phandles in a property
of/base: Clean up exit paths for of_parse_phandle_with_args()
of/selftest: Use selftest() macro throughout
of/selftest: Fix GPIOs selftest to cover the 7th case
of: fix recursive locking in of_get_next_available_child()
documentation/devicetree: Fix a typo in exynos-dw-mshc.txt
OF: convert devtree lock from rw_lock to raw spinlock
of/exynos_g2d: Add Bindings for exynos G2D driver
kbuild: create a rule to run the pre-processor on *.dts files
input: Extend matrix-keypad device tree binding
devicetree: Move NS2 LEDs binding into LEDs directory
of: use platform_device_add
powerpc/5200: Fix size to request_mem_region() call
documentation/devicetree: Fix typos
of: add 'const' to of_node_full_name parameter
of: Output devicetree alias names in uevent
DT: add vendor prefixes for Renesas and Toshiba
...
Diffstat (limited to 'drivers/of/selftest.c')
-rw-r--r-- | drivers/of/selftest.c | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c index f24ffd7088d2..0eb5c38b4e07 100644 --- a/drivers/of/selftest.c +++ b/drivers/of/selftest.c @@ -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> @@ -16,26 +16,30 @@ 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"); return; } - for (i = 0; i < 7; i++) { + rc = of_count_phandle_with_args(np, "phandle-list", "#phandle-cells"); + selftest(rc == 7, "of_count_phandle_with_args() returned %i, expected 7\n", rc); + + for (i = 0; i < 8; i++) { bool passed = true; rc = of_parse_phandle_with_args(np, "phandle-list", "#phandle-cells", i, &args); @@ -79,45 +83,47 @@ 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); + rc = of_count_phandle_with_args(np, "phandle-list-missing", + "#phandle-cells"); + 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); + rc = of_count_phandle_with_args(np, "phandle-list", + "#phandle-cells-missing"); + 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); + rc = of_count_phandle_with_args(np, "phandle-list-bad-phandle", + "#phandle-cells"); + 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); + rc = of_count_phandle_with_args(np, "phandle-list-bad-args", + "#phandle-cells"); + selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); } static void __init of_selftest_property_match_string(void) |