of: change overlay apply input data from unflattened
Subsystems (2)
v2 cover of: change overlay apply input data from unflattened
From: Frank Rowand <frank.rowand-7U/[email protected]>
Move duplicating and unflattening of an overlay flattened devicetree (FDT) into the overlay application code. To accomplish this, of_overlay_apply() is replaced by of_overlay_fdt_apply().
The copy of the FDT (aka "duplicate FDT") now belongs to devicetree code, which is thus responsible for freeing the duplicate FDT. The caller of of_overlay_fdt_apply() remains responsible for freeing the original FDT.
The unflattened devicetree now belongs to devicetree code, which is thus responsible for freeing the unflattened devicetree.
These ownership changes prevent early freeing of the duplicated FDT or the unflattened devicetree, which could result in use after free errors.
These changes led to migrating some unittest overlay data into their own devicetree source files, and then converting most of them to use sugar syntax instead of hand coding fragments.
Changes from v1:
- rebase on v4.16-rc1
- update documentation
- split out error message to a separate patch
Frank Rowand (4):
of: change overlay apply input data from unflattened to FDT
of: Documentation: of_overlay_apply() replaced by
of_overlay_fdt_apply()
of: convert unittest overlay devicetree source to sugar syntax
of: improve reporting invalid overlay target path
Documentation/devicetree/overlay-notes.txt | 4 +- drivers/of/of_private.h | 1 + drivers/of/overlay.c | 124 +++++++++- drivers/of/resolver.c | 6 - drivers/of/unittest-data/Makefile | 28 ++- drivers/of/unittest-data/overlay.dts | 101 ++++---- drivers/of/unittest-data/overlay_0.dts | 14 ++ drivers/of/unittest-data/overlay_1.dts | 14 ++ drivers/of/unittest-data/overlay_10.dts | 27 +++ drivers/of/unittest-data/overlay_11.dts | 28 +++ drivers/of/unittest-data/overlay_12.dts | 14 ++ drivers/of/unittest-data/overlay_13.dts | 14 ++ drivers/of/unittest-data/overlay_15.dts | 30 +++ drivers/of/unittest-data/overlay_2.dts | 9 + drivers/of/unittest-data/overlay_3.dts | 9 + drivers/of/unittest-data/overlay_4.dts | 18 ++ drivers/of/unittest-data/overlay_5.dts | 9 + drivers/of/unittest-data/overlay_6.dts | 10 + drivers/of/unittest-data/overlay_7.dts | 10 + drivers/of/unittest-data/overlay_8.dts | 10 + drivers/of/unittest-data/overlay_9.dts | 10 + drivers/of/unittest-data/overlay_bad_phandle.dts | 23 +- drivers/of/unittest-data/overlay_bad_symbol.dts | 25 +- drivers/of/unittest-data/tests-overlay.dtsi | 217 +---------------- drivers/of/unittest.c | 294 +++++++++++------------ include/linux/of.h | 7 - 26 files changed, 571 insertions(+), 485 deletions(-) create mode 100644 drivers/of/unittest-data/overlay_0.dts create mode 100644 drivers/of/unittest-data/overlay_1.dts create mode 100644 drivers/of/unittest-data/overlay_10.dts create mode 100644 drivers/of/unittest-data/overlay_11.dts create mode 100644 drivers/of/unittest-data/overlay_12.dts create mode 100644 drivers/of/unittest-data/overlay_13.dts create mode 100644 drivers/of/unittest-data/overlay_15.dts create mode 100644 drivers/of/unittest-data/overlay_2.dts create mode 100644 drivers/of/unittest-data/overlay_3.dts create mode 100644 drivers/of/unittest-data/overlay_4.dts create mode 100644 drivers/of/unittest-data/overlay_5.dts create mode 100644 drivers/of/unittest-data/overlay_6.dts create mode 100644 drivers/of/unittest-data/overlay_7.dts create mode 100644 drivers/of/unittest-data/overlay_8.dts create mode 100644 drivers/of/unittest-data/overlay_9.dts
Signature · 6 lines
Frank Rowand <frank.rowand-7U/[email protected]> -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/4 of: change overlay apply input data from unflattened to FDT
From: Frank Rowand <[email protected]>
Move duplicating and unflattening of an overlay flattened devicetree (FDT) into the overlay application code. To accomplish this, of_overlay_apply() is replaced by of_overlay_fdt_apply().
The copy of the FDT (aka "duplicate FDT") now belongs to devicetree code, which is thus responsible for freeing the duplicate FDT. The caller of of_overlay_fdt_apply() remains responsible for freeing the original FDT.
The unflattened devicetree now belongs to devicetree code, which is thus responsible for freeing the unflattened devicetree.
These ownership changes prevent early freeing of the duplicated FDT or the unflattened devicetree, which could result in use after free errors.
of_overlay_fdt_apply() is a private function for the anticipated overlay loader.
Update unittest.c to use of_overlay_fdt_apply() instead of of_overlay_apply().
Move overlay fragments from artificial locations in drivers/of/unittest-data/tests-overlay.dtsi into one devicetree source file per overlay. This led to changes in drivers/of/unitest-data/Makefile and drivers/of/unitest.c.
- Add overlay directives to the overlay devicetree source files so that dtc will compile them as true overlays into one FDT data chunk per overlay.
- Set CFLAGS for drivers/of/unittest-data/testcases.dts so that symbols will be generated for overlay resolution of overlays that are no longer artificially contained in testcases.dts
- Unflatten and apply each unittest overlay FDT using
of_overlay_fdt_apply().
- Enable the of_resolve_phandles() check for whether the unflattened overlay is detached. This check was previously disabled because the overlays from tests-overlay.dtsi were not unflattened into detached trees.
- Other changes to unittest.c infrastructure to manage multiple test FDTs built into the kernel image (access by name instead of arbitrary number).
- of_unittest_overlay_high_level(): previously unused code to add properties from the overlay_base devicetree to the live tree was triggered by the restructuring of tests-overlay.dtsi and thus testcases.dts. This exposed two bugs: (1) the need to dup a property before adding it, and (2) property 'name' is auto-generated in the unflatten code and thus will be a duplicate in the __symbols__ node - do not treat this duplicate as an error.
---
Changes from v1:
- rebase on v4.16-rc1
There are checkpatch warnings. I have reviewed them and feel they can be ignored. They are "line over 80 characters" for either pre-existing long lines, or lines in devicetree source files.
drivers/of/of_private.h | 1 + drivers/of/overlay.c | 107 +++++++++- drivers/of/resolver.c | 6 - drivers/of/unittest-data/Makefile | 28 ++- drivers/of/unittest-data/overlay_0.dts | 14 ++ drivers/of/unittest-data/overlay_1.dts | 14 ++ drivers/of/unittest-data/overlay_10.dts | 34 ++++ drivers/of/unittest-data/overlay_11.dts | 34 ++++ drivers/of/unittest-data/overlay_12.dts | 14 ++ drivers/of/unittest-data/overlay_13.dts | 14 ++ drivers/of/unittest-data/overlay_15.dts | 35 ++++ drivers/of/unittest-data/overlay_2.dts | 14 ++ drivers/of/unittest-data/overlay_3.dts | 14 ++ drivers/of/unittest-data/overlay_4.dts | 23 +++ drivers/of/unittest-data/overlay_5.dts | 14 ++ drivers/of/unittest-data/overlay_6.dts | 15 ++ drivers/of/unittest-data/overlay_7.dts | 15 ++ drivers/of/unittest-data/overlay_8.dts | 15 ++ drivers/of/unittest-data/overlay_9.dts | 15 ++ drivers/of/unittest-data/tests-overlay.dtsi | 213 -------------------- drivers/of/unittest.c | 294 ++++++++++++++-------------- include/linux/of.h | 7 - 22 files changed, 551 insertions(+), 389 deletions(-) create mode 100644 drivers/of/unittest-data/overlay_0.dts create mode 100644 drivers/of/unittest-data/overlay_1.dts create mode 100644 drivers/of/unittest-data/overlay_10.dts create mode 100644 drivers/of/unittest-data/overlay_11.dts create mode 100644 drivers/of/unittest-data/overlay_12.dts create mode 100644 drivers/of/unittest-data/overlay_13.dts create mode 100644 drivers/of/unittest-data/overlay_15.dts create mode 100644 drivers/of/unittest-data/overlay_2.dts create mode 100644 drivers/of/unittest-data/overlay_3.dts create mode 100644 drivers/of/unittest-data/overlay_4.dts create mode 100644 drivers/of/unittest-data/overlay_5.dts create mode 100644 drivers/of/unittest-data/overlay_6.dts create mode 100644 drivers/of/unittest-data/overlay_7.dts create mode 100644 drivers/of/unittest-data/overlay_8.dts create mode 100644 drivers/of/unittest-data/overlay_9.dts
drivers/of/of_private.h +1 -0
@@ -77,6 +77,7 @@ static inline void __of_detach_node_sysfs(struct device_node *np) {}#endif #if defined(CONFIG_OF_OVERLAY ) +int of_overlay_fdt_apply (void *overlay_fdt,int *ovcs_id);void of_overlay_mutex_lock (void );void of_overlay_mutex_unlock (void );#else
drivers/of/overlay.c +98 -9
204 lines not on this page · raw message
drivers/of/resolver.c +0 -6
@@ -248,17 +248,11 @@ int of_resolve_phandles(struct device_node *overlay) goto out; } -#if 0 - Temporarily disable check so that old style overlay unittests - do not fail when of_resolve_phandles() is moved into - of_overlay_apply(). -if (!of_node_check_flag (overlay,OF_DETACHED )) {pr_err ("overlay not detached\n" ); err = -EINVAL ; goto out; } -#endif phandle_delta =live_tree_max_phandle () +1 ;adjust_overlay_phandles (overlay, phandle_delta);
drivers/of/unittest-data/Makefile +23 -5
@@ -1,8 +1,22 @@ # SPDX-License-Identifier: GPL-2.0 -DTC_FLAGS_testcases := -Wno-interrupts_property obj-y += testcases.dtb.o obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \ + overlay_0.dtb.o \ + overlay_1.dtb.o \ + overlay_2.dtb.o \ + overlay_3.dtb.o \ + overlay_4.dtb.o \ + overlay_5.dtb.o \ + overlay_6.dtb.o \ + overlay_7.dtb.o \ + overlay_8.dtb.o \ + overlay_9.dtb.o \ + overlay_10.dtb.o \ + overlay_11.dtb.o \ + overlay_12.dtb.o \ + overlay_13.dtb.o \ + overlay_15.dtb.o \ overlay_bad_phandle.dtb.o \ overlay_bad_symbol.dtb.o \ overlay_base.dtb.o
@@ -10,10 +24,14 @@ obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \ targets += $(foreach suffix, dtb dtb.S, $(patsubst %.dtb.o,%.$(suffix),$(obj-y))) # enable creation of __symbols__ node -DTC_FLAGS_overlay := -@ -DTC_FLAGS_overlay_bad_phandle := -@ -DTC_FLAGS_overlay_bad_symbol := -@ -DTC_FLAGS_overlay_base := -@ +DTC_FLAGS_overlay += -@ +DTC_FLAGS_overlay_bad_phandle += -@ +DTC_FLAGS_overlay_bad_symbol += -@ +DTC_FLAGS_overlay_base += -@ +DTC_FLAGS_testcases += -@ + +# suppress warnings about intentional errors +DTC_FLAGS_testcases += -Wno-interrupts_property .PRECIOUS: \ $(obj)/%.dtb.S \
drivers/of/unittest-data/overlay_0.dts new file +14 -0
@@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_0 - enable using absolute target path */ + + fragment@0 { + target-path = "/testcase-data/overlay-node/test-bus/test-unittest0"; + __overlay__ { + status = "okay"; + }; + }; +};
drivers/of/unittest-data/overlay_1.dts new file +14 -0
@@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_1 - disable using absolute target path */ + + fragment@0 { + target-path = "/testcase-data/overlay-node/test-bus/test-unittest1"; + __overlay__ { + status = "disabled"; + }; + }; +};
drivers/of/unittest-data/overlay_10.dts new file +34 -0
@@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_10 */ + /* overlays 8, 9, 10, 11 application and removal in bad sequence */ + + fragment@0 { + target-path = "/testcase-data/overlay-node/test-bus"; + __overlay__ { + + /* suppress DTC warning */ + #address-cells = <1>; + #size-cells = <0>; + + test-unittest10 { + compatible = "unittest"; + status = "okay"; + reg = <10>; + + #address-cells = <1>; + #size-cells = <0>; + + test-unittest101 { + compatible = "unittest"; + status = "okay"; + reg = <1>; + }; + + }; + }; + }; +};
drivers/of/unittest-data/overlay_11.dts new file +34 -0
@@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_11 */ + /* overlays 8, 9, 10, 11 application and removal in bad sequence */ + + fragment@0 { + target-path = "/testcase-data/overlay-node/test-bus"; + __overlay__ { + + /* suppress DTC warning */ + #address-cells = <1>; + #size-cells = <0>; + + test-unittest11 { + compatible = "unittest"; + status = "okay"; + reg = <11>; + + #address-cells = <1>; + #size-cells = <0>; + + test-unittest111 { + compatible = "unittest"; + status = "okay"; + reg = <1>; + }; + + }; + }; + }; +};
drivers/of/unittest-data/overlay_12.dts new file +14 -0
@@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_12 - enable using absolute target path (i2c) */ + + fragment@0 { + target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest12"; + __overlay__ { + status = "okay"; + }; + }; +};
drivers/of/unittest-data/overlay_13.dts new file +14 -0
@@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_13 - disable using absolute target path (i2c) */ + + fragment@0 { + target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest13"; + __overlay__ { + status = "disabled"; + }; + }; +};
drivers/of/unittest-data/overlay_15.dts new file +35 -0
@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_15 - mux overlay */ + + fragment@0 { + target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus"; + __overlay__ { + #address-cells = <1>; + #size-cells = <0>; + test-unittest15 { + reg = <11>; + compatible = "unittest-i2c-mux"; + status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; + + i2c@0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + test-mux-dev { + reg = <32>; + compatible = "unittest-i2c-dev"; + status = "okay"; + }; + }; + }; + }; + }; +};
drivers/of/unittest-data/overlay_2.dts new file +14 -0
@@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_2 - enable using label */ + + fragment@0 { + target = <&unittest2>; + __overlay__ { + status = "okay"; + }; + }; +};
drivers/of/unittest-data/overlay_3.dts new file +14 -0
@@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_3 - disable using label */ + + fragment@0 { + target = <&unittest3>; + __overlay__ { + status = "disabled"; + }; + }; +};
drivers/of/unittest-data/overlay_4.dts new file +23 -0
@@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_4 - test insertion of a full node */ + + fragment@0 { + target = <&unittestbus>; + __overlay__ { + + /* suppress DTC warning */ + #address-cells = <1>; + #size-cells = <0>; + + test-unittest4 { + compatible = "unittest"; + status = "okay"; + reg = <4>; + }; + }; + }; +};
drivers/of/unittest-data/overlay_5.dts new file +14 -0
@@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_5 - test overlay apply revert */ + + fragment@0 { + target-path = "/testcase-data/overlay-node/test-bus/test-unittest5"; + __overlay__ { + status = "okay"; + }; + }; +};
drivers/of/unittest-data/overlay_6.dts new file +15 -0
@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_6 */ + /* overlays 6, 7 application and removal in sequence */ + + fragment@0 { + target-path = "/testcase-data/overlay-node/test-bus/test-unittest6"; + __overlay__ { + status = "okay"; + }; + }; +};
drivers/of/unittest-data/overlay_7.dts new file +15 -0
@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_7 */ + /* overlays 6, 7 application and removal in sequence */ + + fragment@0 { + target-path = "/testcase-data/overlay-node/test-bus/test-unittest7"; + __overlay__ { + status = "okay"; + }; + }; +};
drivers/of/unittest-data/overlay_8.dts new file +15 -0
@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_8 */ + /* overlays 8, 9, 10, 11 application and removal in bad sequence */ + + fragment@0 { + target-path = "/testcase-data/overlay-node/test-bus/test-unittest8"; + __overlay__ { + status = "okay"; + }; + }; +};
drivers/of/unittest-data/overlay_9.dts new file +15 -0
@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + /* overlay_9 */ + /* overlays 8, 9, 10, 11 application and removal in bad sequence */ + + fragment@0 { + target-path = "/testcase-data/overlay-node/test-bus/test-unittest8"; + __overlay__ { + property-foo = "bar"; + }; + }; +};
drivers/of/unittest-data/tests-overlay.dtsi +0 -213
218 lines not on this page · raw message
drivers/of/unittest.c +145 -149
575 lines not on this page · raw message
include/linux/of.h +0 -7
@@ -1359,8 +1359,6 @@ struct of_overlay_notify_data {#ifdef CONFIG_OF_OVERLAY -/* ID based overlays; the API for external users */ -int of_overlay_apply (struct device_node *tree,int *ovcs_id);int of_overlay_remove (int *ovcs_id);int of_overlay_remove_all (void );
@@ -1369,11 +1367,6 @@ struct of_overlay_notify_data {#else -static inline int of_overlay_apply (struct device_node *tree,int *ovcs_id) -{ -return -ENOTSUPP ; -} -static inline int of_overlay_remove (int *ovcs_id) {return -ENOTSUPP ;
Signature · 1 line
Frank Rowand <[email protected]>
PATCH v2 2/4 of: Documentation: of_overlay_apply() replaced by of_overlay_fdt_apply()
In reply to [email protected]From: Frank Rowand <[email protected]>
---
Changes from v1:
- new patch
Documentation/devicetree/overlay-notes.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/overlay-notes.txt +2 -2
@@ -87,8 +87,8 @@ Overlay in-kernel API The API is quite easy to use. -1. Call of_overlay_apply() to create and apply an overlay changeset. The return -value is an error or a cookie identifying this overlay. +1. Call of_overlay_fdt_apply() to create and apply an overlay changeset. The +return value is an error or a cookie identifying this overlay. 2. Call of_overlay_remove() to remove and cleanup the overlay changeset previously created via the call to of_overlay_apply(). Removal of an overlay
Signature · 1 line
Frank Rowand <[email protected]>
PATCH v2 3/4 of: convert unittest overlay devicetree source to sugar syntax
In reply to [email protected]From: Frank Rowand <[email protected]>
The unittest-data overlays have been pulled into proper overlay devicetree source files without changing their format. The next step is to convert them to use sugar syntax instead of hand coding overlay fragments structure.
A few of the overlays can not be converted because they test absolute target paths in the overlay fragment. dtc does not generate this type of target:
overlay_0.dts
overlay_1.dts
overlay_12.dts
overlay_13.dts
Two pre-existing unittest overlay devicetree source files are also converted:
overlay_bad_phandle.dts
overlay_bad_symbol.dts
---
Changes from v1:
- rebase on v4.16-rc1
There are checkpatch warnings. I have reviewed them and feel they can be ignored. They are pre-existing warnings of un-documented bindings of made up (fake) compatibles in devicetree source for test overlays.
drivers/of/unittest-data/overlay.dts | 101 ++++++++++------------- drivers/of/unittest-data/overlay_10.dts | 39 ++++----- drivers/of/unittest-data/overlay_11.dts | 40 ++++----- drivers/of/unittest-data/overlay_15.dts | 41 ++++----- drivers/of/unittest-data/overlay_2.dts | 11 +-- drivers/of/unittest-data/overlay_3.dts | 11 +-- drivers/of/unittest-data/overlay_4.dts | 23 ++---- drivers/of/unittest-data/overlay_5.dts | 11 +-- drivers/of/unittest-data/overlay_6.dts | 13 +-- drivers/of/unittest-data/overlay_7.dts | 13 +-- drivers/of/unittest-data/overlay_8.dts | 13 +-- drivers/of/unittest-data/overlay_9.dts | 13 +-- drivers/of/unittest-data/overlay_bad_phandle.dts | 23 ++---- drivers/of/unittest-data/overlay_bad_symbol.dts | 25 ++---- drivers/of/unittest-data/tests-overlay.dtsi | 4 +- 15 files changed, 148 insertions(+), 233 deletions(-)
drivers/of/unittest-data/overlay.dts +44 -57
@@ -2,76 +2,63 @@ /dts-v1/; /plugin/; -/ { +&electric_1 { - fragment@0 { - target = <&electric_1>; + status = "okay"; - __overlay__ { - status = "okay"; - - hvac_2: hvac-large-1 { - compatible = "ot,hvac-large"; - heat-range = < 40 75 >; - cool-range = < 65 80 >; - }; - }; + hvac_2: hvac-large-1 { + compatible = "ot,hvac-large"; + heat-range = < 40 75 >; + cool-range = < 65 80 >; }; +}; - fragment@1 { - target = <&rides_1>; - - __overlay__ { - #address-cells = <1>; - #size-cells = <1>; - status = "okay"; - - ride@100 { - #address-cells = <1>; - #size-cells = <1>; - - track@30 { - incline-up = < 48 32 16 >; - }; +&rides_1 { - track@40 { - incline-up = < 47 31 15 >; - }; - }; + #address-cells = <1>; + #size-cells = <1>; + status = "okay"; - ride_200: ride@200 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "ot,ferris-wheel"; - reg = < 0x00000200 0x100 >; - hvac-provider = < &hvac_2 >; - hvac-thermostat = < 27 32 > ; - hvac-zones = < 12 5 >; - hvac-zone-names = "operator", "snack-bar"; - spin-controller = < &spin_ctrl_1 3 >; - spin-rph = < 30 >; - gondolas = < 16 >; - gondola-capacity = < 6 >; + ride@100 { + #address-cells = <1>; + #size-cells = <1>; - ride_200_left: track@10 { - reg = < 0x00000010 0x10 >; - }; + track@30 { + incline-up = < 48 32 16 >; + }; - ride_200_right: track@20 { - reg = < 0x00000020 0x10 >; - }; - }; + track@40 { + incline-up = < 47 31 15 >; }; }; - fragment@2 { - target = <&lights_2>; + ride_200: ride@200 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "ot,ferris-wheel"; + reg = < 0x00000200 0x100 >; + hvac-provider = < &hvac_2 >; + hvac-thermostat = < 27 32 > ; + hvac-zones = < 12 5 >; + hvac-zone-names = "operator", "snack-bar"; + spin-controller = < &spin_ctrl_1 3 >; + spin-rph = < 30 >; + gondolas = < 16 >; + gondola-capacity = < 6 >; + + ride_200_left: track@10 { + reg = < 0x00000010 0x10 >; + }; - __overlay__ { - status = "okay"; - color = "purple", "white", "red", "green"; - rate = < 3 256 >; + ride_200_right: track@20 { + reg = < 0x00000020 0x10 >; }; }; +}; + +&lights_2 { + status = "okay"; + color = "purple", "white", "red", "green"; + rate = < 3 256 >; };
drivers/of/unittest-data/overlay_10.dts +16 -23
@@ -2,33 +2,26 @@ /dts-v1/; /plugin/; -/ { - /* overlay_10 */ - /* overlays 8, 9, 10, 11 application and removal in bad sequence */ +/* overlay_10 */ +/* overlays 8, 9, 10, 11 application and removal in bad sequence */ - fragment@0 { - target-path = "/testcase-data/overlay-node/test-bus"; - __overlay__ { +&unittest_test_bus { + /* suppress DTC warning */ + #address-cells = <1>; + #size-cells = <0>; - /* suppress DTC warning */ - #address-cells = <1>; - #size-cells = <0>; + test-unittest10 { + compatible = "unittest"; + status = "okay"; + reg = <10>; - test-unittest10 { - compatible = "unittest"; - status = "okay"; - reg = <10>; + #address-cells = <1>; + #size-cells = <0>; - #address-cells = <1>; - #size-cells = <0>; - - test-unittest101 { - compatible = "unittest"; - status = "okay"; - reg = <1>; - }; - - }; + test-unittest101 { + compatible = "unittest"; + status = "okay"; + reg = <1>; }; }; };
drivers/of/unittest-data/overlay_11.dts +17 -23
@@ -2,33 +2,27 @@ /dts-v1/; /plugin/; -/ { - /* overlay_11 */ - /* overlays 8, 9, 10, 11 application and removal in bad sequence */ +/* overlay_11 */ +/* overlays 8, 9, 10, 11 application and removal in bad sequence */ - fragment@0 { - target-path = "/testcase-data/overlay-node/test-bus"; - __overlay__ { +&unittest_test_bus { + /* suppress DTC warning */ + #address-cells = <1>; + #size-cells = <0>; - /* suppress DTC warning */ - #address-cells = <1>; - #size-cells = <0>; + test-unittest11 { + compatible = "unittest"; + status = "okay"; + reg = <11>; - test-unittest11 { - compatible = "unittest"; - status = "okay"; - reg = <11>; + #address-cells = <1>; + #size-cells = <0>; - #address-cells = <1>; - #size-cells = <0>; - - test-unittest111 { - compatible = "unittest"; - status = "okay"; - reg = <1>; - }; - - }; + test-unittest111 { + compatible = "unittest"; + status = "okay"; + reg = <1>; }; + }; };
drivers/of/unittest-data/overlay_15.dts +18 -23
51 lines not on this page · raw message
drivers/of/unittest-data/overlay_2.dts +3 -8
@@ -2,13 +2,8 @@ /dts-v1/; /plugin/; -/ { - /* overlay_2 - enable using label */ +/* overlay_2 - enable using label */ - fragment@0 { - target = <&unittest2>; - __overlay__ { - status = "okay"; - }; - }; +&unittest2 { + status = "okay"; };
drivers/of/unittest-data/overlay_3.dts +3 -8
@@ -2,13 +2,8 @@ /dts-v1/; /plugin/; -/ { - /* overlay_3 - disable using label */ +/* overlay_3 - disable using label */ - fragment@0 { - target = <&unittest3>; - __overlay__ { - status = "disabled"; - }; - }; +&unittest3 { + status = "disabled"; };
drivers/of/unittest-data/overlay_4.dts +9 -14
@@ -2,22 +2,17 @@ /dts-v1/; /plugin/; -/ { - /* overlay_4 - test insertion of a full node */ +/* overlay_4 - test insertion of a full node */ - fragment@0 { - target = <&unittestbus>; - __overlay__ { +&unittest_test_bus { - /* suppress DTC warning */ - #address-cells = <1>; - #size-cells = <0>; + /* suppress DTC warning */ + #address-cells = <1>; + #size-cells = <0>; - test-unittest4 { - compatible = "unittest"; - status = "okay"; - reg = <4>; - }; - }; + test-unittest4 { + compatible = "unittest"; + status = "okay"; + reg = <4>; }; };
drivers/of/unittest-data/overlay_5.dts +3 -8
@@ -2,13 +2,8 @@ /dts-v1/; /plugin/; -/ { - /* overlay_5 - test overlay apply revert */ +/* overlay_5 - test overlay apply revert */ - fragment@0 { - target-path = "/testcase-data/overlay-node/test-bus/test-unittest5"; - __overlay__ { - status = "okay"; - }; - }; +&unittest5 { + status = "okay"; };
drivers/of/unittest-data/overlay_6.dts +4 -9
@@ -2,14 +2,9 @@ /dts-v1/; /plugin/; -/ { - /* overlay_6 */ - /* overlays 6, 7 application and removal in sequence */ +/* overlay_6 */ +/* overlays 6, 7 application and removal in sequence */ - fragment@0 { - target-path = "/testcase-data/overlay-node/test-bus/test-unittest6"; - __overlay__ { - status = "okay"; - }; - }; +&unittest6 { + status = "okay"; };
drivers/of/unittest-data/overlay_7.dts +4 -9
@@ -2,14 +2,9 @@ /dts-v1/; /plugin/; -/ { - /* overlay_7 */ - /* overlays 6, 7 application and removal in sequence */ +/* overlay_7 */ +/* overlays 6, 7 application and removal in sequence */ - fragment@0 { - target-path = "/testcase-data/overlay-node/test-bus/test-unittest7"; - __overlay__ { - status = "okay"; - }; - }; +&unittest7 { + status = "okay"; };
drivers/of/unittest-data/overlay_8.dts +4 -9
@@ -2,14 +2,9 @@ /dts-v1/; /plugin/; -/ { - /* overlay_8 */ - /* overlays 8, 9, 10, 11 application and removal in bad sequence */ +/* overlay_8 */ +/* overlays 8, 9, 10, 11 application and removal in bad sequence */ - fragment@0 { - target-path = "/testcase-data/overlay-node/test-bus/test-unittest8"; - __overlay__ { - status = "okay"; - }; - }; +&unittest8 { + status = "okay"; };
drivers/of/unittest-data/overlay_9.dts +4 -9
@@ -2,14 +2,9 @@ /dts-v1/; /plugin/; -/ { - /* overlay_9 */ - /* overlays 8, 9, 10, 11 application and removal in bad sequence */ +/* overlay_9 */ +/* overlays 8, 9, 10, 11 application and removal in bad sequence */ - fragment@0 { - target-path = "/testcase-data/overlay-node/test-bus/test-unittest8"; - __overlay__ { - property-foo = "bar"; - }; - }; +&unittest8 { + property-foo = "bar"; };
drivers/of/unittest-data/overlay_bad_phandle.dts +8 -15
@@ -2,20 +2,13 @@ /dts-v1/; /plugin/; -/ { - - fragment@0 { - target = <&electric_1>; - - __overlay__ { - - // This label should cause an error when the overlay - // is applied. There is already a phandle value - // in the base tree for motor-1. - spin_ctrl_1_conflict: motor-1 { - accelerate = < 3 >; - decelerate = < 5 >; - }; - }; +&electric_1 { + + // This label should cause an error when the overlay + // is applied. There is already a phandle value + // in the base tree for motor-1. + spin_ctrl_1_conflict: motor-1 { + accelerate = < 3 >; + decelerate = < 5 >; }; };
drivers/of/unittest-data/overlay_bad_symbol.dts +9 -16
@@ -2,22 +2,15 @@ /dts-v1/; /plugin/; -/ { +&electric_1 { - fragment@0 { - target = <&electric_1>; - - __overlay__ { - - // This label should cause an error when the overlay - // is applied. There is already a symbol hvac_1 - // in the base tree - hvac_1: hvac-medium-2 { - compatible = "ot,hvac-medium"; - heat-range = < 50 75 >; - cool-range = < 60 80 >; - }; - - }; + // This label should cause an error when the overlay + // is applied. There is already a symbol hvac_1 + // in the base tree + hvac_1: hvac-medium-2 { + compatible = "ot,hvac-medium"; + heat-range = < 50 75 >; + cool-range = < 60 80 >; }; + };
drivers/of/unittest-data/tests-overlay.dtsi +2 -2
@@ -5,7 +5,7 @@ overlay-node { /* test bus */ - unittestbus: test-bus { + unittest_test_bus: test-bus { compatible = "simple-bus"; #address-cells = <1>; #size-cells = <0>;
@@ -70,7 +70,7 @@ reg = <8>; }; - i2c-test-bus { + unittest_i2c_test_bus: i2c-test-bus { compatible = "unittest-i2c-bus"; status = "okay"; reg = <50>;
Signature · 1 line
Frank Rowand <[email protected]>
PATCH v2 4/4 of: improve reporting invalid overlay target path
In reply to [email protected]From: Frank Rowand <[email protected]>
Errors while developing the patch to create of_overlay_fdt_apply() exposed inadequate error messages to debug problems when overlay devicetree fragment nodes contain an invalid target path. Improve the messages in find_target_node() to remedy this.
---
Changes from v1:
- split out from patch 1/2
drivers/of/overlay.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/of/overlay.c +13 -4
@@ -488,17 +488,26 @@ static int build_changeset(struct overlay_changeset *ovcs)*/ static struct device_node *find_target_node (struct device_node *info_node) { +struct device_node *node;const char *path;u32 val;int ret; ret =of_property_read_u32 (info_node,"target" , &val); -if (!ret) -return of_find_node_by_phandle (val); +if (!ret) { + node =of_find_node_by_phandle (val); +if (!node) +pr_err ("target node find by phandle failed\n" ); +return node; + } ret =of_property_read_string (info_node,"target-path" , &path); -if (!ret) -return of_find_node_by_path (path); +if (!ret) { + node =of_find_node_by_path (path); +if (!node) +pr_err ("target node find by path failed\n" ); +return node; + }pr_err ("Failed to find target for node %p (%s)\n" , info_node, info_node->name);
Signature · 1 line
Frank Rowand <[email protected]>
Re: [PATCH v2 4/4] of: improve reporting invalid overlay target path
Hi Frank,
Quoted 8 lines · On Mon, Feb 12, 2018 at 9:51 AM, <[email protected]> wrote:
From: Frank Rowand <[email protected]>
Errors while developing the patch to create
of_overlay_fdt_apply()exposed inadequate error messages to debug problems when overlay devicetree fragment nodes contain an invalid target path. Improve the messages infind_target_node()to remedy this.Signed-off-by Frank Rowand <[email protected]>
Thanks for your patch!
Quoted 8 lines
drivers/of/overlay.c +1
-0@@ -488,17 +488,26 @@ static int build_changeset(struct overlay_changeset *ovcs)*/ static struct device_node *find_target_node (struct device_node *info_node) { +struct device_node *node;const char *path;
drivers/of/overlay.c static int build_changeset(struct overlay_changeset *ovcs) · line 500
Quoted 10 lines
drivers/of/overlay.c +4
-2u32 val;int ret; ret =of_property_read_u32 (info_node,"target" , &val); -if (!ret) -return of_find_node_by_phandle (val); +if (!ret) { + node =of_find_node_by_phandle (val); +if (!node) +pr_err ("target node find by phandle failed\n" );
Do you want to print the actual node, cfr. below?
drivers/of/overlay.c static int build_changeset(struct overlay_changeset *ovcs) · line 508
Quoted 10 lines
drivers/of/overlay.c +6
-2+return node; + } ret =of_property_read_string (info_node,"target-path" , &path); -if (!ret) -return of_find_node_by_path (path); +if (!ret) { + node =of_find_node_by_path (path); +if (!node) +pr_err ("target node find by path failed\n" );
Likewise.
drivers/of/overlay.c static int build_changeset(struct overlay_changeset *ovcs) · line 513
Quoted 5 lines
drivers/of/overlay.c +2
-0+return node; + }pr_err ("Failed to find target for node %p (%s)\n" , info_node, info_node->name);
This one prints more info.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH v2 4/4] of: improve reporting invalid overlay target path
Quoted 25 lines · Geert Uytterhoeven
Hi Frank,
Quoted 8 lines · On Mon, Feb 12, 2018 at 9:51 AM, <[email protected]> wrote:
From: Frank Rowand <[email protected]>
Errors while developing the patch to create
of_overlay_fdt_apply()exposed inadequate error messages to debug problems when overlay devicetree fragment nodes contain an invalid target path. Improve the messages infind_target_node()to remedy this.Signed-off-by Frank Rowand <[email protected]>Thanks for your patch!
Quoted 11 lines
drivers/of/overlay.c +1
-0@@ -488,17 +488,26 @@ static int build_changeset(struct overlay_changeset *ovcs)*/ static struct device_node *find_target_node (struct device_node *info_node) { +struct device_node *node;const char *path;u32 val;int ret;
Quoted 9 lines
drivers/of/overlay.c static int build_changeset(struct overlay_changeset *ovcs) · line 500
Quoted 7 lines
drivers/of/overlay.c +4
-2ret =of_property_read_u32 (info_node,"target" , &val); -if (!ret) -return of_find_node_by_phandle (val); +if (!ret) { + node =of_find_node_by_phandle (val); +if (!node) +pr_err ("target node find by phandle failed\n" );Do you want to print the actual node, cfr. below?
That seems like a good idea. The name printed below is the (short) node name of the fragment, which seems useful.
Will do, but will remove the pointer to the node, which is more of an internal debugging detail.
Quoted 11 lines
drivers/of/overlay.c static int build_changeset(struct overlay_changeset *ovcs) · line 508
Quoted 10 lines
drivers/of/overlay.c +6
-2+return node; + } ret =of_property_read_string (info_node,"target-path" , &path); -if (!ret) -return of_find_node_by_path (path); +if (!ret) { + node =of_find_node_by_path (path); +if (!node) +pr_err ("target node find by path failed\n" );
Quoted 1 line
Likewise.
Will do.
Quoted 19 lines
drivers/of/overlay.c static int build_changeset(struct overlay_changeset *ovcs) · line 513
Quoted 5 lines
drivers/of/overlay.c +2
-0+return node; + }pr_err ("Failed to find target for node %p (%s)\n" , info_node, info_node->name);This one prints more info.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds