File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -167,7 +167,9 @@ impl Node {
167167 false
168168 }
169169 #[ cfg( CONFIG_OF ) ]
170- unsafe { bindings:: of_node_is_root ( self . raw_node ) }
170+ unsafe {
171+ bindings:: of_node_is_root ( self . raw_node )
172+ }
171173 }
172174
173175 /// Returns the parent node, if any.
@@ -500,22 +502,50 @@ where
500502
501503/// Returns the root node of the OF device tree (if any).
502504pub fn root ( ) -> Option < Node > {
503- unsafe { Node :: get_from_raw ( bindings:: of_root) }
505+ #[ cfg( not( CONFIG_OF ) ) ]
506+ {
507+ None
508+ }
509+ #[ cfg( CONFIG_OF ) ]
510+ unsafe {
511+ Node :: get_from_raw ( bindings:: of_root)
512+ }
504513}
505514
506515/// Returns the /chosen node of the OF device tree (if any).
507516pub fn chosen ( ) -> Option < Node > {
508- unsafe { Node :: get_from_raw ( bindings:: of_chosen) }
517+ #[ cfg( not( CONFIG_OF ) ) ]
518+ {
519+ None
520+ }
521+ #[ cfg( CONFIG_OF ) ]
522+ unsafe {
523+ Node :: get_from_raw ( bindings:: of_chosen)
524+ }
509525}
510526
511527/// Returns the /aliases node of the OF device tree (if any).
512528pub fn aliases ( ) -> Option < Node > {
513- unsafe { Node :: get_from_raw ( bindings:: of_aliases) }
529+ #[ cfg( not( CONFIG_OF ) ) ]
530+ {
531+ None
532+ }
533+ #[ cfg( CONFIG_OF ) ]
534+ unsafe {
535+ Node :: get_from_raw ( bindings:: of_aliases)
536+ }
514537}
515538
516539/// Returns the system stdout node of the OF device tree (if any).
517540pub fn stdout ( ) -> Option < Node > {
518- unsafe { Node :: get_from_raw ( bindings:: of_stdout) }
541+ #[ cfg( not( CONFIG_OF ) ) ]
542+ {
543+ None
544+ }
545+ #[ cfg( CONFIG_OF ) ]
546+ unsafe {
547+ Node :: get_from_raw ( bindings:: of_stdout)
548+ }
519549}
520550
521551#[ allow( unused_variables) ]
You can’t perform that action at this time.
0 commit comments