Skip to content

Commit 1dcd763

Browse files
tamirdojeda
authored andcommitted
rust: clk: use CStr::as_char_ptr
Replace the use of `as_ptr` which works through `<CStr as Deref<Target=&[u8]>::deref()` in preparation for replacing `kernel::str::CStr` with `core::ffi::CStr` as the latter does not implement `Deref<Target=&[u8]>`. Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: Viresh Kumar <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 9ce084e commit 1dcd763

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rust/kernel/clk.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ mod common_clk {
136136
///
137137
/// [`clk_get`]: https://docs.kernel.org/core-api/kernel-api.html#c.clk_get
138138
pub fn get(dev: &Device, name: Option<&CStr>) -> Result<Self> {
139-
let con_id = name.map_or(ptr::null(), |n| n.as_ptr());
139+
let con_id = name.map_or(ptr::null(), |n| n.as_char_ptr());
140140

141141
// SAFETY: It is safe to call [`clk_get`] for a valid device pointer.
142142
//
@@ -304,7 +304,7 @@ mod common_clk {
304304
/// [`clk_get_optional`]:
305305
/// https://docs.kernel.org/core-api/kernel-api.html#c.clk_get_optional
306306
pub fn get(dev: &Device, name: Option<&CStr>) -> Result<Self> {
307-
let con_id = name.map_or(ptr::null(), |n| n.as_ptr());
307+
let con_id = name.map_or(ptr::null(), |n| n.as_char_ptr());
308308

309309
// SAFETY: It is safe to call [`clk_get_optional`] for a valid device pointer.
310310
//

0 commit comments

Comments
 (0)