summaryrefslogtreecommitdiff
path: root/drivers/of/resolver.c
AgeCommit message (Collapse)Author
2017-10-17of: overlay: avoid race condition between applying multiple overlaysFrank Rowand
The process of applying an overlay consists of: - unflatten an overlay FDT (flattened device tree) into an EDT (expanded device tree) - fixup the phandle values in the overlay EDT to fit in a range above the phandle values in the live device tree - create the overlay changeset to reflect the contents of the overlay EDT - apply the overlay changeset, to modify the live device tree, potentially changing the maximum phandle value in the live device tree There is currently no protection against two overlay applies concurrently determining what range of phandle values are in use in the live device tree, and subsequently changing that range. Add a mutex to prevent multiple overlay applies from occurring simultaneously. Move of_resolve_phandles() into of_overlay_apply() so that it does not have to be duplicated by each caller of of_overlay_apply(). The test in of_resolve_phandles() that the overlay tree is detached is temporarily disabled so that old style overlay unittests do not fail. Signed-off-by: Frank Rowand <frank.rowand@sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2017-10-16of/resolver: Replace kmalloc + memcpy with kmemdup()Stephen Boyd
Save one line. Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Reviewed-by: Frank Rowand <frowand.list@gmail.com> Signed-off-by: Rob Herring <robh@kernel.org>
2017-10-16of/resolver: Simplify to be32_add_cpu()Stephen Boyd
This is the same as be32_add_cpu(), so simplify the code and remove the now unused local variable. Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Reviewed-by: Frank Rowand <frowand.list@gmail.com> Signed-off-by: Rob Herring <robh@kernel.org>
2017-06-22of: find_node_by_full_name rewrite to compare each levelRob Herring
find_node_by_full_name() does the same thing as of_find_node_by_path(), but takes no locks and doesn't work on aliases. Refactor of_find_node_opts_by_path() into __of_find_node_by_full_path() and replace find_node_by_full_name() with it. Signed-off-by: Rob Herring <robh@kernel.org>
2017-06-22of: use kbasename instead of open codingRob Herring
Several places in DT code open code the equivalent of kbasename. Replace them. The behavior for root nodes in node_name_cmp will be slightly different. Instead of comparing "/", "" will be compared. The comparison will be the same. Reviewed-by: Andy Shevchenko <andy.shevhchenko@gmail.com> Signed-off-by: Rob Herring <robh@kernel.org>
2017-05-04of: fix sparse warnings in fdt, irq, reserved mem, and resolver codeRob Herring
sparse generates the following warnings in drivers/of/: ../drivers/of/fdt.c:63:36: warning: cast to restricted __be32 ../drivers/of/fdt.c:68:33: warning: cast to restricted __be32 ../drivers/of/irq.c:105:88: warning: incorrect type in initializer (different base types) ../drivers/of/irq.c:105:88: expected restricted __be32 ../drivers/of/irq.c:105:88: got int ../drivers/of/irq.c:526:35: warning: incorrect type in assignment (different modifiers) ../drivers/of/irq.c:526:35: expected int ( *const [usertype] irq_init_cb )( ... ) ../drivers/of/irq.c:526:35: got void const *const data ../drivers/of/of_reserved_mem.c:200:50: warning: incorrect type in initializer (different modifiers) ../drivers/of/of_reserved_mem.c:200:50: expected int ( *[usertype] initfn )( ... ) ../drivers/of/of_reserved_mem.c:200:50: got void const *const data ../drivers/of/resolver.c:95:42: warning: incorrect type in assignment (different base types) ../drivers/of/resolver.c:95:42: expected unsigned int [unsigned] [usertype] <noident> ../drivers/of/resolver.c:95:42: got restricted __be32 [usertype] <noident> All these are harmless type mismatches fixed by adjusting the types. Signed-off-by: Rob Herring <robh@kernel.org>
2017-01-04of: drop duplicate headersGeliang Tang
Drop duplicate headers string.h and of_platform.h. Signed-off-by: Geliang Tang <geliangtang@gmail.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-12-09of: Fix issue where code would fall through to error case.Moritz Fischer
No longer fall through into the error case that prints out an error if no error (err = 0) occurred. Fixes d9181b20a83(of: Add back an error message, restructured) Signed-off-by: Moritz Fischer <mdf@kernel.org> Reviewed-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-11-15of: Remove unused variable overlay_symbolsFrank Rowand
Remove unused pointer to node "__symbols__". Signed-off-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-11-15of: Move setting of pointer to beside test for non-nullFrank Rowand
Value of pointer was calculated in an earlier block than where it was used. Move it down into the block where it is used, immediately before where is is checked to be valid. Signed-off-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-11-15of: Add back an error message, restructuredFrank Rowand
Add a single pr_err() to cover a range of errors that were reported by several pr_err() that were removed earlier in this series. Signed-off-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-11-15of: Update comments to reflect changes and increase clarityFrank Rowand
Update comments to better explain what functions are doing. Signed-off-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-11-15of: Remove redundant size checkFrank Rowand
Remove a redundant check of buffer size. Signed-off-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-11-15of: Update structure of code to be clearer, also remove BUG_ON()Frank Rowand
Remove BUG_ON(), which is frowned upon and not needed here. Restructure to remove some excessive complexity. Signed-off-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-11-15of: Rename variables to better reflect purpose or follow conventionFrank Rowand
Rename variables to better reflect what their purpose is. As a side effect, this reduces the need for some of the comments previously removed in this series. Signed-off-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-11-15of: Remove prefix "__of_" from local function namesFrank Rowand
Remove "__of_" prefix from local function names. The pattern of a leading "__" is used in drivers/of/ to signify a function that must be called with a lock held. These functions do not fit that pattern. Signed-off-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-11-15of: Rename functions to more accurately reflect what they doFrank Rowand
Some function names are misleading or do not provide a good sense of what they do. Rename the functions to ne more informative. Signed-off-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-11-15of: Convert comparisons to zero or NULL to logical expressionsFrank Rowand
Convert comparisons to zero or NULL to logical expressions. A small number of such comparisons remain where they provide more clarity of the numeric nature of a variable. Signed-off-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-11-15of: Remove excessive printks to reduce clutter.Frank Rowand
Remove extra debug and error printks. A single pr_err() will be added at the end of this series to replace many of these error messages. Signed-off-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-11-15of: Remove comments that state the obvious, to reduce clutterFrank Rowand
Remove comments that report what is obvious from the code. Signed-off-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-07-18of: overlay: add resolver error printsMichal Suchanek
Applying overlay fails silently in case of an error. Add error prints. Most notably the lack of symbols in the live tree is not reported. Signed-off-by: Michal Suchanek <hramrach@gmail.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-07-18of: use pr_fmt prefix for all console printingRob Herring
Clean-up all the DT printk functions to use common pr_fmt prefix. Some print statements such as kmalloc errors were redundant, so just drop those. Cc: Frank Rowand <frowand.list@gmail.com> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Reviewed-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-02-13of: resolver: Add missing of_node_get and of_node_putAmitoj Kaur Chawla
In __of_find_node_by_full_name, add an of_node_get when detecting the desired element, to ensure that it ends up with a reference count that is one greater than on entering the function. Also in __of_find_node_by_full_name, add an of_node_put on breaking out of the for_each_child_of_node loop, to ensure that the reference count of the returned value is not double incremented. This change was made using Coccinelle. The semantic patch used for this is as follows: // <smpl> @@ expression e; local idexpression n; @@ for_each_child_of_node(..., n) { ... when != of_node_put(n) when != e = n ( return n; | + of_node_put(n); ? return ...; ) ... } // </smpl Finally, add an of_node_put in for_each_child_of_node in the function __of_adjust_phandle_ref after the value returned by __of_find_node_by_full_name is no longer useful. Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com> Signed-off-by: Rob Herring <robh@kernel.org>
2014-11-24of/resolver: Switch to new local fixups format.Pantelis Antoniou
The original resolver format is way too cryptic, switch to using a tree based format that gets rid of repetitions, is more compact and readable. At the same time, update the selftests to using the new local fixups format. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> [grant.likely: Squashed in testcase changes and merged similar functions] Signed-off-by: Grant Likely <grant.likely@linaro.org>
2014-10-04of: Introduce Device Tree resolve support.Pantelis Antoniou
Introduce support for dynamic device tree resolution. Using it, it is possible to prepare a device tree that's been loaded on runtime to be modified and inserted at the kernel live tree. Export of of_resolve and bug fix of double free by Guenter Roeck <groeck@juniper.net> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> [grant.likely: Don't need to select CONFIG_OF_DYNAMIC and CONFIG_OF_DEVICE] [grant.likely: Don't need to depend on OF or !SPARC] [grant.likely: Factor out duplicate code blocks into single function] Signed-off-by: Grant Likely <grant.likely@linaro.org>