From: Danilo Krummrich <dakr@redhat.com>
To: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com,
boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com,
benno.lossin@proton.me, a.hindborg@samsung.com,
aliceryhl@google.com, ajanulgu@redhat.com, zhiw@nvidia.com,
acurrid@nvidia.com, cjia@nvidia.com, jhubbard@nvidia.com
Cc: rust-for-linux@vger.kernel.org, Danilo Krummrich <dakr@redhat.com>
Subject: [PATCH WIP 2/8] rust: alloc: use AllocError from core::alloc
Date: Mon, 29 Apr 2024 22:11:52 +0200 [thread overview]
Message-ID: <20240429201202.3490-3-dakr@redhat.com> (raw)
In-Reply-To: <20240429201202.3490-1-dakr@redhat.com>
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
rust/kernel/alloc.rs | 4 ----
rust/kernel/alloc/box_ext.rs | 3 ++-
rust/kernel/alloc/vec_ext.rs | 3 ++-
rust/kernel/error.rs | 3 ++-
rust/kernel/init.rs | 3 ++-
rust/kernel/str.rs | 3 ++-
rust/kernel/sync/arc.rs | 4 ++--
rust/kernel/workqueue.rs | 3 ++-
8 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs
index f1c2c4aa22d2..9bc1b48b5641 100644
--- a/rust/kernel/alloc.rs
+++ b/rust/kernel/alloc.rs
@@ -8,10 +8,6 @@
pub mod box_ext;
pub mod vec_ext;
-/// Indicates an allocation error.
-#[derive(Copy, Clone, PartialEq, Eq, Debug)]
-pub struct AllocError;
-
/// Flags to be used when allocating memory.
///
/// They can be combined with the operators `|`, `&`, and `!`.
diff --git a/rust/kernel/alloc/box_ext.rs b/rust/kernel/alloc/box_ext.rs
index cdbb5ad166d9..76653d6f4257 100644
--- a/rust/kernel/alloc/box_ext.rs
+++ b/rust/kernel/alloc/box_ext.rs
@@ -2,8 +2,9 @@
//! Extensions to [`Box`] for fallible allocations.
-use super::{AllocError, Flags};
+use super::Flags;
use alloc::boxed::Box;
+use core::alloc::AllocError;
use core::mem::MaybeUninit;
use core::result::Result;
diff --git a/rust/kernel/alloc/vec_ext.rs b/rust/kernel/alloc/vec_ext.rs
index 6a916fcf8bf1..1dc991b44be7 100644
--- a/rust/kernel/alloc/vec_ext.rs
+++ b/rust/kernel/alloc/vec_ext.rs
@@ -2,8 +2,9 @@
//! Extensions to [`Vec`] for fallible allocations.
-use super::{AllocError, Flags};
+use super::Flags;
use alloc::vec::Vec;
+use core::alloc::AllocError;
use core::result::Result;
/// Extensions to [`Vec`].
diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
index fc986bc24c6d..7151a5bd682a 100644
--- a/rust/kernel/error.rs
+++ b/rust/kernel/error.rs
@@ -4,10 +4,11 @@
//!
//! C header: [`include/uapi/asm-generic/errno-base.h`](srctree/include/uapi/asm-generic/errno-base.h)
-use crate::{alloc::AllocError, str::CStr};
+use crate::str::CStr;
use alloc::alloc::LayoutError;
+use core::alloc::AllocError;
use core::convert::From;
use core::fmt;
use core::num::TryFromIntError;
diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs
index 9608f2bd2211..fec47b274ec3 100644
--- a/rust/kernel/init.rs
+++ b/rust/kernel/init.rs
@@ -211,13 +211,14 @@
//! [`pin_init!`]: crate::pin_init!
use crate::{
- alloc::{box_ext::BoxExt, AllocError, Flags},
+ alloc::{box_ext::BoxExt, Flags},
error::{self, Error},
sync::UniqueArc,
types::{Opaque, ScopeGuard},
};
use alloc::boxed::Box;
use core::{
+ alloc::AllocError,
cell::UnsafeCell,
convert::Infallible,
marker::PhantomData,
diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs
index 27641c3e4df8..2e7ab4a620b6 100644
--- a/rust/kernel/str.rs
+++ b/rust/kernel/str.rs
@@ -2,8 +2,9 @@
//! String representations.
-use crate::alloc::{flags::*, vec_ext::VecExt, AllocError};
+use crate::alloc::{flags::*, vec_ext::VecExt};
use alloc::vec::Vec;
+use core::alloc::AllocError;
use core::fmt::{self, Write};
use core::ops::{self, Deref, DerefMut, Index};
diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
index c2a3a2c7cbc5..0866378f1360 100644
--- a/rust/kernel/sync/arc.rs
+++ b/rust/kernel/sync/arc.rs
@@ -16,7 +16,7 @@
//! [`Arc`]: https://doc.rust-lang.org/std/sync/struct.Arc.html
use crate::{
- alloc::{box_ext::BoxExt, AllocError, Flags},
+ alloc::{box_ext::BoxExt, Flags},
bindings,
error::{self, Error},
init::{self, InPlaceInit, Init, PinInit},
@@ -25,7 +25,7 @@
};
use alloc::boxed::Box;
use core::{
- alloc::Layout,
+ alloc::{AllocError, Layout},
fmt,
marker::{PhantomData, Unsize},
mem::{ManuallyDrop, MaybeUninit},
diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
index 9f47bad0b003..0027cc730d6b 100644
--- a/rust/kernel/workqueue.rs
+++ b/rust/kernel/workqueue.rs
@@ -132,9 +132,10 @@
//!
//! C header: [`include/linux/workqueue.h`](srctree/include/linux/workqueue.h)
-use crate::alloc::{AllocError, Flags};
+use crate::alloc::Flags;
use crate::{bindings, prelude::*, sync::Arc, sync::LockClassKey, types::Opaque};
use alloc::boxed::Box;
+use core::alloc::AllocError;
use core::marker::PhantomData;
use core::pin::Pin;
--
2.44.0
next prev parent reply other threads:[~2024-04-29 20:12 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 20:11 [PATCH WIP 0/8] Draft: Alternative allocator support Danilo Krummrich
2024-04-29 20:11 ` [PATCH WIP 1/8] rust: alloc: re-enable allocator_api Danilo Krummrich
2024-04-29 20:11 ` Danilo Krummrich [this message]
2024-04-29 20:11 ` [PATCH WIP 3/8] rust: alloc: implement AllocatorWithFlags trait Danilo Krummrich
2024-05-01 8:32 ` Benno Lossin
2024-05-01 12:50 ` Danilo Krummrich
2024-05-01 15:39 ` Benno Lossin
2024-05-01 15:48 ` Danilo Krummrich
2024-05-01 21:38 ` Miguel Ojeda
2024-05-03 15:27 ` Gary Guo
2024-05-06 13:17 ` Danilo Krummrich
2024-04-29 20:11 ` [PATCH WIP 4/8] rust: alloc: separate krealloc_aligned() Danilo Krummrich
2024-04-29 20:11 ` [PATCH WIP 5/8] rust: alloc: implement AllocatorWithFlags for KernelAllocator Danilo Krummrich
2024-05-01 8:44 ` Benno Lossin
2024-05-01 12:52 ` Danilo Krummrich
2024-04-29 20:11 ` [PATCH WIP 6/8] rust: alloc: implement BoxExtAlloc Danilo Krummrich
2024-05-01 8:53 ` Benno Lossin
2024-05-01 13:06 ` Danilo Krummrich
2024-05-01 15:46 ` Benno Lossin
2024-05-01 17:30 ` Danilo Krummrich
2024-04-29 20:11 ` [PATCH WIP 7/8] rust: alloc: implement VecExtAlloc Danilo Krummrich
2024-04-29 20:11 ` [PATCH WIP 8/8] rust: alloc: implement vmalloc allocator Danilo Krummrich
2024-05-01 21:32 ` [PATCH WIP 0/8] Draft: Alternative allocator support Miguel Ojeda
2024-05-01 22:31 ` Danilo Krummrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240429201202.3490-3-dakr@redhat.com \
--to=dakr@redhat.com \
--cc=a.hindborg@samsung.com \
--cc=acurrid@nvidia.com \
--cc=ajanulgu@redhat.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=cjia@nvidia.com \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.com \
--cc=zhiw@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).