[PATCH v3 0/4] Add capability to create property from old property

Ayush Singh <[email protected]>
Newsgroups org.kernel.vger.devicetree-compiler
Message-ID <[email protected]>
Allow construction of new values for a property using old property
value.

This was originally suggested in /append-property/ Patch series [0] and
can be used to achieve the same results (and much more).

In practice, it looks as follows:

dts-v1/;

/ {
	str-prop = "0";
	int-prop = <0>;
};

/ {
	str-prop = /./, "1", /./;
	int-prop = /./, <1>, /./;
};

dts to source output with -T -T also works as expected:

/dts-v1/;

/ { /* base.dts:3:3-5:3, base.dts:7:3-9:3 */
        int-prop = <0x00 0x01>, <0x02 0x03>, <0x00 0x01>; /* base.dts:4:9-4:26, base.dts:8:9-8:36 */
}; /* base.dts:3:3-5:3, base.dts:7:3-9:3 */

[0]: https://lore.kernel.org/devicetree-compiler/Z24nldCpXpoT7RaK@zatzit/T/#t

Signed-off-by: Ayush Singh <[email protected]>
---
Changes in v3:
- Rebase on main
- Fix Patch 2 commit message example.
- Rename `data_insert_old_value` to `data_insert_data`.
- Move `data_insert_data` to data.c and split into independent patch.
- Rename `DT_PREV_PROP` to `DT_PREV_VALUE`.
- Make `prev_value_used` local to while loop.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Compare against expected dtb instead of checking each property
  individually in tests.
- Use xstrdup when copying refs so each marker has it's own copy.
- Pass struct data by value, not by pointer.
- Add srcpos_free helper to properly free srcpos which have been
  extended previously.
- Remove open items since my original choices seem correct.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Ayush Singh (4):
      srcpos: Define srcpos_free
      dtc: Add data_insert_data function
      dtc: Add /./
      tests: Add test for /./

 data.c                       | 27 +++++++++++++++++++++++++++
 dtc-lexer.l                  |  5 +++++
 dtc-parser.y                 |  5 +++++
 dtc.h                        |  2 ++
 livetree.c                   | 23 +++++++++++++++++++++--
 srcpos.c                     | 11 +++++++++++
 srcpos.h                     |  1 +
 tests/prev_prop.dts          | 25 +++++++++++++++++++++++++
 tests/prev_prop_expected.dts | 13 +++++++++++++
 tests/run_tests.sh           |  5 +++++
 10 files changed, 115 insertions(+), 2 deletions(-)
---
base-commit: e0b7749c26a9ea28a480bca4a87d238e284ac68f
change-id: 20241227-previous-value-c22d4eeaae72

Best regards,
-- 
Ayush Singh <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.