summaryrefslogtreecommitdiff
path: root/drivers/of/unittest.c
AgeCommit message (Collapse)Author
2017-05-04of/unittest: Missing unlocks on errorDan Carpenter
Static checkers complain that we should unlock before returning. Which is true. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Frank Rowand <frank.rowand@sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2017-05-03of: fix uninitialized variable warning for overlay testArnd Bergmann
gcc warns that an empty device tree would cause undefined behavior: drivers/of/unittest.c: In function 'of_unittest': drivers/of/unittest.c:2199:25: warning: 'last_sibling' may be used uninitialized in this function [-Wmaybe-uninitialized] This adds an initialization of the variable to zero, which we handle correctly. Fixes: 81d0848fc8d2 ("of: Add unit tests for applying overlays") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Rob Herring <robh@kernel.org>
2017-04-27of: Add unit tests for applying overlaysFrank Rowand
Existing overlay unit tests examine individual pieces of the overlay code. The new tests target the entire process of applying an overlay. Signed-off-by: Frank Rowand <frank.rowand@sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
2017-01-23of/unittest: Swap arguments of of_unittest_apply_overlay()Alexander Sverdlin
Function signature of_unittest_apply_overlay(int unittest_nr, int overlay_nr, ... and call sites, like in of_unittest_apply_overlay_check(): ret = of_unittest_apply_overlay(overlay_nr, unittest_nr, ... do not match. Fix this in one place (function signature). The only affected test case is 15, which supplies non-existing overlay number 16, but two bugs matched here. Fix the test case. Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com> Cc: Rob Herring <robh+dt@kernel.org> Cc: Frank Rowand <frowand.list@gmail.com> Cc: devicetree@vger.kernel.org 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-06-23of: unittest: use of_platform_default_populate() to populate default busKefeng Wang
Use helper of_platform_default_populate() in linux/of_platform when possible, instead of calling of_platform_populate() with the default match table. Cc: Rob Herring <robh+dt@kernel.org> Cc: Frank Rowand <frowand.list@gmail.com> Cc: Grant Likely <grant.likely@linaro.org> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-05-20Merge tag 'devicetree-for-4.7' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux Pull devicetree updates from Rob Herring: - Rewrite of the unflattening code to avoid recursion and lessen the stack usage. - Rewrite of the phandle args parsing code to get rid of the fixed args size. This is needed for IOMMU code. - Sync to latest dtc which adds more dts style checking. These warnings are enabled with "W=1" compiles. - Tegra documentation updates related to the above warnings. - A bunch of spelling and other doc fixes. - Various vendor prefix additions. * tag 'devicetree-for-4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (52 commits) devicetree: Add Creative Technology vendor id gpio: dt-bindings: add ibm,ppc4xx-gpio binding of/unittest: Remove unnecessary module.h header inclusion drivers/of: Fix build warning in populate_node() drivers/of: Fix depth when unflattening devicetree of: dynamic: changeset prop-update revert fix drivers/of: Export of_detach_node() drivers/of: Return allocated memory from of_fdt_unflatten_tree() drivers/of: Specify parent node in of_fdt_unflatten_tree() drivers/of: Rename unflatten_dt_node() drivers/of: Avoid recursively calling unflatten_dt_node() drivers/of: Split unflatten_dt_node() of: include errno.h in of_graph.h of: document refcount incrementation of of_get_cpu_node() Documentation: dt: soc: fix spelling mistakes Documentation: dt: power: fix spelling mistake Documentation: dt: pinctrl: fix spelling mistake Documentation: dt: opp: fix spelling mistake Documentation: dt: net: fix spelling mistakes Documentation: dt: mtd: fix spelling mistake ...
2016-05-19of/unittest: Remove unnecessary module.h header inclusionJavier Martinez Canillas
The OF_UNITTEST Kconfig symbol is bool so this unittest can only be built-in and not build as a module. Also, nothing defined in this header file used so is not necessary to include it. Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-05-16drivers/of: Specify parent node in of_fdt_unflatten_tree()Gavin Shan
This adds one more argument to of_fdt_unflatten_tree() to specify the parent node of the FDT blob that is going to be unflattened. In the result, the function can be used to unflatten FDT blob that represents device sub-tree in PowerNV PCI hotplug driver. Cc: Jyri Sarha <jsarha@ti.com> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Acked-by: Rob Herring <robh@kernel.org> Acked-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-04-22of/unittest: convert to use an explicit i2c mux corePeter Rosin
Allocate an explicit i2c mux core to handle parent and child adapters etc. Update the select op to be in terms of the i2c mux core instead of the child adapter. Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Peter Rosin <peda@axentia.se> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-03-03of/unittest: fix infinite loop in of_unittest_destroy_tracked_overlays()Sergey Senozhatsky
of_overlay_destroy() can return `-ENODEV' error code once it failed to find the requested overlay in `ov_idr'. However, of_unittest_destroy_tracked_overlays() does not handle this error code correctly and continues to call of_overlay_destroy() on the 'missing' overlay over and over again. This results in a printk flood [..] [ 33.497583] of_overlay_destroy: Could not find overlay #6 [ 33.497583] of_overlay_destroy: Could not find overlay #6 [ 33.497584] ### dt-test ### of_unittest_destroy_tracked_overlays: overlay destroy failed for #6 [ 33.497584] ### dt-test ### of_unittest_destroy_tracked_overlays: overlay destroy failed for #6 [ 33.497586] of_overlay_destroy: Could not find overlay #6 [ 33.497586] of_overlay_destroy: Could not find overlay #6 [ 33.497587] ### dt-test ### of_unittest_destroy_tracked_overlays: overlay destroy failed for #6 [ 33.497587] ### dt-test ### of_unittest_destroy_tracked_overlays: overlay destroy failed for #6 [..] which is not really good due to printk design, and can lead to soft lockups, hard lockups, etc. (depending on the context console_unlock() is being called from). The problem has bee observed in real life and reported by Ying Huang. This patch does not address the root cause of missing overlay in `ov_idr', it fixes the endless loop only. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Reported-by: kernel test robot <ying.huang@linux.intel.com> Link: lkml.kernel.org/r/87fuwk1c0o.fsf@yhuang-dev.intel.com Signed-off-by: Rob Herring <robh@kernel.org>
2016-01-13drivers/of: Export OF changeset functionsGavin Shan
The PowerNV PCI hotplug driver is going to use the OF changeset to manage the changed device sub-tree. This exports those OF changeset functions for that. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Rob Herring <robh@kernel.org>
2016-01-05of/unittest: Show broken behaviour in the platform busGrant Likely
Add a single resource to the test bus device to exercise the platform bus code a little more. This isn't strictly a devicetree test, but it is a corner case that the devicetree runs into. Until we've got platform device unittests, it can live here. It doesn't need to be an explicit text because the kernel will oops when it is wrong. Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Cc: Rob Herring <robh@kernel.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> [wsa: added the comment provided by Grant, rebased, and tested] Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Rob Herring <robh@kernel.org>
2015-10-22of/unittest: add missing of_node_putJulia Lawall
for_each_child_of_node performs an of_node_get on each iteration, so a break out of the loop requires an of_node_put. A simplified version of the semantic patch that fixes this problem is as follows (http://coccinelle.lip6.fr): // <smpl> @@ expression root,e; local idexpression child; @@ for_each_child_of_node(root, child) { ... when != of_node_put(child) when != e = child ( return child; | + of_node_put(child); ? return ...; ) ... } // </smpl> Combine the puts into code at the end of the function, for conciseness. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Rob Herring <robh@kernel.org>
2015-07-27of: Drop owner assignment from platform and i2c driverKrzysztof Kozlowski
platform_driver and i2c_driver do not need to set an owner because core will set it. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Rob Herring <robh@kernel.org>
2015-04-24Merge tag 'devicetree-for-4.1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux Pull second batch of devicetree updates from Rob Herring: "As Grant mentioned in the first devicetree pull request, here is the 2nd batch of DT changes for 4.1. The main remaining item here is the endianness bindings and related 8250 driver support. - DT endianness specification bindings - big-endian 8250 serial support - DT overlay unittest updates - various DT doc updates - compile fixes for OF_IRQ=n" * tag 'devicetree-for-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: frv: add io{read,write}{16,32}be functions mn10300: add io{read,write}{16,32}be functions Documentation: DT bindings: add doc for Altera's SoCFPGA platform of: base: improve of_get_next_child() kernel-doc Doc: dt: arch_timer: discourage clock-frequency use of: unittest: overlay: Keep track of created overlays of/fdt: fix allocation size for device node path serial: of_serial: Support big-endian register accesses serial: 8250: Add support for big-endian MMIO accesses of: Document {little,big,native}-endian bindings of/fdt: Add endianness helper function for early init code of: Add helper function to check MMIO register endianness of/fdt: Remove "reg" data prints from early_init_dt_scan_memory of: add vendor prefix for Artesyn of: Add dummy of_irq_to_resource_table() for IRQ_OF=n of: OF_IRQ should depend on IRQ_DOMAIN
2015-04-14of: unittest: overlay: Keep track of created overlaysPantelis Antoniou
During the course of the overlay selftests some of them remain applied. While this does not pose a real problem, make sure you track them and destroy them at the end of the test. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Rob Herring <robh@kernel.org>
2015-03-29Merge remote-tracking branch 'robh/for-next' into devicetree/nextGrant Likely
Conflicts: drivers/of/unittest.c
2015-03-29of/unittest: Fix of_platform_depopulate test caseGrant Likely
The previous commit, "of/unittest: early return from test skips tests" exposed broken tests for the of_platform_unpopulate() function. The problem was the populate and depopulate calls were not symmetrical like they were intended to be, and unpopulate depends on the parent device to have it's of_node pointer pointing to the parent device node. Fix these bugs so that the test case works correctly. In the process, the test_bus used as a container for the test devices has been changed from a statically allocated struct device (which is bad) to a properly allocated device with a .release() method (which is good). This stops the test code from being a bad example of abusing the device model. Signed-off-by: Grant Likely <grant.likely@linaro.org> Cc: Frank Rowand <frank.rowand@sonymobile.com> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Cc: Pawel Moll <pawel.moll@arm.com>
2015-03-29of/unittest: early return from test skips testsFrank Rowand
Fix bugs pointed out by checkpatch: Mis-coding of two if statements caused early return from function. Number of tests completed increased from 102 to 107. Number of tests failed increased from 0 to 2. Signed-off-by: Frank Rowand <frank.rowand@sonymobile.com> Signed-off-by: Grant Likely <grant.likely@linaro.org>
2015-03-29of/unittest: breadcrumbs to reduce pain of future maintainersFrank Rowand
Fix warnings pointed out by checkpatch. Checkpatch warns: externs should be avoided in .c files Reducing pain for future maintainers - adding a comment so that anyone trying to find where the extern data is created will be able to find it. (grep will not find that location) Signed-off-by: Frank Rowand <frank.rowand@sonymobile.com> Signed-off-by: Grant Likely <grant.likely@linaro.org>
2015-03-29of/unittest: reduce checkpatch noise - line after declarationsFrank Rowand
Fix warnings pointed out by checkpatch. No bug fixes, but reduce the number of checkpatch warnings so that future problems will stand out better. Signed-off-by: Frank Rowand <frank.rowand@sonymobile.com> Signed-off-by: Grant Likely <grant.likely@linaro.org>
2015-03-29of/unittest: typo in error stringFrank Rowand
Fix bug pointed out by checkpatch. Splitting string incorrectly removed a space between two words. Signed-off-by: Frank Rowand <frank.rowand@sonymobile.com> Signed-off-by: Grant Likely <grant.likely@linaro.org>
2015-03-29of/unittest: add const where neededFrank Rowand
Fix warnings pointed out by checkpatch. No bugs fixed, but the test code should be a good example of how to use the devicetree API. Signed-off-by: Frank Rowand <frank.rowand@sonymobile.com> Signed-off-by: Grant Likely <grant.likely@linaro.org>
2015-03-25of/unittest: replace 'selftest' with 'unittest'Wang Long
This patch just replace the string 'selftest' with 'unittest' in OF unittest and data and binding file. I have tested it successfully on ARM. Signed-off-by: Wang Long <long.wanglong@huawei.com> Signed-off-by: Rob Herring <robh@kernel.org>
2015-03-19of: unittest: Add option string test case with longer pathBrian Norris
There were regressions seen with commit 106937e8ccdc ("of: fix handling of '/' in options for of_find_node_by_path()"), where we couldn't handle extra '/' before the ':'. Let's test for this now. Confirmed that this test fails without the previous patch and passes when patched. All other tests pass. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Rob Herring <robh@kernel.org>
2015-03-10of: unittest: Add options string testcase variantsPeter Hurley
Add testcase variants with '/' in the options string to test for scan beyond end path name terminated by ':'. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Rob Herring <robh@kernel.org>
2015-03-10of/unittest: Fix the wrong expected value in of_selftest_property_stringWang Long
This patch fix the wrong expected value of of_property_match_string in of_selftest_property_string. Signed-off-by: Wang Long <long.wanglong@huawei.com> Signed-off-by: Rob Herring <robh@kernel.org>
2015-03-10of/unittest: remove the duplicate of_changeset_initWang Long
Remove the duplicate of_changeset_init. In of_selftest_changeset testcase, the "struct of_changeset chgset" is initialized twice, but only once is enough. so, drop the first initializtion code. Signed-off-by: Wang Long <long.wanglong@huawei.com> Signed-off-by: Rob Herring <robh@kernel.org>
2015-03-10of: unittest: fix I2C dependencyArnd Bergmann
The unittest fails to link if I2C or I2C_MUX is a loadable module: drivers/built-in.o: In function `selftest_i2c_mux_remove': unittest.c:(.text+0xb0ce4): undefined reference to `i2c_del_mux_adapter' This changes the newly added IS_ENABLED() checks to use IS_BUILTIN() instead, which evaluates to false if the other driver is a module. Reported-by: Chen Gang <gang.chen.5i5j@gmail.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Fixes: d5e75500ca401 ("of: unitest: Add I2C overlay unit tests.") Signed-off-by: Rob Herring <robh@kernel.org>
2015-02-11Merge remote-tracking branch 'grant/devicetree/next' into for-nextRob Herring
2015-02-04of: unitest: Add I2C overlay unit tests.Pantelis Antoniou
Introduce I2C device tree overlay tests. Tests insertion and removal of i2c adapters, i2c devices, and muxes. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Rob Herring <robh@kernel.org>
2015-02-04Merge tag 'v3.19-rc6' into HEADRob Herring
Linux 3.19-rc6
2015-01-23of/unittest: Overlays with sub-devices testsPantelis Antoniou
Introduce selftests for overlays using sub-devices present in children nodes. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Grant Likely <grant.likely@linaro.org>
2015-01-22of/unittest: Remove obsolete codeGrant Likely
Commit 3ce04b4a9, "Removes OF_UNITTEST dependency on OF_DYNAMIC config symbol" removes a bunch of code, but missed a few minor bits. Clean it up by removing the node removal cache and flag. Signed-off-by: Grant Likely <grant.likely@linaro.org> Cc: Gaurav Minocha <gaurav.minocha.os@gmail.com> Cc: Rob Herring <robh@kernel.org>
2015-01-13Removes OF_UNITTEST dependency on OF_DYNAMIC config symbolGaurav Minocha
This patch intends to remove the unittests dependency on the functions defined in dynamic.c. So, rather than calling of_attach_node defined in dynamic.c, minimal functionality required to attach a new node is re-defined in unittest.c. Also, now after executing the tests the test data is not removed from the device tree so there is no need to call of_detach_node. Tested with and without OF_DYNAMIC enabled on ppc, arm and x86 Signed-off-by: Gaurav Minocha <gaurav.minocha.os@gmail.com> Signed-off-by: Rob Herring <robh@kernel.org>
2014-12-03of: Delete unnecessary check before calling "of_node_put()"Markus Elfring
The of_node_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Grant Likely <grant.likely@linaro.org>
2014-12-03of: add optional options parameter to of_find_node_by_path()Leif Lindholm
Update of_find_node_by_path(): 1) Rename function to of_find_node_opts_by_path(), adding an optional pointer argument. Provide a static inline wrapper version of of_find_node_by_path() which calls the new function with NULL as the optional argument. 2) Ignore any part of the path beyond and including the ':' separator. 3) Set the new provided pointer argument to the beginning of the string following the ':' separator. 4: Add tests. Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Grant Likely <grant.likely@linaro.org>
2014-11-27of: Remove unneeded and incorrect MODULE_DEVICE_TABLEGrant Likely
The unittest code has a MODULE_DEVICE_TABLE that isn't needed by any of the unittests, and isn't even correct. Remove it. Signed-off-by: Grant Likely <grant.likely@linaro.org> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
2014-11-24of/overlay: Add overlay unittestsPantelis Antoniou
Add unittests for OF overlays. It tests overlay device addition/removal and whether the apply revert sequence is correct. Changes since V1: * Added local fixups entries. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Grant Likely <grant.likely@linaro.org>
2014-11-24of: 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>
2014-11-24of: 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>
2014-11-24Merge tag 'v3.18-rc6' into devicetree/nextGrant Likely
v3.18-rc6 contains an important DT bug fix, c1a2086e2d, "of/selftest: Fix off-by-one error in removal path" which affects testing of the overlay patch series. Merge it into the devicetree/next staging branch so that the overlay patches are applied on top of a known working tree. Linux 3.18-rc6 Conflicts: drivers/of/address.c
2014-11-04of/unittest: Rename selftest.c to unittest.cGrant Likely
This is unit testing code. It should use that name because it makes more sense than 'selftest'. Rename the files to match and rename the config variable. Signed-off-by: Grant Likely <grant.likely@linaro.org>