[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aFB4n-0_gTc3CAf4@pollux>
Date: Mon, 16 Jun 2025 22:03:43 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Igor Korotin <igor.korotin.linux@...il.com>
Cc: ojeda@...nel.org, alex.gaynor@...il.com, rafael@...nel.org,
gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, linux-acpi@...r.kernel.org,
boqun.feng@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com,
benno.lossin@...ton.me, a.hindborg@...nel.org, aliceryhl@...gle.com,
tmgross@...ch.edu, lenb@...nel.org, wedsonaf@...il.com,
viresh.kumar@...aro.org, alex.hung@....com,
dingxiangfei2009@...il.com
Subject: Re: [PATCH v6 1/6] rust: acpi: add `acpi::DeviceId` abstraction
On Fri, Jun 13, 2025 at 02:38:42PM +0100, Igor Korotin wrote:
> +impl DeviceId {
> + const ACPI_ID_LEN: usize = 16;
> +
> + /// Create a new device id from an ACPI 'id' string.
> + pub const fn new(id: &'static CStr) -> Self {
> + assert!(id.len() <= Self::ACPI_ID_LEN, "ID exceeds 16 bytes");
Please use build_assert!() for this check.
> + let src = id.as_bytes_with_nul();
> + // Replace with `bindings::acpi_device_id::default()` once stabilized for `const`.
> + // SAFETY: FFI type is valid to be zero-initialized.
> + let mut acpi: bindings::acpi_device_id = unsafe { core::mem::zeroed() };
> + let mut i = 0;
> + while i < src.len() {
> + acpi.id[i] = src[i];
> + i += 1;
> + }
> +
> + Self(acpi)
> + }
> +}
Powered by blists - more mailing lists