Skip to content

Commit 1f38791

Browse files
authored
Merge pull request #422 from ojeda/prelude
Graduate `Box`, `Arc`, `Vec`, `Pin` and `Error`
2 parents cd8d764 + fccb46b commit 1f38791

File tree

14 files changed

+13
-46
lines changed

14 files changed

+13
-46
lines changed

drivers/android/allocation.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3-
use alloc::{boxed::Box, sync::Arc};
43
use core::mem::{replace, size_of, MaybeUninit};
5-
use kernel::{
6-
bindings, linked_list::List, pages::Pages, prelude::*, user_ptr::UserSlicePtrReader, Error,
7-
};
4+
use kernel::{bindings, linked_list::List, pages::Pages, prelude::*, user_ptr::UserSlicePtrReader};
85

96
use crate::{
107
defs::*,

drivers/android/context.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use kernel::{
55
prelude::*,
66
security,
77
sync::{Mutex, Ref},
8-
Error,
98
};
109

1110
use crate::{

drivers/android/node.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3-
use alloc::sync::Arc;
4-
use core::{
5-
pin::Pin,
6-
sync::atomic::{AtomicU64, Ordering},
7-
};
3+
use core::sync::atomic::{AtomicU64, Ordering};
84
use kernel::{
95
io_buffer::IoBufferWriter,
106
linked_list::{GetLinks, Links, List},

drivers/android/process.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3-
use alloc::{sync::Arc, vec::Vec};
43
use core::{
54
mem::{take, MaybeUninit},
65
ops::Range,
7-
pin::Pin,
86
};
97
use kernel::{
108
bindings, c_types,
@@ -18,7 +16,6 @@ use kernel::{
1816
sync::{Guard, Mutex, Ref},
1917
task::Task,
2018
user_ptr::{UserSlicePtr, UserSlicePtrReader},
21-
Error,
2219
};
2320

2421
use crate::{

drivers/android/range_alloc.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3-
use alloc::boxed::Box;
43
use core::ptr::NonNull;
54
use kernel::{
65
linked_list::{CursorMut, GetLinks, Links, List},
76
prelude::*,
8-
Error,
97
};
108

119
pub(crate) struct RangeAllocator<T> {

drivers/android/rust_binder.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#![no_std]
88
#![feature(global_asm, try_reserve, allocator_api, concat_idents)]
99

10-
use alloc::{boxed::Box, sync::Arc};
11-
use core::pin::Pin;
1210
use kernel::{
1311
c_str,
1412
io_buffer::IoBufferWriter,

drivers/android/thread.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3-
use alloc::{boxed::Box, sync::Arc};
4-
use core::{alloc::AllocError, mem::size_of, pin::Pin};
3+
use core::{alloc::AllocError, mem::size_of};
54
use kernel::{
65
bindings,
76
file::File,
@@ -12,7 +11,6 @@ use kernel::{
1211
security,
1312
sync::{CondVar, Ref, SpinLock},
1413
user_ptr::{UserSlicePtr, UserSlicePtrWriter},
15-
Error,
1614
};
1715

1816
use crate::{

drivers/android/transaction.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3-
use alloc::{boxed::Box, sync::Arc};
4-
use core::{
5-
pin::Pin,
6-
sync::atomic::{AtomicBool, Ordering},
7-
};
3+
use core::sync::atomic::{AtomicBool, Ordering};
84
use kernel::{
95
bindings,
106
file::{File, FileDescriptorReservation},
@@ -14,7 +10,7 @@ use kernel::{
1410
prelude::*,
1511
sync::{Ref, SpinLock},
1612
user_ptr::UserSlicePtrWriter,
17-
Error, ScopeGuard,
13+
ScopeGuard,
1814
};
1915

2016
use crate::{

drivers/char/hw_random/bcm2835_rng_rust.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#![no_std]
66
#![feature(allocator_api, global_asm)]
77

8-
use alloc::boxed::Box;
9-
use core::pin::Pin;
108
use kernel::{
119
file::File,
1210
file_operations::{FileOpener, FileOperations},

rust/kernel/prelude.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,27 @@
22

33
//! The `kernel` prelude.
44
//!
5-
//! These are most common items used by Rust code in the kernel, intended to
6-
//! be imported by all Rust code, for convenience.
5+
//! These are the most common items used by Rust code in the kernel,
6+
//! intended to be imported by all Rust code, for convenience.
77
//!
88
//! # Examples
99
//!
1010
//! ```
1111
//! use kernel::prelude::*;
1212
//! ```
1313
14-
pub use alloc::{borrow::ToOwned, string::String};
14+
pub use core::pin::Pin;
1515

16-
pub use super::build_assert;
16+
pub use alloc::{boxed::Box, string::String, sync::Arc, vec::Vec};
1717

1818
pub use macros::{module, module_misc_device};
1919

20+
pub use super::build_assert;
21+
2022
pub use super::{pr_alert, pr_crit, pr_emerg, pr_err, pr_info, pr_notice, pr_warn};
2123

2224
pub use super::static_assert;
2325

24-
pub use super::{KernelModule, Result};
26+
pub use super::{Error, KernelModule, Result};
2527

2628
pub use crate::traits::TryPin;

samples/rust/rust_chrdev.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#![no_std]
66
#![feature(allocator_api, global_asm)]
77

8-
use alloc::boxed::Box;
9-
use core::pin::Pin;
108
use kernel::prelude::*;
119
use kernel::{c_str, chrdev, file_operations::FileOperations};
1210

samples/rust/rust_miscdev.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#![no_std]
66
#![feature(allocator_api, global_asm)]
77

8-
use alloc::boxed::Box;
9-
use core::pin::Pin;
108
use kernel::prelude::*;
119
use kernel::{
1210
c_str,
@@ -15,7 +13,6 @@ use kernel::{
1513
io_buffer::{IoBufferReader, IoBufferWriter},
1614
miscdev,
1715
sync::{CondVar, Mutex, Ref},
18-
Error,
1916
};
2017

2118
module! {

samples/rust/rust_semaphore.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616
#![no_std]
1717
#![feature(allocator_api, global_asm)]
1818

19-
use alloc::boxed::Box;
20-
use core::{
21-
pin::Pin,
22-
sync::atomic::{AtomicU64, Ordering},
23-
};
19+
use core::sync::atomic::{AtomicU64, Ordering};
2420
use kernel::{
2521
c_str, condvar_init, declare_file_operations,
2622
file::File,
@@ -31,7 +27,6 @@ use kernel::{
3127
prelude::*,
3228
sync::{CondVar, Mutex, Ref},
3329
user_ptr::{UserSlicePtrReader, UserSlicePtrWriter},
34-
Error,
3530
};
3631

3732
module! {

samples/rust/rust_sync.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#![no_std]
66
#![feature(allocator_api, global_asm)]
77

8-
use alloc::boxed::Box;
9-
use core::pin::Pin;
108
use kernel::prelude::*;
119
use kernel::{
1210
condvar_init, mutex_init, spinlock_init,

0 commit comments

Comments
 (0)