Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions drivers/android/allocation.rs
Original file line number Diff line number Diff line change
@@ -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::*,
Expand Down
1 change: 0 additions & 1 deletion drivers/android/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use kernel::{
prelude::*,
security,
sync::{Mutex, Ref},
Error,
};

use crate::{
Expand Down
6 changes: 1 addition & 5 deletions drivers/android/node.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down
3 changes: 0 additions & 3 deletions drivers/android/process.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -18,7 +16,6 @@ use kernel::{
sync::{Guard, Mutex, Ref},
task::Task,
user_ptr::{UserSlicePtr, UserSlicePtrReader},
Error,
};

use crate::{
Expand Down
2 changes: 0 additions & 2 deletions drivers/android/range_alloc.rs
Original file line number Diff line number Diff line change
@@ -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<T> {
Expand Down
2 changes: 0 additions & 2 deletions drivers/android/rust_binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions drivers/android/thread.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -12,7 +11,6 @@ use kernel::{
security,
sync::{CondVar, Ref, SpinLock},
user_ptr::{UserSlicePtr, UserSlicePtrWriter},
Error,
};

use crate::{
Expand Down
8 changes: 2 additions & 6 deletions drivers/android/transaction.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand All @@ -14,7 +10,7 @@ use kernel::{
prelude::*,
sync::{Ref, SpinLock},
user_ptr::UserSlicePtrWriter,
Error, ScopeGuard,
ScopeGuard,
};

use crate::{
Expand Down
2 changes: 0 additions & 2 deletions drivers/char/hw_random/bcm2835_rng_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
12 changes: 7 additions & 5 deletions rust/kernel/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@

//! 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
//!
//! ```
//! use kernel::prelude::*;
//! ```
pub use alloc::{borrow::ToOwned, string::String};
pub use core::pin::Pin;

pub use super::build_assert;
pub use alloc::{borrow::ToOwned, 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;
2 changes: 0 additions & 2 deletions samples/rust/rust_chrdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
3 changes: 0 additions & 3 deletions samples/rust/rust_miscdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -15,7 +13,6 @@ use kernel::{
io_buffer::{IoBufferReader, IoBufferWriter},
miscdev,
sync::{CondVar, Mutex, Ref},
Error,
};

module! {
Expand Down
7 changes: 1 addition & 6 deletions samples/rust/rust_semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -31,7 +27,6 @@ use kernel::{
prelude::*,
sync::{CondVar, Mutex, Ref},
user_ptr::{UserSlicePtrReader, UserSlicePtrWriter},
Error,
};

module! {
Expand Down
2 changes: 0 additions & 2 deletions samples/rust/rust_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down