My research so far into how triggers work was mostly so that I can use the wwan module trigger on the SE10 board I have here, and therefore I did not look into how to write a generic led trigger usable on more then a specific led. Thanks a lot for clearing up possible misunderstandings, Fiona > >> +/// `trigger_activate` function pointer >> +/// >> +/// # Safety >> +/// >> +/// `led_cdev` must be passed by the corresponding callback in `led_trigger`. >> +unsafe extern "C" fn trigger_activate<T>(led_cdev: *mut bindings::led_classdev) -> i32 >> +where >> + T: HardwareOperations, >> +{ >> + from_result(|| { >> + // SAFETY: By the safety requirement of this function `led_cdev` is embedded inside a `T::This<T>`. >> + let led = unsafe { &mut *(T::This::led_container_of(led_cdev.cast())) }; >> + T::activate(led)?; >> + Ok(0) >> + }) >> +} >> + >> +/// `trigger_deactivate` function pointer >> +/// >> +/// # Safety >> +/// >> +/// `led_cdev` must be passed by the corresponding callback in `led_trigger`. >> +unsafe extern "C" fn trigger_deactivate<T>(led_cdev: *mut bindings::led_classdev) >> +where >> + T: HardwareOperations, >> +{ >> + // SAFETY: By the safety requirement of this function `led_cdev` is embedded inside a `T::This<T>`. >> + let led = unsafe { &mut *(T::This::led_container_of(led_cdev.cast())) }; >> + T::deactivate(led) >> +} >> -- >> 2.47.0 >> >>