remove dtb unwraps

This commit is contained in:
Paul Sajna
2025-09-05 23:00:02 -07:00
parent 53c3342e9f
commit 172a0ffd02
2 changed files with 35 additions and 20 deletions
+11 -3
View File
@@ -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}",
+24 -17
View File
@@ -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");
}