aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/arm/omap/omap.txt6
-rw-r--r--arch/arm/boot/dts/testcases/tests-phandle.dtsi2
-rw-r--r--arch/powerpc/kernel/ibmebus.c2
-rw-r--r--arch/powerpc/platforms/8xx/Kconfig1
-rw-r--r--arch/powerpc/platforms/iseries/Kconfig1
-rw-r--r--arch/powerpc/platforms/pseries/Kconfig1
-rw-r--r--arch/powerpc/platforms/wsp/Kconfig1
-rw-r--r--drivers/base/core.c5
-rw-r--r--drivers/base/platform.c2
-rw-r--r--drivers/macintosh/macio_asic.c2
-rw-r--r--drivers/of/Kconfig5
-rw-r--r--drivers/of/base.c40
-rw-r--r--drivers/of/device.c30
-rw-r--r--drivers/of/selftest.c29
-rw-r--r--include/linux/of.h17
-rw-r--r--include/linux/of_device.h8
16 files changed, 121 insertions, 31 deletions
diff --git a/Documentation/devicetree/bindings/arm/omap/omap.txt b/Documentation/devicetree/bindings/arm/omap/omap.txt
index edc618a8aab2..e78e8bccac30 100644
--- a/Documentation/devicetree/bindings/arm/omap/omap.txt
+++ b/Documentation/devicetree/bindings/arm/omap/omap.txt
@@ -41,3 +41,9 @@ Boards:
41 41
42- OMAP4 PandaBoard : Low cost community board 42- OMAP4 PandaBoard : Low cost community board
43 compatible = "ti,omap4-panda", "ti,omap4430" 43 compatible = "ti,omap4-panda", "ti,omap4430"
44
45- OMAP3 EVM : Software Developement Board for OMAP35x, AM/DM37x
46 compatible = "ti,omap3-evm", "ti,omap3"
47
48- AM335X EVM : Software Developement Board for AM335x
49 compatible = "ti,am335x-evm", "ti,am33xx", "ti,omap3"
diff --git a/arch/arm/boot/dts/testcases/tests-phandle.dtsi b/arch/arm/boot/dts/testcases/tests-phandle.dtsi
index ec0c4e6212c9..0007d3cd7dc2 100644
--- a/arch/arm/boot/dts/testcases/tests-phandle.dtsi
+++ b/arch/arm/boot/dts/testcases/tests-phandle.dtsi
@@ -31,6 +31,8 @@
31 phandle-list-bad-phandle = <12345678 0 0>; 31 phandle-list-bad-phandle = <12345678 0 0>;
32 phandle-list-bad-args = <&provider2 1 0>, 32 phandle-list-bad-args = <&provider2 1 0>,
33 <&provider3 0>; 33 <&provider3 0>;
34 empty-property;
35 unterminated-string = [40 41 42 43];
34 }; 36 };
35 }; 37 };
36 }; 38 };
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index d39ae606ff8d..79bb282e6501 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -713,7 +713,7 @@ static struct dev_pm_ops ibmebus_bus_dev_pm_ops = {
713 713
714struct bus_type ibmebus_bus_type = { 714struct bus_type ibmebus_bus_type = {
715 .name = "ibmebus", 715 .name = "ibmebus",
716 .uevent = of_device_uevent, 716 .uevent = of_device_uevent_modalias,
717 .bus_attrs = ibmebus_bus_attrs, 717 .bus_attrs = ibmebus_bus_attrs,
718 .match = ibmebus_bus_bus_match, 718 .match = ibmebus_bus_bus_match,
719 .probe = ibmebus_bus_device_probe, 719 .probe = ibmebus_bus_device_probe,
diff --git a/arch/powerpc/platforms/8xx/Kconfig b/arch/powerpc/platforms/8xx/Kconfig
index ee56a9ea6a79..1fb0b3cddeb3 100644
--- a/arch/powerpc/platforms/8xx/Kconfig
+++ b/arch/powerpc/platforms/8xx/Kconfig
@@ -26,6 +26,7 @@ config MPC86XADS
26config MPC885ADS 26config MPC885ADS
27 bool "MPC885ADS" 27 bool "MPC885ADS"
28 select CPM1 28 select CPM1
29 select OF_DYNAMIC
29 help 30 help
30 Freescale Semiconductor MPC885 Application Development System (ADS). 31 Freescale Semiconductor MPC885 Application Development System (ADS).
31 Also known as DUET. 32 Also known as DUET.
diff --git a/arch/powerpc/platforms/iseries/Kconfig b/arch/powerpc/platforms/iseries/Kconfig
index b57cda3a0817..63835e09e5cc 100644
--- a/arch/powerpc/platforms/iseries/Kconfig
+++ b/arch/powerpc/platforms/iseries/Kconfig
@@ -1,6 +1,7 @@
1config PPC_ISERIES 1config PPC_ISERIES
2 bool "IBM Legacy iSeries" 2 bool "IBM Legacy iSeries"
3 depends on PPC64 && PPC_BOOK3S 3 depends on PPC64 && PPC_BOOK3S
4 select OF_DYNAMIC
4 select PPC_SMP_MUXED_IPI 5 select PPC_SMP_MUXED_IPI
5 select PPC_INDIRECT_PIO 6 select PPC_INDIRECT_PIO
6 select PPC_INDIRECT_MMIO 7 select PPC_INDIRECT_MMIO
diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig
index 31f22c1f657d..f2556257bbdc 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -3,6 +3,7 @@ config PPC_PSERIES
3 bool "IBM pSeries & new (POWER5-based) iSeries" 3 bool "IBM pSeries & new (POWER5-based) iSeries"
4 select HAVE_PCSPKR_PLATFORM 4 select HAVE_PCSPKR_PLATFORM
5 select MPIC 5 select MPIC
6 select OF_DYNAMIC
6 select PCI_MSI 7 select PCI_MSI
7 select PPC_XICS 8 select PPC_XICS
8 select PPC_ICP_NATIVE 9 select PPC_ICP_NATIVE
diff --git a/arch/powerpc/platforms/wsp/Kconfig b/arch/powerpc/platforms/wsp/Kconfig
index 57d22a2f4ba9..79d2225b7608 100644
--- a/arch/powerpc/platforms/wsp/Kconfig
+++ b/arch/powerpc/platforms/wsp/Kconfig
@@ -25,6 +25,7 @@ config PPC_CHROMA
25 bool "PowerEN PCIe Chroma Card" 25 bool "PowerEN PCIe Chroma Card"
26 select EPAPR_BOOT 26 select EPAPR_BOOT
27 select PPC_WSP 27 select PPC_WSP
28 select OF_DYNAMIC
28 default y 29 default y
29 30
30endmenu 31endmenu
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 7050a75dde38..e28ce9898af4 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -18,6 +18,8 @@
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/kdev_t.h> 19#include <linux/kdev_t.h>
20#include <linux/notifier.h> 20#include <linux/notifier.h>
21#include <linux/of.h>
22#include <linux/of_device.h>
21#include <linux/genhd.h> 23#include <linux/genhd.h>
22#include <linux/kallsyms.h> 24#include <linux/kallsyms.h>
23#include <linux/mutex.h> 25#include <linux/mutex.h>
@@ -267,6 +269,9 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
267 if (dev->driver) 269 if (dev->driver)
268 add_uevent_var(env, "DRIVER=%s", dev->driver->name); 270 add_uevent_var(env, "DRIVER=%s", dev->driver->name);
269 271
272 /* Add common DT information about the device */
273 of_device_uevent(dev, env);
274
270 /* have the bus specific function add its stuff */ 275 /* have the bus specific function add its stuff */
271 if (dev->bus && dev->bus->uevent) { 276 if (dev->bus && dev->bus->uevent) {
272 retval = dev->bus->uevent(dev, env); 277 retval = dev->bus->uevent(dev, env);
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f0c605e99ade..a1a722502587 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -621,7 +621,7 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env)
621 int rc; 621 int rc;
622 622
623 /* Some devices have extra OF data and an OF-style MODALIAS */ 623 /* Some devices have extra OF data and an OF-style MODALIAS */
624 rc = of_device_uevent(dev,env); 624 rc = of_device_uevent_modalias(dev,env);
625 if (rc != -ENODEV) 625 if (rc != -ENODEV)
626 return rc; 626 return rc;
627 627
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index 4daf9e5a7736..20e5c2cda430 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -137,7 +137,7 @@ extern struct device_attribute macio_dev_attrs[];
137struct bus_type macio_bus_type = { 137struct bus_type macio_bus_type = {
138 .name = "macio", 138 .name = "macio",
139 .match = macio_bus_match, 139 .match = macio_bus_match,
140 .uevent = of_device_uevent, 140 .uevent = of_device_uevent_modalias,
141 .probe = macio_device_probe, 141 .probe = macio_device_probe,
142 .remove = macio_device_remove, 142 .remove = macio_device_remove,
143 .shutdown = macio_device_shutdown, 143 .shutdown = macio_device_shutdown,
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 268163dd71c7..6ea51dcbc728 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -35,9 +35,10 @@ config OF_EARLY_FLATTREE
35config OF_PROMTREE 35config OF_PROMTREE
36 bool 36 bool
37 37
38# Hardly any platforms need this. It is safe to select, but only do so if you
39# need it.
38config OF_DYNAMIC 40config OF_DYNAMIC
39 def_bool y 41 bool
40 depends on PPC_OF
41 42
42config OF_ADDRESS 43config OF_ADDRESS
43 def_bool y 44 def_bool y
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 133908a6fd8d..580644986945 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -88,7 +88,7 @@ int of_n_size_cells(struct device_node *np)
88} 88}
89EXPORT_SYMBOL(of_n_size_cells); 89EXPORT_SYMBOL(of_n_size_cells);
90 90
91#if !defined(CONFIG_SPARC) /* SPARC doesn't do ref counting (yet) */ 91#if defined(CONFIG_OF_DYNAMIC)
92/** 92/**
93 * of_node_get - Increment refcount of a node 93 * of_node_get - Increment refcount of a node
94 * @node: Node to inc refcount, NULL is supported to 94 * @node: Node to inc refcount, NULL is supported to
@@ -161,7 +161,7 @@ void of_node_put(struct device_node *node)
161 kref_put(&node->kref, of_node_release); 161 kref_put(&node->kref, of_node_release);
162} 162}
163EXPORT_SYMBOL(of_node_put); 163EXPORT_SYMBOL(of_node_put);
164#endif /* !CONFIG_SPARC */ 164#endif /* CONFIG_OF_DYNAMIC */
165 165
166struct property *of_find_property(const struct device_node *np, 166struct property *of_find_property(const struct device_node *np,
167 const char *name, 167 const char *name,
@@ -761,6 +761,42 @@ int of_property_read_string_index(struct device_node *np, const char *propname,
761} 761}
762EXPORT_SYMBOL_GPL(of_property_read_string_index); 762EXPORT_SYMBOL_GPL(of_property_read_string_index);
763 763
764/**
765 * of_property_match_string() - Find string in a list and return index
766 * @np: pointer to node containing string list property
767 * @propname: string list property name
768 * @string: pointer to string to search for in string list
769 *
770 * This function searches a string list property and returns the index
771 * of a specific string value.
772 */
773int of_property_match_string(struct device_node *np, const char *propname,
774 const char *string)
775{
776 struct property *prop = of_find_property(np, propname, NULL);
777 size_t l;
778 int i;
779 const char *p, *end;
780
781 if (!prop)
782 return -EINVAL;
783 if (!prop->value)
784 return -ENODATA;
785
786 p = prop->value;
787 end = p + prop->length;
788
789 for (i = 0; p < end; i++, p += l) {
790 l = strlen(p) + 1;
791 if (p + l > end)
792 return -EILSEQ;
793 pr_debug("comparing %s with %s\n", string, p);
794 if (strcmp(string, p) == 0)
795 return i; /* Found it; return index */
796 }
797 return -ENODATA;
798}
799EXPORT_SYMBOL_GPL(of_property_match_string);
764 800
765/** 801/**
766 * of_property_count_strings - Find and return the number of strings from a 802 * of_property_count_strings - Find and return the number of strings from a
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 62b4b32ac887..4c74e4fc5a51 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -128,39 +128,41 @@ ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
128/** 128/**
129 * of_device_uevent - Display OF related uevent information 129 * of_device_uevent - Display OF related uevent information
130 */ 130 */
131int of_device_uevent(struct device *dev, struct kobj_uevent_env *env) 131void of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
132{ 132{
133 const char *compat; 133 const char *compat;
134 int seen = 0, cplen, sl; 134 int seen = 0, cplen, sl;
135 135
136 if ((!dev) || (!dev->of_node)) 136 if ((!dev) || (!dev->of_node))
137 return -ENODEV; 137 return;
138
139 if (add_uevent_var(env, "OF_NAME=%s", dev->of_node->name))
140 return -ENOMEM;
141 138
142 if (add_uevent_var(env, "OF_TYPE=%s", dev->of_node->type)) 139 add_uevent_var(env, "OF_NAME=%s", dev->of_node->name);
143 return -ENOMEM; 140 add_uevent_var(env, "OF_FULLNAME=%s", dev->of_node->full_name);
141 if (dev->of_node->type && strcmp("<NULL>", dev->of_node->type) != 0)
142 add_uevent_var(env, "OF_TYPE=%s", dev->of_node->type);
144 143
145 /* Since the compatible field can contain pretty much anything 144 /* Since the compatible field can contain pretty much anything
146 * it's not really legal to split it out with commas. We split it 145 * it's not really legal to split it out with commas. We split it
147 * up using a number of environment variables instead. */ 146 * up using a number of environment variables instead. */
148
149 compat = of_get_property(dev->of_node, "compatible", &cplen); 147 compat = of_get_property(dev->of_node, "compatible", &cplen);
150 while (compat && *compat && cplen > 0) { 148 while (compat && *compat && cplen > 0) {
151 if (add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat)) 149 add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat);
152 return -ENOMEM;
153
154 sl = strlen(compat) + 1; 150 sl = strlen(compat) + 1;
155 compat += sl; 151 compat += sl;
156 cplen -= sl; 152 cplen -= sl;
157 seen++; 153 seen++;
158 } 154 }
155 add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen);
156}
159 157
160 if (add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen)) 158int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
161 return -ENOMEM; 159{
160 int sl;
161
162 if ((!dev) || (!dev->of_node))
163 return -ENODEV;
162 164
163 /* modalias is trickier, we add it in 2 steps */ 165 /* Devicetree modalias is tricky, we add it in 2 steps */
164 if (add_uevent_var(env, "MODALIAS=")) 166 if (add_uevent_var(env, "MODALIAS="))
165 return -ENOMEM; 167 return -ENOMEM;
166 168
diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c
index 9d2b4803a9d6..f24ffd7088d2 100644
--- a/drivers/of/selftest.c
+++ b/drivers/of/selftest.c
@@ -120,6 +120,34 @@ static void __init of_selftest_parse_phandle_with_args(void)
120 pr_info("end - %s\n", passed_all ? "PASS" : "FAIL"); 120 pr_info("end - %s\n", passed_all ? "PASS" : "FAIL");
121} 121}
122 122
123static void __init of_selftest_property_match_string(void)
124{
125 struct device_node *np;
126 int rc;
127
128 pr_info("start\n");
129 np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a");
130 if (!np) {
131 pr_err("No testcase data in device tree\n");
132 return;
133 }
134
135 rc = of_property_match_string(np, "phandle-list-names", "first");
136 selftest(rc == 0, "first expected:0 got:%i\n", rc);
137 rc = of_property_match_string(np, "phandle-list-names", "second");
138 selftest(rc == 1, "second expected:0 got:%i\n", rc);
139 rc = of_property_match_string(np, "phandle-list-names", "third");
140 selftest(rc == 2, "third expected:0 got:%i\n", rc);
141 rc = of_property_match_string(np, "phandle-list-names", "fourth");
142 selftest(rc == -ENODATA, "unmatched string; rc=%i", rc);
143 rc = of_property_match_string(np, "missing-property", "blah");
144 selftest(rc == -EINVAL, "missing property; rc=%i", rc);
145 rc = of_property_match_string(np, "empty-property", "blah");
146 selftest(rc == -ENODATA, "empty property; rc=%i", rc);
147 rc = of_property_match_string(np, "unterminated-string", "blah");
148 selftest(rc == -EILSEQ, "unterminated string; rc=%i", rc);
149}
150
123static int __init of_selftest(void) 151static int __init of_selftest(void)
124{ 152{
125 struct device_node *np; 153 struct device_node *np;
@@ -133,6 +161,7 @@ static int __init of_selftest(void)
133 161
134 pr_info("start of selftest - you will see error messages\n"); 162 pr_info("start of selftest - you will see error messages\n");
135 of_selftest_parse_phandle_with_args(); 163 of_selftest_parse_phandle_with_args();
164 of_selftest_property_match_string();
136 pr_info("end of selftest - %s\n", selftest_passed ? "PASS" : "FAIL"); 165 pr_info("end of selftest - %s\n", selftest_passed ? "PASS" : "FAIL");
137 return 0; 166 return 0;
138} 167}
diff --git a/include/linux/of.h b/include/linux/of.h
index 92cf6ad35e0e..f02d8b2f799d 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -72,19 +72,17 @@ struct of_phandle_args {
72 uint32_t args[MAX_PHANDLE_ARGS]; 72 uint32_t args[MAX_PHANDLE_ARGS];
73}; 73};
74 74
75#if defined(CONFIG_SPARC) || !defined(CONFIG_OF) 75#ifdef CONFIG_OF_DYNAMIC
76extern struct device_node *of_node_get(struct device_node *node);
77extern void of_node_put(struct device_node *node);
78#else /* CONFIG_OF_DYNAMIC */
76/* Dummy ref counting routines - to be implemented later */ 79/* Dummy ref counting routines - to be implemented later */
77static inline struct device_node *of_node_get(struct device_node *node) 80static inline struct device_node *of_node_get(struct device_node *node)
78{ 81{
79 return node; 82 return node;
80} 83}
81static inline void of_node_put(struct device_node *node) 84static inline void of_node_put(struct device_node *node) { }
82{ 85#endif /* !CONFIG_OF_DYNAMIC */
83}
84#else
85extern struct device_node *of_node_get(struct device_node *node);
86extern void of_node_put(struct device_node *node);
87#endif
88 86
89#ifdef CONFIG_OF 87#ifdef CONFIG_OF
90 88
@@ -217,6 +215,9 @@ extern int of_property_read_string(struct device_node *np,
217extern int of_property_read_string_index(struct device_node *np, 215extern int of_property_read_string_index(struct device_node *np,
218 const char *propname, 216 const char *propname,
219 int index, const char **output); 217 int index, const char **output);
218extern int of_property_match_string(struct device_node *np,
219 const char *propname,
220 const char *string);
220extern int of_property_count_strings(struct device_node *np, 221extern int of_property_count_strings(struct device_node *np,
221 const char *propname); 222 const char *propname);
222extern int of_device_is_compatible(const struct device_node *device, 223extern int of_device_is_compatible(const struct device_node *device,
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index ae5638480ef2..cbc42143fa5b 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -34,7 +34,8 @@ extern void of_device_unregister(struct platform_device *ofdev);
34extern ssize_t of_device_get_modalias(struct device *dev, 34extern ssize_t of_device_get_modalias(struct device *dev,
35 char *str, ssize_t len); 35 char *str, ssize_t len);
36 36
37extern int of_device_uevent(struct device *dev, struct kobj_uevent_env *env); 37extern void of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
38extern int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env);
38 39
39static inline void of_device_node_put(struct device *dev) 40static inline void of_device_node_put(struct device *dev)
40{ 41{
@@ -49,7 +50,10 @@ static inline int of_driver_match_device(struct device *dev,
49 return 0; 50 return 0;
50} 51}
51 52
52static inline int of_device_uevent(struct device *dev, 53static inline void of_device_uevent(struct device *dev,
54 struct kobj_uevent_env *env) { }
55
56static inline int of_device_uevent_modalias(struct device *dev,
53 struct kobj_uevent_env *env) 57 struct kobj_uevent_env *env)
54{ 58{
55 return -ENODEV; 59 return -ENODEV;