diff options
Diffstat (limited to 'drivers/gpu/nova-core/firmware/riscv.rs')
| -rw-r--r-- | drivers/gpu/nova-core/firmware/riscv.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/gpu/nova-core/firmware/riscv.rs b/drivers/gpu/nova-core/firmware/riscv.rs index 196dedb96aeb..270b2c7dc219 100644 --- a/drivers/gpu/nova-core/firmware/riscv.rs +++ b/drivers/gpu/nova-core/firmware/riscv.rs @@ -14,7 +14,8 @@ use kernel::{ use crate::{ dma::DmaObject, - firmware::BinFirmware, // + firmware::BinFirmware, + num::FromSafeCast, // }; /// Descriptor for microcode running on a RISC-V core. @@ -45,7 +46,7 @@ impl RmRiscvUCodeDesc { /// /// Fails if the header pointed at by `bin_fw` is not within the bounds of the firmware image. fn new(bin_fw: &BinFirmware<'_>) -> Result<Self> { - let offset = bin_fw.hdr.header_offset as usize; + let offset = usize::from_safe_cast(bin_fw.hdr.header_offset); bin_fw .fw @@ -78,8 +79,8 @@ impl RiscvFirmware { let riscv_desc = RmRiscvUCodeDesc::new(&bin_fw)?; let ucode = { - let start = bin_fw.hdr.data_offset as usize; - let len = bin_fw.hdr.data_size as usize; + let start = usize::from_safe_cast(bin_fw.hdr.data_offset); + let len = usize::from_safe_cast(bin_fw.hdr.data_size); DmaObject::from_data(dev, fw.data().get(start..start + len).ok_or(EINVAL)?)? }; |