From: John Hubbard Date: Tue, 10 Mar 2026 02:10:52 +0000 (-0700) Subject: gpu: nova-core: add FbRange.len() and use it in boot.rs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a247f8a107b5ddbf21084599ad8d8190d1357de8;p=thirdparty%2Fkernel%2Flinux.git gpu: nova-core: add FbRange.len() and use it in boot.rs A tiny simplification: now that FbLayout uses its own specific FbRange type, add an FbRange.len() method, and use that to (very slightly) simplify the calculation of Frts::frts_size initialization. Suggested-by: Alexandre Courbot Reviewed-by: Gary Guo Signed-off-by: John Hubbard Link: https://patch.msgid.link/20260310021125.117855-3-jhubbard@nvidia.com Signed-off-by: Alexandre Courbot --- diff --git a/drivers/gpu/nova-core/fb.rs b/drivers/gpu/nova-core/fb.rs index 6fb804c118c60..6536d0035cb13 100644 --- a/drivers/gpu/nova-core/fb.rs +++ b/drivers/gpu/nova-core/fb.rs @@ -100,6 +100,12 @@ impl SysmemFlush { pub(crate) struct FbRange(Range); +impl FbRange { + pub(crate) fn len(&self) -> u64 { + self.0.end - self.0.start + } +} + impl From> for FbRange { fn from(range: Range) -> Self { Self(range) @@ -118,7 +124,7 @@ impl fmt::Debug for FbRange { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // Use alternate format ({:#?}) to include size, compact format ({:?}) for just the range. if f.alternate() { - let size = self.0.end - self.0.start; + let size = self.len(); if size < usize_as_u64(SZ_1M) { let size_kib = size / usize_as_u64(SZ_1K); diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/boot.rs index 9a00ddb922ac9..d278ce620c244 100644 --- a/drivers/gpu/nova-core/gsp/boot.rs +++ b/drivers/gpu/nova-core/gsp/boot.rs @@ -73,7 +73,7 @@ impl super::Gsp { bios, FwsecCommand::Frts { frts_addr: fb_layout.frts.start, - frts_size: fb_layout.frts.end - fb_layout.frts.start, + frts_size: fb_layout.frts.len(), }, )?;