From 5786aa1472387bdf52547bced061ac2882b3d371 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Mon, 10 Mar 2025 08:45:27 +0000 Subject: [PATCH] ANDROID: fix build breakages with Rust alloc backport When backporting the Rust alloc and FFI integer changes, there is some breakage in ashmem and related files due to API changes. Thus, update these files to use the new API. This should be applied at the same time as the merge of the stable release containing this backport. Link: https://lore.kernel.org/all/20250307225008.779961-1-ojeda@kernel.org/ Change-Id: I31aeaca89eb007302d1738e1be9d3789e92b404c Fixes: 1ef4cf5f98c4 ("rust: alloc: update module comment of alloc.rs") Signed-off-by: Alice Ryhl Signed-off-by: Greg Kroah-Hartman [Removed FFI integer changes because the stable backport does not yet contain those. ] Signed-off-by: Matthew Maurer --- drivers/staging/android/ashmem_rust.rs | 20 ++++++++++---------- drivers/staging/android/ashmem_toggle.rs | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/android/ashmem_rust.rs b/drivers/staging/android/ashmem_rust.rs index 3be718cef354..91eb93f0a11f 100644 --- a/drivers/staging/android/ashmem_rust.rs +++ b/drivers/staging/android/ashmem_rust.rs @@ -82,10 +82,10 @@ module! { } struct AshmemModule { - _misc: Pin>>, - _toggle_unpin: Pin>>>, - _toggle_read: Pin>>>, - _toggle_exec: Pin>>>, + _misc: Pin>>, + _toggle_unpin: Pin>>>, + _toggle_read: Pin>>>, + _toggle_exec: Pin>>>, } impl kernel::Module for AshmemModule { @@ -102,7 +102,7 @@ impl kernel::Module for AshmemModule { ashmem_range::set_shrinker_enabled(true)?; Ok(Self { - _misc: Box::pin_init( + _misc: KBox::pin_init( MiscDeviceRegistration::register(MiscDeviceOptions { name: c_str!("ashmem"), }), @@ -126,17 +126,17 @@ struct AshmemInner { size: usize, prot_mask: usize, /// If set, then this holds the ashmem name without the dev/ashmem/ prefix. No zero terminator. - name: Option>, + name: Option>, file: Option, area: Area, } #[vtable] impl MiscDevice for Ashmem { - type Ptr = Pin>; + type Ptr = Pin>; - fn open(_: &File, _: &MiscDeviceRegistration) -> Result>> { - Box::try_pin_init( + fn open(_: &File, _: &MiscDeviceRegistration) -> Result>> { + KBox::try_pin_init( try_pin_init! { Ashmem { inner <- new_mutex!(AshmemInner { @@ -296,7 +296,7 @@ impl Ashmem { .position(|&c| c == 0) .unwrap_or(local_name.len() - 1); - let mut v = Vec::with_capacity(len, GFP_KERNEL)?; + let mut v = KVec::with_capacity(len, GFP_KERNEL)?; v.extend_from_slice(&local_name[..len], GFP_KERNEL)?; let mut asma = self.inner.lock(); diff --git a/drivers/staging/android/ashmem_toggle.rs b/drivers/staging/android/ashmem_toggle.rs index 741d5e8569bd..1ab234f17085 100644 --- a/drivers/staging/android/ashmem_toggle.rs +++ b/drivers/staging/android/ashmem_toggle.rs @@ -29,8 +29,8 @@ pub(crate) trait AshmemToggle { pub(crate) struct AshmemToggleMisc(PhantomData); impl AshmemToggleMisc { - pub(crate) fn new() -> Result>>>> { - Box::pin_init( + pub(crate) fn new() -> Result>>>> { + KBox::pin_init( MiscDeviceRegistration::register(MiscDeviceOptions { name: T::NAME }), GFP_KERNEL, )