diff options
| author | Miguel Ojeda <ojeda@kernel.org> | 2026-10-11 18:53:20 +0200 |
|---|---|---|
| committer | Miguel Ojeda <ojeda@kernel.org> | 2026-10-11 18:53:20 +0200 |
| commit | 334238e68398bd4e1e84a0b2931a71129100ef6a (patch) | |
| tree | 209767838ec657f129323dc2bc6af450a7ec897e /rust/kernel | |
| parent | 2dee3d3adcadcc57d62ba6608cd02f50b0c10264 (diff) | |
| parent | 6e8339118040f24ebcc21db22c9c1b7398b7e39e (diff) | |
Merge tag 'alloc-7.4-rc1' of https://github.com/Rust-for-Linux/linux into rust-next
Pull alloc updates from Danilo Krummrich:
- Add Alice Ryhl as co-maintainer for Rust [ALLOC]
- Allow different error types in KBox::pin_slice(), enabling use of
infallible initializers
- Add NumaNode::id() accessor to retrieve the underlying NUMA node
identifier
* tag 'alloc-7.4-rc1' of https://github.com/Rust-for-Linux/linux:
rust: alloc: add `NumaNode::id()` accessor
rust: alloc: allow different error types in `KBox::pin_slice`
MAINTAINERS: add Alice Ryhl as co-maintainer for Rust [ALLOC]
Diffstat (limited to 'rust/kernel')
| -rw-r--r-- | rust/kernel/alloc.rs | 6 | ||||
| -rw-r--r-- | rust/kernel/alloc/kbox.rs | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs index 21067bde6860..68d80f3fa6c8 100644 --- a/rust/kernel/alloc.rs +++ b/rust/kernel/alloc.rs @@ -130,6 +130,12 @@ impl NumaNode { } Ok(Self(node)) } + + /// Returns the raw NUMA node identifier as an `i32`. + #[inline] + pub fn id(&self) -> i32 { + self.0 + } } /// Specify necessary constant to pass the information to Allocator that the caller doesn't care diff --git a/rust/kernel/alloc/kbox.rs b/rust/kernel/alloc/kbox.rs index c63d6acdbb6f..2c929eb1c3d6 100644 --- a/rust/kernel/alloc/kbox.rs +++ b/rust/kernel/alloc/kbox.rs @@ -345,7 +345,7 @@ where /// } /// /// // Allocate a boxed slice of 10 `Example`s. - /// let s = KBox::pin_slice( + /// let s = KBox::pin_slice::<_, _, Error, _>( /// | _i | Example::new(), /// 10, /// GFP_KERNEL @@ -355,15 +355,16 @@ where /// assert_eq!(s[3].d.lock().a, 20); /// # Ok::<(), Error>(()) /// ``` - pub fn pin_slice<Func, Item, E>( + pub fn pin_slice<Func, Item, E, E2>( mut init: Func, len: usize, flags: Flags, ) -> Result<Pin<Box<[T], A>>, E> where Func: FnMut(usize) -> Item, - Item: PinInit<T, E>, + Item: PinInit<T, E2>, E: From<AllocError>, + E: From<E2>, { let mut buffer = super::Vec::<T, A>::with_capacity(len, flags)?; for i in 0..len { |
