[PATCH] rust: device: Use as_char_ptr() to avoid explicit cast

From: Viresh Kumar
Date: Thu Jan 16 2025 - 03:35:01 EST


Use as_char_ptr() to avoid explicit cast.

Suggested-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
---
Rebased over:

https://lore.kernel.org/all/e97dcbe0418cc1053fb4bcfac65cc02a0afcdf78.1737005078.git.viresh.kumar@xxxxxxxxxx/

rust/kernel/device.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs
index c775266ae164..db2d9658ba47 100644
--- a/rust/kernel/device.rs
+++ b/rust/kernel/device.rs
@@ -185,7 +185,7 @@ unsafe fn printk(&self, klevel: &[u8], msg: fmt::Arguments<'_>) {
/// Checks if property is present or not.
pub fn property_present(&self, name: &CStr) -> bool {
// SAFETY: By the invariant of `CStr`, `name` is null-terminated.
- unsafe { bindings::device_property_present(self.as_raw().cast_const(), name.as_ptr() as *const _) }
+ unsafe { bindings::device_property_present(self.as_raw().cast_const(), name.as_char_ptr()) }
}
}

--
2.31.1.272.g89b43f80a514