Skip to content

Commit 3d7361e

Browse files
authored
Merge pull request raspberrypi#731 from wedsonaf/module
rust: rename `KernelModule` to `Module`
2 parents aee0f6d + 4d90b2c commit 3d7361e

16 files changed

+24
-24
lines changed

drivers/android/rust_binder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct BinderModule {
102102
_reg: Pin<Box<Registration<process::Process>>>,
103103
}
104104

105-
impl KernelModule for BinderModule {
105+
impl kernel::Module for BinderModule {
106106
fn init(name: &'static CStr, _module: &'static kernel::ThisModule) -> Result<Self> {
107107
let ctx = Context::new()?;
108108
let reg = Registration::new_pinned(fmt!("{name}"), ctx)?;

rust/kernel/chrdev.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<const N: usize> Registration<{ N }> {
100100
///
101101
/// This associated function is intended to be used when you need to avoid
102102
/// a memory allocation, e.g. when the [`Registration`] is a member of
103-
/// a bigger structure inside your [`crate::KernelModule`] instance. If you
103+
/// a bigger structure inside your [`crate::Module`] instance. If you
104104
/// are going to pin the registration right away, call
105105
/// [`Self::new_pinned()`] instead.
106106
pub fn new(

rust/kernel/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! Each bus/subsystem is expected to implement [`DriverOps`], which allows drivers to register
66
//! using the [`Registration`] class.
77
8-
use crate::{error::code::*, str::CStr, sync::Ref, KernelModule, Result, ThisModule};
8+
use crate::{error::code::*, str::CStr, sync::Ref, Result, ThisModule};
99
use alloc::boxed::Box;
1010
use core::{cell::UnsafeCell, marker::PhantomData, ops::Deref, pin::Pin};
1111

@@ -415,7 +415,7 @@ pub struct Module<T: DriverOps> {
415415
_driver: Pin<Box<Registration<T>>>,
416416
}
417417

418-
impl<T: DriverOps> KernelModule for Module<T> {
418+
impl<T: DriverOps> crate::Module for Module<T> {
419419
fn init(name: &'static CStr, module: &'static ThisModule) -> Result<Self> {
420420
Ok(Self {
421421
_driver: Registration::new_pinned(name, module)?,

rust/kernel/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const __LOG_PREFIX: &[u8] = b"rust_kernel\0";
115115
/// The top level entrypoint to implementing a kernel module.
116116
///
117117
/// For any teardown or cleanup operations, your type may implement [`Drop`].
118-
pub trait KernelModule: Sized + Sync {
118+
pub trait Module: Sized + Sync {
119119
/// Called at module initialization time.
120120
///
121121
/// Use this method to perform whatever setup or registration your module

rust/kernel/miscdev.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use crate::bindings;
1010
use crate::error::{code::*, Error, Result};
1111
use crate::file;
12-
use crate::{device, str::CStr, str::CString, KernelModule, ThisModule};
12+
use crate::{device, str::CStr, str::CString, ThisModule};
1313
use alloc::boxed::Box;
1414
use core::marker::PhantomPinned;
1515
use core::{fmt, mem::MaybeUninit, pin::Pin};
@@ -242,7 +242,7 @@ pub struct Module<T: file::Operations<OpenData = ()>> {
242242
_dev: Pin<Box<Registration<T>>>,
243243
}
244244

245-
impl<T: file::Operations<OpenData = ()>> KernelModule for Module<T> {
245+
impl<T: file::Operations<OpenData = ()>> crate::Module for Module<T> {
246246
fn init(name: &'static CStr, _module: &'static ThisModule) -> Result<Self> {
247247
Ok(Self {
248248
_dev: Registration::new_pinned(crate::fmt!("{name}"), ())?,

rust/kernel/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ pub use super::module_amba_driver;
3131

3232
pub use super::static_assert;
3333

34-
pub use super::{error::code::*, Error, KernelModule, Result};
34+
pub use super::{error::code::*, Error, Result};
3535

3636
pub use super::{str::CStr, ARef, ThisModule};

rust/macros/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ use proc_macro::TokenStream;
99

1010
/// Declares a kernel module.
1111
///
12-
/// The `type` argument should be a type which implements the [`KernelModule`]
12+
/// The `type` argument should be a type which implements the [`Module`]
1313
/// trait. Also accepts various forms of kernel metadata.
1414
///
1515
/// C header: [`include/linux/moduleparam.h`](../../../include/linux/moduleparam.h)
1616
///
17-
/// [`KernelModule`]: ../kernel/trait.KernelModule.html
17+
/// [`Module`]: ../kernel/trait.Module.html
1818
///
1919
/// # Examples
2020
///
2121
/// ```ignore
2222
/// use kernel::prelude::*;
2323
///
2424
/// module!{
25-
/// type: MyKernelModule,
25+
/// type: MyModule,
2626
/// name: b"my_kernel_module",
2727
/// author: b"Rust for Linux Contributors",
2828
/// description: b"My very own kernel module!",
@@ -41,9 +41,9 @@ use proc_macro::TokenStream;
4141
/// },
4242
/// }
4343
///
44-
/// struct MyKernelModule;
44+
/// struct MyModule;
4545
///
46-
/// impl KernelModule for MyKernelModule {
46+
/// impl kernel::Module for MyModule {
4747
/// fn init() -> Result<Self> {
4848
/// // If the parameter is writeable, then the kparam lock must be
4949
/// // taken to read the parameter:
@@ -54,13 +54,13 @@ use proc_macro::TokenStream;
5454
/// // If the parameter is read only, it can be read without locking
5555
/// // the kernel parameters:
5656
/// pr_info!("i32 param is: {}\n", my_i32.read());
57-
/// Ok(MyKernelModule)
57+
/// Ok(Self)
5858
/// }
5959
/// }
6060
/// ```
6161
///
6262
/// # Supported argument types
63-
/// - `type`: type which implements the [`KernelModule`] trait (required).
63+
/// - `type`: type which implements the [`Module`] trait (required).
6464
/// - `name`: byte array of the name of the kernel module (required).
6565
/// - `author`: byte array of the author of the kernel module.
6666
/// - `description`: byte array of the description of the kernel module.

rust/macros/module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
569569
}}
570570
571571
fn __init() -> kernel::c_types::c_int {{
572-
match <{type_} as kernel::KernelModule>::init(kernel::c_str!(\"{name}\"), &THIS_MODULE) {{
572+
match <{type_} as kernel::Module>::init(kernel::c_str!(\"{name}\"), &THIS_MODULE) {{
573573
Ok(m) => {{
574574
unsafe {{
575575
__MOD = Some(m);

samples/rust/rust_chrdev.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct RustChrdev {
2727
_dev: Pin<Box<chrdev::Registration<2>>>,
2828
}
2929

30-
impl KernelModule for RustChrdev {
30+
impl kernel::Module for RustChrdev {
3131
fn init(name: &'static CStr, module: &'static ThisModule) -> Result<Self> {
3232
pr_info!("Rust character device sample (init)\n");
3333

samples/rust/rust_minimal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct RustMinimal {
1616
message: String,
1717
}
1818

19-
impl KernelModule for RustMinimal {
19+
impl kernel::Module for RustMinimal {
2020
fn init(_name: &'static CStr, _module: &'static ThisModule) -> Result<Self> {
2121
pr_info!("Rust minimal sample (init)\n");
2222
pr_info!("Am I built-in? {}\n", !cfg!(MODULE));

samples/rust/rust_miscdev.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct RustMiscdev {
124124
_dev: Pin<Box<miscdev::Registration<Token>>>,
125125
}
126126

127-
impl KernelModule for RustMiscdev {
127+
impl kernel::Module for RustMiscdev {
128128
fn init(name: &'static CStr, _module: &'static ThisModule) -> Result<Self> {
129129
pr_info!("Rust miscellaneous device sample (init)\n");
130130

samples/rust/rust_module_parameters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module! {
4141

4242
struct RustModuleParameters;
4343

44-
impl KernelModule for RustModuleParameters {
44+
impl kernel::Module for RustModuleParameters {
4545
fn init(_name: &'static CStr, module: &'static ThisModule) -> Result<Self> {
4646
pr_info!("Rust module parameters sample (init)\n");
4747

samples/rust/rust_print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module! {
1515

1616
struct RustPrint;
1717

18-
impl KernelModule for RustPrint {
18+
impl kernel::Module for RustPrint {
1919
fn init(_name: &'static CStr, _module: &'static ThisModule) -> Result<Self> {
2020
pr_info!("Rust printing macros sample (init)\n");
2121

samples/rust/rust_semaphore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct RustSemaphore {
106106
_dev: Pin<Box<Registration<FileState>>>,
107107
}
108108

109-
impl KernelModule for RustSemaphore {
109+
impl kernel::Module for RustSemaphore {
110110
fn init(name: &'static CStr, _module: &'static ThisModule) -> Result<Self> {
111111
pr_info!("Rust semaphore sample (init)\n");
112112

samples/rust/rust_stack_probing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module! {
1414

1515
struct RustStackProbing;
1616

17-
impl KernelModule for RustStackProbing {
17+
impl kernel::Module for RustStackProbing {
1818
fn init(_name: &'static CStr, _module: &'static ThisModule) -> Result<Self> {
1919
pr_info!("Rust stack probing sample (init)\n");
2020

samples/rust/rust_sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ kernel::init_static_sync! {
2323

2424
struct RustSync;
2525

26-
impl KernelModule for RustSync {
26+
impl kernel::Module for RustSync {
2727
fn init(_name: &'static CStr, _module: &'static ThisModule) -> Result<Self> {
2828
pr_info!("Rust synchronisation primitives sample (init)\n");
2929

0 commit comments

Comments
 (0)