Skip to content

Commit a2263db

Browse files
Valentin Obstojeda
authored andcommitted
rust: kernel: fix multiple typos in documentation
Fixes multiple trivial typos in documentation and comments of the kernel crate. allocator: - Fix a trivial list item alignment issue in the last SAFETY comment of `krealloc_aligned`. init: - Replace 'type' with 'trait' in the doc comments of the `PinInit` and `Init` traits. - Add colons before starting lists. - Add spaces between the type and equal sign to respect the code formatting rules in example code. - End a sentence with a full stop instead of a colon. ioctl: - Replace 'an' with 'a' where appropriate. str: - Replace 'Return' with 'Returns' in the doc comment of `bytes_written` as the text describes what the function does. sync/lock: - Fix a trivial list item alignment issue in the Safety section of the `Backend` trait's description. sync/lock/spinlock: - The code in this module operates on spinlocks, not mutexes. Thus, replace 'mutex' with 'spinlock' in the SAFETY comment of `unlock`. workqueue: - Replace "wont" with "won't" in the doc comment of `__enqueue`. Signed-off-by: Valentin Obst <kernel@valentinobst.de> Reviewed-by: Trevor Gross <tmgross@umich.edu> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20240131-doc-fixes-v3-v3-1-0c8af94ed7de@valentinobst.de Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent d0e95ca commit a2263db

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

rust/kernel/allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ unsafe fn krealloc_aligned(ptr: *mut u8, new_layout: Layout, flags: bindings::gf
3535
// - `ptr` is either null or a pointer returned from a previous `k{re}alloc()` by the
3636
// function safety requirement.
3737
// - `size` is greater than 0 since it's either a `layout.size()` (which cannot be zero
38-
// according to the function safety requirement) or a result from `next_power_of_two()`.
38+
// according to the function safety requirement) or a result from `next_power_of_two()`.
3939
unsafe { bindings::krealloc(ptr as *const core::ffi::c_void, size, flags) as *mut u8 }
4040
}
4141

rust/kernel/init.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -751,10 +751,10 @@ macro_rules! try_init {
751751
///
752752
/// # Safety
753753
///
754-
/// When implementing this type you will need to take great care. Also there are probably very few
754+
/// When implementing this trait you will need to take great care. Also there are probably very few
755755
/// cases where a manual implementation is necessary. Use [`pin_init_from_closure`] where possible.
756756
///
757-
/// The [`PinInit::__pinned_init`] function
757+
/// The [`PinInit::__pinned_init`] function:
758758
/// - returns `Ok(())` if it initialized every field of `slot`,
759759
/// - returns `Err(err)` if it encountered an error and then cleaned `slot`, this means:
760760
/// - `slot` can be deallocated without UB occurring,
@@ -861,10 +861,10 @@ where
861861
///
862862
/// # Safety
863863
///
864-
/// When implementing this type you will need to take great care. Also there are probably very few
864+
/// When implementing this trait you will need to take great care. Also there are probably very few
865865
/// cases where a manual implementation is necessary. Use [`init_from_closure`] where possible.
866866
///
867-
/// The [`Init::__init`] function
867+
/// The [`Init::__init`] function:
868868
/// - returns `Ok(())` if it initialized every field of `slot`,
869869
/// - returns `Err(err)` if it encountered an error and then cleaned `slot`, this means:
870870
/// - `slot` can be deallocated without UB occurring,
@@ -1013,7 +1013,7 @@ pub fn uninit<T, E>() -> impl Init<MaybeUninit<T>, E> {
10131013
///
10141014
/// ```rust
10151015
/// use kernel::{error::Error, init::init_array_from_fn};
1016-
/// let array: Box<[usize; 1_000]>= Box::init::<Error>(init_array_from_fn(|i| i)).unwrap();
1016+
/// let array: Box<[usize; 1_000]> = Box::init::<Error>(init_array_from_fn(|i| i)).unwrap();
10171017
/// assert_eq!(array.len(), 1_000);
10181018
/// ```
10191019
pub fn init_array_from_fn<I, const N: usize, T, E>(
@@ -1027,7 +1027,7 @@ where
10271027
// Counts the number of initialized elements and when dropped drops that many elements from
10281028
// `slot`.
10291029
let mut init_count = ScopeGuard::new_with_data(0, |i| {
1030-
// We now free every element that has been initialized before:
1030+
// We now free every element that has been initialized before.
10311031
// SAFETY: The loop initialized exactly the values from 0..i and since we
10321032
// return `Err` below, the caller will consider the memory at `slot` as
10331033
// uninitialized.
@@ -1056,7 +1056,7 @@ where
10561056
///
10571057
/// ```rust
10581058
/// use kernel::{sync::{Arc, Mutex}, init::pin_init_array_from_fn, new_mutex};
1059-
/// let array: Arc<[Mutex<usize>; 1_000]>=
1059+
/// let array: Arc<[Mutex<usize>; 1_000]> =
10601060
/// Arc::pin_init(pin_init_array_from_fn(|i| new_mutex!(i))).unwrap();
10611061
/// assert_eq!(array.len(), 1_000);
10621062
/// ```
@@ -1071,7 +1071,7 @@ where
10711071
// Counts the number of initialized elements and when dropped drops that many elements from
10721072
// `slot`.
10731073
let mut init_count = ScopeGuard::new_with_data(0, |i| {
1074-
// We now free every element that has been initialized before:
1074+
// We now free every element that has been initialized before.
10751075
// SAFETY: The loop initialized exactly the values from 0..i and since we
10761076
// return `Err` below, the caller will consider the memory at `slot` as
10771077
// uninitialized.

rust/kernel/ioctl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ pub const fn _IO(ty: u32, nr: u32) -> u32 {
2828
_IOC(uapi::_IOC_NONE, ty, nr, 0)
2929
}
3030

31-
/// Build an ioctl number for an read-only ioctl.
31+
/// Build an ioctl number for a read-only ioctl.
3232
#[inline(always)]
3333
pub const fn _IOR<T>(ty: u32, nr: u32) -> u32 {
3434
_IOC(uapi::_IOC_READ, ty, nr, core::mem::size_of::<T>())
3535
}
3636

37-
/// Build an ioctl number for an write-only ioctl.
37+
/// Build an ioctl number for a write-only ioctl.
3838
#[inline(always)]
3939
pub const fn _IOW<T>(ty: u32, nr: u32) -> u32 {
4040
_IOC(uapi::_IOC_WRITE, ty, nr, core::mem::size_of::<T>())

rust/kernel/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ impl RawFormatter {
449449
self.pos as _
450450
}
451451

452-
/// Return the number of bytes written to the formatter.
452+
/// Returns the number of bytes written to the formatter.
453453
pub(crate) fn bytes_written(&self) -> usize {
454454
self.pos - self.beg
455455
}

rust/kernel/sync/lock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ pub mod spinlock;
2121
/// # Safety
2222
///
2323
/// - Implementers must ensure that only one thread/CPU may access the protected data once the lock
24-
/// is owned, that is, between calls to `lock` and `unlock`.
24+
/// is owned, that is, between calls to `lock` and `unlock`.
2525
/// - Implementers must also ensure that `relock` uses the same locking method as the original
26-
/// lock operation.
26+
/// lock operation.
2727
pub unsafe trait Backend {
2828
/// The state required by the lock.
2929
type State;

rust/kernel/sync/lock/spinlock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ unsafe impl super::Backend for SpinLockBackend {
112112

113113
unsafe fn unlock(ptr: *mut Self::State, _guard_state: &Self::GuardState) {
114114
// SAFETY: The safety requirements of this function ensure that `ptr` is valid and that the
115-
// caller is the owner of the mutex.
115+
// caller is the owner of the spinlock.
116116
unsafe { bindings::spin_unlock(ptr) }
117117
}
118118
}

rust/kernel/workqueue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl<T: FnOnce()> WorkItem for ClosureWork<T> {
253253
/// actual value of the id is not important as long as you use different ids for different fields
254254
/// of the same struct. (Fields of different structs need not use different ids.)
255255
///
256-
/// Note that the id is used only to select the right method to call during compilation. It wont be
256+
/// Note that the id is used only to select the right method to call during compilation. It won't be
257257
/// part of the final executable.
258258
///
259259
/// # Safety

0 commit comments

Comments
 (0)