Re: [PATCH v2 1/3] rust: device_id: split out index support into a separate trait

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux