Re: [PATCH v2 0/2] Preserve datatypes in DTC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Mon, Mar 26, 2018 at 05:51:52PM -0700, Frank Rowand wrote:
> On 03/20/18 20:45, Grant Likely wrote:
> > I've refactored the patch to preserve datatype information when parsing
> > the dts format, and reproducing it when emitting .dts source. I did this
> > as part of working with a YAML encoding, but the change is independently
> > useful when round tripping through DTC.
> > 
> > All of the existing test cases continue to pass. You can see an example
> > of a DTC round trip using one of the test .dts files:
> > 
> > $ dtc -o tests/test01-roundtrip.dts tests/test01.dts
> > $ diff tests/test01.dts tests/test01-roundtrip.dts
> > 
> > I've got another patch that builds on this to emit YAML. You can find it
> > in my github tree at https://github.com/glikely/dtc if you're
> > interested.
> > 
> >  data.c       |   4 +-
> >  dtc-parser.y |  15 ++--
> >  dtc.h        |   8 ++
> >  treesource.c | 227 +++++++++++++++++++++++++++++++--------------------------
> >  4 files changed, 145 insertions(+), 109 deletions(-)
> > 
> 
> How much difference should I expect to see after a round trip?
> 
> (Less is reported by 'diff -w', which is shown second.)

Well, duh, we can't really expect whitespace changes to be preserved.
I guess how we put that in the output de facto becaose the standard
form of indentation.

> With the patches applied on top of:
> 
>    $ git log -n1
>    commit 46df1fb1b211ec65b004c79b0f7adae25fb49dc3
>    Author: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
>    Date:   Fri Mar 9 13:55:17 2018 +1100
> 
>        .travis.yml: Run valgrind checks via Travis
>     
>        To improve our coverage, run the testsuite under Valgrind via Travis.
>     
> 
> $ ./dtc -o tests/test01-roundtrip.dts tests/test01.dts
>
[snip]
> $ diff -w tests/test01.dts tests/test01-roundtrip.dts

Ugh.  I find diffs without -u almost unreadable.

> 6d5
> < 
> 10,11c9,10
> < 	#address-cells = <2>;
> < 	#size-cells = <2>;
> ---
> > 	#address-cells = < 0x02 >;
> > 	#size-cells = < 0x02 >;

Right, I don't think we can reasonably preseve the exact way integers
are expressed.

> 14,16c13,16
> < 		linux,phandle = <0x1>;
> < 		#address-cells = <1>;
> < 		#size-cells = <0>;
> ---
> > 		linux,phandle = < 0x01 >;
> > 		#address-cells = < 0x01 >;
> > 		#size-cells = < 0x00 >;
> > 
> 18d17
> < 			name = "PowerPC,970";
> 20,22c19,21
> < 			reg = <0x00000000>;
> < 			clock-frequency = <1600000000>;
> < 			timebase-frequency = <33333333>;
> ---
> > 			reg = < 0x00 >;
> > 			clock-frequency = < 0x5f5e1000 >;
> > 			timebase-frequency = < 0x1fca055 >;
> 24,25c23,24
> < 			i-cache-size = <65536>;
> < 			d-cache-size = <32768>;
> ---
> > 			i-cache-size = < 0x10000 >;
> > 			d-cache-size = < 0x8000 >;
> 29d27
> < 			name = "PowerPC,970";
> 31,35c29,33
> < 			reg = <0x00000001>;
> < 			clock-frequency = <1600000000>;
> < 			timebase-frequency = <33333333>;
> < 			i-cache-size = <65536>;
> < 			d-cache-size = <32768>;
> ---
> > 			reg = < 0x01 >;
> > 			clock-frequency = < 0x5f5e1000 >;
> > 			timebase-frequency = < 0x1fca055 >;
> > 			i-cache-size = < 0x10000 >;
> > 			d-cache-size = < 0x8000 >;
> 37d34
> < 
> 41c38
> < 		string = "\xff\0stuffstuff\t\t\t\n\n\n";
> ---
> > 		string = "\xffffffff", "stuffstuff\t\t\t\n\n\n";
> 43,44c40,41
> < 		ref = < &{/memory@0} >;
> < 		mixed = "abc", [1234], <0xa 0xb 0xc>;
> ---
> > 		ref = < 0x02 >;
> > 		mixed = "abc", [ 12 34 ], < 0x0a 0x0b 0x0c >;
> 49c46,47
> < 		memreg: reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
> ---
> > 		memreg: reg = < 0x00 0x00 0x00 0x20000000 >;
> > 		phandle = < 0x02 >;
> 56d53
> < 

-- 
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: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux