diff options
| -rw-r--r-- | Documentation/ABI/testing/sysfs-firmware-ofw | 28 | ||||
| -rw-r--r-- | arch/powerpc/platforms/pseries/dlpar.c | 2 | ||||
| -rw-r--r-- | arch/powerpc/platforms/pseries/reconfig.c | 2 | ||||
| -rw-r--r-- | arch/powerpc/sysdev/msi_bitmap.c | 2 | ||||
| -rw-r--r-- | drivers/of/base.c | 174 | ||||
| -rw-r--r-- | drivers/of/fdt.c | 3 | ||||
| -rw-r--r-- | drivers/of/pdt.c | 4 | ||||
| -rw-r--r-- | drivers/of/testcase-data/tests-phandle.dtsi | 3 | ||||
| -rw-r--r-- | include/linux/of.h | 9 |
9 files changed, 209 insertions, 18 deletions
diff --git a/Documentation/ABI/testing/sysfs-firmware-ofw b/Documentation/ABI/testing/sysfs-firmware-ofw new file mode 100644 index 000000000000..f562b188e71d --- /dev/null +++ b/Documentation/ABI/testing/sysfs-firmware-ofw | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | What: /sys/firmware/devicetree/* | ||
| 2 | Date: November 2013 | ||
| 3 | Contact: Grant Likely <grant.likely@linaro.org> | ||
| 4 | Description: | ||
| 5 | When using OpenFirmware or a Flattened Device Tree to enumerate | ||
| 6 | hardware, the device tree structure will be exposed in this | ||
| 7 | directory. | ||
| 8 | |||
| 9 | It is possible for multiple device-tree directories to exist. | ||
| 10 | Some device drivers use a separate detached device tree which | ||
| 11 | have no attachment to the system tree and will appear in a | ||
| 12 | different subdirectory under /sys/firmware/devicetree. | ||
| 13 | |||
| 14 | Userspace must not use the /sys/firmware/devicetree/base | ||
| 15 | path directly, but instead should follow /proc/device-tree | ||
| 16 | symlink. It is possible that the absolute path will change | ||
| 17 | in the future, but the symlink is the stable ABI. | ||
| 18 | |||
| 19 | The /proc/device-tree symlink replaces the devicetree /proc | ||
| 20 | filesystem support, and has largely the same semantics and | ||
| 21 | should be compatible with existing userspace. | ||
| 22 | |||
| 23 | The contents of /sys/firmware/devicetree/ is a | ||
| 24 | hierarchy of directories, one per device tree node. The | ||
| 25 | directory name is the resolved path component name (node | ||
| 26 | name plus address). Properties are represented as files | ||
| 27 | in the directory. The contents of each file is the exact | ||
| 28 | binary data from the device tree. | ||
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index a8fe5aa3d34f..022b38e6a80b 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
| 14 | #include <linux/kref.h> | ||
| 15 | #include <linux/notifier.h> | 14 | #include <linux/notifier.h> |
| 16 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
| 17 | #include <linux/cpu.h> | 16 | #include <linux/cpu.h> |
| @@ -87,7 +86,6 @@ static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa, | |||
| 87 | } | 86 | } |
| 88 | 87 | ||
| 89 | of_node_set_flag(dn, OF_DYNAMIC); | 88 | of_node_set_flag(dn, OF_DYNAMIC); |
| 90 | kref_init(&dn->kref); | ||
| 91 | 89 | ||
| 92 | return dn; | 90 | return dn; |
| 93 | } | 91 | } |
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c index f93cdf55628c..0435bb65d0aa 100644 --- a/arch/powerpc/platforms/pseries/reconfig.c +++ b/arch/powerpc/platforms/pseries/reconfig.c | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | */ | 12 | */ |
| 13 | 13 | ||
| 14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
| 15 | #include <linux/kref.h> | ||
| 16 | #include <linux/notifier.h> | 15 | #include <linux/notifier.h> |
| 17 | #include <linux/proc_fs.h> | 16 | #include <linux/proc_fs.h> |
| 18 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
| @@ -70,7 +69,6 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist | |||
| 70 | 69 | ||
| 71 | np->properties = proplist; | 70 | np->properties = proplist; |
| 72 | of_node_set_flag(np, OF_DYNAMIC); | 71 | of_node_set_flag(np, OF_DYNAMIC); |
| 73 | kref_init(&np->kref); | ||
| 74 | 72 | ||
| 75 | np->parent = derive_parent(path); | 73 | np->parent = derive_parent(path); |
| 76 | if (IS_ERR(np->parent)) { | 74 | if (IS_ERR(np->parent)) { |
diff --git a/arch/powerpc/sysdev/msi_bitmap.c b/arch/powerpc/sysdev/msi_bitmap.c index 0968b66b4cf9..8ba60424be95 100644 --- a/arch/powerpc/sysdev/msi_bitmap.c +++ b/arch/powerpc/sysdev/msi_bitmap.c | |||
| @@ -202,7 +202,7 @@ void __init test_of_node(void) | |||
| 202 | 202 | ||
| 203 | /* There should really be a struct device_node allocator */ | 203 | /* There should really be a struct device_node allocator */ |
| 204 | memset(&of_node, 0, sizeof(of_node)); | 204 | memset(&of_node, 0, sizeof(of_node)); |
| 205 | kref_init(&of_node.kref); | 205 | kref_init(&of_node.kobj.kref); |
| 206 | of_node.full_name = node_name; | 206 | of_node.full_name = node_name; |
| 207 | 207 | ||
| 208 | check(0 == msi_bitmap_alloc(&bmp, size, &of_node)); | 208 | check(0 == msi_bitmap_alloc(&bmp, size, &of_node)); |
diff --git a/drivers/of/base.c b/drivers/of/base.c index 48594f334151..3b70a468c8ab 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | #include <linux/of.h> | 23 | #include <linux/of.h> |
| 24 | #include <linux/spinlock.h> | 24 | #include <linux/spinlock.h> |
| 25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
| 26 | #include <linux/string.h> | ||
| 26 | #include <linux/proc_fs.h> | 27 | #include <linux/proc_fs.h> |
| 27 | 28 | ||
| 28 | #include "of_private.h" | 29 | #include "of_private.h" |
| @@ -35,6 +36,12 @@ struct device_node *of_chosen; | |||
| 35 | struct device_node *of_aliases; | 36 | struct device_node *of_aliases; |
| 36 | static struct device_node *of_stdout; | 37 | static struct device_node *of_stdout; |
| 37 | 38 | ||
| 39 | static struct kset *of_kset; | ||
| 40 | |||
| 41 | /* | ||
| 42 | * Used to protect the of_aliases; but also overloaded to hold off addition of | ||
| 43 | * nodes to sysfs | ||
| 44 | */ | ||
| 38 | DEFINE_MUTEX(of_aliases_mutex); | 45 | DEFINE_MUTEX(of_aliases_mutex); |
| 39 | 46 | ||
| 40 | /* use when traversing tree through the allnext, child, sibling, | 47 | /* use when traversing tree through the allnext, child, sibling, |
| @@ -92,14 +99,14 @@ int __weak of_node_to_nid(struct device_node *np) | |||
| 92 | struct device_node *of_node_get(struct device_node *node) | 99 | struct device_node *of_node_get(struct device_node *node) |
| 93 | { | 100 | { |
| 94 | if (node) | 101 | if (node) |
| 95 | kref_get(&node->kref); | 102 | kobject_get(&node->kobj); |
| 96 | return node; | 103 | return node; |
| 97 | } | 104 | } |
| 98 | EXPORT_SYMBOL(of_node_get); | 105 | EXPORT_SYMBOL(of_node_get); |
| 99 | 106 | ||
| 100 | static inline struct device_node *kref_to_device_node(struct kref *kref) | 107 | static inline struct device_node *kobj_to_device_node(struct kobject *kobj) |
| 101 | { | 108 | { |
| 102 | return container_of(kref, struct device_node, kref); | 109 | return container_of(kobj, struct device_node, kobj); |
| 103 | } | 110 | } |
| 104 | 111 | ||
| 105 | /** | 112 | /** |
| @@ -109,16 +116,15 @@ static inline struct device_node *kref_to_device_node(struct kref *kref) | |||
| 109 | * In of_node_put() this function is passed to kref_put() | 116 | * In of_node_put() this function is passed to kref_put() |
| 110 | * as the destructor. | 117 | * as the destructor. |
| 111 | */ | 118 | */ |
| 112 | static void of_node_release(struct kref *kref) | 119 | static void of_node_release(struct kobject *kobj) |
| 113 | { | 120 | { |
| 114 | struct device_node *node = kref_to_device_node(kref); | 121 | struct device_node *node = kobj_to_device_node(kobj); |
| 115 | struct property *prop = node->properties; | 122 | struct property *prop = node->properties; |
| 116 | 123 | ||
| 117 | /* We should never be releasing nodes that haven't been detached. */ | 124 | /* We should never be releasing nodes that haven't been detached. */ |
| 118 | if (!of_node_check_flag(node, OF_DETACHED)) { | 125 | if (!of_node_check_flag(node, OF_DETACHED)) { |
| 119 | pr_err("ERROR: Bad of_node_put() on %s\n", node->full_name); | 126 | pr_err("ERROR: Bad of_node_put() on %s\n", node->full_name); |
| 120 | dump_stack(); | 127 | dump_stack(); |
| 121 | kref_init(&node->kref); | ||
| 122 | return; | 128 | return; |
| 123 | } | 129 | } |
| 124 | 130 | ||
| @@ -151,11 +157,140 @@ static void of_node_release(struct kref *kref) | |||
| 151 | void of_node_put(struct device_node *node) | 157 | void of_node_put(struct device_node *node) |
| 152 | { | 158 | { |
| 153 | if (node) | 159 | if (node) |
| 154 | kref_put(&node->kref, of_node_release); | 160 | kobject_put(&node->kobj); |
| 155 | } | 161 | } |
| 156 | EXPORT_SYMBOL(of_node_put); | 162 | EXPORT_SYMBOL(of_node_put); |
| 163 | #else | ||
| 164 | static void of_node_release(struct kobject *kobj) | ||
| 165 | { | ||
| 166 | /* Without CONFIG_OF_DYNAMIC, no nodes gets freed */ | ||
| 167 | } | ||
| 157 | #endif /* CONFIG_OF_DYNAMIC */ | 168 | #endif /* CONFIG_OF_DYNAMIC */ |
| 158 | 169 | ||
| 170 | struct kobj_type of_node_ktype = { | ||
| 171 | .release = of_node_release, | ||
| 172 | }; | ||
| 173 | |||
