public inbox for linux-next@vger.kernel.org 
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@kernel•org>
To: Stephen Rothwell <sfr@canb•auug.org.au>
Cc: Benno Lossin <lossin@kernel•org>,
	Linux Kernel Mailing List <linux-kernel@vger•kernel.org>,
	Linux Next Mailing List <linux-next@vger•kernel.org>
Subject: Re: linux-next: manual merge of the rust-pin-init tree with Linus' tree
Date: Fri, 12 Sep 2025 09:58:26 +0200	[thread overview]
Message-ID: <f22491ca-d133-4d61-8ad4-cf7ae3ac9338@kernel.org> (raw)
In-Reply-To: <20250912135146.0c3ea18f@canb.auug.org.au>

On 9/12/25 5:51 AM, Stephen Rothwell wrote:
> diff --cc rust/kernel/devres.rs
> index 132545962218,91dbf3f4b166..000000000000
> --- a/rust/kernel/devres.rs
> +++ b/rust/kernel/devres.rs
> @@@ -135,21 -134,11 +135,19 @@@ impl<T: Send> Devres<T> 
>           T: 'a,
>           Error: From<E>,
>       {
> -         let callback = Self::devres_callback;
> - 
>           try_pin_init!(&this in Self {
>               dev: dev.into(),
> -             callback,
> +             callback: Self::devres_callback,
>               // INVARIANT: `inner` is properly initialized.
>  -            inner <- {
>  +            inner <- Opaque::pin_init(try_pin_init!(Inner {
>  +                    devm <- Completion::new(),
>  +                    revoke <- Completion::new(),
>  +                    data <- Revocable::new(data),
>  +            })),
>  +            // TODO: Replace with "initializer code blocks" [1] once available.
>  +            //
>  +            // [1] https://github.com/Rust-for-Linux/pin-init/pull/69
>  +            _add_action: {
>                   // SAFETY: `this` is a valid pointer to uninitialized memory.
>                   let inner = unsafe { &raw mut (*this.as_ptr()).inner };
>   
> @@@ -160,14 -149,14 +158,14 @@@
>                   //    properly initialized, because we require `dev` (i.e. the *bound* device) to
>                   //    live at least as long as the returned `impl PinInit<Self, Error>`.
>                   to_result(unsafe {
> -                     bindings::devm_add_action(dev.as_raw(), Some(callback), inner.cast())
> +                     bindings::devm_add_action(dev.as_raw(), Some(*callback), inner.cast())
>  -                })?;
>  +                }).inspect_err(|_| {
>  +                    let inner = Opaque::cast_into(inner);
>   
>  -                Opaque::pin_init(try_pin_init!(Inner {
>  -                    devm <- Completion::new(),
>  -                    revoke <- Completion::new(),
>  -                    data <- Revocable::new(data),
>  -                }))
>  +                    // SAFETY: `inner` is a valid pointer to an `Inner<T>` and valid for both reads
>  +                    // and writes.
>  +                    unsafe { core::ptr::drop_in_place(inner) };
>  +                })?;
>               },
>           })
>       }

Looks good, thanks!

      reply	other threads:[~2025-09-12  7:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-12  3:51 linux-next: manual merge of the rust-pin-init tree with Linus' tree Stephen Rothwell
2025-09-12  7:58 ` Danilo Krummrich [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f22491ca-d133-4d61-8ad4-cf7ae3ac9338@kernel.org \
    --to=dakr@kernel$(echo .)org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-next@vger$(echo .)kernel.org \
    --cc=lossin@kernel$(echo .)org \
    --cc=sfr@canb$(echo .)auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox