lkml.org 
[lkml]   [2024]   [Apr]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 3/3] cpufreq: Add Rust based cpufreq-dt driver
On 05.04.24 13:09, Viresh Kumar wrote:
> +// Finds exact supply name from the OF node.
> +fn find_supply_name_exact(np: *mut bindings::device_node, name: &str) -> Option<CString> {
> + let sname = CString::try_from_fmt(fmt!("{}-supply", name)).ok()?;
> +
> + // SAFETY: The OF node is guaranteed by the C code to be valid.
> + let pp = unsafe { bindings::of_find_property(np, sname.as_ptr() as *mut _, ptr::null_mut()) };

Drivers should avoid calling `unsafe` code as much as possible. They
also should not be calling `bindings` code directly. Please write (or
find) abstractions for these `unsafe` calls.

--
Cheers,
Benno

> + if pp.is_null() {
> + None
> + } else {
> + CString::try_from_fmt(fmt!("{}", name)).ok()
> + }
> +}


\
 
 \ /
  Last update: 2024-05-27 16:27    [W:0.058 / U:0.444 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site