21 #include <linux/module.h>
22 #include <linux/kernel.h>
24 #include <linux/device.h>
25 #include <linux/slab.h>
38 static void transient_timer_function(
unsigned long data)
44 __led_set_brightness(led_cdev, transient_data->
restore_state);
64 ret = kstrtoul(buf, 10, &state);
68 if (state != 1 && state != 0)
72 if (state == 0 && transient_data->
activate == 1) {
75 __led_set_brightness(led_cdev, transient_data->
restore_state);
80 if (state == 1 && transient_data->
activate == 0 &&
83 __led_set_brightness(led_cdev, transient_data->
state);
115 ret = kstrtoul(buf, 10, &state);
131 return sprintf(buf,
"%d\n", state);
142 ret = kstrtoul(buf, 10, &state);
146 if (state != 1 && state != 0)
154 transient_activate_store);
156 transient_duration_store);
157 static DEVICE_ATTR(state, 0644, transient_state_show, transient_state_store);
159 static void transient_trig_activate(
struct led_classdev *led_cdev)
167 "unable to allocate transient trigger\n");
170 led_cdev->trigger_data = tdata;
178 goto err_out_duration;
185 (
unsigned long) led_cdev);
186 led_cdev->activated =
true;
195 dev_err(led_cdev->
dev,
"unable to register transient trigger\n");
196 led_cdev->trigger_data =
NULL;
200 static void transient_trig_deactivate(
struct led_classdev *led_cdev)
204 if (led_cdev->activated) {
206 __led_set_brightness(led_cdev, transient_data->
restore_state);
210 led_cdev->trigger_data =
NULL;
211 led_cdev->activated =
false;
212 kfree(transient_data);
216 static struct led_trigger transient_trigger = {
218 .activate = transient_trig_activate,
219 .deactivate = transient_trig_deactivate,
222 static int __init transient_trig_init(
void)
227 static void __exit transient_trig_exit(
void)