Skip to content

Commit 02b1b2f

Browse files
hoshinolinajannau
authored andcommitted
drm/asahi: crashdump: Clippy fixes
Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent a87a3a1 commit 02b1b2f

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

drivers/gpu/drm/asahi/crashdump.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ pub(crate) struct CrashDump {
2525
pages: KVVec<Owned<Page>>,
2626
}
2727

28-
const NOTE_NAME_AGX: &str = &"AGX";
28+
const NOTE_NAME_AGX: &str = "AGX";
2929
const NOTE_AGX_DUMP_INFO: u32 = 1;
3030

31-
const NOTE_NAME_RTKIT: &str = &"RTKIT";
31+
const NOTE_NAME_RTKIT: &str = "RTKIT";
3232
const NOTE_RTKIT_CRASHLOG: u32 = 1;
3333

3434
#[repr(C)]
@@ -53,8 +53,12 @@ pub(crate) struct CrashDumpBuilder {
5353
notes: KVec<ELFNote>,
5454
}
5555

56-
// Helper to convert ELF headers into byte slices
57-
// TODO: Hook this up into kernel::AsBytes somehow
56+
/// Helper to convert ELF headers into byte slices
57+
/// TODO: Hook this up into kernel::AsBytes somehow
58+
///
59+
/// # Safety
60+
///
61+
/// Types implementing this trait must have no padding bytes.
5862
unsafe trait AsBytes: Sized {
5963
fn as_bytes(&self) -> &[u8] {
6064
// SAFETY: This trait is only implemented for types with no padding bytes
@@ -63,10 +67,7 @@ unsafe trait AsBytes: Sized {
6367
fn slice_as_bytes(slice: &[Self]) -> &[u8] {
6468
// SAFETY: This trait is only implemented for types with no padding bytes
6569
unsafe {
66-
core::slice::from_raw_parts(
67-
slice.as_ptr() as *const u8,
68-
slice.len() * size_of::<Self>(),
69-
)
70+
core::slice::from_raw_parts(slice.as_ptr() as *const u8, core::mem::size_of_val(slice))
7071
}
7172
}
7273
}
@@ -124,7 +125,7 @@ impl CrashDumpBuilder {
124125

125126
pub(crate) fn add_crashlog(&mut self, crashlog: &[u8]) -> Result {
126127
let mut data = KVVec::new();
127-
data.extend_from_slice(&crashlog, GFP_KERNEL)?;
128+
data.extend_from_slice(crashlog, GFP_KERNEL)?;
128129

129130
self.notes.push(
130131
ELFNote {
@@ -149,7 +150,7 @@ impl CrashDumpBuilder {
149150
ehdr.e_ident[uapi::EI_VERSION as usize] = uapi::EV_CURRENT as u8;
150151
ehdr.e_type = uapi::ET_CORE as u16;
151152
ehdr.e_machine = uapi::EM_AARCH64 as u16;
152-
ehdr.e_version = uapi::EV_CURRENT as u32;
153+
ehdr.e_version = uapi::EV_CURRENT;
153154
ehdr.e_entry = FIRMWARE_ENTRYPOINT;
154155
ehdr.e_ehsize = core::mem::size_of::<uapi::Elf64_Ehdr>() as u16;
155156
ehdr.e_phentsize = core::mem::size_of::<uapi::Elf64_Phdr>() as u16;
@@ -194,7 +195,6 @@ impl CrashDumpBuilder {
194195
p_memsz: UAT_PGSZ as u64,
195196
p_flags: flags,
196197
p_align: UAT_PGSZ as u64,
197-
..Default::default()
198198
},
199199
GFP_KERNEL,
200200
)?;

0 commit comments

Comments
 (0)