Skip to content

Commit 63cbe11

Browse files
committed
rust: Fix x86 build more
Signed-off-by: Hector Martin <[email protected]>
1 parent 8c64975 commit 63cbe11

1 file changed

Lines changed: 35 additions & 5 deletions

File tree

rust/kernel/of.rs

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff 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).
502504
pub 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).
507516
pub 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).
512528
pub 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).
517540
pub 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)]

0 commit comments

Comments
 (0)