diff --git a/drivers/android/allocation.rs b/drivers/android/allocation.rs index 3239b96ce01bcb..3bd5a068273455 100644 --- a/drivers/android/allocation.rs +++ b/drivers/android/allocation.rs @@ -1,10 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 -use alloc::{boxed::Box, sync::Arc}; use core::mem::{replace, size_of, MaybeUninit}; -use kernel::{ - bindings, linked_list::List, pages::Pages, prelude::*, user_ptr::UserSlicePtrReader, Error, -}; +use kernel::{bindings, linked_list::List, pages::Pages, prelude::*, user_ptr::UserSlicePtrReader}; use crate::{ defs::*, diff --git a/drivers/android/context.rs b/drivers/android/context.rs index c402882930849e..3e10f441640018 100644 --- a/drivers/android/context.rs +++ b/drivers/android/context.rs @@ -5,7 +5,6 @@ use kernel::{ prelude::*, security, sync::{Mutex, Ref}, - Error, }; use crate::{ diff --git a/drivers/android/node.rs b/drivers/android/node.rs index 3883aa01aaa6c8..2a886e31df4cb5 100644 --- a/drivers/android/node.rs +++ b/drivers/android/node.rs @@ -1,10 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 -use alloc::sync::Arc; -use core::{ - pin::Pin, - sync::atomic::{AtomicU64, Ordering}, -}; +use core::sync::atomic::{AtomicU64, Ordering}; use kernel::{ io_buffer::IoBufferWriter, linked_list::{GetLinks, Links, List}, diff --git a/drivers/android/process.rs b/drivers/android/process.rs index 19ae270ee2d4a0..8c6caaae9c7d77 100644 --- a/drivers/android/process.rs +++ b/drivers/android/process.rs @@ -1,10 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 -use alloc::{sync::Arc, vec::Vec}; use core::{ mem::{take, MaybeUninit}, ops::Range, - pin::Pin, }; use kernel::{ bindings, c_types, @@ -18,7 +16,6 @@ use kernel::{ sync::{Guard, Mutex, Ref}, task::Task, user_ptr::{UserSlicePtr, UserSlicePtrReader}, - Error, }; use crate::{ diff --git a/drivers/android/range_alloc.rs b/drivers/android/range_alloc.rs index 42d9c364d51293..9ece39c5e1dfac 100644 --- a/drivers/android/range_alloc.rs +++ b/drivers/android/range_alloc.rs @@ -1,11 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 -use alloc::boxed::Box; use core::ptr::NonNull; use kernel::{ linked_list::{CursorMut, GetLinks, Links, List}, prelude::*, - Error, }; pub(crate) struct RangeAllocator { diff --git a/drivers/android/rust_binder.rs b/drivers/android/rust_binder.rs index 8f457913154afe..c2b080fd5eb34b 100644 --- a/drivers/android/rust_binder.rs +++ b/drivers/android/rust_binder.rs @@ -7,8 +7,6 @@ #![no_std] #![feature(global_asm, try_reserve, allocator_api, concat_idents)] -use alloc::{boxed::Box, sync::Arc}; -use core::pin::Pin; use kernel::{ c_str, io_buffer::IoBufferWriter, diff --git a/drivers/android/thread.rs b/drivers/android/thread.rs index 5dab75f849d664..3da133aa258c27 100644 --- a/drivers/android/thread.rs +++ b/drivers/android/thread.rs @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 -use alloc::{boxed::Box, sync::Arc}; -use core::{alloc::AllocError, mem::size_of, pin::Pin}; +use core::{alloc::AllocError, mem::size_of}; use kernel::{ bindings, file::File, @@ -12,7 +11,6 @@ use kernel::{ security, sync::{CondVar, Ref, SpinLock}, user_ptr::{UserSlicePtr, UserSlicePtrWriter}, - Error, }; use crate::{ diff --git a/drivers/android/transaction.rs b/drivers/android/transaction.rs index 7835d5b2189a03..106762a8c20a55 100644 --- a/drivers/android/transaction.rs +++ b/drivers/android/transaction.rs @@ -1,10 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 -use alloc::{boxed::Box, sync::Arc}; -use core::{ - pin::Pin, - sync::atomic::{AtomicBool, Ordering}, -}; +use core::sync::atomic::{AtomicBool, Ordering}; use kernel::{ bindings, file::{File, FileDescriptorReservation}, @@ -14,7 +10,7 @@ use kernel::{ prelude::*, sync::{Ref, SpinLock}, user_ptr::UserSlicePtrWriter, - Error, ScopeGuard, + ScopeGuard, }; use crate::{ diff --git a/drivers/char/hw_random/bcm2835_rng_rust.rs b/drivers/char/hw_random/bcm2835_rng_rust.rs index f3c0680011d355..ef7e0f6a29fde1 100644 --- a/drivers/char/hw_random/bcm2835_rng_rust.rs +++ b/drivers/char/hw_random/bcm2835_rng_rust.rs @@ -5,8 +5,6 @@ #![no_std] #![feature(allocator_api, global_asm)] -use alloc::boxed::Box; -use core::pin::Pin; use kernel::{ file::File, file_operations::{FileOpener, FileOperations}, diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs index 38e9b4050363e9..c0bf618099adc5 100644 --- a/rust/kernel/prelude.rs +++ b/rust/kernel/prelude.rs @@ -2,8 +2,8 @@ //! The `kernel` prelude. //! -//! These are most common items used by Rust code in the kernel, intended to -//! be imported by all Rust code, for convenience. +//! These are the most common items used by Rust code in the kernel, +//! intended to be imported by all Rust code, for convenience. //! //! # Examples //! @@ -11,16 +11,18 @@ //! use kernel::prelude::*; //! ``` -pub use alloc::{borrow::ToOwned, string::String}; +pub use core::pin::Pin; -pub use super::build_assert; +pub use alloc::{boxed::Box, string::String, sync::Arc, vec::Vec}; pub use macros::{module, module_misc_device}; +pub use super::build_assert; + pub use super::{pr_alert, pr_crit, pr_emerg, pr_err, pr_info, pr_notice, pr_warn}; pub use super::static_assert; -pub use super::{KernelModule, Result}; +pub use super::{Error, KernelModule, Result}; pub use crate::traits::TryPin; diff --git a/samples/rust/rust_chrdev.rs b/samples/rust/rust_chrdev.rs index 0e8151dd783940..ccdfb2da785557 100644 --- a/samples/rust/rust_chrdev.rs +++ b/samples/rust/rust_chrdev.rs @@ -5,8 +5,6 @@ #![no_std] #![feature(allocator_api, global_asm)] -use alloc::boxed::Box; -use core::pin::Pin; use kernel::prelude::*; use kernel::{c_str, chrdev, file_operations::FileOperations}; diff --git a/samples/rust/rust_miscdev.rs b/samples/rust/rust_miscdev.rs index db3fd025315ac4..df8681af9cc270 100644 --- a/samples/rust/rust_miscdev.rs +++ b/samples/rust/rust_miscdev.rs @@ -5,8 +5,6 @@ #![no_std] #![feature(allocator_api, global_asm)] -use alloc::boxed::Box; -use core::pin::Pin; use kernel::prelude::*; use kernel::{ c_str, @@ -15,7 +13,6 @@ use kernel::{ io_buffer::{IoBufferReader, IoBufferWriter}, miscdev, sync::{CondVar, Mutex, Ref}, - Error, }; module! { diff --git a/samples/rust/rust_semaphore.rs b/samples/rust/rust_semaphore.rs index 2ca4ae97e485f6..1408d5095b887e 100644 --- a/samples/rust/rust_semaphore.rs +++ b/samples/rust/rust_semaphore.rs @@ -16,11 +16,7 @@ #![no_std] #![feature(allocator_api, global_asm)] -use alloc::boxed::Box; -use core::{ - pin::Pin, - sync::atomic::{AtomicU64, Ordering}, -}; +use core::sync::atomic::{AtomicU64, Ordering}; use kernel::{ c_str, condvar_init, declare_file_operations, file::File, @@ -31,7 +27,6 @@ use kernel::{ prelude::*, sync::{CondVar, Mutex, Ref}, user_ptr::{UserSlicePtrReader, UserSlicePtrWriter}, - Error, }; module! { diff --git a/samples/rust/rust_sync.rs b/samples/rust/rust_sync.rs index 76f8f8d4e4ba37..40bbfec9ad278f 100644 --- a/samples/rust/rust_sync.rs +++ b/samples/rust/rust_sync.rs @@ -5,8 +5,6 @@ #![no_std] #![feature(allocator_api, global_asm)] -use alloc::boxed::Box; -use core::pin::Pin; use kernel::prelude::*; use kernel::{ condvar_init, mutex_init, spinlock_init,