Skip to content

dtc: Preserve negative integers in yaml and dts output

Andrei Ziureaev devicetree-compiler 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3dtc: Turn 'uint64_t integer' into a structdtc-lexer.l dtc-parser.y dtc.h+102 -380 replies
2/3dtc: Preserve negative integers in yaml and dts outputdtc-parser.y dtc.h treesource.c +1 more+63 -240 replies
3/3dtc: Add sign preservation teststests/run_tests.sh tests/sign-preservation-bytes.dt.yaml tests/sign-preservation-bytes.dts +2 more+62 -21 reply

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchRob Herring
1/3
2/3
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/3] dtc: Preserve negative integers in yaml and dts output

Currently, in yaml output, negative values are indistinguishable from positive ones. Some bindings (for example Documentation/devicetree/bindings/iio/accel/lis302.txt) mention negative values. If those binding are converted to yaml, dt-schema validation wouldn't work with them.

The first patch is a mechanical change and shouldn't affect dtc's behaviour.

The second one is the functional change. When applied, dts to dts and dts to yaml conversions preserve the '-' sign in front of integers.

For now, in dts parsing, only the unary '-' operator creates negative values (the other operators just set the 'is_negative' flag to false), but it should be easy to add support for other operators if needed.

One issue is that there are two ways to format an array of bytes in dts:
'/bits/ 8 <...>' and '[...]'. Only the former supports negative integers. But, in dts output, only the latter is used. Therefore, I didn't include support for negative 8-bit values in dts output (I did add support for them in yaml output). Some possible alternatives are:

- switch to the '/bits/ 8 <>' format in dts output

- only switch to the '/bits/ 8 <>' format if the array contains negative values

- add another marker to differentiate between the two formats

Thanks,
Andrei.

Andrei Ziureaev (3):
dtc: Turn 'uint64_t integer' into a struct
dtc: Preserve negative integers in yaml and dts output
dtc: Add sign preservation tests

 dtc-lexer.l                           |  10 +-
 dtc-parser.y                          | 132 +++++++++++++++++++-------
 dtc.h                                 |  14 +++
 tests/run_tests.sh                    |   4 +-
 tests/sign-preservation-bytes.dt.yaml |   5 +
 tests/sign-preservation-bytes.dts     |   7 ++
 tests/sign-preservation.dt.yaml       |  20 ++++
 tests/sign-preservation.dts           |  28 ++++++
 treesource.c                          |  35 +++++--
 yamltree.c                            |  32 ++++---
 10 files changed, 225 insertions(+), 62 deletions(-)
 create mode 100644 tests/sign-preservation-bytes.dt.yaml
 create mode 100644 tests/sign-preservation-bytes.dts
 create mode 100644 tests/sign-preservation.dt.yaml
 create mode 100644 tests/sign-preservation.dts
Signature · 1 line
2.17.1