lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <905217b6dc4dda707e3596737b4ade9a210aa445.1766331321.git.foxido@foxido.dev>
Date: Sun, 21 Dec 2025 21:22:39 +0300
From: Gladyshev Ilya <foxido@...ido.dev>
To: "foxido @ foxido . dev-cc= Rafael J. Wysocki" <rafael@...nel.org>
Cc: Len Brown <lenb@...nel.org>,
	Miguel Ojeda <ojeda@...nel.org>,
	Boqun Feng <boqun.feng@...il.com>,
	Gary Guo <gary@...yguo.net>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>,
	Benno Lossin <lossin@...nel.org>,
	Andreas Hindborg <a.hindborg@...nel.org>,
	Alice Ryhl <aliceryhl@...gle.com>,
	Trevor Gross <tmgross@...ch.edu>,
	Danilo Krummrich <dakr@...nel.org>,
	Tamir Duberstein <tamird@...il.com>,
	Armin Wolf <W_Armin@....de>,
	platform-driver-x86@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	rust-for-linux@...r.kernel.org,
	linux-acpi@...r.kernel.org,
	Gladyshev Ilya <foxido@...ido.dev>
Subject: [RFC PATCH 3/3] rust: sample driver for WMI demonstrations

This driver is for RFC demonstration only. It will be removed before
real submission, however it's working and can be transformed into
sample driver
---
 drivers/platform/x86/Makefile        |  1 +
 drivers/platform/x86/redmi_wmi_rs.rs | 60 ++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)
 create mode 100644 drivers/platform/x86/redmi_wmi_rs.rs

diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index d25762f7114f..3045e42618ef 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_MXM_WMI)			+= mxm-wmi.o
 obj-$(CONFIG_NVIDIA_WMI_EC_BACKLIGHT)	+= nvidia-wmi-ec-backlight.o
 obj-$(CONFIG_XIAOMI_WMI)		+= xiaomi-wmi.o
 obj-$(CONFIG_REDMI_WMI)			+= redmi-wmi.o
+obj-m					+= redmi_wmi_rs.o
 obj-$(CONFIG_GIGABYTE_WMI)		+= gigabyte-wmi.o
 
 # Acer
diff --git a/drivers/platform/x86/redmi_wmi_rs.rs b/drivers/platform/x86/redmi_wmi_rs.rs
new file mode 100644
index 000000000000..65300bad022d
--- /dev/null
+++ b/drivers/platform/x86/redmi_wmi_rs.rs
@@ -0,0 +1,60 @@
+//! This is SAMPLE DRIVER
+//! It doesn't aim into upstream and serves only demonstration purposes for
+//! RFC patchset
+
+use kernel::sync::atomic::{Atomic, Relaxed};
+
+use kernel::{
+    acpi::AcpiObject,
+    device, module_wmi_driver, pr_info,
+    prelude::*,
+    wmi::{self, Device, DeviceId, Driver},
+    wmi_device_table,
+};
+
+wmi_device_table!(
+    REDMI_TABLE,
+    MODULE_REDMI_TABLE,
+    <RedmiWMIDriver as Driver>::IdInfo,
+    [(DeviceId::new(b"46C93E13-EE9B-4262-8488-563BCA757FEF"), 12)]
+);
+
+struct RedmiWMIDriver {
+    probed_val: i32,
+    invokation_cnt: Atomic<i64>,
+}
+
+#[vtable]
+impl wmi::Driver for RedmiWMIDriver {
+    type IdInfo = i32;
+
+    const TABLE: &'static dyn kernel::device_id::IdTable<DeviceId, Self::IdInfo> = &REDMI_TABLE;
+
+    fn probe(
+        _: &Device<kernel::device::Core>,
+        id_info: &Self::IdInfo,
+    ) -> impl PinInit<Self, Error> {
+        pr_info!("Rust WMI Sample Driver probed with val {id_info}\n");
+
+        Ok(Self {
+            probed_val: *id_info,
+            invokation_cnt: Atomic::new(0),
+        })
+    }
+
+    fn notify(&self, _: &Device<device::Core>, _: &AcpiObject) {
+        pr_info!(
+            "Notified driver with probed_val: {}, invokation cnt: {}",
+            self.probed_val,
+            self.invokation_cnt.fetch_add(1, Relaxed)
+        );
+    }
+}
+
+module_wmi_driver!(
+    type: RedmiWMIDriver,
+    name: "redmi_wmi_sample",
+    authors: ["Gladyshev Ilya"],
+    description: "SAMPLE DRIVER for RFC demonstration only",
+    license: "GPL v2",
+);
-- 
2.51.1.dirty


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ