of: Add a testcase for of_find_node_by_path()

Add a testcase for the find_node_by_path() function to make sure it
handles all the valid scenarios.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
OF: fix of_find_node_by_path() assumption that of_allnodes is root

Pantelis Antoniou reports that of_find_node_by_path() is borked because
of_allnodes is not guaranteed to contain the root of the tree after using
any of the dynamic update functions because some other nodes ends up as
of_allnodes.

Fixes: c22e650e66b8 of: Make of_find_node_by_path() handle /aliases

Signed-off-by: Frank Rowand <frank.rowand@sonymobile.com>
dtc: Dynamic symbols & fixup support (v2)

Enable the generation of symbol & fixup information for
usage with dynamic DT loading.

Passing the -@ option generates a __symbols__ node at the
root node of the resulting blob for any node labels used.

When using the /plugin/ tag all unresolved label references
be tracked in the __fixups__ node, while all local phandle
references will the tracked in the __local_fixups__ node.

This is sufficient to implement a dynamic DT object loader.

Changes since v1:

* Forward ported to 1.4 version
* Added manual entries for the -@ option

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
dtc: Update shipped files after DT objects

Update shipped files after DT object support.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: Export __of_get_next_child & __for_each_child_of_node

Both of __of_get_next_child & __for_each_child_of_node have uses besides
being static in base.c, so export them appropriately.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: Add [__]of_find_node_by_full_name

__of_find_node_by_full_name recursively searches for a matching node
with the given full name without taking any locks.

of_find_node_by_full_name takes locks and takes a reference on the
matching node.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
of: platform: Fix and export of_platform_device_destroy

of_platform_destroy did not work properly, since the tree
population test was iterating on all devices having a parent
a given platform device.

The check was intended to check whether any other *platform*
devices were still populated, but instead checked for every
kind of device. This is wrong, since platform devices typically
create a subsystem regular device and set themselves as parents.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
of: export various non-locking accessors

As part of the move to transactional DT, the following
methods are exported

__of_add_property, __of_remove_property, __of_update_property,
__of_attach_node and __of_detach_node.

Note that __of_update_property has been reworked to be more efficient
(double walk of the property list eliminated)

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
of: export a few more internal __of functions.

Export __of_device_is_compatible and __of_device_is_available.
Also export __of_get_property && rework of_get_property to use it.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: Utility helper functions for dynamic nodes

Introduce helper functions for working with the live DT tree,
all of them related to dynamically adding/removing nodes and
properties.

__of_free_property() frees a dynamically created property
__of_free_tree() recursively frees a device node tree
__of_copy_property() copies a property dynamically
__of_create_empty_node() creates an empty node

Bug fix about prop->len == 0 by Ionut Nicu <ioan.nicu.ext@nsn.com>

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
of: Introduce tree change __foo_post methods.

As part of the DT transactional support these need to be introduced.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
of: Transactional DT support.

Introducing DT transactional support.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: Introduce Device Tree resolve support.

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>
OF: Introduce DT overlay support.

Introduce DT overlay support.
Makes it possible to dynamically overlay a part of the kernel's
tree with another tree that's been dynamically loaded.
Removal of nodes and properties is also possible.

The hard part of applying and reverting the overlay is done
using transactions.

Documentation about internal and APIs is provided in
	Documentation/devicetree/overlay-notes.txt

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
configfs: Implement binary attributes

Some problems require the use of binary configfs attributes, so
this patch implements them.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: DT-Overlay configfs interface (v2)

Add a runtime interface to using configfs for generic device tree overlay
usage.

A device-tree configfs entry is created in /config/device-tree/overlays

* To create an overlay you mkdir the directory:

	# mkdir /config/device-tree/overlays/foo

* Either you echo the overlay firmware file to the path property file.

	# echo foo.dtbo >/config/device-tree/overlays/foo/path

* Or you cat the contents of the overlay to the dtbo file

	# cat foo.dtbo >/config/device-tree/overlays/foo/dtbo

The overlay file will be applied.

To remove it simply rmdir the directory.

	# rmdir /config/device-tree/overlays/foo

Changes since v1:
* Implemented dtbo interface (relies on binary configfs attributes)

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: platform: Add OF notifier handler (v2)

Add OF notifier handler needed for creating/destroying platform devices
according to dynamic runtime changes in the DT live tree.

Changes since V1:
* Use of_platform_device_destroy since it handles OF_POPULATED correctly.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
of: i2c: Export single device registration method

Dynamically inserting i2c client device nodes requires the use
of a single device registration method. Rework and export it.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: i2c: Add OF notifier handler

Add OF notifier handler needed for creating/destroying i2c devices
according to dynamic runtime changes in the DT live tree.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
of: spi: Export single device registration method and accessors

Dynamically inserting spi device nodes requires the use of a single
device registration method. Rework and export it.

Methods to lookup a device/master using a device node are added
as well, of_find_spi_master_by_node() & of_find_spi_device_by_node().

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>