diff options
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/Kconfig | 3 | ||||
-rw-r--r-- | drivers/of/address.c | 11 | ||||
-rw-r--r-- | drivers/of/base.c | 18 | ||||
-rw-r--r-- | drivers/of/irq.c | 10 | ||||
-rw-r--r-- | drivers/of/overlay.c | 3 | ||||
-rw-r--r-- | drivers/of/unittest.c | 33 |
6 files changed, 52 insertions, 26 deletions
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 38d1c51f58b1..7bcaeec876c0 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig | |||
@@ -84,8 +84,7 @@ config OF_RESOLVE | |||
84 | bool | 84 | bool |
85 | 85 | ||
86 | config OF_OVERLAY | 86 | config OF_OVERLAY |
87 | bool | 87 | bool "Device Tree overlays" |
88 | depends on OF | ||
89 | select OF_DYNAMIC | 88 | select OF_DYNAMIC |
90 | select OF_RESOLVE | 89 | select OF_RESOLVE |
91 | 90 | ||
diff --git a/drivers/of/address.c b/drivers/of/address.c index ad2906919d45..78a7dcbec7d8 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c | |||
@@ -450,12 +450,17 @@ static struct of_bus *of_match_bus(struct device_node *np) | |||
450 | return NULL; | 450 | return NULL; |
451 | } | 451 | } |
452 | 452 | ||
453 | static int of_empty_ranges_quirk(void) | 453 | static int of_empty_ranges_quirk(struct device_node *np) |
454 | { | 454 | { |
455 | if (IS_ENABLED(CONFIG_PPC)) { | 455 | if (IS_ENABLED(CONFIG_PPC)) { |
456 | /* To save cycles, we cache the result */ | 456 | /* To save cycles, we cache the result for global "Mac" setting */ |
457 | static int quirk_state = -1; | 457 | static int quirk_state = -1; |
458 | 458 | ||
459 | /* PA-SEMI sdc DT bug */ | ||
460 | if (of_device_is_compatible(np, "1682m-sdc")) | ||
461 | return true; | ||
462 | |||
463 | /* Make quirk cached */ | ||
459 | if (quirk_state < 0) | 464 | if (quirk_state < 0) |
460 | quirk_state = | 465 | quirk_state = |
461 | of_machine_is_compatible("Power Macintosh") || | 466 | of_machine_is_compatible("Power Macintosh") || |
@@ -490,7 +495,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, | |||
490 | * This code is only enabled on powerpc. --gcl | 495 | * This code is only enabled on powerpc. --gcl |
491 | */ | 496 | */ |
492 | ranges = of_get_property(parent, rprop, &rlen); | 497 | ranges = of_get_property(parent, rprop, &rlen); |
493 | if (ranges == NULL && !of_empty_ranges_quirk()) { | 498 | if (ranges == NULL && !of_empty_ranges_quirk(parent)) { |
494 | pr_debug("OF: no ranges; cannot translate\n"); | 499 | pr_debug("OF: no ranges; cannot translate\n"); |
495 | return 1; | 500 | return 1; |
496 | } | 501 | } |
diff --git a/drivers/of/base.c b/drivers/of/base.c index 0a8aeb8523fe..8f165b112e03 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -714,16 +714,12 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent, | |||
714 | const char *path) | 714 | const char *path) |
715 | { | 715 | { |
716 | struct device_node *child; | 716 | struct device_node *child; |
717 | int len = strchrnul(path, '/') - path; | 717 | int len; |
718 | int term; | ||
719 | 718 | ||
719 | len = strcspn(path, "/:"); | ||
720 | if (!len) | 720 | if (!len) |
721 | return NULL; | 721 | return NULL; |
722 | 722 | ||
723 | term = strchrnul(path, ':') - path; | ||
724 | if (term < len) | ||
725 | len = term; | ||
726 | |||
727 | __for_each_child_of_node(parent, child) { | 723 | __for_each_child_of_node(parent, child) { |
728 | const char *name = strrchr(child->full_name, '/'); | 724 | const char *name = strrchr(child->full_name, '/'); |
729 | if (WARN(!name, "malformed device_node %s\n", child->full_name)) | 725 | if (WARN(!name, "malformed device_node %s\n", child->full_name)) |
@@ -768,8 +764,12 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt | |||
768 | 764 | ||
769 | /* The path could begin with an alias */ | 765 | /* The path could begin with an alias */ |
770 | if (*path != '/') { | 766 | if (*path != '/') { |
771 | char *p = strchrnul(path, '/'); | 767 | int len; |
772 | int len = separator ? separator - path : p - path; | 768 | const char *p = separator; |
769 | |||
770 | if (!p) | ||
771 | p = strchrnul(path, '/'); | ||
772 | len = p - path; | ||
773 | 773 | ||
774 | /* of_aliases must not be NULL */ | 774 | /* of_aliases must not be NULL */ |
775 | if (!of_aliases) | 775 | if (!of_aliases) |
@@ -794,6 +794,8 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt | |||
794 | path++; /* Increment past '/' delimiter */ | 794 | path++; /* Increment past '/' delimiter */ |
795 | np = __of_find_node_by_path(np, path); | 795 | np = __of_find_node_by_path(np, path); |
796 | path = strchrnul(path, '/'); | 796 | path = strchrnul(path, '/'); |
797 | if (separator && separator < path) | ||
798 | break; | ||
797 | } | 799 | } |
798 | raw_spin_unlock_irqrestore(&devtree_lock, flags); | 800 | raw_spin_unlock_irqrestore(&devtree_lock, flags); |
799 | return np; | 801 | return np; |
diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 0d7765807f49..1a7980692f25 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c | |||
@@ -290,7 +290,7 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar | |||
290 | struct device_node *p; | 290 | struct device_node *p; |
291 | const __be32 *intspec, *tmp, *addr; | 291 | const __be32 *intspec, *tmp, *addr; |
292 | u32 intsize, intlen; | 292 | u32 intsize, intlen; |
293 | int i, res = -EINVAL; | 293 | int i, res; |
294 | 294 | ||
295 | pr_debug("of_irq_parse_one: dev=%s, index=%d\n", of_node_full_name(device), index); | 295 | pr_debug("of_irq_parse_one: dev=%s, index=%d\n", of_node_full_name(device), index); |
296 | 296 | ||
@@ -323,15 +323,19 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar | |||
323 | 323 | ||
324 | /* Get size of interrupt specifier */ | 324 | /* Get size of interrupt specifier */ |
325 | tmp = of_get_property(p, "#interrupt-cells", NULL); | 325 | tmp = of_get_property(p, "#interrupt-cells", NULL); |
326 | if (tmp == NULL) | 326 | if (tmp == NULL) { |
327 | res = -EINVAL; | ||
327 | goto out; | 328 | goto out; |
329 | } | ||
328 | intsize = be32_to_cpu(*tmp); | 330 | intsize = be32_to_cpu(*tmp); |
329 | 331 | ||
330 | pr_debug(" intsize=%d intlen=%d\n", intsize, intlen); | 332 | pr_debug(" intsize=%d intlen=%d\n", intsize, intlen); |
331 | 333 | ||
332 | /* Check index */ | 334 | /* Check index */ |
333 | if ((index + 1) * intsize > intlen) | 335 | if ((index + 1) * intsize > intlen) { |
336 | res = -EINVAL; | ||
334 | goto out; | 337 | goto out; |
338 | } | ||
335 | 339 | ||
336 | /* Copy intspec into irq structure */ | 340 | /* Copy intspec into irq structure */ |
337 | intspec += index * intsize; | 341 | intspec += index * intsize; |
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 352b4f28f82c..dee9270ba547 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/idr.h> | ||
22 | 23 | ||
23 | #include "of_private.h" | 24 | #include "of_private.h" |
24 | 25 | ||
@@ -85,7 +86,7 @@ static int of_overlay_apply_single_device_node(struct of_overlay *ov, | |||
85 | struct device_node *target, struct device_node *child) | 86 | struct device_node *target, struct device_node *child) |
86 | { | 87 | { |
87 | const char *cname; | 88 | const char *cname; |
88 | struct device_node *tchild, *grandchild; | 89 | struct device_node *tchild; |
89 | int ret = 0; | 90 | int ret = 0; |
90 | 91 | ||
91 | cname = kbasename(child->full_name); | 92 | cname = kbasename(child->full_name); |
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 0cf9a236d438..52c45c7df07f 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c | |||
@@ -92,6 +92,16 @@ static void __init of_selftest_find_node_by_name(void) | |||
92 | "option path test failed\n"); | 92 | "option path test failed\n"); |
93 | of_node_put(np); | 93 | of_node_put(np); |
94 | 94 | ||
95 | np = of_find_node_opts_by_path("/testcase-data:test/option", &options); | ||
96 | selftest(np && !strcmp("test/option", options), | ||
97 | "option path test, subcase #1 failed\n"); | ||
98 | of_node_put(np); | ||
99 | |||
100 | np = of_find_node_opts_by_path("/testcase-data/testcase-device1:test/option", &options); | ||
101 | selftest(np && !strcmp("test/option", options), | ||
102 | "option path test, subcase #2 failed\n"); | ||
103 | of_node_put(np); | ||
104 | |||
95 | np = of_find_node_opts_by_path("/testcase-data:testoption", NULL); | 105 | np = of_find_node_opts_by_path("/testcase-data:testoption", NULL); |
96 | selftest(np, "NULL option path test failed\n"); | 106 | selftest(np, "NULL option path test failed\n"); |
97 | of_node_put(np); | 107 | of_node_put(np); |
@@ -102,6 +112,12 @@ static void __init of_selftest_find_node_by_name(void) | |||
102 | "option alias path test failed\n"); | 112 | "option alias path test failed\n"); |
103 | of_node_put(np); | 113 | of_node_put(np); |
104 | 114 | ||
115 | np = of_find_node_opts_by_path("testcase-alias:test/alias/option", | ||
116 | &options); | ||
117 | selftest(np && !strcmp("test/alias/option", options), | ||
118 | "option alias path test, subcase #1 failed\n"); | ||
119 | of_node_put(np); | ||
120 | |||
105 | np = of_find_node_opts_by_path("testcase-alias:testaliasoption", NULL); | 121 | np = of_find_node_opts_by_path("testcase-alias:testaliasoption", NULL); |
106 | selftest(np, "NULL option alias path test failed\n"); | 122 | selftest(np, "NULL option alias path test failed\n"); |
107 | of_node_put(np); | 123 | of_node_put(np); |
@@ -378,9 +394,9 @@ static void __init of_selftest_property_string(void) | |||
378 | rc = of_property_match_string(np, "phandle-list-names", "first"); | 394 | rc = of_property_match_string(np, "phandle-list-names", "first"); |
379 | selftest(rc == 0, "first expected:0 got:%i\n", rc); | 395 | selftest(rc == 0, "first expected:0 got:%i\n", rc); |
380 | rc = of_property_match_string(np, "phandle-list-names", "second"); | 396 | rc = of_property_match_string(np, "phandle-list-names", "second"); |
381 | selftest(rc == 1, "second expected:0 got:%i\n", rc); | 397 | selftest(rc == 1, "second expected:1 got:%i\n", rc); |
382 | rc = of_property_match_string(np, "phandle-list-names", "third"); | 398 | rc = of_property_match_string(np, "phandle-list-names", "third"); |
383 | selftest(rc == 2, "third expected:0 got:%i\n", rc); | 399 | selftest(rc == 2, "third expected:2 got:%i\n", rc); |
384 | rc = of_property_match_string(np, "phandle-list-names", "fourth"); | 400 | rc = of_property_match_string(np, "phandle-list-names", "fourth"); |
385 | selftest(rc == -ENODATA, "unmatched string; rc=%i\n", rc); | 401 | selftest(rc == -ENODATA, "unmatched string; rc=%i\n", rc); |
386 | rc = of_property_match_string(np, "missing-property", "blah"); | 402 | rc = of_property_match_string(np, "missing-property", "blah"); |
@@ -478,7 +494,6 @@ static void __init of_selftest_changeset(void) | |||
478 | struct device_node *n1, *n2, *n21, *nremove, *parent, *np; | 494 | struct device_node *n1, *n2, *n21, *nremove, *parent, *np; |
479 | struct of_changeset chgset; | 495 | struct of_changeset chgset; |
480 | 496 | ||
481 | of_changeset_init(&chgset); | ||
482 | n1 = __of_node_dup(NULL, "/testcase-data/changeset/n1"); | 497 | n1 = __of_node_dup(NULL, "/testcase-data/changeset/n1"); |
483 | selftest(n1, "testcase setup failure\n"); | 498 | selftest(n1, "testcase setup failure\n"); |
484 | n2 = __of_node_dup(NULL, "/testcase-data/changeset/n2"); | 499 | n2 = __of_node_dup(NULL, "/testcase-data/changeset/n2"); |
@@ -979,7 +994,7 @@ static int of_path_platform_device_exists(const char *path) | |||
979 | return pdev != NULL; | 994 | return pdev != NULL; |
980 | } | 995 | } |
981 | 996 | ||
982 | #if IS_ENABLED(CONFIG_I2C) | 997 | #if IS_BUILTIN(CONFIG_I2C) |
983 | 998 | ||
984 | /* get the i2c client device instantiated at the path */ | 999 | /* get the i2c client device instantiated at the path */ |
985 | static struct i2c_client *of_path_to_i2c_client(const char *path) | 1000 | static struct i2c_client *of_path_to_i2c_client(const char *path) |
@@ -1445,7 +1460,7 @@ static void of_selftest_overlay_11(void) | |||
1445 | return; | 1460 | return; |
1446 | } | 1461 | } |
1447 | 1462 | ||
1448 | #if IS_ENABLED(CONFIG_I2C) && IS_ENABLED(CONFIG_OF_OVERLAY) | 1463 | #if IS_BUILTIN(CONFIG_I2C) && IS_ENABLED(CONFIG_OF_OVERLAY) |
1449 | 1464 | ||
1450 | struct selftest_i2c_bus_data { | 1465 | struct selftest_i2c_bus_data { |
1451 | struct platform_device *pdev; | 1466 | struct platform_device *pdev; |
@@ -1584,7 +1599,7 @@ static struct i2c_driver selftest_i2c_dev_driver = { | |||
1584 | .id_table = selftest_i2c_dev_id, | 1599 | .id_table = selftest_i2c_dev_id, |
1585 | }; | 1600 | }; |
1586 | 1601 | ||
1587 | #if IS_ENABLED(CONFIG_I2C_MUX) | 1602 | #if IS_BUILTIN(CONFIG_I2C_MUX) |
1588 | 1603 | ||
1589 | struct selftest_i2c_mux_data { | 1604 | struct selftest_i2c_mux_data { |
1590 | int nchans; | 1605 | int nchans; |
@@ -1695,7 +1710,7 @@ static int of_selftest_overlay_i2c_init(void) | |||
1695 | "could not register selftest i2c bus driver\n")) | 1710 | "could not register selftest i2c bus driver\n")) |
1696 | return ret; | 1711 | return ret; |
1697 | 1712 | ||
1698 | #if IS_ENABLED(CONFIG_I2C_MUX) | 1713 | #if IS_BUILTIN(CONFIG_I2C_MUX) |
1699 | ret = i2c_add_driver(&selftest_i2c_mux_driver); | 1714 | ret = i2c_add_driver(&selftest_i2c_mux_driver); |
1700 | if (selftest(ret == 0, | 1715 | if (selftest(ret == 0, |
1701 | "could not register selftest i2c mux driver\n")) | 1716 | "could not register selftest i2c mux driver\n")) |
@@ -1707,7 +1722,7 @@ static int of_selftest_overlay_i2c_init(void) | |||
1707 | 1722 | ||
1708 | static void of_selftest_overlay_i2c_cleanup(void) | 1723 | static void of_selftest_overlay_i2c_cleanup(void) |
1709 | { | 1724 | { |
1710 | #if IS_ENABLED(CONFIG_I2C_MUX) | 1725 | #if IS_BUILTIN(CONFIG_I2C_MUX) |
1711 | i2c_del_driver(&selftest_i2c_mux_driver); | 1726 | i2c_del_driver(&selftest_i2c_mux_driver); |
1712 | #endif | 1727 | #endif |
1713 | platform_driver_unregister(&selftest_i2c_bus_driver); | 1728 | platform_driver_unregister(&selftest_i2c_bus_driver); |
@@ -1814,7 +1829,7 @@ static void __init of_selftest_overlay(void) | |||
1814 | of_selftest_overlay_10(); | 1829 | of_selftest_overlay_10(); |
1815 | of_selftest_overlay_11(); | 1830 | of_selftest_overlay_11(); |
1816 | 1831 | ||
1817 | #if IS_ENABLED(CONFIG_I2C) | 1832 | #if IS_BUILTIN(CONFIG_I2C) |
1818 | if (selftest(of_selftest_overlay_i2c_init() == 0, "i2c init failed\n")) | 1833 | if (selftest(of_selftest_overlay_i2c_init() == 0, "i2c init failed\n")) |
1819 | goto out; | 1834 | goto out; |
1820 | 1835 | ||