Skip to content

Commit 1c57948

Browse files
committed
ASoC: apple: aop: Import unaligned u32 from asahi
Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 0467678 commit 1c57948

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

sound/soc/apple/aop_audio.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
use core::sync::atomic::{AtomicU32, Ordering};
99
use core::{mem, ptr, slice};
10+
use core::fmt;
1011

1112
use kernel::{
1213
bindings, c_str, device,
@@ -23,6 +24,24 @@ use kernel::{
2324

2425
use pin_init::Zeroable;
2526

27+
/// An unaligned u32 type.
28+
///
29+
/// This is useful to avoid having to pack firmware structures entirely, since that is incompatible
30+
/// with `#[derive(Debug)]` and atomics.
31+
#[derive(Copy, Clone, Default)]
32+
#[repr(C, packed(1))]
33+
pub(crate) struct U32(pub(crate) u32);
34+
35+
// SAFETY: U32 is zeroable just like u32
36+
unsafe impl Zeroable for U32 {}
37+
38+
impl fmt::Debug for U32 {
39+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40+
let v = self.0;
41+
f.write_fmt(format_args!("{:#x}", v))
42+
}
43+
}
44+
2645
const EPIC_SUBTYPE_WRAPPED_CALL: u16 = 0x20;
2746
const CALLTYPE_AUDIO_ATTACH_DEVICE: u32 = 0xc3000002;
2847
const CALLTYPE_AUDIO_SET_PROP: u32 = 0xc3000005;

0 commit comments

Comments
 (0)