From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v3 5/5] treesource: Maintain phandle label/path on output
Date: Mon, 11 Oct 2021 16:21:43 +1100 [thread overview]
Message-ID: <YWPJ5y9nMlW43pbd@yekko> (raw)
In-Reply-To: <20210727183023.3212077-6-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 3952 bytes --]
On Tue, Jul 27, 2021 at 12:30:23PM -0600, Rob Herring wrote:
> The dts output will just output phandle integer values, but often the
> necessary markers are present with path or label references. Improve the
> output and maintain phandle label or path references when present in dts
> output.
>
> Signed-off-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
I actually like this one, regardless of the rest, so I've applied it.
> ---
> v3:
> - Add phandle properties to type-preservation test
> v2:
> - New patch
> ---
> tests/type-preservation.dt.yaml | 3 +++
> tests/type-preservation.dts | 3 +++
> treesource.c | 25 +++++++++++++++++++------
> 3 files changed, 25 insertions(+), 6 deletions(-)
>
> diff --git a/tests/type-preservation.dt.yaml b/tests/type-preservation.dt.yaml
> index ee8cfdebe9be..a0cc64cc4b69 100644
> --- a/tests/type-preservation.dt.yaml
> +++ b/tests/type-preservation.dt.yaml
> @@ -13,8 +13,11 @@
> int64: [!u64 [0x200000000]]
> int64-array: [!u64 [0x100000000, 0x0]]
> a-string-with-nulls: ["foo\0bar", "baz"]
> + a-phandle: [[!phandle 0x1]]
> + a-phandle-with-args: [[!phandle 0x1, 0x0, 0x1], [!phandle 0x1, 0x2, 0x3]]
> subsubnode:
> compatible: ["subsubnode1", "subsubnode"]
> + phandle: [[0x1]]
> subsubsubnode:
> compatible: ["subsubsubnode1", [0x1234], "subsubsubnode"]
> ...
> diff --git a/tests/type-preservation.dts b/tests/type-preservation.dts
> index 3e380ba6c8a5..921ea21172d1 100644
> --- a/tests/type-preservation.dts
> +++ b/tests/type-preservation.dts
> @@ -16,9 +16,12 @@
> int64 = /bits/ 64 <0x200000000>;
> int64-array = /bits/ 64 <0x100000000 0x00> int64_array_label_end:;
> a-string-with-nulls = "foo\0bar", "baz";
> + a-phandle = <&subsub1>;
> + a-phandle-with-args = <&subsub1 0x00 0x01>, <&subsub1 0x02 0x03>;
>
> subsub1: subsubnode {
> compatible = "subsubnode1", "subsubnode";
> + phandle = <0x01>;
>
> subsubsub1: subsubsubnode {
> compatible = "subsubsubnode1", <0x1234>, valuea: valueb: "subsubsubnode";
> diff --git a/treesource.c b/treesource.c
> index db2ff69f5ccb..33fedee82d58 100644
> --- a/treesource.c
> +++ b/treesource.c
> @@ -208,26 +208,39 @@ static void write_propval(FILE *f, struct property *prop)
> size_t chunk_len = (m->next ? m->next->offset : len) - m->offset;
> size_t data_len = type_marker_length(m) ? : len - m->offset;
> const char *p = &prop->val.val[m->offset];
> + struct marker *m_phandle;
>
> if (is_type_marker(m->type)) {
> emit_type = m->type;
> fprintf(f, " %s", delim_start[emit_type]);
> } else if (m->type == LABEL)
> fprintf(f, " %s:", m->ref);
> - else if (m->offset)
> - fputc(' ', f);
>
> - if (emit_type == TYPE_NONE) {
> - assert(chunk_len == 0);
> + if (emit_type == TYPE_NONE || chunk_len == 0)
> continue;
> - }
>
> switch(emit_type) {
> case TYPE_UINT16:
> write_propval_int(f, p, chunk_len, 2);
> break;
> case TYPE_UINT32:
> - write_propval_int(f, p, chunk_len, 4);
> + m_phandle = prop->val.markers;
> + for_each_marker_of_type(m_phandle, REF_PHANDLE)
> + if (m->offset == m_phandle->offset)
> + break;
> +
> + if (m_phandle) {
> + if (m_phandle->ref[0] == '/')
> + fprintf(f, "&{%s}", m_phandle->ref);
> + else
> + fprintf(f, "&%s", m_phandle->ref);
> + if (chunk_len > 4) {
> + fputc(' ', f);
> + write_propval_int(f, p + 4, chunk_len - 4, 4);
> + }
> + } else {
> + write_propval_int(f, p, chunk_len, 4);
> + }
> break;
> case TYPE_UINT64:
> write_propval_int(f, p, chunk_len, 8);
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2021-10-11 5:21 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-27 18:30 [PATCH v3 0/5] Improve output type formatting Rob Herring
[not found] ` <20210727183023.3212077-1-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2021-07-27 18:30 ` [PATCH v3 1/5] Move marker functions to dtc.h Rob Herring
[not found] ` <20210727183023.3212077-2-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2021-08-26 4:00 ` David Gibson
2021-09-27 20:56 ` Rob Herring
[not found] ` <CAL_Jsq+QAnyu=Fj_RtRu-dS4Ta0bZJWFUABsK1uKbnAKpXi1mA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-10-11 5:29 ` David Gibson
2021-07-27 18:30 ` [PATCH v3 2/5] Add has_type_markers() helper Rob Herring
2021-07-27 18:30 ` [PATCH v3 3/5] checks: Add markers on known properties Rob Herring
[not found] ` <20210727183023.3212077-4-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2021-10-11 5:09 ` David Gibson
2021-10-11 13:57 ` Rob Herring
2021-07-27 18:30 ` [PATCH v3 4/5] dtc: Drop dts source restriction for yaml output Rob Herring
[not found] ` <20210727183023.3212077-5-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2021-10-11 5:15 ` David Gibson
2021-10-11 13:22 ` Rob Herring
[not found] ` <CAL_Jsq+sMrRWqqPgcvoaiY0rLSp_s+gXOqJ9OuFLQ-3piUHSVA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-10-13 3:12 ` David Gibson
2021-10-14 1:29 ` Rob Herring
[not found] ` <CAL_Jsq+iv7eM+LZ1O8d3V18dHraEAyfgdT8ucFKKVXZc9jEp4g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-11-03 4:42 ` David Gibson
2021-11-03 15:59 ` Rob Herring
[not found] ` <CAL_JsqLNyfe8Ou4RXeLm0ie1vvJ+z15J6EDgB96dPbCC5qvHVQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-11-03 19:16 ` Rob Herring
[not found] ` <CAL_JsqKeNne0Bf0ahG_h977snsBtsk3hbQOPO-6RiyFSyiOsfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-11-03 19:56 ` Simon Glass
[not found] ` <CAPnjgZ3BNPW+L4BrhQ9W4nLovSgcchWPfbznYxtf20sv2ntYaA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-11-03 22:42 ` Rob Herring
[not found] ` <CAL_JsqLdKsVO9kzkZcqL160COrpEp6GsR10AyPvmSG3B=grAXg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-11-03 22:48 ` Simon Glass
2021-11-09 4:41 ` David Gibson
2021-07-27 18:30 ` [PATCH v3 5/5] treesource: Maintain phandle label/path on output Rob Herring
[not found] ` <20210727183023.3212077-6-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2021-10-11 5:21 ` David Gibson [this message]
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=YWPJ5y9nMlW43pbd@yekko \
--to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=robh-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).