From: Anton Staaf <robotboy-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.orgdevicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Subject: [PATCH v4 3/3] dtc: Support character literals in bytestrings
Date: Fri, 9 Sep 2011 12:16:31 -0700 [thread overview]
Message-ID: <1315595791-25793-4-git-send-email-robotboy@chromium.org> (raw)
In-Reply-To: <1315595791-25793-1-git-send-email-robotboy-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
With this patch the following property assignment:
property = ['a' 2b '\r'];
is equivalent to:
property = [61 2b 0d];
Signed-off-by: Anton Staaf <robotboy-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Cc: Jon Loeliger <jdl-CYoMK+44s/E@public.gmane.org>
Cc: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
---
Documentation/dts-format.txt | 5 +++--
dtc-parser.y | 4 ++++
tests/char_literal.c | 8 ++++++++
tests/char_literal.dts | 1 +
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/Documentation/dts-format.txt b/Documentation/dts-format.txt
index eae8b76..555bd89 100644
--- a/Documentation/dts-format.txt
+++ b/Documentation/dts-format.txt
@@ -48,11 +48,12 @@ NUL-terminated strings, as bytestrings or a combination of these.
e.g. compatible = "simple-bus";
* A bytestring is enclosed in square brackets [] with each byte
- represented by two hexadecimal digits. Spaces between each byte are
- optional.
+ represented by two hexadecimal digits or a character literal.
+ Spaces between each byte or character literal are optional.
e.g. local-mac-address = [00 00 12 34 56 78]; or equivalently
local-mac-address = [000012345678];
+ e.g. keymap = ['a' 'b' 'c' 'd'];
* Values may have several comma-separated components, which are
concatenated together.
diff --git a/dtc-parser.y b/dtc-parser.y
index 554f11a..bc05a24 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -286,6 +286,10 @@ bytestring:
{
$$ = data_add_marker($1, LABEL, $2);
}
+ | bytestring DT_CHAR_LITERAL
+ {
+ $$ = data_append_byte($1, eval_char_literal($2));
+ }
;
subnodes:
diff --git a/tests/char_literal.c b/tests/char_literal.c
index 150f2a0..c6e2405 100644
--- a/tests/char_literal.c
+++ b/tests/char_literal.c
@@ -33,6 +33,11 @@ int main(int argc, char *argv[])
{
void *fdt;
uint32_t expected_cells[5];
+ uint8_t expected_bytes[5] = {TEST_CHAR1,
+ TEST_CHAR2,
+ TEST_CHAR3,
+ TEST_CHAR4,
+ TEST_CHAR5};
expected_cells[0] = cpu_to_fdt32((unsigned char)TEST_CHAR1);
expected_cells[1] = cpu_to_fdt32((unsigned char)TEST_CHAR2);
@@ -46,5 +51,8 @@ int main(int argc, char *argv[])
check_getprop(fdt, 0, "char-literal-cells",
sizeof(expected_cells), expected_cells);
+ check_getprop(fdt, 0, "char-literal-bytes",
+ sizeof(expected_bytes), expected_bytes);
+
PASS();
}
diff --git a/tests/char_literal.dts b/tests/char_literal.dts
index 22e17ed..9baba5c 100644
--- a/tests/char_literal.dts
+++ b/tests/char_literal.dts
@@ -2,4 +2,5 @@
/ {
char-literal-cells = <'\r' 'b' '\0' '\'' '\xff'>;
+ char-literal-bytes = ['\r' 'b' '\0' '\'' '\xff'];
};
--
1.7.3.1
prev parent reply other threads:[~2011-09-09 19:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-09 19:16 [PATCH v4 0/3] Support character literals Anton Staaf
[not found] ` <1315595791-25793-1-git-send-email-robotboy-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-09 19:16 ` [PATCH v4 1/3] dtc: Refactor character literal parsing code Anton Staaf
[not found] ` <1315595791-25793-2-git-send-email-robotboy-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-09 21:07 ` Jon Loeliger
2011-09-09 19:16 ` [PATCH v4 2/3] dtc: Support character literals in cell lists Anton Staaf
[not found] ` <1315595791-25793-3-git-send-email-robotboy-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-12 0:44 ` David Gibson
[not found] ` <20110912004437.GG9025-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-17 16:49 ` Jon Loeliger
[not found] ` <E1R4y4v-0000Nf-5A-CYoMK+44s/E@public.gmane.org>
2011-09-19 2:00 ` David Gibson
[not found] ` <20110919020034.GJ9025-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-19 16:45 ` Anton Staaf
[not found] ` <CAF6FioU5_uEh0fLyRBnD7DkPyo_UfjAaWxNONXSxDukpg3QPeg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-20 0:59 ` David Gibson
[not found] ` <20110920005931.GB29197-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-20 2:54 ` Anton Staaf
[not found] ` <CAF6FioWTyMEf_BP+_VcJ57jqQt-y9np0n7SkTy6TFMNWWQE-MQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-20 3:34 ` David Gibson
[not found] ` <20110920033441.GI29197-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-21 19:38 ` Anton Staaf
[not found] ` <CAF6FioUJkya4kSFQ6+6tYbGcNw5WPSUT8UkgUANmqhhBwZhU1g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-22 2:09 ` David Gibson
[not found] ` <20110922020916.GC22223-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-22 14:29 ` Jon Loeliger
2011-09-22 14:27 ` Jon Loeliger
2011-09-09 19:16 ` Anton Staaf [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=1315595791-25793-4-git-send-email-robotboy@chromium.org \
--to=robotboy-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.orgdevicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ \
/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).