From: Andrei Ziureaev <andrei.ziureaev-5wv7dgnIgG8@public.gmane.org>
To: robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 0/3] dtc: Preserve negative integers in yaml and dts output
Date: Fri, 26 Jun 2020 17:25:25 +0100 [thread overview]
Message-ID: <20200626162528.2129-1-andrei.ziureaev@arm.com> (raw)
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
--
2.17.1
next reply other threads:[~2020-06-26 16:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-26 16:25 Andrei Ziureaev [this message]
[not found] ` <20200626162528.2129-1-andrei.ziureaev-5wv7dgnIgG8@public.gmane.org>
2020-06-26 16:25 ` [PATCH 1/3] dtc: Turn 'uint64_t integer' into a struct Andrei Ziureaev
2020-06-26 16:25 ` [PATCH 2/3] dtc: Preserve negative integers in yaml and dts output Andrei Ziureaev
2020-06-26 16:25 ` [PATCH 3/3] dtc: Add sign preservation tests Andrei Ziureaev
[not found] ` <20200626162528.2129-4-andrei.ziureaev-5wv7dgnIgG8@public.gmane.org>
2020-06-30 1:40 ` Rob Herring
2020-06-30 1:43 ` [PATCH 0/3] dtc: Preserve negative integers in yaml and dts output Rob Herring
2020-07-05 8:59 ` David Gibson
[not found] ` <20200705085940.GB12576-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2020-07-07 15:47 ` Rob Herring
[not found] ` <CAL_JsqJt5a1SGN4JsTLBdO0+7niYh0hvEP_Ta80iuFV-__5TZA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-07-08 11:12 ` David Gibson
[not found] ` <20200708111204.GI18595-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2020-07-08 16:26 ` Rob Herring
[not found] ` <CAL_JsqJ5+um_2XMzzL90K3wS-N98MXP52SBSnJgNQ1agsjz-eg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-07-17 11:13 ` David Gibson
[not found] ` <20200717111316.GK5607-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2020-07-17 20:25 ` Rob Herring
[not found] ` <CAL_JsqKwQ0wFq60EKNz_g8R-We9JKWh7P=hgtRTOYtufac179Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-08-03 8:52 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200626162528.2129-1-andrei.ziureaev@arm.com \
--to=andrei.ziureaev-5wv7dgnigg8@public.gmane.org \
--cc=david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).