Commit e3a89cc2 authored by Viresh Kumar's avatar Viresh Kumar Committed by Greg Kroah-Hartman
Browse files

rust: device: Add property_present()



This implements Device::property_present(), which calls C APIs
device_property_present() helper.

The new helper will be used by Rust based cpufreq drivers.

Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/f43fe3f7b3151a89c261ad728b0f3bb2fc24caef.1736766672.git.viresh.kumar@linaro.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f7862dfe
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <linux/pid_namespace.h>
#include <linux/platform_device.h>
#include <linux/poll.h>
#include <linux/property.h>
#include <linux/refcount.h>
#include <linux/sched.h>
#include <linux/security.h>
+7 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@

use crate::{
    bindings,
    str::CString,
    types::{ARef, Opaque},
};
use core::{fmt, ptr};
@@ -180,6 +181,12 @@ unsafe fn printk(&self, klevel: &[u8], msg: fmt::Arguments<'_>) {
            )
        };
    }

    /// Checks if property is present or not.
    pub fn property_present(&self, name: &CString) -> bool {
        // SAFETY: By the invariant of `CString`, `name` is null-terminated.
        unsafe { bindings::device_property_present(self.as_raw().cast_const(), name.as_ptr() as *const _) }
    }
}

// SAFETY: Instances of `Device` are always reference-counted.