@@ -2,6 +2,7 @@ extern crate alloc;
22
33use alloc:: collections:: BTreeMap ;
44use serde_derive:: Deserialize ;
5+ use serde_device_tree:: Compatible ;
56
67static DEVICE_TREE : & ' static [ u8 ] = include_bytes ! ( "hifive-unmatched-a00.dtb" ) ;
78
@@ -12,7 +13,7 @@ struct Tree<'a> {
1213 #[ serde( rename = "#size-cells" ) ]
1314 num_size_cells : u32 ,
1415 model : & ' a str ,
15- compatible : & ' a str ,
16+ compatible : Compatible < ' a > ,
1617 chosen : Option < Chosen < ' a > > ,
1718 cpus : Cpus < ' a > ,
1819}
@@ -43,7 +44,8 @@ enum MaybeCpu<'a> {
4344
4445#[ derive( Debug , Deserialize ) ]
4546struct Cpu < ' a > {
46- compatible : & ' a str ,
47+ #[ serde( borrow) ]
48+ compatible : Compatible < ' a > ,
4749}
4850
4951fn main ( ) {
@@ -52,7 +54,7 @@ fn main() {
5254 println ! ( "#address_cells = {}" , t. num_address_cells) ;
5355 println ! ( "#size_cells = {}" , t. num_size_cells) ;
5456 println ! ( "model = {}" , t. model) ;
55- println ! ( "compatible = {}" , t. compatible) ;
57+ println ! ( "compatible = {:? }" , t. compatible) ;
5658 if let Some ( chosen) = t. chosen {
5759 if let Some ( stdout_path) = chosen. stdout_path {
5860 println ! ( "stdout = {}" , stdout_path) ;
@@ -64,7 +66,7 @@ fn main() {
6466 println ! ( "cpu u_boot_dm_spl = {}" , t. cpus. u_boot_dm_spl) ;
6567 for ( cpu_name, cpu) in t. cpus . cpu {
6668 if let MaybeCpu :: Cpu ( cpu) = cpu {
67- println ! ( "cpu {}, compaible = {}" , cpu_name, cpu. compatible)
69+ println ! ( "cpu {}, compaible = {:? }" , cpu_name, cpu. compatible)
6870 }
6971 }
7072}
0 commit comments