devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] Add capability to create property from old property
@ 2025-06-05 10:48 Ayush Singh
  2025-06-05 10:48 ` [PATCH v3 1/4] srcpos: Define srcpos_free Ayush Singh
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Ayush Singh @ 2025-06-05 10:48 UTC (permalink / raw)
  To: David Gibson, Andreas Gnau, d-gole, lorforlinux, jkridner,
	robertcnelson, Andrew Davis, Geert Uytterhoeven, Simon Glass
  Cc: devicetree-compiler, Ayush Singh

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 <ayush@beagleboard.org>
---
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/20250311-previous-value-v2-0-e4a8611e956f@beagleboard.org

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/20250301-previous-value-v1-0-71d612eb0ea9@beagleboard.org

---
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 <ayush@beagleboard.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-12 10:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-05 10:48 [PATCH v3 0/4] Add capability to create property from old property Ayush Singh
2025-06-05 10:48 ` [PATCH v3 1/4] srcpos: Define srcpos_free Ayush Singh
2025-06-09 12:39   ` David Gibson
2025-06-05 10:48 ` [PATCH v3 2/4] dtc: Add data_insert_data function Ayush Singh
2025-06-12 10:56   ` David Gibson
2025-06-05 10:48 ` [PATCH v3 3/4] dtc: Add /./ Ayush Singh
2025-06-05 10:48 ` [PATCH v3 4/4] tests: Add test for /./ Ayush Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).