Lines Matching +full:i +full:- +full:leak +full:- +full:current

1 // SPDX-License-Identifier: GPL-2.0
6 #define pr_fmt(fmt) "### dt-test ### " fmt
10 #include <linux/dma-direct.h> /* to test phys_to_dma/dma_to_phys */
29 #include <linux/i2c-mux.h>
45 pr_err("FAIL %s():%i " fmt, __func__, __LINE__, ##__VA_ARGS__); \
48 pr_info("pass %s():%i\n", __func__, __LINE__); \
54 #define OF_KREF_READ(NODE) kref_read(&(NODE)->kobj.kref)
61 * Print the expected message only if the current loglevel will allow
85 np = of_find_node_by_path("/testcase-data"); in of_unittest_find_node_by_name()
87 unittest(np && name && !strcmp("/testcase-data", name), in of_unittest_find_node_by_name()
88 "find /testcase-data failed\n"); in of_unittest_find_node_by_name()
93 np = of_find_node_by_path("/testcase-data/"); in of_unittest_find_node_by_name()
94 unittest(!np, "trailing '/' on /testcase-data/ should fail\n"); in of_unittest_find_node_by_name()
96 np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); in of_unittest_find_node_by_name()
98 unittest(np && name && !strcmp("/testcase-data/phandle-tests/consumer-a", name), in of_unittest_find_node_by_name()
99 "find /testcase-data/phandle-tests/consumer-a failed\n"); in of_unittest_find_node_by_name()
103 np = of_find_node_by_path("testcase-alias"); in of_unittest_find_node_by_name()
105 unittest(np && name && !strcmp("/testcase-data", name), in of_unittest_find_node_by_name()
106 "find testcase-alias failed\n"); in of_unittest_find_node_by_name()
111 np = of_find_node_by_path("testcase-alias/"); in of_unittest_find_node_by_name()
112 unittest(!np, "trailing '/' on testcase-alias/ should fail\n"); in of_unittest_find_node_by_name()
114 np = of_find_node_by_path("testcase-alias/phandle-tests/consumer-a"); in of_unittest_find_node_by_name()
116 unittest(np && name && !strcmp("/testcase-data/phandle-tests/consumer-a", name), in of_unittest_find_node_by_name()
117 "find testcase-alias/phandle-tests/consumer-a failed\n"); in of_unittest_find_node_by_name()
121 np = of_find_node_by_path("/testcase-data/missing-path"); in of_unittest_find_node_by_name()
122 unittest(!np, "non-existent path returned node %pOF\n", np); in of_unittest_find_node_by_name()
125 np = of_find_node_by_path("missing-alias"); in of_unittest_find_node_by_name()
126 unittest(!np, "non-existent alias returned node %pOF\n", np); in of_unittest_find_node_by_name()
129 np = of_find_node_by_path("testcase-alias/missing-path"); in of_unittest_find_node_by_name()
130 unittest(!np, "non-existent alias with relative path returned node %pOF\n", np); in of_unittest_find_node_by_name()
133 np = of_find_node_opts_by_path("/testcase-data:testoption", &options); in of_unittest_find_node_by_name()
138 np = of_find_node_opts_by_path("/testcase-data:test/option", &options); in of_unittest_find_node_by_name()
143 np = of_find_node_opts_by_path("/testcase-data/testcase-device1:test/option", &options); in of_unittest_find_node_by_name()
148 np = of_find_node_opts_by_path("/testcase-data:testoption", NULL); in of_unittest_find_node_by_name()
152 np = of_find_node_opts_by_path("testcase-alias:testaliasoption", in of_unittest_find_node_by_name()
158 np = of_find_node_opts_by_path("testcase-alias:test/alias/option", in of_unittest_find_node_by_name()
164 np = of_find_node_opts_by_path("testcase-alias:testaliasoption", NULL); in of_unittest_find_node_by_name()
169 np = of_find_node_opts_by_path("testcase-alias", &options); in of_unittest_find_node_by_name()
184 np = of_find_node_by_path("/testcase-data"); in of_unittest_dynamic()
197 /* Add a new property - should pass*/ in of_unittest_dynamic()
198 prop->name = "new-property"; in of_unittest_dynamic()
199 prop->value = "new-property-data"; in of_unittest_dynamic()
200 prop->length = strlen(prop->value) + 1; in of_unittest_dynamic()
203 /* Try to add an existing property - should fail */ in of_unittest_dynamic()
205 prop->name = "new-property"; in of_unittest_dynamic()
206 prop->value = "new-property-data-should-fail"; in of_unittest_dynamic()
207 prop->length = strlen(prop->value) + 1; in of_unittest_dynamic()
211 /* Try to modify an existing property - should pass */ in of_unittest_dynamic()
212 prop->value = "modify-property-data-should-pass"; in of_unittest_dynamic()
213 prop->length = strlen(prop->value) + 1; in of_unittest_dynamic()
217 /* Try to modify non-existent property - should pass*/ in of_unittest_dynamic()
219 prop->name = "modify-property"; in of_unittest_dynamic()
220 prop->value = "modify-missing-property-data-should-pass"; in of_unittest_dynamic()
221 prop->length = strlen(prop->value) + 1; in of_unittest_dynamic()
225 /* Remove property - should pass */ in of_unittest_dynamic()
229 /* Adding very large property - should pass */ in of_unittest_dynamic()
231 prop->name = "large-property-PAGE_SIZEx8"; in of_unittest_dynamic()
232 prop->length = PAGE_SIZE * 8; in of_unittest_dynamic()
233 prop->value = kzalloc(prop->length, GFP_KERNEL); in of_unittest_dynamic()
234 unittest(prop->value != NULL, "Unable to allocate large buffer\n"); in of_unittest_dynamic()
235 if (prop->value) in of_unittest_dynamic()
246 if (child->parent != np) { in of_unittest_check_node_linkage()
249 rc = -EINVAL; in of_unittest_check_node_linkage()
279 "allnodes list size (%i) doesn't match sibling lists size (%i)\n", in of_unittest_check_tree_linkage()
281 pr_debug("allnodes list size (%i); sibling lists size (%i)\n", allnode_count, child_count); in of_unittest_check_tree_linkage()
289 int size, i; in of_unittest_printf_one() local
298 size = snprintf(buf, buf_size - 2, fmt, np); in of_unittest_printf_one()
307 for (i = 0; i < 2; i++, size--) { in of_unittest_printf_one()
312 "snprintf failed; size=%i fmt='%s' expected='%s' rslt='%s'\n", in of_unittest_printf_one()
321 const char *full_name = "/testcase-data/platform-tests/test-device@1/dev@100"; in of_unittest_printf()
330 num_to_str(phandle_str, sizeof(phandle_str), np->phandle, 0); in of_unittest_printf()
337 of_unittest_printf_one(np, "%pOFnc", "dev:test-sub-device"); in of_unittest_printf()
342 of_unittest_printf_one(np, "%-10pOFP", "dev@100 "); in of_unittest_printf()
344 of_unittest_printf_one(np, "%pOFF", "----"); in of_unittest_printf()
345 of_unittest_printf_one(np, "%pOFPF", "dev@100:----"); in of_unittest_printf()
346 of_unittest_printf_one(np, "%pOFPFPc", "dev@100:----:dev@100:test-sub-device"); in of_unittest_printf()
347 of_unittest_printf_one(np, "%pOFc", "test-sub-device"); in of_unittest_printf()
349 "\"test-sub-device\",\"test-compat2\",\"test-compat3\""); in of_unittest_printf()
363 int i, dup_count = 0, phandle_count = 0; in of_unittest_check_phandles() local
366 if (!np->phandle) in of_unittest_check_phandles()
369 hash_for_each_possible(phandle_ht, nh, node, np->phandle) { in of_unittest_check_phandles()
370 if (nh->np->phandle == np->phandle) { in of_unittest_check_phandles()
371 pr_info("Duplicate phandle! %i used by %pOF and %pOF\n", in of_unittest_check_phandles()
372 np->phandle, nh->np, np); in of_unittest_check_phandles()
382 nh->np = np; in of_unittest_check_phandles()
383 hash_add(phandle_ht, &nh->node, np->phandle); in of_unittest_check_phandles()
386 unittest(dup_count == 0, "Found %i duplicates in %i phandles\n", in of_unittest_check_phandles()
390 hash_for_each_safe(phandle_ht, i, tmp, nh, node) { in of_unittest_check_phandles()
391 hash_del(&nh->node); in of_unittest_check_phandles()
400 int i, rc; in of_unittest_parse_phandle_with_args() local
402 np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); in of_unittest_parse_phandle_with_args()
408 rc = of_count_phandle_with_args(np, "phandle-list", "#phandle-cells"); in of_unittest_parse_phandle_with_args()
409 unittest(rc == 7, "of_count_phandle_with_args() returned %i, expected 7\n", rc); in of_unittest_parse_phandle_with_args()
411 for (i = 0; i < 8; i++) { in of_unittest_parse_phandle_with_args()
415 rc = of_parse_phandle_with_args(np, "phandle-list", in of_unittest_parse_phandle_with_args()
416 "#phandle-cells", i, &args); in of_unittest_parse_phandle_with_args()
418 /* Test the values from tests-phandle.dtsi */ in of_unittest_parse_phandle_with_args()
419 switch (i) { in of_unittest_parse_phandle_with_args()
423 passed &= (args.args[0] == (i + 1)); in of_unittest_parse_phandle_with_args()
428 passed &= (args.args[0] == (i + 1)); in of_unittest_parse_phandle_with_args()
432 passed &= (rc == -ENOENT); in of_unittest_parse_phandle_with_args()
437 passed &= (args.args[0] == (i + 1)); in of_unittest_parse_phandle_with_args()
444 passed &= (args.args[0] == (i + 1)); in of_unittest_parse_phandle_with_args()
454 passed &= (args.args[0] == (i + 1)); in of_unittest_parse_phandle_with_args()
457 passed &= (rc == -ENOENT); in of_unittest_parse_phandle_with_args()
463 unittest(passed, "index %i - data error on node %pOF rc=%i\n", in of_unittest_parse_phandle_with_args()
464 i, args.np, rc); in of_unittest_parse_phandle_with_args()
472 rc = of_parse_phandle_with_args(np, "phandle-list-missing", in of_unittest_parse_phandle_with_args()
473 "#phandle-cells", 0, &args); in of_unittest_parse_phandle_with_args()
474 unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); in of_unittest_parse_phandle_with_args()
475 rc = of_count_phandle_with_args(np, "phandle-list-missing", in of_unittest_parse_phandle_with_args()
476 "#phandle-cells"); in of_unittest_parse_phandle_with_args()
477 unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); in of_unittest_parse_phandle_with_args()
483 …"OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-d… in of_unittest_parse_phandle_with_args()
485 rc = of_parse_phandle_with_args(np, "phandle-list", in of_unittest_parse_phandle_with_args()
486 "#phandle-cells-missing", 0, &args); in of_unittest_parse_phandle_with_args()
489 …"OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-d… in of_unittest_parse_phandle_with_args()
491 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); in of_unittest_parse_phandle_with_args()
494 …"OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-d… in of_unittest_parse_phandle_with_args()
496 rc = of_count_phandle_with_args(np, "phandle-list", in of_unittest_parse_phandle_with_args()
497 "#phandle-cells-missing"); in of_unittest_parse_phandle_with_args()
500 …"OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-d… in of_unittest_parse_phandle_with_args()
502 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); in of_unittest_parse_phandle_with_args()
508 "OF: /testcase-data/phandle-tests/consumer-a: could not find phandle"); in of_unittest_parse_phandle_with_args()
510 rc = of_parse_phandle_with_args(np, "phandle-list-bad-phandle", in of_unittest_parse_phandle_with_args()
511 "#phandle-cells", 0, &args); in of_unittest_parse_phandle_with_args()
514 "OF: /testcase-data/phandle-tests/consumer-a: could not find phandle"); in of_unittest_parse_phandle_with_args()
516 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); in of_unittest_parse_phandle_with_args()
519 "OF: /testcase-data/phandle-tests/consumer-a: could not find phandle"); in of_unittest_parse_phandle_with_args()
521 rc = of_count_phandle_with_args(np, "phandle-list-bad-phandle", in of_unittest_parse_phandle_with_args()
522 "#phandle-cells"); in of_unittest_parse_phandle_with_args()
525 "OF: /testcase-data/phandle-tests/consumer-a: could not find phandle"); in of_unittest_parse_phandle_with_args()
527 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); in of_unittest_parse_phandle_with_args()
533 "OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found 1"); in of_unittest_parse_phandle_with_args()
535 rc = of_parse_phandle_with_args(np, "phandle-list-bad-args", in of_unittest_parse_phandle_with_args()
536 "#phandle-cells", 1, &args); in of_unittest_parse_phandle_with_args()
539 "OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found 1"); in of_unittest_parse_phandle_with_args()
541 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); in of_unittest_parse_phandle_with_args()
544 "OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found 1"); in of_unittest_parse_phandle_with_args()
546 rc = of_count_phandle_with_args(np, "phandle-list-bad-args", in of_unittest_parse_phandle_with_args()
547 "#phandle-cells"); in of_unittest_parse_phandle_with_args()
550 "OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found 1"); in of_unittest_parse_phandle_with_args()
552 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); in of_unittest_parse_phandle_with_args()
560 int i, rc; in of_unittest_parse_phandle_with_args_map() local
562 np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-b"); in of_unittest_parse_phandle_with_args_map()
568 p[0] = of_find_node_by_path("/testcase-data/phandle-tests/provider0"); in of_unittest_parse_phandle_with_args_map()
569 p[1] = of_find_node_by_path("/testcase-data/phandle-tests/provider1"); in of_unittest_parse_phandle_with_args_map()
570 p[2] = of_find_node_by_path("/testcase-data/phandle-tests/provider2"); in of_unittest_parse_phandle_with_args_map()
571 p[3] = of_find_node_by_path("/testcase-data/phandle-tests/provider3"); in of_unittest_parse_phandle_with_args_map()
572 p[4] = of_find_node_by_path("/testcase-data/phandle-tests/provider4"); in of_unittest_parse_phandle_with_args_map()
573 p[5] = of_find_node_by_path("/testcase-data/phandle-tests/provider5"); in of_unittest_parse_phandle_with_args_map()
574 for (i = 0; i < ARRAY_SIZE(p); ++i) { in of_unittest_parse_phandle_with_args_map()
575 if (!p[i]) { in of_unittest_parse_phandle_with_args_map()
579 prefs[i] = OF_KREF_READ(p[i]); in of_unittest_parse_phandle_with_args_map()
582 rc = of_count_phandle_with_args(np, "phandle-list", "#phandle-cells"); in of_unittest_parse_phandle_with_args_map()
583 unittest(rc == 8, "of_count_phandle_with_args() returned %i, expected 8\n", rc); in of_unittest_parse_phandle_with_args_map()
585 for (i = 0; i < 9; i++) { in of_unittest_parse_phandle_with_args_map()
589 rc = of_parse_phandle_with_args_map(np, "phandle-list", in of_unittest_parse_phandle_with_args_map()
590 "phandle", i, &args); in of_unittest_parse_phandle_with_args_map()
592 /* Test the values from tests-phandle.dtsi */ in of_unittest_parse_phandle_with_args_map()
593 switch (i) { in of_unittest_parse_phandle_with_args_map()
609 passed &= (rc == -ENOENT); in of_unittest_parse_phandle_with_args_map()
643 passed &= (rc == -ENOENT); in of_unittest_parse_phandle_with_args_map()
649 unittest(passed, "index %i - data error on node %s rc=%i\n", in of_unittest_parse_phandle_with_args_map()
650 i, args.np->full_name, rc); in of_unittest_parse_phandle_with_args_map()
658 rc = of_parse_phandle_with_args_map(np, "phandle-list-missing", in of_unittest_parse_phandle_with_args_map()
660 unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); in of_unittest_parse_phandle_with_args_map()
666 …"OF: /testcase-data/phandle-tests/consumer-b: could not get #phandle-missing-cells for /testcase-d… in of_unittest_parse_phandle_with_args_map()
668 rc = of_parse_phandle_with_args_map(np, "phandle-list", in of_unittest_parse_phandle_with_args_map()
669 "phandle-missing", 0, &args); in of_unittest_parse_phandle_with_args_map()
671 …"OF: /testcase-data/phandle-tests/consumer-b: could not get #phandle-missing-cells for /testcase-d… in of_unittest_parse_phandle_with_args_map()
673 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); in of_unittest_parse_phandle_with_args_map()
679 "OF: /testcase-data/phandle-tests/consumer-b: could not find phandle 12345678"); in of_unittest_parse_phandle_with_args_map()
681 rc = of_parse_phandle_with_args_map(np, "phandle-list-bad-phandle", in of_unittest_parse_phandle_with_args_map()
684 "OF: /testcase-data/phandle-tests/consumer-b: could not find phandle 12345678"); in of_unittest_parse_phandle_with_args_map()
686 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); in of_unittest_parse_phandle_with_args_map()
692 "OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found 1"); in of_unittest_parse_phandle_with_args_map()
694 rc = of_parse_phandle_with_args_map(np, "phandle-list-bad-args", in of_unittest_parse_phandle_with_args_map()
697 "OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found 1"); in of_unittest_parse_phandle_with_args_map()
699 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); in of_unittest_parse_phandle_with_args_map()
701 for (i = 0; i < ARRAY_SIZE(p); ++i) { in of_unittest_parse_phandle_with_args_map()
702 unittest(prefs[i] == OF_KREF_READ(p[i]), in of_unittest_parse_phandle_with_args_map()
704 i, prefs[i], OF_KREF_READ(p[i])); in of_unittest_parse_phandle_with_args_map()
705 of_node_put(p[i]); in of_unittest_parse_phandle_with_args_map()
715 np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); in of_unittest_property_string()
721 rc = of_property_match_string(np, "phandle-list-names", "first"); in of_unittest_property_string()
722 unittest(rc == 0, "first expected:0 got:%i\n", rc); in of_unittest_property_string()
723 rc = of_property_match_string(np, "phandle-list-names", "second"); in of_unittest_property_string()
724 unittest(rc == 1, "second expected:1 got:%i\n", rc); in of_unittest_property_string()
725 rc = of_property_match_string(np, "phandle-list-names", "third"); in of_unittest_property_string()
726 unittest(rc == 2, "third expected:2 got:%i\n", rc); in of_unittest_property_string()
727 rc = of_property_match_string(np, "phandle-list-names", "fourth"); in of_unittest_property_string()
728 unittest(rc == -ENODATA, "unmatched string; rc=%i\n", rc); in of_unittest_property_string()
729 rc = of_property_match_string(np, "missing-property", "blah"); in of_unittest_property_string()
730 unittest(rc == -EINVAL, "missing property; rc=%i\n", rc); in of_unittest_property_string()
731 rc = of_property_match_string(np, "empty-property", "blah"); in of_unittest_property_string()
732 unittest(rc == -ENODATA, "empty property; rc=%i\n", rc); in of_unittest_property_string()
733 rc = of_property_match_string(np, "unterminated-string", "blah"); in of_unittest_property_string()
734 unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); in of_unittest_property_string()
737 rc = of_property_count_strings(np, "string-property"); in of_unittest_property_string()
738 unittest(rc == 1, "Incorrect string count; rc=%i\n", rc); in of_unittest_property_string()
739 rc = of_property_count_strings(np, "phandle-list-names"); in of_unittest_property_string()
740 unittest(rc == 3, "Incorrect string count; rc=%i\n", rc); in of_unittest_property_string()
741 rc = of_property_count_strings(np, "unterminated-string"); in of_unittest_property_string()
742 unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); in of_unittest_property_string()
743 rc = of_property_count_strings(np, "unterminated-string-list"); in of_unittest_property_string()
744 unittest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc); in of_unittest_property_string()
747 rc = of_property_read_string_index(np, "string-property", 0, strings); in of_unittest_property_string()
748 …unittest(rc == 0 && !strcmp(strings[0], "foobar"), "of_property_read_string_index() failure; rc=%i in of_unittest_property_string()
750 rc = of_property_read_string_index(np, "string-property", 1, strings); in of_unittest_property_string()
751 …unittest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n",… in of_unittest_property_string()
752 rc = of_property_read_string_index(np, "phandle-list-names", 0, strings); in of_unittest_property_string()
753 …unittest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\… in of_unittest_property_string()
754 rc = of_property_read_string_index(np, "phandle-list-names", 1, strings); in of_unittest_property_string()
755 …unittest(rc == 0 && !strcmp(strings[0], "second"), "of_property_read_string_index() failure; rc=%i in of_unittest_property_string()
756 rc = of_property_read_string_index(np, "phandle-list-names", 2, strings); in of_unittest_property_string()
757 …unittest(rc == 0 && !strcmp(strings[0], "third"), "of_property_read_string_index() failure; rc=%i\… in of_unittest_property_string()
759 rc = of_property_read_string_index(np, "phandle-list-names", 3, strings); in of_unittest_property_string()
760 …unittest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n",… in of_unittest_property_string()
762 rc = of_property_read_string_index(np, "unterminated-string", 0, strings); in of_unittest_property_string()
763 …unittest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", … in of_unittest_property_string()
764 rc = of_property_read_string_index(np, "unterminated-string-list", 0, strings); in of_unittest_property_string()
765 …unittest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\… in of_unittest_property_string()
767 rc = of_property_read_string_index(np, "unterminated-string-list", 2, strings); /* should fail */ in of_unittest_property_string()
768 …unittest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", … in of_unittest_property_string()
772 rc = of_property_read_string_array(np, "string-property", strings, 4); in of_unittest_property_string()
773 unittest(rc == 1, "Incorrect string count; rc=%i\n", rc); in of_unittest_property_string()
774 rc = of_property_read_string_array(np, "phandle-list-names", strings, 4); in of_unittest_property_string()
775 unittest(rc == 3, "Incorrect string count; rc=%i\n", rc); in of_unittest_property_string()
776 rc = of_property_read_string_array(np, "unterminated-string", strings, 4); in of_unittest_property_string()
777 unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc); in of_unittest_property_string()
778 /* -- An incorrectly formed string should cause a failure */ in of_unittest_property_string()
779 rc = of_property_read_string_array(np, "unterminated-string-list", strings, 4); in of_unittest_property_string()
780 unittest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc); in of_unittest_property_string()
781 /* -- parsing the correctly formed strings should still work: */ in of_unittest_property_string()
783 rc = of_property_read_string_array(np, "unterminated-string-list", strings, 2); in of_unittest_property_string()
784 unittest(rc == 2 && strings[2] == NULL, "of_property_read_string_array() failure; rc=%i\n", rc); in of_unittest_property_string()
786 rc = of_property_read_string_array(np, "phandle-list-names", strings, 1); in of_unittest_property_string()
787 …unittest(rc == 1 && strings[1] == NULL, "Overwrote end of string array; rc=%i, str='%s'\n", rc, st… in of_unittest_property_string()
790 #define propcmp(p1, p2) (((p1)->length == (p2)->length) && \
791 (p1)->value && (p2)->value && \
792 !memcmp((p1)->value, (p2)->value, (p1)->length) && \
793 !strcmp((p1)->name, (p2)->name))
803 kfree(new->value); in of_unittest_property_copy()
804 kfree(new->name); in of_unittest_property_copy()
808 unittest(new && propcmp(&p2, new), "non-empty property didn't copy correctly\n"); in of_unittest_property_copy()
809 kfree(new->value); in of_unittest_property_copy()
810 kfree(new->name); in of_unittest_property_copy()
819 struct property *ppadd, padd = { .name = "prop-add", .length = 1, .value = "" }; in of_unittest_changeset()
823 struct property *ppupdate, pupdate = { .name = "prop-update", .length = 5, .value = "abcd" }; in of_unittest_changeset()
840 nchangeset = of_find_node_by_path("/testcase-data/changeset"); in of_unittest_changeset()
841 nremove = of_get_child_by_name(nchangeset, "node-remove"); in of_unittest_changeset()
860 n1->parent = parent; in of_unittest_changeset()
861 n2->parent = parent; in of_unittest_changeset()
862 n21->parent = n2; in of_unittest_changeset()
864 ppremove = of_find_property(parent, "prop-remove", NULL); in of_unittest_changeset()
880 unittest(!of_changeset_add_property(&chgset, parent, ppadd), "fail add prop prop-add\n"); in of_unittest_changeset()
885 unittest(!of_changeset_add_prop_string(&chgset, n22, "prop-str", "abcd"), in of_unittest_changeset()
886 "fail add prop prop-str"); in of_unittest_changeset()
887 unittest(!of_changeset_add_prop_string_array(&chgset, n22, "prop-str-array", in of_unittest_changeset()
890 "fail add prop prop-str-array"); in of_unittest_changeset()
891 unittest(!of_changeset_add_prop_u32_array(&chgset, n22, "prop-u32-array", in of_unittest_changeset()
893 "fail add prop prop-u32-array"); in of_unittest_changeset()
900 unittest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")), in of_unittest_changeset()
903 unittest((np = of_find_node_by_path("/testcase-data/changeset/n2/n22")), in of_unittest_changeset()
909 unittest(!of_find_node_by_path("/testcase-data/changeset/n2/n21"), in of_unittest_changeset()
912 ppremove = of_find_property(parent, "prop-remove", NULL); in of_unittest_changeset()
915 ret = of_property_read_string(parent, "prop-update", &propstr); in of_unittest_changeset()
937 np = of_find_node_by_path("/testcase-data/address-tests"); in of_unittest_dma_get_max_cpu_address()
965 unittest(!rc, "of_dma_get_range failed on node %pOF rc=%i\n", np, rc); in of_unittest_dma_ranges_one()
979 dev_bogus->dma_range_map = map; in of_unittest_dma_ranges_one()
999 of_unittest_dma_ranges_one("/testcase-data/address-tests/device@70000000", in of_unittest_parse_dma_ranges()
1002 of_unittest_dma_ranges_one("/testcase-data/address-tests/bus@80000000/device@1000", in of_unittest_parse_dma_ranges()
1004 of_unittest_dma_ranges_one("/testcase-data/address-tests/pci@90000000", in of_unittest_parse_dma_ranges()
1013 int i = 0; in of_unittest_pci_dma_ranges() local
1018 np = of_find_node_by_path("/testcase-data/address-tests/pci@90000000"); in of_unittest_pci_dma_ranges()
1025 pr_err("missing dma-ranges property\n"); in of_unittest_pci_dma_ranges()
1030 * Get the dma-ranges from the device tree in of_unittest_pci_dma_ranges()
1033 if (!i) { in of_unittest_pci_dma_ranges()
1054 i++; in of_unittest_pci_dma_ranges()
1066 int ret, count, i = 0; in of_unittest_bus_ranges() local
1068 np = of_find_node_by_path("/testcase-data/address-tests"); in of_unittest_bus_ranges()
1104 if (!i) { in of_unittest_bus_ranges()
1125 i++; in of_unittest_bus_ranges()
1136 int i = 0; in of_unittest_bus_3cell_ranges() local
1138 np = of_find_node_by_path("/testcase-data/address-tests/bus@a0000000"); in of_unittest_bus_3cell_ranges()
1153 if (!i) { in of_unittest_bus_3cell_ranges()
1180 i++; in of_unittest_bus_3cell_ranges()
1192 np = of_find_node_by_path("/testcase-data/address-tests/bus@80000000/device@1000"); in of_unittest_reg()
1233 while (count--) { in of_unittest_check_addr()
1234 ret = of_address_to_resource(np, expected->index, &res); in of_unittest_check_addr()
1236 np, expected->index, ret); in of_unittest_check_addr()
1237 unittest(resource_type(&res) == resource_type(&expected->res) && in of_unittest_check_addr()
1238 res.start == expected->res.start && in of_unittest_check_addr()
1239 resource_size(&res) == resource_size(&expected->res), in of_unittest_check_addr()
1241 np, expected->index, &res, &expected->res); in of_unittest_check_addr()
1270 of_unittest_check_addr("/testcase-data/address-tests2/bus-2cell@10000000/device@100000", in of_unittest_translate_addr()
1274 …of_unittest_check_addr("/testcase-data/address-tests2/bus-3cell@20000000/local-bus@100000/device@f… in of_unittest_translate_addr()
1278 …of_unittest_check_addr("/testcase-data/address-tests2/pcie@d1070000/pci@0,0/dev@0,0/local-bus@0/de… in of_unittest_translate_addr()
1287 int i, rc; in of_unittest_parse_interrupts() local
1292 np = of_find_node_by_path("/testcase-data/interrupts/interrupts0"); in of_unittest_parse_interrupts()
1298 for (i = 0; i < 4; i++) { in of_unittest_parse_interrupts()
1302 rc = of_irq_parse_one(np, i, &args); in of_unittest_parse_interrupts()
1306 passed &= (args.args[0] == (i + 1)); in of_unittest_parse_interrupts()
1308 unittest(passed, "index %i - data error on node %pOF rc=%i\n", in of_unittest_parse_interrupts()
1309 i, args.np, rc); in of_unittest_parse_interrupts()
1313 np = of_find_node_by_path("/testcase-data/interrupts/interrupts1"); in of_unittest_parse_interrupts()
1319 for (i = 0; i < 4; i++) { in of_unittest_parse_interrupts()
1323 rc = of_irq_parse_one(np, i, &args); in of_unittest_parse_interrupts()
1325 /* Test the values from tests-phandle.dtsi */ in of_unittest_parse_interrupts()
1326 switch (i) { in of_unittest_parse_interrupts()
1354 unittest(passed, "index %i - data error on node %pOF rc=%i\n", in of_unittest_parse_interrupts()
1355 i, args.np, rc); in of_unittest_parse_interrupts()
1364 int i, rc; in of_unittest_parse_interrupts_extended() local
1369 np = of_find_node_by_path("/testcase-data/interrupts/interrupts-extended0"); in of_unittest_parse_interrupts_extended()
1375 for (i = 0; i < 7; i++) { in of_unittest_parse_interrupts_extended()
1379 rc = of_irq_parse_one(np, i, &args); in of_unittest_parse_interrupts_extended()
1381 /* Test the values from tests-phandle.dtsi */ in of_unittest_parse_interrupts_extended()
1382 switch (i) { in of_unittest_parse_interrupts_extended()
1422 * #address-cells. See the comments in in of_unittest_parse_interrupts_extended()
1423 * drivers/of/unittest-data/tests-interrupts.dtsi in of_unittest_parse_interrupts_extended()
1424 * nodes intmap1 and interrupts-extended0 in of_unittest_parse_interrupts_extended()
1434 unittest(passed, "index %i - data error on node %pOF rc=%i\n", in of_unittest_parse_interrupts_extended()
1435 i, args.np, rc); in of_unittest_parse_interrupts_extended()
1451 { .data = "I", .compatible = "compat2", .type = "type1", },
1461 { .path = "/testcase-data/match-node/name0", .data = "A", },
1462 { .path = "/testcase-data/match-node/name1", .data = "B", },
1463 { .path = "/testcase-data/match-node/a/name2", .data = "Ca", },
1464 { .path = "/testcase-data/match-node/b/name2", .data = "Cb", },
1465 { .path = "/testcase-data/match-node/c/name2", .data = "Cc", },
1466 { .path = "/testcase-data/match-node/name3", .data = "E", },
1467 { .path = "/testcase-data/match-node/name4", .data = "G", },
1468 { .path = "/testcase-data/match-node/name5", .data = "H", },
1469 { .path = "/testcase-data/match-node/name6", .data = "G", },
1470 { .path = "/testcase-data/match-node/name7", .data = "I", },
1471 { .path = "/testcase-data/match-node/name8", .data = "J", },
1472 { .path = "/testcase-data/match-node/name9", .data = "K", },
1479 int i; in of_unittest_match_node() local
1481 for (i = 0; i < ARRAY_SIZE(match_node_tests); i++) { in of_unittest_match_node()
1482 np = of_find_node_by_path(match_node_tests[i].path); in of_unittest_match_node()
1485 match_node_tests[i].path); in of_unittest_match_node()
1492 match_node_tests[i].path); in of_unittest_match_node()
1496 if (strcmp(match->data, match_node_tests[i].data) != 0) { in of_unittest_match_node()
1498 match_node_tests[i].path, match_node_tests[i].data, in of_unittest_match_node()
1499 (const char *)match->data); in of_unittest_match_node()
1508 .name = "unittest-bus",
1516 { .compatible = "test-device", }, in of_unittest_platform_populate()
1520 np = of_find_node_by_path("/testcase-data"); in of_unittest_platform_populate()
1523 /* Test that a missing irq domain returns -EPROBE_DEFER */ in of_unittest_platform_populate()
1524 np = of_find_node_by_path("/testcase-data/testcase-device1"); in of_unittest_platform_populate()
1530 unittest(irq == -EPROBE_DEFER, in of_unittest_platform_populate()
1531 "device deferred probe failed - %d\n", irq); in of_unittest_platform_populate()
1533 /* Test that a parsing failure does not return -EPROBE_DEFER */ in of_unittest_platform_populate()
1534 np = of_find_node_by_path("/testcase-data/testcase-device2"); in of_unittest_platform_populate()
1539 "platform testcase-data:testcase-device2: error -ENXIO: IRQ index 0 not found"); in of_unittest_platform_populate()
1544 "platform testcase-data:testcase-device2: error -ENXIO: IRQ index 0 not found"); in of_unittest_platform_populate()
1546 unittest(irq < 0 && irq != -EPROBE_DEFER, in of_unittest_platform_populate()
1547 "device parsing error failed - %d\n", irq); in of_unittest_platform_populate()
1550 np = of_find_node_by_path("/testcase-data/platform-tests"); in of_unittest_platform_populate()
1557 unittest(!rc, "testbus registration failed; rc=%i\n", rc); in of_unittest_platform_populate()
1562 test_bus->dev.of_node = np; in of_unittest_platform_populate()
1566 * registered to catch problems with un-inserted resources. The in of_unittest_platform_populate()
1573 of_platform_populate(np, match, NULL, &test_bus->dev); in of_unittest_platform_populate()
1584 of_platform_depopulate(&test_bus->dev); in of_unittest_platform_populate()
1597 * update_node_properties - adds the properties
1613 child->parent = dup; in update_node_properties()
1622 * compiled with the '-@' option. If you encounter this error, in update_node_properties()
1630 * sets prop->next to NULL in update_node_properties()
1632 for (prop = np->properties; prop != NULL; prop = save_next) { in update_node_properties()
1633 save_next = prop->next; in update_node_properties()
1636 if (ret == -EEXIST && !strcmp(prop->name, "name")) in update_node_properties()
1639 np, prop->name); in update_node_properties()
1645 * attach_node_and_children - attaches nodes
1647 * CAUTION: misleading function name - if node @np already exists in
1649 * tree. This works for the current test devicetree nodes because such
1677 child = np->child; in attach_node_and_children()
1678 np->child = NULL; in attach_node_and_children()
1682 np->sibling = np->parent->child; in attach_node_and_children()
1683 np->parent->child = np; in attach_node_and_children()
1691 next = child->sibling; in attach_node_and_children()
1698 * unittest_data_add - Reads, copies data from
1712 const int size = __dtbo_testcases_end - __dtbo_testcases_begin; in unittest_data_add()
1718 return -ENODATA; in unittest_data_add()
1724 return -ENOMEM; in unittest_data_add()
1733 return -ENODATA; in unittest_data_add()
1738 return -ENODATA; in unittest_data_add()
1748 pr_err("%s: Failed to resolve phandles (rc=%i)\n", __func__, rc); in unittest_data_add()
1750 return -EINVAL; in unittest_data_add()
1764 "Duplicate name in testcase-data, renamed to \"duplicate-name#1\""); in unittest_data_add()
1766 /* attach the sub-tree to live tree */ in unittest_data_add()
1767 np = unittest_data_node->child; in unittest_data_add()
1769 struct device_node *next = np->sibling; in unittest_data_add()
1771 np->parent = of_root; in unittest_data_add()
1778 "Duplicate name in testcase-data, renamed to \"duplicate-name#1\""); in unittest_data_add()
1790 struct device *dev = &pdev->dev; in unittest_probe()
1791 struct device_node *np = dev->of_node; in unittest_probe()
1795 return -EINVAL; in unittest_probe()
1801 of_platform_populate(np, NULL, NULL, &pdev->dev); in unittest_probe()
1808 struct device *dev = &pdev->dev; in unittest_remove()
1809 struct device_node *np = dev->of_node; in unittest_remove()
1868 pr_debug("%s(): %s %d %d\n", __func__, chip->label, offset, in unittest_gpio_chip_request()
1882 return -ENOMEM; in unittest_gpio_probe()
1886 devptr->chip.fwnode = dev_fwnode(&pdev->dev); in unittest_gpio_probe()
1887 devptr->chip.label = "of-unittest-gpio"; in unittest_gpio_probe()
1888 devptr->chip.base = -1; /* dynamic allocation */ in unittest_gpio_probe()
1889 devptr->chip.ngpio = 5; in unittest_gpio_probe()
1890 devptr->chip.request = unittest_gpio_chip_request; in unittest_gpio_probe()
1892 ret = gpiochip_add_data(&devptr->chip, NULL); in unittest_gpio_probe()
1895 "gpiochip_add_data() for node @%pfw failed, ret = %d\n", devptr->chip.fwnode, ret); in unittest_gpio_probe()
1905 struct device *dev = &pdev->dev; in unittest_gpio_remove()
1907 dev_dbg(dev, "%s for node @%pfw\n", __func__, devptr->chip.fwnode); in unittest_gpio_remove()
1909 if (devptr->chip.base != -1) in unittest_gpio_remove()
1910 gpiochip_remove(&devptr->chip); in unittest_gpio_remove()
1916 { .compatible = "unittest-gpio", },
1924 .name = "unittest-gpio",
1945 * - apply overlay_gpio_01 in of_unittest_overlay_gpio()
1946 * - apply overlay_gpio_02a in of_unittest_overlay_gpio()
1947 * - apply overlay_gpio_02b in of_unittest_overlay_gpio()
1948 * - register driver in of_unittest_overlay_gpio()
1951 * - probe and processing gpio hog for overlay_gpio_01 in of_unittest_overlay_gpio()
1952 * - probe for overlay_gpio_02a in of_unittest_overlay_gpio()
1953 * - processing gpio for overlay_gpio_02b in of_unittest_overlay_gpio()
1983 unittest_gpio_chip_request_count - chip_request_count); in of_unittest_overlay_gpio()
1988 * Similar to a driver built-in to the kernel, the in of_unittest_overlay_gpio()
1993 * - apply overlay_gpio_03 in of_unittest_overlay_gpio()
1996 * - probe and processing gpio hog. in of_unittest_overlay_gpio()
2012 unittest_gpio_chip_request_count - chip_request_count); in of_unittest_overlay_gpio()
2017 * - apply overlay_gpio_04a in of_unittest_overlay_gpio()
2020 * - probe for overlay_gpio_04a in of_unittest_overlay_gpio()
2037 * - apply overlay_gpio_04b in of_unittest_overlay_gpio()
2040 * - processing gpio for overlay_gpio_04b in of_unittest_overlay_gpio()
2050 unittest_gpio_chip_request_count - chip_request_count); in of_unittest_overlay_gpio()
2087 put_device(&client->dev); in of_path_i2c_client_exists()
2121 base = "/testcase-data/overlay-node/test-bus"; in unittest_path()
2124 base = "/testcase-data/overlay-node/test-bus/i2c-test-bus"; in unittest_path()
2130 snprintf(buf, sizeof(buf) - 1, "%s/test-unittest%d", base, nr); in unittest_path()
2131 buf[sizeof(buf) - 1] = '\0'; in unittest_path()
2154 snprintf(buf, sizeof(buf) - 1, in overlay_name_from_nr()
2156 buf[sizeof(buf) - 1] = '\0'; in overlay_name_from_nr()
2161 static const char *bus_path = "/testcase-data/overlay-node/test-bus";
2184 track_ovcs_id_cnt--; in of_unittest_untrack_overlay()
2197 ovcs_id = track_ovcs_id[track_ovcs_id_cnt - 1]; in of_unittest_remove_tracked_overlays()
2198 overlay_nr = track_ovcs_id_overlay_nr[track_ovcs_id_cnt - 1]; in of_unittest_remove_tracked_overlays()
2201 if (ret == -ENODEV) { in of_unittest_remove_tracked_overlays()
2224 return -EFAULT; in of_unittest_apply_overlay()
2243 return -EINVAL; in __of_unittest_apply_overlay_check()
2260 return -EINVAL; in __of_unittest_apply_overlay_check()
2308 return -EINVAL; in of_unittest_apply_revert_overlay_check()
2320 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_0()
2326 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_0()
2340 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_1()
2346 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_1()
2361 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_2()
2367 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_2()
2380 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_3()
2386 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_3()
2410 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_5()
2416 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_5()
2427 int i, save_ovcs_id[2], ovcs_id; in of_unittest_overlay_6() local
2435 for (i = 0; i < 2; i++) { in of_unittest_overlay_6()
2436 if (of_unittest_device_exists(unittest_nr + i, PDEV_OVERLAY) in of_unittest_overlay_6()
2439 overlay_name_from_nr(overlay_nr + i), in of_unittest_overlay_6()
2440 unittest_path(unittest_nr + i, in of_unittest_overlay_6()
2450 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_6()
2464 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_6()
2467 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_6()
2481 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_6()
2484 for (i = 0; i < 2; i++) { in of_unittest_overlay_6()
2486 if (of_unittest_device_exists(unittest_nr + i, PDEV_OVERLAY) in of_unittest_overlay_6()
2489 overlay_name_from_nr(overlay_nr + i), in of_unittest_overlay_6()
2490 unittest_path(unittest_nr + i, in of_unittest_overlay_6()
2497 for (i = 1; i >= 0; i--) { in of_unittest_overlay_6()
2498 ovcs_id = save_ovcs_id[i]; in of_unittest_overlay_6()
2501 overlay_name_from_nr(overlay_nr + i), in of_unittest_overlay_6()
2502 unittest_path(unittest_nr + i, in of_unittest_overlay_6()
2506 of_unittest_untrack_overlay(save_ovcs_id[i]); in of_unittest_overlay_6()
2509 for (i = 0; i < 2; i++) { in of_unittest_overlay_6()
2511 if (of_unittest_device_exists(unittest_nr + i, PDEV_OVERLAY) in of_unittest_overlay_6()
2514 overlay_name_from_nr(overlay_nr + i), in of_unittest_overlay_6()
2515 unittest_path(unittest_nr + i, in of_unittest_overlay_6()
2529 int i, save_ovcs_id[2], ovcs_id; in of_unittest_overlay_8() local
2537 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_8()
2546 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay in of_unittest_overlay_8()
2557 …erlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/t… in of_unittest_overlay_8()
2563 …erlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/t… in of_unittest_overlay_8()
2577 …rlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unitt… in of_unittest_overlay_8()
2588 …rlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unitt… in of_unittest_overlay_8()
2603 for (i = 1; i >= 0; i--) { in of_unittest_overlay_8()
2604 ovcs_id = save_ovcs_id[i]; in of_unittest_overlay_8()
2607 overlay_name_from_nr(overlay_nr + i), in of_unittest_overlay_8()
2612 of_unittest_untrack_overlay(save_ovcs_id[i]); in of_unittest_overlay_8()
2631 child_path = kasprintf(GFP_KERNEL, "%s/test-unittest101", in of_unittest_overlay_10()
2683 struct device *dev = &pdev->dev; in unittest_i2c_bus_probe()
2684 struct device_node *np = dev->of_node; in unittest_i2c_bus_probe()
2691 return -EINVAL; in unittest_i2c_bus_probe()
2699 return -ENOMEM; in unittest_i2c_bus_probe()
2702 std->pdev = pdev; in unittest_i2c_bus_probe()
2705 adap = &std->adap; in unittest_i2c_bus_probe()
2707 adap->nr = -1; in unittest_i2c_bus_probe()
2708 strscpy(adap->name, pdev->name, sizeof(adap->name)); in unittest_i2c_bus_probe()
2709 adap->class = I2C_CLASS_DEPRECATED; in unittest_i2c_bus_probe()
2710 adap->algo = &unittest_i2c_algo; in unittest_i2c_bus_probe()
2711 adap->dev.parent = dev; in unittest_i2c_bus_probe()
2712 adap->dev.of_node = dev->of_node; in unittest_i2c_bus_probe()
2713 adap->timeout = 5 * HZ; in unittest_i2c_bus_probe()
2714 adap->retries = 3; in unittest_i2c_bus_probe()
2727 struct device *dev = &pdev->dev; in unittest_i2c_bus_remove()
2728 struct device_node *np = dev->of_node; in unittest_i2c_bus_remove()
2732 i2c_del_adapter(&std->adap); in unittest_i2c_bus_remove()
2736 { .compatible = "unittest-i2c-bus", },
2744 .name = "unittest-i2c-bus",
2751 struct device *dev = &client->dev; in unittest_i2c_dev_probe()
2752 struct device_node *np = client->dev.of_node; in unittest_i2c_dev_probe()
2756 return -EINVAL; in unittest_i2c_dev_probe()
2766 struct device *dev = &client->dev; in unittest_i2c_dev_remove()
2767 struct device_node *np = client->dev.of_node; in unittest_i2c_dev_remove()
2773 { .name = "unittest-i2c-dev" },
2779 .name = "unittest-i2c-dev",
2795 int i, nchans; in unittest_i2c_mux_probe() local
2796 struct device *dev = &client->dev; in unittest_i2c_mux_probe()
2797 struct i2c_adapter *adap = client->adapter; in unittest_i2c_mux_probe()
2798 struct device_node *np = client->dev.of_node, *child; in unittest_i2c_mux_probe()
2806 return -EINVAL; in unittest_i2c_mux_probe()
2809 max_reg = (u32)-1; in unittest_i2c_mux_probe()
2813 if (max_reg == (u32)-1 || reg > max_reg) in unittest_i2c_mux_probe()
2816 nchans = max_reg == (u32)-1 ? 0 : max_reg + 1; in unittest_i2c_mux_probe()
2819 return -EINVAL; in unittest_i2c_mux_probe()
2825 return -ENOMEM; in unittest_i2c_mux_probe()
2826 for (i = 0; i < nchans; i++) { in unittest_i2c_mux_probe()
2827 if (i2c_mux_add_adapter(muxc, 0, i, 0)) { in unittest_i2c_mux_probe()
2828 dev_err(dev, "Failed to register mux #%d\n", i); in unittest_i2c_mux_probe()
2830 return -ENODEV; in unittest_i2c_mux_probe()
2841 struct device *dev = &client->dev; in unittest_i2c_mux_remove()
2842 struct device_node *np = client->dev.of_node; in unittest_i2c_mux_remove()
2850 { .name = "unittest-i2c-mux" },
2856 .name = "unittest-i2c-mux",
2883 "i2c i2c-1: Added multiplexed i2c bus 2"); in of_unittest_overlay_i2c_init()
2888 "i2c i2c-1: Added multiplexed i2c bus 2"); in of_unittest_overlay_i2c_init()
2913 … overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-nod… in of_unittest_overlay_i2c_12()
2918 … overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-nod… in of_unittest_overlay_i2c_12()
2932 … overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-nod… in of_unittest_overlay_i2c_13()
2938 … overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-nod… in of_unittest_overlay_i2c_13()
2957 "i2c i2c-1: Added multiplexed i2c bus 3"); in of_unittest_overlay_i2c_15()
2962 "i2c i2c-1: Added multiplexed i2c bus 3"); in of_unittest_overlay_i2c_15()
2988 * ret = -EBUSY which is -16. in of_notify()
2997 of_node_get(nd->overlay); in of_notify()
3002 found = of_find_node_by_name(nd->overlay, "test-unittest16"); in of_notify()
3005 ret = -EBUSY; in of_notify()
3010 found = of_find_node_by_name(nd->overlay, "test-unittest17"); in of_notify()
3013 ret = -EEXIST; in of_notify()
3018 found = of_find_node_by_name(nd->overlay, "test-unittest18"); in of_notify()
3021 ret = -EXDEV; in of_notify()
3026 found = of_find_node_by_name(nd->overlay, "test-unittest19"); in of_notify()
3029 ret = -ENODEV; in of_notify()
3034 of_node_put(nd->overlay); in of_notify()
3035 ret = -EINVAL; in of_notify()
3066 * Applying overlays 16 - 19 will each trigger an error for a in of_unittest_overlay_notify()
3072 /* --- overlay 16 --- */ in of_unittest_overlay_notify()
3074 …_INFO, "OF: overlay: overlay changeset pre-apply notifier error -16, target: /testcase-data/overla… in of_unittest_overlay_notify()
3079 …_INFO, "OF: overlay: overlay changeset pre-apply notifier error -16, target: /testcase-data/overla… in of_unittest_overlay_notify()
3083 /* --- overlay 17 --- */ in of_unittest_overlay_notify()
3085 …INFO, "OF: overlay: overlay changeset post-apply notifier error -17, target: /testcase-data/overla… in of_unittest_overlay_notify()
3090 …INFO, "OF: overlay: overlay changeset post-apply notifier error -17, target: /testcase-data/overla… in of_unittest_overlay_notify()
3094 /* --- overlay 18 --- */ in of_unittest_overlay_notify()
3102 …_INFO, "OF: overlay: overlay changeset pre-remove notifier error -18, target: /testcase-data/overl… in of_unittest_overlay_notify()
3105 …_INFO, "OF: overlay: overlay changeset pre-remove notifier error -18, target: /testcase-data/overl… in of_unittest_overlay_notify()
3106 if (ret == -EXDEV) { in of_unittest_overlay_notify()
3120 /* --- overlay 19 --- */ in of_unittest_overlay_notify()
3128 …INFO, "OF: overlay: overlay changeset post-remove notifier error -19, target: /testcase-data/overl… in of_unittest_overlay_notify()
3130 …INFO, "OF: overlay: overlay changeset post-remove notifier error -19, target: /testcase-data/overl… in of_unittest_overlay_notify()
3131 if (ret == -ENODEV) in of_unittest_overlay_notify()
3142 /* --- overlay 20 --- */ in of_unittest_overlay_notify()
3163 unsigned int i; in of_unittest_overlay() local
3201 for (i = 0; i < 3; i++) in of_unittest_overlay()
3243 const char *refcount_path = "/testcase-data/refcount-node"; in of_unittest_lifecycle()
3244 const char *refcount_parent_path = "/testcase-data"; in of_unittest_lifecycle()
3247 * Node lifecycle tests, non-dynamic node: in of_unittest_lifecycle()
3249 * - Decrementing refcount to zero via of_node_put() should cause the in of_unittest_lifecycle()
3253 * - Decrementing refcount past zero should result in additional in of_unittest_lifecycle()
3269 refcount = kref_read(&np->kobj.kref); in of_unittest_lifecycle()
3276 …N_INFO, "OF: ERROR: of_node_release() detected bad of_node_put() on /testcase-data/refcount-node"); in of_unittest_lifecycle()
3283 unittest(1, "/testcase-data/refcount-node is one"); in of_unittest_lifecycle()
3286 …N_INFO, "OF: ERROR: of_node_release() detected bad of_node_put() on /testcase-data/refcount-node"); in of_unittest_lifecycle()
3297 EXPECT_BEGIN(KERN_INFO, "------------[ cut here ]------------"); in of_unittest_lifecycle()
3299 EXPECT_BEGIN(KERN_INFO, "refcount_t: underflow; use-after-free."); in of_unittest_lifecycle()
3300 EXPECT_BEGIN(KERN_INFO, "---[ end trace <<int>> ]---"); in of_unittest_lifecycle()
3303 unittest(1, "/testcase-data/refcount-node is zero"); in of_unittest_lifecycle()
3306 EXPECT_END(KERN_INFO, "---[ end trace <<int>> ]---"); in of_unittest_lifecycle()
3307 EXPECT_END(KERN_INFO, "refcount_t: underflow; use-after-free."); in of_unittest_lifecycle()
3309 EXPECT_END(KERN_INFO, "------------[ cut here ]------------"); in of_unittest_lifecycle()
3315 EXPECT_NOT_BEGIN(KERN_INFO, "------------[ cut here ]------------"); in of_unittest_lifecycle()
3317 EXPECT_NOT_BEGIN(KERN_INFO, "refcount_t: underflow; use-after-free."); in of_unittest_lifecycle()
3318 EXPECT_NOT_BEGIN(KERN_INFO, "---[ end trace <<int>> ]---"); in of_unittest_lifecycle()
3320 unittest(1, "/testcase-data/refcount-node is zero, second time"); in of_unittest_lifecycle()
3323 EXPECT_NOT_END(KERN_INFO, "---[ end trace <<int>> ]---"); in of_unittest_lifecycle()
3324 EXPECT_NOT_END(KERN_INFO, "refcount_t: underflow; use-after-free."); in of_unittest_lifecycle()
3326 EXPECT_NOT_END(KERN_INFO, "------------[ cut here ]------------"); in of_unittest_lifecycle()
3330 * attempt to of_node_get() node "refcount-node". One example of in of_unittest_lifecycle()
3335 * Prevent the stack trace by removing node "refcount-node" from in of_unittest_lifecycle()
3340 * Directly manipulate the child list of node /testcase-data to in of_unittest_lifecycle()
3341 * remove child refcount-node. This is ignoring all proper methods in of_unittest_lifecycle()
3342 * of removing a child and will leak a small amount of memory. in of_unittest_lifecycle()
3351 prev_sibling = np->child; in of_unittest_lifecycle()
3352 next_sibling = prev_sibling->sibling; in of_unittest_lifecycle()
3353 if (!strcmp(prev_sibling->full_name, "refcount-node")) { in of_unittest_lifecycle()
3354 np->child = next_sibling; in of_unittest_lifecycle()
3355 next_sibling = next_sibling->sibling; in of_unittest_lifecycle()
3358 if (!strcmp(next_sibling->full_name, "refcount-node")) in of_unittest_lifecycle()
3359 prev_sibling->sibling = next_sibling->sibling; in of_unittest_lifecycle()
3361 next_sibling = next_sibling->sibling; in of_unittest_lifecycle()
3437 OVERLAY_INFO(overlay_base, -9999, 0),
3454 OVERLAY_INFO(overlay_16, -EBUSY, 0),
3455 OVERLAY_INFO(overlay_17, -EEXIST, 0),
3466 OVERLAY_INFO(overlay_bad_add_dup_node, -EINVAL, -ENODEV),
3467 OVERLAY_INFO(overlay_bad_add_dup_prop, -EINVAL, -ENODEV),
3468 OVERLAY_INFO(overlay_bad_phandle, -EINVAL, 0),
3469 OVERLAY_INFO(overlay_bad_symbol, -EINVAL, -ENODEV),
3470 OVERLAY_INFO(overlay_bad_unresolved, -EINVAL, 0),
3511 for (info = overlays; info && info->name; info++) { in unittest_unflatten_overlay_base()
3512 if (!strcmp(overlay_name, info->name)) { in unittest_unflatten_overlay_base()
3524 if (info->expected_result != -9999) { in unittest_unflatten_overlay_base()
3529 data_size = info->dtbo_end - info->dtbo_begin; in unittest_unflatten_overlay_base()
3535 size = fdt_totalsize(info->dtbo_begin); in unittest_unflatten_overlay_base()
3547 memcpy(new_fdt, info->dtbo_begin, size); in unittest_unflatten_overlay_base()
3559 * /proc/device-tree/ contains the updated structure and values from
3572 for (info = overlays; info && info->name; info++) { in overlay_data_apply()
3573 if (!strcmp(overlay_name, info->name)) { in overlay_data_apply()
3583 size = info->dtbo_end - info->dtbo_begin; in overlay_data_apply()
3587 ret = of_overlay_fdt_apply(info->dtbo_begin, size, &info->ovcs_id, in overlay_data_apply()
3590 *ovcs_id = info->ovcs_id; in overlay_data_apply()
3597 if (ret != info->expected_result) { in overlay_data_apply()
3599 info->expected_result, ret, overlay_name); in overlay_data_apply()
3605 ret2 = of_overlay_remove(&info->ovcs_id); in overlay_data_apply()
3606 if (ret2 != info->expected_result_remove) { in overlay_data_apply()
3608 info->expected_result_remove, ret2, in overlay_data_apply()
3658 pprev = &overlay_base_root->child; in of_unittest_overlay_high_level()
3659 for (np = overlay_base_root->child; np; np = np->sibling) { in of_unittest_overlay_high_level()
3661 *pprev = np->sibling; in of_unittest_overlay_high_level()
3664 pprev = &np->sibling; in of_unittest_overlay_high_level()
3671 pprev = &overlay_base_root->child; in of_unittest_overlay_high_level()
3672 for (np = overlay_base_root->child; np; np = np->sibling) { in of_unittest_overlay_high_level()
3675 *pprev = np->sibling; in of_unittest_overlay_high_level()
3678 pprev = &np->sibling; in of_unittest_overlay_high_level()
3685 if (!strcmp(np->full_name, base_child->full_name)) { in of_unittest_overlay_high_level()
3703 for (np = overlay_base_root->child; np; np = np->sibling) in of_unittest_overlay_high_level()
3704 np->parent = of_root; in of_unittest_overlay_high_level()
3708 for (last_sibling = np = of_root->child; np; np = np->sibling) in of_unittest_overlay_high_level()
3712 last_sibling->sibling = overlay_base_root->child; in of_unittest_overlay_high_level()
3714 of_root->child = overlay_base_root->child; in of_unittest_overlay_high_level()
3726 prop->name); in of_unittest_overlay_high_level()
3730 kfree(new_prop->name); in of_unittest_overlay_high_level()
3731 kfree(new_prop->value); in of_unittest_overlay_high_level()
3733 /* "name" auto-generated by unflatten */ in of_unittest_overlay_high_level()
3734 if (!strcmp(prop->name, "name")) in of_unittest_overlay_high_level()
3737 prop->name); in of_unittest_overlay_high_level()
3742 prop->name); in of_unittest_overlay_high_level()
3753 /* --- overlay --- */ in of_unittest_overlay_high_level()
3756 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/subst… in of_unittest_overlay_high_level()
3758 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairw… in of_unittest_overlay_high_level()
3760 …: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway- in of_unittest_overlay_high_level()
3762 …: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway- in of_unittest_overlay_high_level()
3764 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/light… in of_unittest_overlay_high_level()
3766 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/light… in of_unittest_overlay_high_level()
3768 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/light… in of_unittest_overlay_high_level()
3770 … "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/hvac_2"); in of_unittest_overlay_high_level()
3772 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200"… in of_unittest_overlay_high_level()
3774 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_… in of_unittest_overlay_high_level()
3776 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_… in of_unittest_overlay_high_level()
3781 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_… in of_unittest_overlay_high_level()
3783 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_… in of_unittest_overlay_high_level()
3785 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200"… in of_unittest_overlay_high_level()
3787 … "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/hvac_2"); in of_unittest_overlay_high_level()
3789 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/light… in of_unittest_overlay_high_level()
3791 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/light… in of_unittest_overlay_high_level()
3793 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/light… in of_unittest_overlay_high_level()
3795 …: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway- in of_unittest_overlay_high_level()
3797 …: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway- in of_unittest_overlay_high_level()
3799 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairw… in of_unittest_overlay_high_level()
3801 …"OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/subst… in of_unittest_overlay_high_level()
3805 /* --- overlay_bad_add_dup_node --- */ in of_unittest_overlay_high_level()
3808 …ay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/contr… in of_unittest_overlay_high_level()
3810 …ltiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/contr… in of_unittest_overlay_high_level()
3812 …"OF: changeset: apply failed: REMOVE_PROPERTY /testcase-data-2/substation@100/motor-1/controller:n… in of_unittest_overlay_high_level()
3814 "OF: Error reverting changeset (-19)"); in of_unittest_overlay_high_level()
3820 "OF: Error reverting changeset (-19)"); in of_unittest_overlay_high_level()
3822 …"OF: changeset: apply failed: REMOVE_PROPERTY /testcase-data-2/substation@100/motor-1/controller:n… in of_unittest_overlay_high_level()
3824 …ltiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/contr… in of_unittest_overlay_high_level()
3826 …ay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/contr… in of_unittest_overlay_high_level()
3828 /* --- overlay_bad_add_dup_prop --- */ in of_unittest_overlay_high_level()
3831 …ay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/elect… in of_unittest_overlay_high_level()
3833 …ltiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/elect… in of_unittest_overlay_high_level()
3835 …ltiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/elect… in of_unittest_overlay_high_level()
3837 …"OF: changeset: apply failed: REMOVE_PROPERTY /testcase-data-2/substation@100/motor-1/electric:nam… in of_unittest_overlay_high_level()
3839 "OF: Error reverting changeset (-19)"); in of_unittest_overlay_high_level()
3845 "OF: Error reverting changeset (-19)"); in of_unittest_overlay_high_level()
3847 …"OF: changeset: apply failed: REMOVE_PROPERTY /testcase-data-2/substation@100/motor-1/electric:nam… in of_unittest_overlay_high_level()
3849 …ltiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/elect… in of_unittest_overlay_high_level()
3851 …ltiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/elect… in of_unittest_overlay_high_level()
3853 …ay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/elect… in of_unittest_overlay_high_level()
3855 /* --- overlay_bad_phandle --- */ in of_unittest_overlay_high_level()
3860 /* --- overlay_bad_symbol --- */ in of_unittest_overlay_high_level()
3863 …"OF: changeset: apply failed: REMOVE_PROPERTY /testcase-data-2/substation@100/hvac-medium-2:name"); in of_unittest_overlay_high_level()
3865 "OF: Error reverting changeset (-19)"); in of_unittest_overlay_high_level()
3871 "OF: Error reverting changeset (-19)"); in of_unittest_overlay_high_level()
3873 …"OF: changeset: apply failed: REMOVE_PROPERTY /testcase-data-2/substation@100/hvac-medium-2:name"); in of_unittest_overlay_high_level()
3875 /* --- overlay_bad_unresolved --- */ in of_unittest_overlay_high_level()
3880 "OF: resolver: overlay phandle fixup failed: -22"); in of_unittest_overlay_high_level()
3886 "OF: resolver: overlay phandle fixup failed: -22"); in of_unittest_overlay_high_level()
3914 dn = pdev->dev.of_node; in testdrv_probe()
3916 dev_err(&pdev->dev, "does not find bus endpoint"); in testdrv_probe()
3917 return -EINVAL; in testdrv_probe()
3920 for (info = overlays; info && info->name; info++) { in testdrv_probe()
3921 if (!strcmp(info->name, "overlay_pci_node")) in testdrv_probe()
3924 if (!info || !info->name) { in testdrv_probe()
3925 dev_err(&pdev->dev, "no overlay data for overlay_pci_node"); in testdrv_probe()
3926 return -ENODEV; in testdrv_probe()
3929 size = info->dtbo_end - info->dtbo_begin; in testdrv_probe()
3930 ret = of_overlay_fdt_apply(info->dtbo_begin, size, &ovcs_id, dn); in testdrv_probe()
3935 of_platform_default_populate(dn, NULL, &pdev->dev); in testdrv_probe()
3945 of_platform_depopulate(&pdev->dev); in testdrv_remove()
3964 return -ENODEV; in unittest_pci_probe()
3966 dev = &pdev->dev; in unittest_pci_probe()
3968 dev = dev->parent; in unittest_pci_probe()
3971 return -ENODEV; in unittest_pci_probe()
3975 unittest(res->start == exp_addr, "Incorrect translated address %llx, expected %llx\n", in unittest_pci_probe()
3976 (u64)res->start, exp_addr); in unittest_pci_probe()
3984 { .compatible = "unittest-pci" },
3991 .name = "unittest-pci",
4004 pnp = pdev->dev.of_node; in of_unittest_pci_node_verify()
4007 return -ENODEV; in of_unittest_pci_node_verify()
4010 path = kasprintf(GFP_KERNEL, "%pOF/pci-ep-bus@0/unittest-pci@100", pnp); in of_unittest_pci_node_verify()
4012 unittest(np, "Failed to get unittest-pci node under PCI node\n"); in of_unittest_pci_node_verify()
4014 rc = -ENODEV; in of_unittest_pci_node_verify()
4021 rc = -ENODEV; in of_unittest_pci_node_verify()
4023 path = kasprintf(GFP_KERNEL, "%pOF/pci-ep-bus@0", pnp); in of_unittest_pci_node_verify()
4026 child_dev = device_find_any_child(&pdev->dev); in of_unittest_pci_node_verify()
4065 "No test PCI device been found. Please run QEMU with '-device pci-testdev'\n"); in of_unittest_pci_node()
4090 pr_info("start of unittest - you will see error messages\n"); in of_unittest()
4106 np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); in of_unittest()
4143 pr_info("end of unittest - %i passed, %i failed\n", in of_unittest()