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 1/5] Move marker functions to dtc.h
Date: Thu, 26 Aug 2021 14:00:53 +1000 [thread overview]
Message-ID: <YScR9WbrB/1KHsk9@yekko> (raw)
In-Reply-To: <20210727183023.3212077-2-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 2934 bytes --]
On Tue, Jul 27, 2021 at 12:30:19PM -0600, Rob Herring wrote:
> In preparation to share the marker related functions, let's move them all
> out of treeresource.c into dtc.h. Rework the next_type_marker()
> implementation to use for_each_marker() instead of open coding it.
>
> Signed-off-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Applied, thanks.
> ---
> v3:
> - New patch
> ---
> dtc.h | 23 ++++++++++++++++++++++-
> treesource.c | 23 +----------------------
> 2 files changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/dtc.h b/dtc.h
> index cf2c6ac6e81e..0a1f54991026 100644
> --- a/dtc.h
> +++ b/dtc.h
> @@ -116,6 +116,12 @@ enum markertype {
> TYPE_UINT64,
> TYPE_STRING,
> };
> +
> +static inline bool is_type_marker(enum markertype type)
> +{
> + return type >= TYPE_UINT8;
> +}
> +
> extern const char *markername(enum markertype markertype);
>
> struct marker {
> @@ -140,7 +146,22 @@ struct data {
> for_each_marker(m) \
> if ((m)->type == (t))
>
> -size_t type_marker_length(struct marker *m);
> +static inline struct marker *next_type_marker(struct marker *m)
> +{
> + for_each_marker(m)
> + if (is_type_marker(m->type))
> + break;
> + return m;
> +}
> +
> +static inline size_t type_marker_length(struct marker *m)
> +{
> + struct marker *next = next_type_marker(m->next);
> +
> + if (next)
> + return next->offset - m->offset;
> + return 0;
> +}
>
> void data_free(struct data d);
>
> diff --git a/treesource.c b/treesource.c
> index 061ba8c9c5e8..db2ff69f5ccb 100644
> --- a/treesource.c
> +++ b/treesource.c
> @@ -124,27 +124,6 @@ static void write_propval_int(FILE *f, const char *p, size_t len, size_t width)
> }
> }
>
> -static bool has_data_type_information(struct marker *m)
> -{
> - return m->type >= TYPE_UINT8;
> -}
> -
> -static struct marker *next_type_marker(struct marker *m)
> -{
> - while (m && !has_data_type_information(m))
> - m = m->next;
> - return m;
> -}
> -
> -size_t type_marker_length(struct marker *m)
> -{
> - struct marker *next = next_type_marker(m->next);
> -
> - if (next)
> - return next->offset - m->offset;
> - return 0;
> -}
> -
> static const char *delim_start[] = {
> [TYPE_UINT8] = "[",
> [TYPE_UINT16] = "/bits/ 16 <",
> @@ -230,7 +209,7 @@ static void write_propval(FILE *f, struct property *prop)
> size_t data_len = type_marker_length(m) ? : len - m->offset;
> const char *p = &prop->val.val[m->offset];
>
> - if (has_data_type_information(m)) {
> + if (is_type_marker(m->type)) {
> emit_type = m->type;
> fprintf(f, " %s", delim_start[emit_type]);
> } else if (m->type == LABEL)
--
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 --]
next prev parent reply other threads:[~2021-08-26 4:00 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 [this message]
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
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=YScR9WbrB/1KHsk9@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).