Re: [PATCH v2 3/4] rust: wmi: add Driver trait, Adapter and implement RegistrationOps
From: Armin Wolf
Date: Fri Dec 04 2026 - 15:41:26 EST
Am 29.11.26 um 02:32 schrieb Nick Dowsett:
Hi Armin,
Thanks for taking a look.
+// SAFETY: It's always valid to unregister a registered `wmi_driver`.
+unsafe impl<T: Driver> driver::RegistrationOps for Adapter<T> {
+ unsafe fn register(
+ reg: &Opaque<Self::DriverType>,
+ name: &'static CStr,
+ module: &'static ThisModule,
+ ) -> Result {
+ // SAFETY:
+ // - It's safe to set the fields of `wmi_driver` on initialization.
+ // - All set fields meet the invariants of `wmi_driver`.
+ unsafe {
+ // SAFETY: `name` is valid for the static lifetime.
+ (*reg.get()).driver.name = name.as_char_ptr();
Hi,
can drivers set driver.probe_type = PROBE_PREFER_ASYNCHRONOUS? If no then please
set it here is possible.
Thanks,
Armin Wolf
At the moment I didn't wrap `probe_type` from `driver.h` so drivers are
not able to set this themselves. If I can confirm it's OK to use
`PROBE_PREFER_ASYNCHRONOUS` for the reference Clevo driver are you OK if
this is hardcoded here for now? If a future consumer of the binding has
this requirement they could add a new associated const to `wmi::Driver`
defaulting to 'prefer asynchronous' in line with the recommendation from
the wmi subsystem docs.
Cheers Nick
Hardcoding this is fine.
Thanks,
Armin Wolf