diff options
| author | Takashi Iwai <tiwai@suse.de> | 2025-10-16 20:14:24 +0200 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2025-10-16 20:14:24 +0200 |
| commit | ec2e0fb07d789976c601bec19ecced7a501c3705 (patch) | |
| tree | d593e7b6153618ca10855a3141404e952debe73c /rust/kernel/alloc/layout.rs | |
| parent | c6fceaf166479c05f7d3158ef08e78ae3e3dfa23 (diff) | |
| parent | f1a450f9e17d341f69f8fb19f6d13ef9f1aa508b (diff) | |
Merge tag 'asoc-fix-v6.18-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Fixes for v6.18
A moderately large collection of driver specific fixes, plus a few new
quirks and device IDs. The NAU8821 changes are a little large but more
in mechanical ways than in ways that are complex.
Diffstat (limited to 'rust/kernel/alloc/layout.rs')
| -rw-r--r-- | rust/kernel/alloc/layout.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/rust/kernel/alloc/layout.rs b/rust/kernel/alloc/layout.rs index 93ed514f7cc7..9f8be72feb7a 100644 --- a/rust/kernel/alloc/layout.rs +++ b/rust/kernel/alloc/layout.rs @@ -80,7 +80,7 @@ impl<T> ArrayLayout<T> { /// # Safety /// /// `len` must be a value, for which `len * size_of::<T>() <= isize::MAX` is true. - pub unsafe fn new_unchecked(len: usize) -> Self { + pub const unsafe fn new_unchecked(len: usize) -> Self { // INVARIANT: By the safety requirements of this function // `len * size_of::<T>() <= isize::MAX`. Self { @@ -98,6 +98,11 @@ impl<T> ArrayLayout<T> { pub const fn is_empty(&self) -> bool { self.len == 0 } + + /// Returns the size of the [`ArrayLayout`] in bytes. + pub const fn size(&self) -> usize { + self.len() * core::mem::size_of::<T>() + } } impl<T> From<ArrayLayout<T>> for Layout { |
