diff --git a/src/dtb/irqchip.rs b/src/dtb/irqchip.rs index 2a1f554da3..cec0ba057c 100644 --- a/src/dtb/irqchip.rs +++ b/src/dtb/irqchip.rs @@ -69,9 +69,17 @@ impl IrqChipList { fn init_inner1(&mut self, fdt: &Fdt) { for node in fdt.all_nodes() { if node.property("interrupt-controller").is_some() { - let compatible = node.property("compatible").unwrap().as_str().unwrap(); - let phandle = node.property("phandle").unwrap().as_usize().unwrap() as u32; - let intr_cells = node.interrupt_cells().unwrap(); + let Some(compatible) = node.compatible() else { + continue; + }; + let compatible = compatible.first(); + let Some(phandle) = node.property("phandle") else { + continue; + }; + let phandle = phandle.as_usize().unwrap() as u32; + let Some(intr_cells) = node.interrupt_cells() else { + continue; + }; debug!( "{}, compatible = {}, #interrupt-cells = 0x{:08x}, phandle = 0x{:08x}", diff --git a/src/dtb/mod.rs b/src/dtb/mod.rs index 68a9dda536..d8670543a9 100644 --- a/src/dtb/mod.rs +++ b/src/dtb/mod.rs @@ -44,24 +44,31 @@ pub fn travel_interrupt_ctrl(fdt: &Fdt) { } for node in fdt.all_nodes() { if node.property("interrupt-controller").is_some() { - let compatible = node.property("compatible").unwrap().as_str().unwrap(); - let phandle = node.property("phandle").unwrap().as_usize().unwrap(); - let intr_cells = node.interrupt_cells().unwrap(); - let _intr = node - .property("interrupt-parent") - .and_then(NodeProperty::as_usize); - let _intr_data = node.property("interrupts"); + let Some(compatible) = node.property("compatible") else { + continue; + }; + let compatible = compatible.as_str().unwrap(); + let Some(phandle) = node.property("phandle") else { + continue; + }; + let phandle = phandle.as_usize().unwrap(); + if let Some(intr_cells) = node.interrupt_cells() { + let _intr = node + .property("interrupt-parent") + .and_then(NodeProperty::as_usize); + let _intr_data = node.property("interrupts"); - debug!( - "{}, compatible = {}, #interrupt-cells = 0x{:08x}, phandle = 0x{:08x}", - node.name, compatible, intr_cells, phandle - ); - if let Some(intr) = _intr { - if let Some(intr_data) = _intr_data { - debug!("interrupt-parent = 0x{:08x}", intr); - debug!("interrupts begin:"); - for chunk in intr_data.value.chunks(4) { - debug!("0x{:08x}, ", BE::read_u32(chunk)); + debug!( + "{}, compatible = {}, #interrupt-cells = 0x{:08x}, phandle = 0x{:08x}", + node.name, compatible, intr_cells, phandle + ); + if let Some(intr) = _intr { + if let Some(intr_data) = _intr_data { + debug!("interrupt-parent = 0x{:08x}", intr); + debug!("interrupts begin:"); + for chunk in intr_data.value.chunks(4) { + debug!("0x{:08x}, ", BE::read_u32(chunk)); + } } debug!("interrupts end"); }