From nobody Wed Feb 11 05:17:53 2026 Received: from m.foxido.dev (m.foxido.dev [81.177.217.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 998B03054EC; Sun, 21 Dec 2025 18:24:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=81.177.217.87 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766341497; cv=none; b=NrMifPJNYoS3X/dklL5uvjItdnCTqc7tgd7VMHyRi2BRv6k2ifHtPk/l2wVkhh0aB0U9qdOoTu/T15monNGePIjg7RPg4Qq4aM0QvSNZu55QOvQAj9KLon+34+mSMI0vrKZb2K+tN8Dj8mq/l6CMqy2ESQjTw9lxdrbfWeoFoJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766341497; c=relaxed/simple; bh=kmRPjQahAG5tcZJ52oMaww+i2Cz9UEX9U5JzqXyIrM4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=th00gOYQQjaszPMwhyW/TcjuxxLWg5e/+mpWo+nc0RGvuI/CUgP+tuvJujan45qCVWyMCW3GHt40Uu1lpBJG6TWDBNKqv6vcozkg/qCsmp8yqu6ECB0c591fLOTcdx4RIc2+WoMjD2W6aUsls6FDMae5KO9er4HPLS5xLoA7U54= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=foxido.dev; spf=pass smtp.mailfrom=foxido.dev; dkim=pass (2048-bit key) header.d=foxido.dev header.i=@foxido.dev header.b=dRWhkOVi; dkim=permerror (0-bit key) header.d=foxido.dev header.i=@foxido.dev header.b=dacypMTh; arc=none smtp.client-ip=81.177.217.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=foxido.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foxido.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foxido.dev header.i=@foxido.dev header.b="dRWhkOVi"; dkim=permerror (0-bit key) header.d=foxido.dev header.i=@foxido.dev header.b="dacypMTh" DKIM-Signature: v=1; a=rsa-sha256; s=202508r; d=foxido.dev; c=relaxed/relaxed; h=Message-ID:Date:Subject:To:From; t=1766341464; bh=O9n5olvByOk66OI2JwAlHzR OWhgir85jJcDtWN3YL+0=; b=dRWhkOViuFPxyZIFdS12tHwLUKko2wpuOm1j3qg5vTqD7Xos+K uhXgaEn9m1MVRWgbCcemheBbJM7Niob8d6e1gXAx8acw294pF2PD5pbh5w5ODiSTYi38socsEKz 2TZp3Spc6yiDIIWyfkq/oSVF4Ol5W4TR3lUZN2P9amOirWVDqfYLai8NuLHdW5J701Ryt80wMg8 m2uzDuo9eL0kMsCuRli64suwEEo2tZ0eNZ3lMcvSwSp6PxvSWyRvRsOqwcT91reE12Mdm/hW04A iG930pgMVtYOmh20Qa/ixlNi0v0vVWafRsQoluThpBe40mI5BcmYxsPh19A8HbJxgQg==; DKIM-Signature: v=1; a=ed25519-sha256; s=202508e; d=foxido.dev; c=relaxed/relaxed; h=Message-ID:Date:Subject:To:From; t=1766341464; bh=O9n5olvByOk66OI2JwAlHzR OWhgir85jJcDtWN3YL+0=; b=dacypMTh93BDBR3XkNJXx8ADsJUjMYc0HXIyvjJKXf4QjybJGx tqRbwXkSWHIiyf7+VVSIn+50pNfjedegalDg==; From: Gladyshev Ilya To: "foxido @ foxido . dev-cc= Rafael J. Wysocki" Cc: Len Brown , Miguel Ojeda , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Tamir Duberstein , Armin Wolf , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-acpi@vger.kernel.org, Gladyshev Ilya Subject: [RFC PATCH 3/3] rust: sample driver for WMI demonstrations Date: Sun, 21 Dec 2025 21:22:39 +0300 Message-ID: <905217b6dc4dda707e3596737b4ade9a210aa445.1766331321.git.foxido@foxido.dev> X-Mailer: git-send-email 2.51.1.dirty In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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) +=3D mxm-wmi.o obj-$(CONFIG_NVIDIA_WMI_EC_BACKLIGHT) +=3D nvidia-wmi-ec-backlight.o obj-$(CONFIG_XIAOMI_WMI) +=3D xiaomi-wmi.o obj-$(CONFIG_REDMI_WMI) +=3D redmi-wmi.o +obj-m +=3D redmi_wmi_rs.o obj-$(CONFIG_GIGABYTE_WMI) +=3D gigabyte-wmi.o =20 # Acer diff --git a/drivers/platform/x86/redmi_wmi_rs.rs b/drivers/platform/x86/re= dmi_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, + ::IdInfo, + [(DeviceId::new(b"46C93E13-EE9B-4262-8488-563BCA757FEF"), 12)] +); + +struct RedmiWMIDriver { + probed_val: i32, + invokation_cnt: Atomic, +} + +#[vtable] +impl wmi::Driver for RedmiWMIDriver { + type IdInfo =3D i32; + + const TABLE: &'static dyn kernel::device_id::IdTable =3D &REDMI_TABLE; + + fn probe( + _: &Device, + id_info: &Self::IdInfo, + ) -> impl PinInit { + 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, _: &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", +); --=20 2.51.1.dirty