From 6553a8f168fb7941ae73d39eccac64f3a2b9b399 Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Wed, 29 Oct 2025 08:12:11 +0900 Subject: gpu: nova-core: use `try_from` instead of `as` for u32 conversions There are a few situations in the driver where we convert a `usize` into a `u32` using `as`. Even though most of these are obviously correct, use `try_from` and let the compiler optimize wherever it is safe to do so. Acked-by: Danilo Krummrich Signed-off-by: Alexandre Courbot Message-ID: <20251029-nova-as-v3-3-6a30c7333ad9@nvidia.com> --- drivers/gpu/nova-core/firmware/fwsec.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/gpu/nova-core/firmware/fwsec.rs') diff --git a/drivers/gpu/nova-core/firmware/fwsec.rs b/drivers/gpu/nova-core/firmware/fwsec.rs index dd3420aaa2bf..ce78c1563754 100644 --- a/drivers/gpu/nova-core/firmware/fwsec.rs +++ b/drivers/gpu/nova-core/firmware/fwsec.rs @@ -291,7 +291,7 @@ impl FirmwareDmaObject { frts_cmd.read_vbios = ReadVbios { ver: 1, - hdr: size_of::() as u32, + hdr: u32::try_from(size_of::())?, addr: 0, size: 0, flags: 2, @@ -304,9 +304,9 @@ impl FirmwareDmaObject { } => { frts_cmd.frts_region = FrtsRegion { ver: 1, - hdr: size_of::() as u32, - addr: (frts_addr >> 12) as u32, - size: (frts_size >> 12) as u32, + hdr: u32::try_from(size_of::())?, + addr: u32::try_from(frts_addr >> 12)?, + size: u32::try_from(frts_size >> 12)?, ftype: NVFW_FRTS_CMD_REGION_TYPE_FB, }; -- cgit v1.2.3