Skip to content

Commit d249f15

Browse files
committed
rust: kernel: rustfmt documentation examples cleanups
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 94c0961 commit d249f15

File tree

12 files changed

+38
-35
lines changed

12 files changed

+38
-35
lines changed

rust/kernel/amba.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ macro_rules! module_amba_driver {
243243
/// # fn probe(_dev: &mut amba::Device, _id: Option<&Self::IdInfo>) -> Result {
244244
/// # Ok(())
245245
/// # }
246-
/// define_amba_id_table! {(), [
247-
/// ({ id: 0x00041061, mask: 0x000fffff }, None),
248-
/// ]}
246+
/// define_amba_id_table! {(), [
247+
/// ({ id: 0x00041061, mask: 0x000fffff }, None),
248+
/// ]}
249249
/// # }
250250
/// ```
251251
#[macro_export]

rust/kernel/driver.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,16 @@ macro_rules! first_item {
280280
/// assert_eq!([] as [u32; 0], second_item!());
281281
/// assert_eq!([10u32], second_item!((X, 10u32)));
282282
/// assert_eq!([10u32], second_item!((X, 10u32),));
283-
/// assert_eq!([10u32], second_item!(({X}, 10u32)));
284-
/// assert_eq!([10u32], second_item!(({X}, 10u32),));
283+
/// assert_eq!([10u32], second_item!(({ X }, 10u32)));
284+
/// assert_eq!([10u32], second_item!(({ X }, 10u32),));
285285
/// assert_eq!([10u32, 20], second_item!((X, 10u32), (X, 20)));
286286
/// assert_eq!([10u32, 20], second_item!((X, 10u32), (X, 20),));
287-
/// assert_eq!([10u32, 20], second_item!(({X}, 10u32), ({X}, 20)));
288-
/// assert_eq!([10u32, 20], second_item!(({X}, 10u32), ({X}, 20),));
287+
/// assert_eq!([10u32, 20], second_item!(({ X }, 10u32), ({ X }, 20)));
288+
/// assert_eq!([10u32, 20], second_item!(({ X }, 10u32), ({ X }, 20),));
289289
/// assert_eq!([10u32, 20, 30], second_item!((X, 10u32), (X, 20), (X, 30)));
290290
/// assert_eq!([10u32, 20, 30], second_item!((X, 10u32), (X, 20), (X, 30),));
291-
/// assert_eq!([10u32, 20, 30], second_item!(({X}, 10u32), ({X}, 20), ({X}, 30)));
292-
/// assert_eq!([10u32, 20, 30], second_item!(({X}, 10u32), ({X}, 20), ({X}, 30),));
291+
/// assert_eq!([10u32, 20, 30], second_item!(({ X }, 10u32), ({ X }, 20), ({ X }, 30)));
292+
/// assert_eq!([10u32, 20, 30], second_item!(({ X }, 10u32), ({ X }, 20), ({ X }, 30),));
293293
/// ```
294294
#[macro_export]
295295
macro_rules! second_item {

rust/kernel/fs/param.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,12 +417,12 @@ impl<S, T: Fn(&mut S, &bindings::fs_parameter, &bindings::fs_parse_result) -> Re
417417
/// # use kernel::count_brace_items;
418418
///
419419
/// assert_eq!(0, count_brace_items!());
420-
/// assert_eq!(1, count_brace_items!({A}));
421-
/// assert_eq!(1, count_brace_items!({A},));
422-
/// assert_eq!(2, count_brace_items!({A}, {B}));
423-
/// assert_eq!(2, count_brace_items!({A}, {B},));
424-
/// assert_eq!(3, count_brace_items!({A}, {B}, {C}));
425-
/// assert_eq!(3, count_brace_items!({A}, {B}, {C},));
420+
/// assert_eq!(1, count_brace_items!({ A }));
421+
/// assert_eq!(1, count_brace_items!({ A },));
422+
/// assert_eq!(2, count_brace_items!({ A }, { B }));
423+
/// assert_eq!(2, count_brace_items!({ A }, { B },));
424+
/// assert_eq!(3, count_brace_items!({ A }, { B }, { C }));
425+
/// assert_eq!(3, count_brace_items!({ A }, { B }, { C },));
426426
/// ```
427427
#[macro_export]
428428
macro_rules! count_brace_items {
@@ -462,7 +462,7 @@ macro_rules! count_brace_items {
462462
/// impl fs::Context<Self> for Example {
463463
/// type Data = Box<State>;
464464
///
465-
/// kernel::define_fs_params!{Box<State>,
465+
/// kernel::define_fs_params! {Box<State>,
466466
/// {flag, "flag", |s, v| { s.flag = Some(v); Ok(()) } },
467467
/// {flag_no, "flagno", |s, v| { s.flag_no = Some(v); Ok(()) } },
468468
/// {bool, "bool", |s, v| { s.bool_value = Some(v); Ok(()) } },

rust/kernel/gpio.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ pub trait Chip {
7979
///
8080
/// ```
8181
/// # use kernel::prelude::*;
82-
/// use kernel::{device::RawDevice, gpio::{self, Registration}};
82+
/// use kernel::{
83+
/// device::RawDevice,
84+
/// gpio::{self, Registration},
85+
/// };
8386
///
8487
/// struct MyGpioChip;
8588
/// #[vtable]

rust/kernel/io_mem.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ impl Resource {
5656
///
5757
/// Ok(())
5858
/// }
59-
///
6059
/// ```
6160
pub struct IoMem<const SIZE: usize> {
6261
ptr: usize,

rust/kernel/irq.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,7 @@ pub trait Handler {
395395
/// }
396396
///
397397
/// fn request_irq(irq: u32, data: Box<u32>) -> Result<irq::Registration<Example>> {
398-
/// irq::Registration::try_new(
399-
/// irq, data, irq::flags::SHARED, fmt!("example_{irq}"))
398+
/// irq::Registration::try_new(irq, data, irq::flags::SHARED, fmt!("example_{irq}"))
400399
/// }
401400
/// ```
402401
pub struct Registration<H: Handler>(InternalRegistration<H::Data>);
@@ -450,7 +449,10 @@ pub trait ThreadedHandler {
450449
///
451450
/// ```
452451
/// # use kernel::prelude::*;
453-
/// use kernel::{irq, sync::{Ref, RefBorrow}};
452+
/// use kernel::{
453+
/// irq,
454+
/// sync::{Ref, RefBorrow},
455+
/// };
454456
///
455457
/// struct Example;
456458
///
@@ -463,8 +465,7 @@ pub trait ThreadedHandler {
463465
/// }
464466
///
465467
/// fn request_irq(irq: u32, data: Ref<u32>) -> Result<irq::ThreadedRegistration<Example>> {
466-
/// irq::ThreadedRegistration::try_new(
467-
/// irq, data, irq::flags::SHARED, fmt!("example_{irq}"))
468+
/// irq::ThreadedRegistration::try_new(irq, data, irq::flags::SHARED, fmt!("example_{irq}"))
468469
/// }
469470
/// ```
470471
pub struct ThreadedRegistration<H: ThreadedHandler>(InternalRegistration<H::Data>);

rust/kernel/kasync/executor/workqueue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ struct ExecutorInner {
174174
/// ```
175175
/// # use kernel::prelude::*;
176176
/// use kernel::kasync::executor::workqueue::Executor;
177-
/// use kernel::workqueue;
178177
/// use kernel::spawn_task;
178+
/// use kernel::workqueue;
179179
///
180180
/// fn example_shared_workqueue() -> Result {
181181
/// let mut handle = Executor::try_new(workqueue::system())?;

rust/kernel/sync/nowait.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const CONTENDED: u8 = 2;
3030
/// b: u32,
3131
/// }
3232
///
33-
/// let x = NoWaitLock::new(Example{ a: 10, b: 20 });
33+
/// let x = NoWaitLock::new(Example { a: 10, b: 20 });
3434
///
3535
/// // Modifying the protected value.
3636
/// {
@@ -72,7 +72,7 @@ const CONTENDED: u8 = 2;
7272
/// b: u32,
7373
/// }
7474
///
75-
/// let x = NoWaitLock::new(Example{ a: 10, b: 20 });
75+
/// let x = NoWaitLock::new(Example { a: 10, b: 20 });
7676
///
7777
/// // No contention when lock is released.
7878
/// let guard = x.try_lock().unwrap();

rust/kernel/sync/seqlock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use core::{cell::UnsafeCell, marker::PhantomPinned, ops::Deref, pin::Pin};
1818
/// # Examples
1919
///
2020
///```
21-
/// use kernel::sync::{SeqLock, SpinLock};
2221
/// use core::sync::atomic::{AtomicU32, Ordering};
22+
/// use kernel::sync::{SeqLock, SpinLock};
2323
///
2424
/// struct Example {
2525
/// a: AtomicU32,

rust/kernel/sync/smutex.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const LOCKED: usize = 1;
7171
/// b: u32,
7272
/// }
7373
///
74-
/// static EXAMPLE: Mutex<Example> = Mutex::new(Example{ a: 10, b: 20 });
74+
/// static EXAMPLE: Mutex<Example> = Mutex::new(Example { a: 10, b: 20 });
7575
///
7676
/// fn inc_a(example: &Mutex<Example>) {
7777
/// let mut guard = example.lock();
@@ -84,7 +84,7 @@ const LOCKED: usize = 1;
8484
/// }
8585
///
8686
/// fn try_new(a: u32, b: u32) -> Result<Ref<Mutex<Example>>> {
87-
/// Ref::try_new(Mutex::new(Example {a, b}))
87+
/// Ref::try_new(Mutex::new(Example { a, b }))
8888
/// }
8989
///
9090
/// assert_eq!(EXAMPLE.lock().a, 10);

0 commit comments

Comments
 (0)