All of lore.kernel.org
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@kernel.org>
To: FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: alex.gaynor@gmail.com, gregkh@linuxfoundation.org,
	ojeda@kernel.org, rafael@kernel.org, robh@kernel.org,
	saravanak@google.com, a.hindborg@kernel.org,
	aliceryhl@google.com, bhelgaas@google.com,
	bjorn3_gh@protonmail.com, boqun.feng@gmail.com,
	david.m.ertman@intel.com, devicetree@vger.kernel.org,
	gary@garyguo.net, ira.weiny@intel.com, kwilczynski@kernel.org,
	leon@kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org, lossin@kernel.org,
	netdev@vger.kernel.org, rust-for-linux@vger.kernel.org,
	tmgross@umich.edu
Subject: Re: [PATCH v2 1/3] rust: device_id: split out index support into a separate trait
Date: Fri, 4 Jul 2025 02:44:57 +0200	[thread overview]
Message-ID: <aGckCY3BiPRCPmS7@pollux> (raw)
In-Reply-To: <20250701141252.600113-2-fujita.tomonori@gmail.com>

On Tue, Jul 01, 2025 at 11:12:50PM +0900, FUJITA Tomonori wrote:
> +// SAFETY:
> +// * `DRIVER_DATA_OFFSET` is the offset to the `driver_data` field.

Here and for a few other occurances, this doesn't need to be a list, since it's
just a single item.

> +/// Extension trait for [`RawDeviceId`] for devices that embed an index or context value.
> +///
> +/// This is typically used when the device ID struct includes a field like `driver_data`
> +/// that is used to store a pointer-sized value (e.g., an index or context pointer).
> +///
> +/// # Safety
> +///
> +/// Implementers must ensure that:
> +///   - `DRIVER_DATA_OFFSET` is the correct offset (in bytes) to the context/data field (e.g., the
> +///     `driver_data` field) within the raw device ID structure. This field must be correctly sized
> +///     to hold a `usize`.
> +///
> +///     Ideally, the data should ideally be added during `Self` to `RawType` conversion,

Remove one of the duplicate "ideally".

> +///     but there's currently no way to do it when using traits in const.
> +///
> +///   - The `index` method must return the value stored at the location specified
> +///     by `DRIVER_DATA_OFFSET`, assuming `self` is layout-compatible with `RawType`.

I think technically this safety requirement isn't needed.

With this:

	Acked-by: Danilo Krummrich <dakr@kernel.org>

  reply	other threads:[~2025-07-04  0:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-01 14:12 [PATCH v2 0/3] rust: Build PHY device tables by using module_device_table macro FUJITA Tomonori
2025-07-01 14:12 ` [PATCH v2 1/3] rust: device_id: split out index support into a separate trait FUJITA Tomonori
2025-07-04  0:44   ` Danilo Krummrich [this message]
2025-07-04  3:12     ` FUJITA Tomonori
2025-07-01 14:12 ` [PATCH v2 2/3] rust: net::phy represent DeviceId as transparent wrapper over mdio_device_id FUJITA Tomonori
2025-07-01 14:12 ` [PATCH v2 3/3] rust: net::phy Change module_phy_driver macro to use module_device_table macro FUJITA Tomonori

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=aGckCY3BiPRCPmS7@pollux \
    --to=dakr@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bhelgaas@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=david.m.ertman@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=ira.weiny@intel.com \
    --cc=kwilczynski@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=saravanak@google.com \
    --cc=tmgross@umich.edu \
    /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.