120
120
//! `slot` gets called.
121
121
//!
122
122
//! ```rust
123
- //! use kernel::{prelude::*, init};
123
+ //! # #![allow(unreachable_pub, clippy::disallowed_names)]
124
+ //! use kernel::{prelude::*, init, types::Opaque};
124
125
//! use core::{ptr::addr_of_mut, marker::PhantomPinned, pin::Pin};
125
126
//! # mod bindings {
127
+ //! # #![allow(non_camel_case_types)]
126
128
//! # pub struct foo;
127
129
//! # pub unsafe fn init_foo(_ptr: *mut foo) {}
128
130
//! # pub unsafe fn destroy_foo(_ptr: *mut foo) {}
129
131
//! # pub unsafe fn enable_foo(_ptr: *mut foo, _flags: u32) -> i32 { 0 }
130
132
//! # }
133
+ //! # // `Error::from_errno` is `pub(crate)` in the `kernel` crate, thus provide a workaround.
134
+ //! # trait FromErrno {
135
+ //! # fn from_errno(errno: core::ffi::c_int) -> Error {
136
+ //! # // Dummy error that can be constructed outside the `kernel` crate.
137
+ //! # Error::from(core::fmt::Error)
138
+ //! # }
139
+ //! # }
140
+ //! # impl FromErrno for Error {}
131
141
//! /// # Invariants
132
142
//! ///
133
143
//! /// `foo` is always initialized
158
168
//! if err != 0 {
159
169
//! // Enabling has failed, first clean up the foo and then return the error.
160
170
//! bindings::destroy_foo(Opaque::raw_get(foo));
161
- //! return Err(Error::from_kernel_errno (err));
171
+ //! return Err(Error::from_errno (err));
162
172
//! }
163
173
//!
164
174
//! // All fields of `RawFoo` have been initialized, since `_p` is a ZST.
@@ -227,8 +237,7 @@ pub mod macros;
227
237
///
228
238
/// ```rust
229
239
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
230
- /// # use kernel::{init, pin_init, stack_pin_init, init::*, sync::Mutex, new_mutex};
231
- /// # use macros::pin_data;
240
+ /// # use kernel::{init, macros::pin_data, pin_init, stack_pin_init, init::*, sync::Mutex, new_mutex};
232
241
/// # use core::pin::Pin;
233
242
/// #[pin_data]
234
243
/// struct Foo {
@@ -278,7 +287,7 @@ macro_rules! stack_pin_init {
278
287
///
279
288
/// # Examples
280
289
///
281
- /// ```rust
290
+ /// ```rust,ignore
282
291
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
283
292
/// # use kernel::{init, pin_init, stack_try_pin_init, init::*, sync::Mutex, new_mutex};
284
293
/// # use macros::pin_data;
@@ -304,7 +313,7 @@ macro_rules! stack_pin_init {
304
313
/// pr_info!("a: {}", &*foo.a.lock());
305
314
/// ```
306
315
///
307
- /// ```rust
316
+ /// ```rust,ignore
308
317
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
309
318
/// # use kernel::{init, pin_init, stack_try_pin_init, init::*, sync::Mutex, new_mutex};
310
319
/// # use macros::pin_data;
@@ -518,7 +527,7 @@ macro_rules! stack_try_pin_init {
518
527
///
519
528
/// ```rust
520
529
/// # use kernel::pin_init;
521
- /// # use macros::{Zeroable, pin_data};
530
+ /// # use kernel:: macros::{Zeroable, pin_data};
522
531
/// # use core::{ptr::addr_of_mut, marker::PhantomPinned};
523
532
/// #[pin_data]
524
533
/// #[derive(Zeroable)]
@@ -684,7 +693,7 @@ macro_rules! init {
684
693
/// # Examples
685
694
///
686
695
/// ```rust
687
- /// use kernel::{init::PinInit, error::Error, InPlaceInit };
696
+ /// use kernel::{init::{ PinInit, zeroed}, error::Error};
688
697
/// struct BigBuf {
689
698
/// big: Box<[u8; 1024 * 1024 * 1024]>,
690
699
/// small: [u8; 1024 * 1024],
0 commit comments