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: 1ef4cf5f98 ("rust: alloc: update module comment of alloc.rs")
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
[Removed FFI integer changes because the stable backport does not yet
contain those. <mmaurer@google.com>]
Signed-off-by: Matthew Maurer <mmaurer@google.com>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
dfed1574cd
commit
5786aa1472
@@ -82,10 +82,10 @@ module! {
|
||||
}
|
||||
|
||||
struct AshmemModule {
|
||||
_misc: Pin<Box<MiscDeviceRegistration<Ashmem>>>,
|
||||
_toggle_unpin: Pin<Box<MiscDeviceRegistration<AshmemToggleMisc<AshmemToggleShrinker>>>>,
|
||||
_toggle_read: Pin<Box<MiscDeviceRegistration<AshmemToggleMisc<AshmemToggleRead>>>>,
|
||||
_toggle_exec: Pin<Box<MiscDeviceRegistration<AshmemToggleMisc<AshmemToggleExec>>>>,
|
||||
_misc: Pin<KBox<MiscDeviceRegistration<Ashmem>>>,
|
||||
_toggle_unpin: Pin<KBox<MiscDeviceRegistration<AshmemToggleMisc<AshmemToggleShrinker>>>>,
|
||||
_toggle_read: Pin<KBox<MiscDeviceRegistration<AshmemToggleMisc<AshmemToggleRead>>>>,
|
||||
_toggle_exec: Pin<KBox<MiscDeviceRegistration<AshmemToggleMisc<AshmemToggleExec>>>>,
|
||||
}
|
||||
|
||||
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<Vec<u8>>,
|
||||
name: Option<KVec<u8>>,
|
||||
file: Option<ShmemFile>,
|
||||
area: Area,
|
||||
}
|
||||
|
||||
#[vtable]
|
||||
impl MiscDevice for Ashmem {
|
||||
type Ptr = Pin<Box<Self>>;
|
||||
type Ptr = Pin<KBox<Self>>;
|
||||
|
||||
fn open(_: &File, _: &MiscDeviceRegistration<Ashmem>) -> Result<Pin<Box<Self>>> {
|
||||
Box::try_pin_init(
|
||||
fn open(_: &File, _: &MiscDeviceRegistration<Ashmem>) -> Result<Pin<KBox<Self>>> {
|
||||
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();
|
||||
|
||||
@@ -29,8 +29,8 @@ pub(crate) trait AshmemToggle {
|
||||
pub(crate) struct AshmemToggleMisc<T>(PhantomData<T>);
|
||||
|
||||
impl<T: AshmemToggle> AshmemToggleMisc<T> {
|
||||
pub(crate) fn new() -> Result<Pin<Box<MiscDeviceRegistration<AshmemToggleMisc<T>>>>> {
|
||||
Box::pin_init(
|
||||
pub(crate) fn new() -> Result<Pin<KBox<MiscDeviceRegistration<AshmemToggleMisc<T>>>>> {
|
||||
KBox::pin_init(
|
||||
MiscDeviceRegistration::register(MiscDeviceOptions { name: T::NAME }),
|
||||
GFP_KERNEL,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user