@@ -30,14 +30,15 @@ mod parse;
30
30
31
31
pub use augment:: { Augment , load_augments} ;
32
32
33
+ /// Representation of a parsed device tree.
33
34
pub struct DeviceTree {
34
35
/// The root of the tree.
35
36
root : Rc < Node > ,
36
37
/// All of the labels.
37
38
labels : BTreeMap < String , Rc < Node > > ,
38
39
}
39
40
40
- // This is a single node in the devicetree .
41
+ // A single node in a [`DeviceTree`] .
41
42
pub struct Node {
42
43
// The name of the node itself.
43
44
name : String ,
@@ -90,27 +91,22 @@ pub enum Word {
90
91
}
91
92
92
93
impl DeviceTree {
93
- /// Decode the zephyr.dts and devicetree_generated.h files from the build and build an internal
94
+ /// Decode the ` zephyr.dts` and ` devicetree_generated.h` files from the build and build an internal
94
95
/// representation of the devicetree itself.
95
96
pub fn new < P1 : AsRef < Path > , P2 : AsRef < Path > > ( dts_path : P1 , dt_gen : P2 ) -> DeviceTree {
96
97
let ords = OrdMap :: new ( dt_gen) ;
97
98
98
99
let dts = std:: fs:: read_to_string ( dts_path)
99
100
. expect ( "Reading zephyr.dts file" ) ;
100
101
let dt = parse:: parse ( & dts, & ords) ;
101
- dt. resolve_phandles ( ) ;
102
- dt. set_parents ( ) ;
103
- dt
104
- }
105
102
106
- /// Walk the node tree, fixing any phandles to include their reference.
107
- fn resolve_phandles ( & self ) {
108
- self . root . phandle_walk ( & self . labels ) ;
109
- }
103
+ // Walk the node tree, fixing any phandles to include their reference.
104
+ dt. root . phandle_walk ( & dt. labels ) ;
110
105
111
- /// Walk the node tree, setting each node's parent appropriately.
112
- fn set_parents ( & self ) {
113
- self . root . parent_walk ( ) ;
106
+ // Walk the node tree, setting each node's parent appropriately.
107
+ dt. root . parent_walk ( ) ;
108
+
109
+ dt
114
110
}
115
111
}
116
112
0 commit comments