|
1 | 1 | // SPDX-License-Identifier: GPL-2.0
|
2 | 2 |
|
3 |
| -//! Proc macro crate implementing the [`module!`] magic. |
4 |
| -//! |
5 |
| -//! C header: [`include/linux/moduleparam.h`](../../../include/linux/moduleparam.h) |
6 |
| -
|
7 | 3 | #![deny(clippy::complexity)]
|
8 | 4 | #![deny(clippy::correctness)]
|
9 | 5 | #![deny(clippy::perf)]
|
@@ -399,86 +395,6 @@ impl ModuleInfo {
|
399 | 395 | }
|
400 | 396 | }
|
401 | 397 |
|
402 |
| -/// Declares a kernel module. |
403 |
| -/// |
404 |
| -/// The `type` argument should be a type which implements the [`KernelModule`] |
405 |
| -/// trait. Also accepts various forms of kernel metadata. |
406 |
| -/// |
407 |
| -/// [`KernelModule`]: ../kernel/trait.KernelModule.html |
408 |
| -/// |
409 |
| -/// # Examples |
410 |
| -/// |
411 |
| -/// ```rust,no_run |
412 |
| -/// use kernel::prelude::*; |
413 |
| -/// |
414 |
| -/// module!{ |
415 |
| -/// type: MyKernelModule, |
416 |
| -/// name: b"my_kernel_module", |
417 |
| -/// author: b"Rust for Linux Contributors", |
418 |
| -/// description: b"My very own kernel module!", |
419 |
| -/// license: b"GPL v2", |
420 |
| -/// params: { |
421 |
| -/// my_i32: i32 { |
422 |
| -/// default: 42, |
423 |
| -/// permissions: 0o000, |
424 |
| -/// description: b"Example of i32", |
425 |
| -/// }, |
426 |
| -/// writeable_i32: i32 { |
427 |
| -/// default: 42, |
428 |
| -/// permissions: 0o644, |
429 |
| -/// description: b"Example of i32", |
430 |
| -/// }, |
431 |
| -/// }, |
432 |
| -/// } |
433 |
| -/// |
434 |
| -/// struct MyKernelModule; |
435 |
| -/// |
436 |
| -/// impl KernelModule for MyKernelModule { |
437 |
| -/// fn init() -> Result<Self> { |
438 |
| -/// // If the parameter is writeable, then the kparam lock must be |
439 |
| -/// // taken to read the parameter: |
440 |
| -/// { |
441 |
| -/// let lock = THIS_MODULE.kernel_param_lock(); |
442 |
| -/// pr_info!("i32 param is: {}\n", writeable_i32.read(&lock)); |
443 |
| -/// } |
444 |
| -/// // If the parameter is read only, it can be read without locking |
445 |
| -/// // the kernel parameters: |
446 |
| -/// pr_info!("i32 param is: {}\n", my_i32.read()); |
447 |
| -/// Ok(MyKernelModule) |
448 |
| -/// } |
449 |
| -/// } |
450 |
| -/// ``` |
451 |
| -/// |
452 |
| -/// # Supported argument types |
453 |
| -/// - `type`: type which implements the [`KernelModule`] trait (required). |
454 |
| -/// - `name`: byte array of the name of the kernel module (required). |
455 |
| -/// - `author`: byte array of the author of the kernel module. |
456 |
| -/// - `description`: byte array of the description of the kernel module. |
457 |
| -/// - `license`: byte array of the license of the kernel module (required). |
458 |
| -/// - `alias`: byte array of alias name of the kernel module. |
459 |
| -/// - `alias_rtnl_link`: byte array of the `rtnl_link_alias` of the kernel module (mutually exclusive with `alias`). |
460 |
| -/// - `params`: parameters for the kernel module, as described below. |
461 |
| -/// |
462 |
| -/// # Supported parameter types |
463 |
| -/// |
464 |
| -/// - `bool`: Corresponds to C `bool` param type. |
465 |
| -/// - `i8`: No equivalent C param type. |
466 |
| -/// - `u8`: Corresponds to C `char` param type. |
467 |
| -/// - `i16`: Corresponds to C `short` param type. |
468 |
| -/// - `u16`: Corresponds to C `ushort` param type. |
469 |
| -/// - `i32`: Corresponds to C `int` param type. |
470 |
| -/// - `u32`: Corresponds to C `uint` param type. |
471 |
| -/// - `i64`: No equivalent C param type. |
472 |
| -/// - `u64`: Corresponds to C `ullong` param type. |
473 |
| -/// - `isize`: No equivalent C param type. |
474 |
| -/// - `usize`: No equivalent C param type. |
475 |
| -/// - `str`: Corresponds to C `charp` param type. Reading returns a byte slice. |
476 |
| -/// - `ArrayParam<T,N>`: Corresponds to C parameters created using `module_param_array`. An array |
477 |
| -/// of `T`'s of length at **most** `N`. |
478 |
| -/// |
479 |
| -/// `invbool` is unsupported: it was only ever used in a few modules. |
480 |
| -/// Consider using a `bool` and inverting the logic instead. |
481 |
| -#[proc_macro] |
482 | 398 | pub fn module(ts: TokenStream) -> TokenStream {
|
483 | 399 | let mut it = ts.into_iter();
|
484 | 400 |
|
@@ -775,34 +691,6 @@ pub fn module(ts: TokenStream) -> TokenStream {
|
775 | 691 | ).parse().expect("Error parsing formatted string into token stream.")
|
776 | 692 | }
|
777 | 693 |
|
778 |
| -/// Declares a kernel module that exposes a single misc device. |
779 |
| -/// |
780 |
| -/// The `type` argument should be a type which implements the [`FileOpener`] trait. Also accepts |
781 |
| -/// various forms of kernel metadata. |
782 |
| -/// |
783 |
| -/// [`FileOpener`]: ../kernel/file_operations/trait.FileOpener.html |
784 |
| -/// |
785 |
| -/// # Examples |
786 |
| -/// |
787 |
| -/// ```rust,no_run |
788 |
| -/// use kernel::prelude::*; |
789 |
| -/// |
790 |
| -/// module_misc_device! { |
791 |
| -/// type: MyFile, |
792 |
| -/// name: b"my_miscdev_kernel_module", |
793 |
| -/// author: b"Rust for Linux Contributors", |
794 |
| -/// description: b"My very own misc device kernel module!", |
795 |
| -/// license: b"GPL v2", |
796 |
| -/// } |
797 |
| -/// |
798 |
| -/// #[derive(Default)] |
799 |
| -/// struct MyFile; |
800 |
| -/// |
801 |
| -/// impl kernel::file_operations::FileOperations for MyFile { |
802 |
| -/// kernel::declare_file_operations!(); |
803 |
| -/// } |
804 |
| -/// ``` |
805 |
| -#[proc_macro] |
806 | 694 | pub fn module_misc_device(ts: TokenStream) -> TokenStream {
|
807 | 695 | let mut it = ts.into_iter();
|
808 | 696 |
|
|
0 commit comments