[PATCH v3] gpu: nova-core: vbios: change PmuLookupTableEntry to use size_of
Rhys Lloyd
krakow20 at gmail.com
Fri Jul 18 07:36:25 UTC 2025
Annotate the PmuLookupTableEntry with an `#[repr(C, packed)]` attribute.
Removes another magic number by making the struct the same size as
the data it needs to read, allowing the use of
`size_of::<PmuLookupTableEntry>()`
Signed-off-by: Rhys Lloyd <krakow20 at gmail.com>
---
Changes in v2:
- get_data helper function renamed to data
Changes in v3:
- Change PmuLookupTableEntry.data back to u32
- Remove helper function
- Annotate `PmuLookupTableEntry` with `#[repr(C, packed)]`
---
drivers/gpu/nova-core/vbios.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
index 5b5d9f38cbb3..4c8368946bd6 100644
--- a/drivers/gpu/nova-core/vbios.rs
+++ b/drivers/gpu/nova-core/vbios.rs
@@ -893,6 +893,7 @@ fn try_from(base: BiosImageBase) -> Result<Self> {
///
/// See the [`PmuLookupTable`] description for more information.
#[expect(dead_code)]
+#[repr(C, packed)]
struct PmuLookupTableEntry {
application_id: u8,
target_id: u8,
@@ -901,7 +902,7 @@ struct PmuLookupTableEntry {
impl PmuLookupTableEntry {
fn new(data: &[u8]) -> Result<Self> {
- if data.len() < 6 {
+ if data.len() < core::mem::size_of::<Self>() {
return Err(EINVAL);
}
base-commit: 14ae91a81ec8fa0bc23170d4aa16dd2a20d54105
--
2.50.1
More information about the dri-devel
mailing list