Skip to content

Commit 3c77946

Browse files
committed
rust: workqueue: simplify examples
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 0822a56 commit 3c77946

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

rust/kernel/workqueue.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,9 @@ macro_rules! init_work_item_adapter {
119119
///
120120
/// ```
121121
/// # use kernel::{spawn_work_item, workqueue};
122-
///
123-
/// # fn example() -> Result {
124122
/// spawn_work_item!(workqueue::system(), || pr_info!("Hello from a work item\n"))?;
125-
/// # Ok(())
126-
/// # }
127123
///
128-
/// # example().unwrap()
124+
/// # Ok::<(), Error>(())
129125
/// ```
130126
///
131127
/// The following example is used to create a work item and enqueue it several times. We note that
@@ -152,7 +148,6 @@ macro_rules! init_work_item_adapter {
152148
/// }
153149
/// });
154150
///
155-
/// # fn example() -> Result {
156151
/// let e = UniqueArc::try_new(Example {
157152
/// count: AtomicU32::new(0),
158153
/// // SAFETY: `work` is initialised below.
@@ -163,10 +158,8 @@ macro_rules! init_work_item_adapter {
163158
///
164159
/// // Queue the first time.
165160
/// workqueue::system().enqueue(e.into());
166-
/// # Ok(())
167-
/// # }
168161
///
169-
/// # example().unwrap()
162+
/// # Ok::<(), Error>(())
170163
/// ```
171164
///
172165
/// The following example has two different work items in the same struct, which allows it to be
@@ -187,7 +180,6 @@ macro_rules! init_work_item_adapter {
187180
/// struct SecondAdapter;
188181
/// kernel::impl_work_adapter!(SecondAdapter, Example, work2, |_| pr_info!("Second work\n"));
189182
///
190-
/// # fn example() -> Result {
191183
/// let e = UniqueArc::try_new(Example {
192184
/// // SAFETY: `work1` is initialised below.
193185
/// work1: unsafe { Work::new() },
@@ -203,10 +195,8 @@ macro_rules! init_work_item_adapter {
203195
/// // Enqueue the two different work items.
204196
/// workqueue::system().enqueue(e.clone());
205197
/// workqueue::system().enqueue_adapter::<SecondAdapter>(e);
206-
/// # Ok(())
207-
/// # }
208198
///
209-
/// # example().unwrap()
199+
/// # Ok::<(), Error>(())
210200
/// ```
211201
#[repr(transparent)]
212202
pub struct Queue(Opaque<bindings::workqueue_struct>);

0 commit comments

Comments
 (0)