rust: acpi: use core::ffi::CStr method names
Prepare for `core::ffi::CStr` taking the place of `kernel::str::CStr` by avoid methods that only exist on the latter. Signed-off-by: Tamir Duberstein <tamird@gmail.com> Reviewed-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
committed by
Miguel Ojeda
parent
5749cd1ed8
commit
657403637f
@@ -37,11 +37,8 @@ impl DeviceId {
|
|||||||
/// Create a new device id from an ACPI 'id' string.
|
/// Create a new device id from an ACPI 'id' string.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub const fn new(id: &'static CStr) -> Self {
|
pub const fn new(id: &'static CStr) -> Self {
|
||||||
build_assert!(
|
let src = id.to_bytes_with_nul();
|
||||||
id.len_with_nul() <= Self::ACPI_ID_LEN,
|
build_assert!(src.len() <= Self::ACPI_ID_LEN, "ID exceeds 16 bytes");
|
||||||
"ID exceeds 16 bytes"
|
|
||||||
);
|
|
||||||
let src = id.as_bytes_with_nul();
|
|
||||||
// Replace with `bindings::acpi_device_id::default()` once stabilized for `const`.
|
// Replace with `bindings::acpi_device_id::default()` once stabilized for `const`.
|
||||||
// SAFETY: FFI type is valid to be zero-initialized.
|
// SAFETY: FFI type is valid to be zero-initialized.
|
||||||
let mut acpi: bindings::acpi_device_id = unsafe { core::mem::zeroed() };
|
let mut acpi: bindings::acpi_device_id = unsafe { core::mem::zeroed() };
|
||||||
|
|||||||
Reference in New Issue
Block a user