From: Andrei Ziureaev <andreiziureaev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
Subject: [RFC PATCH v4 1/4] dtc: Add marker type functionality to dtc.h
Date: Tue, 15 Sep 2020 18:07:23 +0100 [thread overview]
Message-ID: <20200915170726.15434-2-andreiziureaev@gmail.com> (raw)
In-Reply-To: <20200915170726.15434-1-andreiziureaev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
From: Andrei Ziureaev <andrei.ziureaev-5wv7dgnIgG8@public.gmane.org>
Add an inline helper function to dtc.h that checks if there's a marker
of a type at an offset.
Also, there are two useful static functions in treesource.c. Make them
public, add their prototypes to dtc.h and rename one of them.
Signed-off-by: Andrei Ziureaev <andrei.ziureaev-5wv7dgnIgG8@public.gmane.org>
Signed-off-by: Andrei Ziureaev <andreiziureaev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
dtc.h | 11 +++++++++++
treesource.c | 8 ++++----
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/dtc.h b/dtc.h
index a08f415..286d999 100644
--- a/dtc.h
+++ b/dtc.h
@@ -125,6 +125,17 @@ struct data {
for_each_marker(m) \
if ((m)->type == (t))
+static inline bool markers_have_type_at_offset(struct marker *m, enum markertype type, int off)
+{
+ for_each_marker_of_type(m, type)
+ if (m->offset == off)
+ return true;
+
+ return false;
+}
+
+bool marker_has_data_type_information(struct marker *m);
+struct marker *next_type_marker(struct marker *m);
size_t type_marker_length(struct marker *m);
void data_free(struct data d);
diff --git a/treesource.c b/treesource.c
index 061ba8c..0785d83 100644
--- a/treesource.c
+++ b/treesource.c
@@ -124,14 +124,14 @@ 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)
+bool marker_has_data_type_information(struct marker *m)
{
return m->type >= TYPE_UINT8;
}
-static struct marker *next_type_marker(struct marker *m)
+struct marker *next_type_marker(struct marker *m)
{
- while (m && !has_data_type_information(m))
+ while (m && !marker_has_data_type_information(m))
m = m->next;
return m;
}
@@ -230,7 +230,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 (marker_has_data_type_information(m)) {
emit_type = m->type;
fprintf(f, " %s", delim_start[emit_type]);
} else if (m->type == LABEL)
--
2.17.1
next prev parent reply other threads:[~2020-09-15 17:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-15 17:07 [RFC PATCH v4 0/4] dtc: Add a plugin interface Andrei Ziureaev
[not found] ` <20200915170726.15434-1-andreiziureaev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2020-09-15 17:07 ` Andrei Ziureaev [this message]
2020-09-15 17:07 ` [RFC PATCH v4 2/4] dtc: Add a live tree API Andrei Ziureaev
2020-09-15 17:07 ` [RFC PATCH v4 3/4] dtc: Add plugin documentation and examples Andrei Ziureaev
2020-09-15 17:07 ` [RFC PATCH v4 4/4] dtc: Add a plugin interface Andrei Ziureaev
2020-11-19 15:44 ` [RFC PATCH v4 0/4] " Rob Herring
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=20200915170726.15434-2-andreiziureaev@gmail.com \
--to=andreiziureaev-re5jqeeqqe8avxtiumwx3w@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 \
--cc=sjg-F7+t8E8rja9g9hUCZPvPmw@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 read-only IMAP folder(s) and NNTP newsgroup(s).