All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lyude Paul" <lyude@redhat.com>
Cc: ojeda@kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v21 3/4] rust: faux: Allow retrieving a bound Device
Date: Fri, 12 Jun 2026 20:14:27 +0000	[thread overview]
Message-ID: <20260612201428.3DEFB1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260612194436.585385-4-lyude@redhat.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Missing `// INVARIANT:` comment in `Registration::new` to justify the newly added struct invariant.
- [Low] Documentation typo: states the object is 'bound to a device' instead of 'bound to a driver'.
--

commit 53b3c6bd4c01a202375ed187c918196f25a37895
Author: Lyude Paul <lyude@redhat.com>

rust: faux: Allow retrieving a bound Device

This commit updates faux::Registration to implement AsRef for a
device::Device<device::Bound>. It relies on the registration object being
proof that a driver is bound to the device.

> diff --git a/rust/kernel/faux.rs b/rust/kernel/faux.rs
> index 43b4974f48cd2..36c92ae2943c0 100644
> --- a/rust/kernel/faux.rs
> +++ b/rust/kernel/faux.rs
> @@ -25,7 +25,8 @@
>  ///
>  /// # Invariants
>  ///
> -/// `self.0` always holds a valid pointer to an initialized and registered [`struct faux_device`].
> +/// - `self.0` always holds a valid pointer to an initialized and registered [`struct faux_device`].
> +/// - This object is proof that the object described by this `Registration` is bound to a device.

[Severity: Low]
This isn't a bug, but there appears to be a typo in the documentation. The
invariant states the object is bound to a "device", but the commit message
and the code (device::Device<device::Bound>) indicate it should be bound
to a "driver". Should this be updated to say "bound to a driver"?

[Severity: Low]
This isn't a bug, but since a new invariant was added here, does it need to
be explicitly justified when the struct is constructed?

According to the subsystem guidelines, constructing a struct with an
# Invariants section requires an // INVARIANT: comment explaining why the
invariants are satisfied.

Looking at Registration::new():

    // The above function will return either a valid device, or NULL on failure
    // INVARIANT: The device will remain registered until faux_device_destroy() is called, which
    // happens in our Drop implementation.
    Ok(Self(NonNull::new(dev).ok_or(ENODEV)?))

Could we add a comment here justifying the new invariant about the driver
being bound?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260612194436.585385-1-lyude@redhat.com?part=3

  reply	other threads:[~2026-06-12 20:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-12 19:43 [PATCH v21 0/4] Rust bindings for gem shmem Lyude Paul
2026-06-12 19:43 ` Lyude Paul
2026-06-12 19:43 ` [PATCH v21 1/4] rust: drm: gem: shmem: Add DmaResvGuard helper Lyude Paul
2026-06-12 19:43   ` Lyude Paul
2026-06-12 19:43 ` [PATCH v21 2/4] rust: drm: gem: shmem: Add vmap functions Lyude Paul
2026-06-12 19:43   ` Lyude Paul
2026-06-12 19:43 ` [PATCH v21 3/4] rust: faux: Allow retrieving a bound Device Lyude Paul
2026-06-12 19:43   ` Lyude Paul
2026-06-12 20:14   ` sashiko-bot [this message]
2026-06-12 19:43 ` [PATCH v21 4/4] rust: drm: gem: Introduce shmem::Object::sg_table() Lyude Paul
2026-06-12 19:43   ` Lyude Paul
2026-06-12 20:28   ` sashiko-bot
2026-06-25 21:24   ` Danilo Krummrich
2026-06-25 21:24     ` Danilo Krummrich
2026-06-25 21:24 ` (subset) [PATCH v21 0/4] Rust bindings for gem shmem Danilo Krummrich
2026-06-25 21:24   ` Danilo Krummrich

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=20260612201428.3DEFB1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lyude@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.