lkml.org 
[lkml]   [2023]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v4 4/7] rust: workqueue: add helper for defining work_struct fields
From
Benno Lossin <benno.lossin@proton.me> writes:
>> +impl<T: ?Sized, const ID: u64> Work<T, ID> {
>> + /// Creates a new instance of [`Work`].
>> + #[inline]
>> + #[allow(clippy::new_ret_no_self)]
>> + pub fn new(name: &'static CStr, key: &'static LockClassKey) -> impl PinInit<Self>
>> + where
>> + T: WorkItem<ID>,
>> + {
>> + // SAFETY: The `WorkItemPointer` implementation promises that `run` can be used as the work
>> + // item function.
>> + unsafe {
>> + kernel::init::pin_init_from_closure(move |slot| {
>> + let slot = Self::raw_get(slot);
>> + bindings::init_work_with_key(
>> + slot,
>> + Some(T::Pointer::run),
>> + false,
>> + name.as_char_ptr(),
>> + key.as_ptr(),
>> + );
>> + Ok(())
>> + })
>> + }
>
> I would suggest this instead:
> ```
> pin_init!(Self {
> // SAFETY: The `WorkItemPointer` implementation promises that `run` can be used as the
> // work item function.
> work <- Opaque::ffi_init(|slot| unsafe {
> bindings::init_work_with_key(
> slot,
> Some(T::Pointer::run),
> false,
> name.as_char_ptr(),
> key.as_ptr(),
> )
> }),
> _inner: PhantomData,
> })
> ```

I thought that I changed this in this patchset ...

Anyway, I don't think it's a big deal. If I need to send a v5 for some
other reason, then I will fix this there. Otherwise, I don't think it's
necessary to send a v5 just for this.

Alice

\
 
 \ /
  Last update: 2023-09-06 11:58    [W:0.148 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site