aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2015-02-21Merge branch 'linux-linaro-lsk' into linux-linaro-lsk-rtlsk-v3.10-rt-15.02lsk-v3.10-rt-14.02Mark Brown
2015-02-21Merge branch 'lsk/v3.10/topic/of' into linux-linaro-lsklsk-v3.10-15.02lsk-v3.10-14.02Mark Brown
2015-02-21i2c: Mark instantiated device nodes with OF_POPULATEv3.10/topic/ofPantelis Antoniou
Mark (and unmark) device nodes with the POPULATE flag as appropriate. This is required to avoid multi probing when using I2C and device overlays containing a mux. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> (cherry picked from commit 6d0a0d9ad09be16e3ca676b245643945b4bff47d) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/i2c/i2c-core.c
2015-02-21i2c: Mark instantiated device nodes with OF_POPULATEPantelis Antoniou
Mark (and unmark) device nodes with the POPULATE flag as appropriate. This is required to avoid multi probing when using I2C and device overlays containing a mux. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> (cherry picked from commit d5285c36e6d27c1a411a3131c034641a5fa452cb) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-21i2c/of: Add OF_RECONFIG notifier handlerPantelis Antoniou
CONFIG_OF_DYNAMIC enables runtime changes to the device tree which in turn may trigger addition or removal of devices from Linux. Add an OF_RECONFIG notifier handler to receive tree change events and to creating or destroy i2c devices as required. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> [grant.likely: clean up #ifdefs and drop unneeded error handling] Signed-off-by: Grant Likely <grant.likely@linaro.org> Reviewed-by: Wolfram Sang <wsa@the-dreams.de> Cc: Rob Herring <robh+dt@kernel.org> Cc: linux-i2c@vger.kernel.org (cherry picked from commit ea7513bbc04170f1cbf42953187a4d8b731c71c4) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-21i2c/of: Factor out Devicetree registration codePantelis Antoniou
Dynamically inserting i2c client device nodes requires the use of a single device registration method. Factor out the loop body of of_i2c_register_devices() so that it can be called for individual device_nodes instead of for all the children of a node. Note: The diff of this commit looks far more complicated than it actually is due the indentation being changed for a large block of code. When viewed using the diff -w flag to ignore whitespace changes it can be seen that the change is actually quite simple. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> [grant.likely: Made new function static and removed changes to header] Signed-off-by: Grant Likely <grant.likely@linaro.org> Reviewed-by: Wolfram Sang <wsa@the-dreams.de> Cc: Rob Herring <robh+dt@kernel.org> Cc: linux-i2c@vger.kernel.org (cherry picked from commit a430a3455f2c48995e06b359a82a1109a419e9ef) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/i2c/i2c-core.c
2015-02-21i2c: move OF helpers into the coreWolfram Sang
I2C of helpers used to live in of_i2c.c but experience (from SPI) shows that it is much cleaner to have this in the core. This also removes a circular dependency between the helpers and the core, and so we can finally register child nodes in the core instead of doing this manually in each driver. So, fix the drivers and documentation, too. [Modified to keep a stub device registration API exposed to drivers in order to avoid disruption] Signed-off-by: Wolfram Sang <wsa@the-dreams.de> (cherry picked from commit 687b81d083c082bc1e853032e3a2a54f8c251d27) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/i2c/busses/i2c-designware-platdrv.c drivers/i2c/busses/i2c-imx.c drivers/i2c/busses/i2c-stu300.c drivers/i2c/busses/i2c-wmt.c drivers/of/Kconfig drivers/of/Makefile drivers/staging/imx-drm/imx-tve.c sound/soc/fsl/imx-wm8962.c
2015-02-19Merge branch 'linux-linaro-lsk' into linux-linaro-lsk-rtMark Brown
2015-02-19Merge remote-tracking branch 'lsk/v3.10/topic/of' into linux-linaro-lskMark Brown
Conflicts: drivers/of/Makefile
2015-02-17of/overlay: Directly include idr.hMark Brown
The overlay code uses IDRs but does not explicitly include the header providing the interface, instead relying on an implicit inclusion. Make the dependency implict to avoid potential future build issues if the implicit inclusion goes away. Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-17of/platform: Handle of_populate drivers in notifierPantelis Antoniou
When using overlays with drivers calling of_populate the notifier will try to create the device twice. Using the populated bit before proceeding protects against this. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 15204ab1ebc5aba608cd19c83c37b98438b938b0) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-17of/overlay: Do not generate duplicate nodesPantelis Antoniou
During the course of the rewrites a bug sneaked in when dealing with children nodes of overlays, which ends up duplicating sub nodes. Simply remove the duplicate traversal of child nodes to fix. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 3e7f7626fd49a9ffba8520a1a073f62929acad63) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-17of/overlay: Introduce DT overlay supportPantelis Antoniou
Overlays are a method to dynamically modify part of the kernel's device tree with dynamically loaded data. Add the core functionality to parse, apply and remove an overlay changeset. The core functionality takes care of managing the overlay data format and performing the add and remove. Drivers are expected to use the overlay functionality to support custom expansion busses commonly found on consumer development boards like the BeagleBone or Raspberry Pi. The overlay code uses CONFIG_OF_DYNAMIC changesets to perform the low level work of modifying the devicetree. Documentation about internal and APIs is provided in Documentation/devicetree/overlay-notes.txt v2: - Switch from __of_node_alloc() to __of_node_dup() - Documentation fixups - Remove 2-pass processing of properties - Remove separate ov_lock; just use the DT mutex. v1: - Drop delete capability using '-' prefix. The '-' prefixed names are valid properties and nodes and there is no need for it just yet. - Do not update special properties - name & phandle ones. - Change order of node attachment, so that the special property update works. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 7518b5890d8ac366faa2326ce2356ef6392ce63d) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/of/Makefile
2015-02-17of: Refactor __of_node_alloc() into __of_node_dup()Grant Likely
Add a node argument to __of_node_alloc() and rename it to __of_node_dup() so that it can also be used to duplicate a node with its properties. This is important for the overlay code so that it can create new nodes without using separate changeset items for every single property. At the same time rework the overlay code to use the new function and drop the extra changeset items. Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit e51795815ef1a7adc018cbaf05aac46e3d24eda8) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/of/unittest.c
2015-02-17of: Use vargs in __of_node_allocGrant Likely
The overlay code needs to construct a new full_name from the parent name and the node name, but the current method has to allocate and then free an temporary string which is wasteful. Fix this problem by using vargs to pass in a format and arguments into __of_node_alloc(). At the same time remove the allocflags argument to __of_node_alloc(). The only users all use GFP_KERNEL, so there is no need to provide it as an option. If there is ever a need later it can be added back. Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit ef8bbd73a76197cf8362a2b43aaadc5717bd0746) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/of/unittest.c
2015-02-17of/reconfig: Add OF_DYNAMIC notifier for platform_bus_typePantelis Antoniou
Add OF notifier handler needed for creating/destroying platform devices according to dynamic runtime changes in the DT live tree. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 801d728c10db4b28e01590b46bf1f0df930760cc) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-17of/platform: Fix of_platform_device_destroy iteration of devicesGrant Likely
of_platform_destroy does not work properly, since the tree population test was iterating on all devices having as its parent the given platform device. The check was intended to check whether any other platform or amba devices created by of_platform_populate 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. Instead, go ahead and call the unregister functions for any devices created with of_platform_populate. The driver core will take care of unbinding drivers, and drivers are responsible for getting rid of any child devices that weren't created by of_platform_populate. Signed-off-by: Grant Likely <grant.likely@linaro.org> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> (cherry picked from commit 75f353b61342b5847c7f6d8499fd6301dce09845) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: include/linux/of_platform.h
2015-02-17of: Keep track of populated platform devicesPawel Moll
In "Device Tree powered" systems, platform devices are usually massively populated with of_platform_populate() call, executed at some level of initcalls, either by generic architecture or by platform-specific code. There are situations though where certain devices must be created (and bound with drivers) before all the others. This presents a challenge, as devices created explicitly would be created again by of_platform_populate(). This patch tries to solve that issue in a generic way, adding a "populated" flag for a DT node description. Subsequent of_platform_populate() will skip such nodes (and its children) in a similar way to the non-available ones. This patch also adds of_platform_depopulate() as an operation complementary to the _populate() one. It removes a platform or an amba device populated from the Device Tree, together with its all children (leaving, however, devices without associated of_node untouched) clearing the "populated" flag on the way. Signed-off-by: Pawel Moll <pawel.moll@arm.com> Reviewed-by: Rob Herring <robh@kernel.org> Acked-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit c6e126de43e7d4abfd6cf796b40589db3a046167) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/of/platform.c include/linux/of_platform.h
2015-02-16Merge remote-tracking branch 'lsk/v3.10/topic/of' into linux-linaro-lskMark Brown
Conflicts: arch/powerpc/kernel/prom.c drivers/of/Kconfig drivers/of/Makefile drivers/of/selftest.c include/linux/of.h
2015-02-16of/reconfig: Always use the same structure for notifiersGrant Likely
The OF_RECONFIG notifier callback uses a different structure depending on whether it is a node change or a property change. This is silly, and not very safe. Rework the code to use the same data structure regardless of the type of notifier. Signed-off-by: Grant Likely <grant.likely@linaro.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Cc: <linuxppc-dev@lists.ozlabs.org> (cherry picked from commit f5242e5a883bf1c1aba6bfd87b85e7dda0e62191) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: arch/powerpc/platforms/pseries/hotplug-memory.c include/linux/of.h
2015-02-16of/reconfig: Add debug output for OF_RECONFIG notifiersGrant Likely
Add some additional debug output to cover OF_RECONFIG notifier activity. At the same time, refactor the changeset debug output to use the same strings as the notifier debug output. Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 00aa37206e1a54dae61a0dba96bf2ee0938b99d7) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of/reconfig: Add of_reconfig_get_state_change() of notifier helper.Pantelis Antoniou
Introduce of_reconfig_get_state_change() which allows an of notifier to query about device state changes. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit b53a2340d0d30468b7315992ba77fe188c3bc5c8) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of/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> (cherry picked from commit da56d04c806a3e9986c66a061d7363ca3157c37b) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/of/unittest-data/testcases.dts
2015-02-16of: 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> (cherry picked from commit 7941b27b16e3282f6ec8817e36492f1deec753a7) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/of/Kconfig drivers/of/Makefile
2015-02-16of: Transactional DT support.Pantelis Antoniou
Introducing DT transactional support. A DT transaction is a method which allows one to apply changes in the live tree, in such a way that either the full set of changes take effect, or the state of the tree can be rolled-back to the state it was before it was attempted. An applied transaction can be rolled-back at any time. Documentation is in Documentation/devicetree/changesets.txt Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> [glikely: Removed device notifiers and reworked to be more consistent] Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 201c910bd6898d81d4ac6685d0f421b7e10f3c5d) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/of/selftest.c drivers/of/testcase-data/testcases.dtsi include/linux/of.h
2015-02-16of: Reorder device tree changes and notifiersGrant Likely
Currently, devicetree reconfig notifiers get emitted before the change is applied to the tree, but that behaviour is problematic if the receiver wants the determine the new state of the tree. The current users don't care, but the changeset code to follow will be making multiple changes at once. Reorder notifiers to get emitted after the change has been applied to the tree so that callbacks see the new tree state. At the same time, fixup the existing callbacks to expect the new order. There are a few callbacks that compare the old and new values of a changed property. Put both property pointers into the of_prop_reconfig structure. The current notifiers also allow the notifier callback to fail and cancel the change to the tree, but that feature isn't actually used. It really isn't valid to ignore a tree modification provided by firmware anyway, so remove the ability to cancel a change to the tree. Signed-off-by: Grant Likely <grant.likely@linaro.org> Cc: Nathan Fontenot <nfont@austin.ibm.com> (cherry picked from commit 259092a35c7e11f1d4616b0f5b3ba7b851fe4fa6) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of: Move dynamic node fixups out of powerpc and into common codeGrant Likely
PowerPC does an odd thing with dynamic nodes. It uses a notifier to catch new node additions and set some of the values like name and type. This makes no sense since that same code can be put directly into of_attach_node(). Besides, all dynamic node users need this, not just powerpc. Fix this problem by moving the logic out of arch/powerpc and into drivers/of/dynamic.c. It is also important to remove this notifier because we want to move the firing of notifiers from before the tree is modified to after so that the receiver gets a consistent view of the tree, but that is incompatible with notifiers that modify the node. Signed-off-by: Grant Likely <grant.likely@linaro.org> Cc: Nathan Fontenot <nfont@austin.ibm.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> (cherry picked from commit a25095d451ece23b1fef34474f3230100db7aa05) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: arch/powerpc/kernel/prom.c
2015-02-16of: Make sure attached nodes don't carry along extra childrenGrant Likely
The child pointer does not get cleared when attaching new nodes which could cause the tree to be inconsistent. Clear the child pointer in __of_attach_node() to be absolutely sure that the structure remains in a consistent layout. Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 6162dbe49a451f96431a23b4821f05e3bd925bc1) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of: Make devicetree sysfs update functions consistent.Grant Likely
All of the DT modification functions are split into two parts, the first part manipulates the DT data structure, and the second part updates sysfs, but the code isn't very consistent about how the second half is called. They don't all enforce the same rules about when it is valid to update sysfs, and there isn't any clarity on locking. The transactional DT modification feature that is coming also needs access to these functions so that it can perform all the structure changes together, and then all the sysfs updates as a second stage instead of doing each one at a time. Fix up the second have by creating a separate __of_*_sysfs() function for each of the helpers. The new functions have consistent naming (ie. of_node_add() becomes __of_attach_node_sysfs()) and all of them now defer if of_init hasn't been called yet. Callers of the new functions must hold the of_mutex to ensure there are no race conditions with of_init(). The mutex ensures that there will only ever be one writer to the tree at any given time. There can still be any number of readers and the raw_spin_lock is still used to make sure access to the data structure is still consistent. Finally, put the function prototypes into of_private.h so they are accessible to the transaction code. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> [grant.likely: Changed suffix from _post to _sysfs to match existing code] [grant.likely: Reorganized to eliminate trivial wrappers] Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 8a2b22a2595bf89d4396530edf8388159fad9d83) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/of/base.c
2015-02-16of: rename of_aliases_mutex to just of_mutexPantelis Antoniou
We're overloading usage of of_aliases_mutex for sysfs changes, so rename to something that is more generic. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit c05aba2bd5f9dd3f363611ff844513de1341ac60) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of: Create unlocked versions of node and property add/remove functionsPantelis Antoniou
The DT overlay code will need to manipulate nodes and properties while already holding the devicetree lock, or on nodes that are not yet attached to the tree, but the current helper functions don't allow that. Extract the core behaviour from the accessors and create the following unlocked variants. The unlocked variants require either the lock to already be held or for the nodes to be detached from the tree. Changes to live nodes will not get updated in sysfs, so the caller must arrange for housekeeping to take place after dropping the lock. The new functions are: __of_add_property(), __of_remove_property(), __of_update_property(), __of_attach_node() and __of_detach_node(). Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> [Remove unnecessary diff hunks and rewrite commit text] Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit d8c50088417ebf61ad8b132caad20d10f7736034) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/of/base.c
2015-02-16of: add __of_add_property() without lock operationsXiubo Li
There two places will use the same code for adding one new property to the DT node. Adding __of_add_property() and prepare for fixing of_update_property()'s bug. Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 62664f67775fad840cf6f68d6b5f428817bef6c5) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/of/base.c
2015-02-16OF: Utility helper functions for dynamic nodesPantelis Antoniou
Introduce helper functions for working with the live DT tree, all of them related to dynamically adding/removing nodes and properties. __of_prop_dup() copies a property dynamically __of_node_alloc() 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> [glikely: Added unittest for of_copy_property and dropped fine-grained allocations] [glikely: removed name, type and phandle arguments from __of_node_alloc] Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 698433963b98d6de7b102c242805c99fda4fa1fb) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/of/selftest.c
2015-02-16of: Move CONFIG_OF_DYNAMIC code into a separate fileGrant Likely
Split the dynamic device tree code into a separate file to make it really clear what features CONFIF_OF_DYNAMIC add to the kernel. Without CONFIG_OF_DYNAMIC only properties can be changed, and notifiers do not get sent. Enabling it turns on reference counting, notifiers and the ability to add and remove nodes. v2: Moved of_node_release() into dynamic.c Signed-off-by: Grant Likely <grant.likely@linaro.org> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Cc: Rob Herring <robh+dt@kernel.org> (cherry picked from commit 6afc0dc381573559251de9a8259404f49e6aed14) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/of/Makefile drivers/of/base.c
2015-02-16of: Introduce device tree node flag helpers.Pantelis Antoniou
Helper functions for working with device node flags. Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 588453c69dace39351129a038dd2796608f74bb3) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of: device_node kobject lifecycle fixesPantelis Antoniou
After the move to having device nodes be proper kobjects the lifecycle of the node needs to be controlled better. At first convert of_add_node() in the unflattened functions to of_init_node() which initializes the kobject so that of_node_get/put work correctly even before of_init is called. Afterwards introduce of_node_is_initialized & of_node_is_attached that query the underlying kobject about the state (attached means kobj is visible in sysfs) Using that make sure the lifecycle of the tree is correct at all times. Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com> [grant.likely: moved of_node_init() calls, fixed up locking, and dropped __of_populate() hunks] Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 0829f6d1f69e4f2fae4062987ae6531a9af1a2e3) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of: remove /proc/device-treeGrant Likely
The same data is now available in sysfs, so we can remove the code that exports it in /proc and replace it with a symlink to the sysfs version. Tested on versatile qemu model and mpc5200 eval board. More testing would be appreciated. v5: Fixed up conflicts with mainline changes Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Cc: Rob Herring <rob.herring@calxeda.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: David S. Miller <davem@davemloft.net> Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com> Cc: Pantelis Antoniou <panto@antoniou-consulting.com> (cherry picked from commit 8357041a69b368991d1b04d9f1d297f8d71e1314) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: drivers/of/base.c fs/proc/proc_devtree.c include/linux/of.h
2015-02-16of: add functions to count number of elements in a propertyHeiko Stuebner
The need to know the number of array elements in a property is a common pattern. To prevent duplication of open-coded implementations add a helper static function that also centralises strict sanity checking and DTB format details, as well as a set of wrapper functions for u8, u16, u32 and u64. Suggested-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Heiko Stuebner <heiko.stuebner@bqreaders.com> Acked-by: Rob Herring <robh@kernel.org> Acked-by: Grant Likely <grant.likely@linaro.org> Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Mark Brown <broonie@linaro.org> (cherry picked from commit ad54a0cfbeb4bd4033d09017557ccbc423f9d5ff) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16fs/proc/proc_devtree.c: remove empty /proc/device-tree when no openfirmware ↵Dave Jones
exists. Distribution kernels might want to build in support for /proc/device-tree for kernels that might end up running on hardware that doesn't support openfirmware. This results in an empty /proc/device-tree existing. Remove it if the OFW root node doesn't exist. This situation actually confuses grub2, resulting in install failures. grub2 sees the /proc/device-tree and picks the wrong install target cf. http://bzr.savannah.gnu.org/lh/grub/trunk/grub/annotate/4300/util/grub-install.in#L311 grub should be more robust, but still, leaving an empty proc dir seems pointless. Addresses https://bugzilla.redhat.com/show_bug.cgi?id=818378. Signed-off-by: Dave Jones <davej@redhat.com> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Paul Mackerras <paulus@samba.org> Cc: Josh Boyer <jwboyer@fedoraproject.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> (cherry picked from commit c1d867a54d426b45da017fbe8e585f8a3064ce8d) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of: Make device nodes kobjects so they show up in sysfsGrant Likely
Device tree nodes are already treated as objects, and we already want to expose them to userspace which is done using the /proc filesystem today. Right now the kernel has to do a lot of work to keep the /proc view in sync with the in-kernel representation. If device_nodes are switched to be kobjects then the device tree code can be a whole lot simpler. It also turns out that switching to using /sysfs from /proc results in smaller code and data size, and the userspace ABI won't change if /proc/device-tree symlinks to /sys/firmware/devicetree/base. v7: Add missing sysfs_bin_attr_init() v6: Add __of_add_property() early init fixes from Pantelis v5: Rename firmware/ofw to firmware/devicetree Fix updating property values in sysfs v4: Fixed build error on Powerpc Fixed handling of dynamic nodes on powerpc v3: Fixed handling of duplicate attribute and child node names v2: switch to using sysfs bin_attributes which solve the problem of reporting incorrect property size. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Tested-by: Sascha Hauer <s.hauer@pengutronix.de> Cc: Rob Herring <rob.herring@calxeda.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: David S. Miller <davem@davemloft.net> Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com> Cc: Pantelis Antoniou <panto@antoniou-consulting.com> (cherry picked from commit 75b57ecf9d1d1e17d099ab13b8f48e6e038676be) Signed-off-by: Mark Brown <broonie@kernel.org> Conflicts: arch/powerpc/platforms/pseries/dlpar.c
2015-02-16Merge remote-tracking branch 'lsk/v3.10/topic/of' into linux-linaro-lskMark Brown
Conflicts: drivers/of/base.c drivers/of/fdt.c
2015-02-16of/irq: Pass trigger type in IRQ resource flagsTomasz Figa
Some drivers might rely on availability of trigger flags in IRQ resource, for example to configure the hardware for particular interrupt type. However current code creating IRQ resources from data in device tree does not configure trigger flags in resulting resources. This patch tries to solve the problem, based on the fact that irq_of_parse_and_map() configures the trigger based on DT interrupt specifier and IRQD_TRIGGER_* flags are consistent with IORESOURCE_IRQ_*, and we can get correct trigger flags by calling irqd_get_trigger_type() after mapping the interrupt. Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com> [grant.likely: Merged the two assignments to r->flags] Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 4a43d686fe336cc0e955c4400ba4d3fcff788786) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of: Fix dereferencing node name in debug output to be safeGrant Likely
Several locations in the of_address and of_irq code dereference the full_name parameter from a device_node pointer without checking if the pointer is valid. This patch switches to use of_node_full_name() which always checks the pointer. Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 8804827b305dbc1c6e24f2b36f1df4a9856b80e8) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of/fdt: Remove duplicate memory clearing on FDT unflatteningGrant Likely
Patch 9e4012752, "of: fdt: fix memory initialization for expanded DT" fixed incomplete clearing of memory when unflattening the device tree. However the code was already clearing some of the memory, it just wasn't doing so for all allocations. Now that the memory is cleared right at the point of allocation, the memset after unflatten_dt_alloc() is redundant. Remove it. Signed-off-by: Grant Likely <grant.likely@linaro.org> Acked-by: Wladislav Wiebe <wladislav.kw@gmail.com> (cherry picked from commit 92d31610aac907c046f0e9c0f888c30415f20936) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of: call __of_parse_phandle_with_args from of_parse_phandleStephen Warren
The simplest case of __of_parse_phandle_with_args() now implements the semantics of of_parse_phandle(). Rewrite of_parse_phandle() to call __of_parse_phandle_with_args() rather than open-coding the simple case. Optimize __of_parse_phandle_with_args() so that it doesn't call of_find_node_by_phandle() except when it's strictly needed. This avoids introducing too much overhead when replacing of_parse_phandle(). Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 91d9942c28ee691dab47185f38b052f84db4e0f7) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of: introduce of_parse_phandle_with_fixed_argsStephen Warren
This is identical to of_parse_phandle_with_args(), except that the number of argument cells is fixed, rather than being parsed out of the node referenced by each phandle. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 035fd9482274bf43858b00e0ff95179af66df8e8) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of: move of_parse_phandle()Stephen Warren
Move of_parse_phandle() after __of_parse_phandle_with_args(), since a future patch will call __of_parse_phandle_with_args() from of_parse_phandle(). Moving the function avoids adding a prototype. Doing the move separately highlights the code changes separately. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit 5fba49e3a8c22a7bb71c3526ec32b373b3ef32b8) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of: move documentation of of_parse_phandle_with_argsStephen Warren
Commit bd69f73 "of: Create function for counting number of phandles in a property" renamed of_parse_phandle_with_args(), and created a wrapper function that implemented the original name. However, the documentation of the original function was not moved, leaving it apparently documenting the newly renamed function. Move the documentation so that it is adjacent to the function it documents. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit eded9dd40b1e30215ab7379dc433f3d3c662ec88) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16of: fdt: fix memory initialization for expanded DTWladislav Wiebe
Already existing property flags are filled wrong for properties created from initial FDT. This could cause problems if this DYNAMIC device-tree functions are used later, i.e. properties are attached/detached/replaced. Simply dumping flags from the running system show, that some initial static (not allocated via kzmalloc()) nodes are marked as dynamic. I putted some debug extensions to property_proc_show(..) : .. + if (OF_IS_DYNAMIC(pp)) + pr_err("DEBUG: xxx : OF_IS_DYNAMIC\n"); + if (OF_IS_DETACHED(pp)) + pr_err("DEBUG: xxx : OF_IS_DETACHED\n"); when you operate on the nodes (e.g.: ~$ cat /proc/device-tree/*some_node*) you will see that those flags are filled wrong, basically in most cases it will dump a DYNAMIC or DETACHED status, which is in not true. (BTW. this OF_IS_DETACHED is a own define for debug purposes which which just make a test_bit(OF_DETACHED, &x->_flags) If nodes are dynamic kernel is allowed to kfree() them. But it will crash attempting to do so on the nodes from FDT -- they are not allocated via kzmalloc(). Signed-off-by: Wladislav Wiebe <wladislav.kw@gmail.com> Acked-by: Alexander Sverdlin <alexander.sverdlin@nsn.com> Cc: stable@vger.kernel.org Signed-off-by: Rob Herring <rob.herring@calxeda.com> (cherry picked from commit 9e40127526e857fa3f29d51e83277204fbdfc6ba) Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-16OF: Add helper for matching against linux,stdout-pathSascha Hauer
devicetrees may have a linux,stdout-path property in the chosen node describing the console device. This adds a helper function to match a device against this property so a driver can call add_preferred_console for a matching device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 5c19e95216b93b0d29c6a4887e69a980edc6fc81) Signed-off-by: Mark Brown <broonie@kernel.org>