* [PATCH v1 0/2] update dt-extract-example
@ 2020-04-25 10:52 Sam Ravnborg
2020-04-25 10:52 ` [PATCH v1 1/2] tools/dt-extract-example: support examples with root node Sam Ravnborg
2020-04-25 10:52 ` [PATCH v1 2/2] tools/dt-extract-example: beautify output Sam Ravnborg
0 siblings, 2 replies; 3+ messages in thread
From: Sam Ravnborg @ 2020-04-25 10:52 UTC (permalink / raw)
To: Rob Herring, devicetree; +Cc: Sam Ravnborg, Maxime Ripard
First one patch to add support for root nodes in dt-extract-example.
This will allow us to modify the example for simple-frambuffer to it
is more correct without any warnings.
And we may ahve a potential to use this in other places.
Verified that this did not introduce any regressions in
mainline kernel.
Looking at the generating output there was one line with wrong ident.
Fixed this so reading the generated outlut was a little easier
to the eye. The fix has no impact on the checks.
Patching simple-frambuffer.yaml in the kernel will
have to wait a little. At a minimum this patch should be accepted
and dt-schema shall have a higher version.
Sam
Sam Ravnborg (2):
tools/dt-extract-example: support examples with root node
tools/dt-extract-example: beautify output
tools/dt-extract-example | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v1 1/2] tools/dt-extract-example: support examples with root node
2020-04-25 10:52 [PATCH v1 0/2] update dt-extract-example Sam Ravnborg
@ 2020-04-25 10:52 ` Sam Ravnborg
2020-04-25 10:52 ` [PATCH v1 2/2] tools/dt-extract-example: beautify output Sam Ravnborg
1 sibling, 0 replies; 3+ messages in thread
From: Sam Ravnborg @ 2020-04-25 10:52 UTC (permalink / raw)
To: Rob Herring, devicetree; +Cc: Sam Ravnborg, Maxime Ripard
Examples are prefixed with boiler plate in the normal case.
In the rare case a root node is required this boiler plate shall not be
used.
Example with root node:
/ {
chosen {
...;
}
}
Teach the script to recognize that the example starts with a root node
and avoid the boiler plate in such cases.
The root node is recognized using a simple regular expression search.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
| 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
--git a/tools/dt-extract-example b/tools/dt-extract-example
index 99e59c3..0e933e4 100755
--- a/tools/dt-extract-example
+++ b/tools/dt-extract-example
@@ -4,6 +4,7 @@
# Copyright 2019 Arm Ltd.
import os
+import re
import sys
import ruamel.yaml
import argparse
@@ -17,11 +18,14 @@ example_template = """
{example}
}};
+}};
"""
example_header = """
/dts-v1/;
/plugin/; // silence any missing phandle references
+"""
+example_start = """
/{
compatible = "foo";
model = "foo";
@@ -49,7 +53,15 @@ if __name__ == "__main__":
if 'examples' in binding.keys():
for idx,ex in enumerate(binding['examples']):
- ex = ' '.join(ex.splitlines(True))
- print(example_template.format(example=ex,example_num=idx))
+ # Check if example contains a root node "/{"
+ root_node = re.search('^/\s*{', ex)
- print("\n};")
+ if not root_node:
+ print(example_start)
+ ex = ' '.join(ex.splitlines(True))
+ print(example_template.format(example=ex,example_num=idx))
+ else:
+ print(ex)
+ else:
+ print(example_start)
+ print("\n};")
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH v1 2/2] tools/dt-extract-example: beautify output
2020-04-25 10:52 [PATCH v1 0/2] update dt-extract-example Sam Ravnborg
2020-04-25 10:52 ` [PATCH v1 1/2] tools/dt-extract-example: support examples with root node Sam Ravnborg
@ 2020-04-25 10:52 ` Sam Ravnborg
1 sibling, 0 replies; 3+ messages in thread
From: Sam Ravnborg @ 2020-04-25 10:52 UTC (permalink / raw)
To: Rob Herring, devicetree; +Cc: Sam Ravnborg, Maxime Ripard
Fix so first line in the output has same indent as the
rest of the lines in the example.
This makes the examples a little easier to read.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
| 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--git a/tools/dt-extract-example b/tools/dt-extract-example
index 0e933e4..f1a222f 100755
--- a/tools/dt-extract-example
+++ b/tools/dt-extract-example
@@ -15,8 +15,7 @@ example_template = """
#address-cells = <1>;
#size-cells = <1>;
-{example}
-
+ {example}
}};
}};
"""
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-25 10:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-25 10:52 [PATCH v1 0/2] update dt-extract-example Sam Ravnborg
2020-04-25 10:52 ` [PATCH v1 1/2] tools/dt-extract-example: support examples with root node Sam Ravnborg
2020-04-25 10:52 ` [PATCH v1 2/2] tools/dt-extract-example: beautify output Sam Ravnborg
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).