File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ name = "fdt-raw"
1111readme = " README.md"
1212homepage = " https://github.com/drivercraft/fdt-parser"
1313repository = " https://github.com/drivercraft/fdt-parser"
14- version = " 0.1.2 "
14+ version = " 0.1.3 "
1515
1616[dependencies ]
1717heapless = " 0.9"
Original file line number Diff line number Diff line change @@ -119,6 +119,12 @@ impl<'a> NodeBase<'a> {
119119 prop. data ( ) ,
120120 ) )
121121 }
122+
123+ pub fn compatibles ( & self ) -> impl Iterator < Item = & ' a str > {
124+ self . find_property ( "compatible" )
125+ . into_iter ( )
126+ . flat_map ( |p| p. as_str_iter ( ) )
127+ }
122128}
123129
124130/// 写入缩进
Original file line number Diff line number Diff line change @@ -600,3 +600,15 @@ fn test_memory_in_fdt(raw: &[u8], name: &str) {
600600 ) ;
601601 info ! ( "[{}] Found {} memory node(s)" , name, memory_nodes_found) ;
602602}
603+
604+
605+ #[ test]
606+ fn test_compatibles ( ) {
607+ init_logging ( ) ;
608+ let raw = fdt_qemu ( ) ;
609+ let fdt = Fdt :: from_bytes ( & raw ) . unwrap ( ) ;
610+ let node = fdt. find_by_path ( "/pl061@9030000" ) . unwrap ( ) ;
611+ for compatible in node. compatibles ( ) {
612+ info ! ( "compatible: {}" , compatible) ;
613+ }
614+ }
You can’t perform that action at this time.
0 commit comments