diff options
| author | Alexandre Courbot <acourbot@nvidia.com> | 2025-10-29 08:12:11 +0900 |
|---|---|---|
| committer | Alexandre Courbot <acourbot@nvidia.com> | 2025-11-04 13:26:54 +0900 |
| commit | 6553a8f168fb7941ae73d39eccac64f3a2b9b399 (patch) | |
| tree | 9587545e99edd6e6ba3e47fc0e840e6c42b72c5c /drivers/gpu/nova-core/firmware/fwsec.rs | |
| parent | 505c3ec507a7eb4bbaef9aa8b13b6452e86baca2 (diff) | |
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 <dakr@kernel.org>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Message-ID: <20251029-nova-as-v3-3-6a30c7333ad9@nvidia.com>
Diffstat (limited to 'drivers/gpu/nova-core/firmware/fwsec.rs')
| -rw-r--r-- | drivers/gpu/nova-core/firmware/fwsec.rs | 8 |
1 files changed, 4 insertions, 4 deletions
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<FwsecFirmware, Unsigned> { frts_cmd.read_vbios = ReadVbios { ver: 1, - hdr: size_of::<ReadVbios>() as u32, + hdr: u32::try_from(size_of::<ReadVbios>())?, addr: 0, size: 0, flags: 2, @@ -304,9 +304,9 @@ impl FirmwareDmaObject<FwsecFirmware, Unsigned> { } => { frts_cmd.frts_region = FrtsRegion { ver: 1, - hdr: size_of::<FrtsRegion>() as u32, - addr: (frts_addr >> 12) as u32, - size: (frts_size >> 12) as u32, + hdr: u32::try_from(size_of::<FrtsRegion>())?, + addr: u32::try_from(frts_addr >> 12)?, + size: u32::try_from(frts_size >> 12)?, ftype: NVFW_FRTS_CMD_REGION_TYPE_FB, }; |