2 * Set LED GPIO to Input "Trigger"
4 * Copyright 2015 Phil Elwell <phil@raspberrypi.org>
6 * Based on Nick Forbes's ledtrig-default-on.c.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/leds.h>
18 #include <linux/gpio.h>
21 static int input_trig_activate(struct led_classdev *led_cdev)
23 led_cdev->flags |= SET_GPIO_INPUT;
24 led_set_brightness(led_cdev, 0);
28 static void input_trig_deactivate(struct led_classdev *led_cdev)
30 led_cdev->flags |= SET_GPIO_OUTPUT;
31 led_set_brightness(led_cdev, 0);
34 static struct led_trigger input_led_trigger = {
36 .activate = input_trig_activate,
37 .deactivate = input_trig_deactivate,
40 static int __init input_trig_init(void)
42 return led_trigger_register(&input_led_trigger);
45 static void __exit input_trig_exit(void)
47 led_trigger_unregister(&input_led_trigger);
50 module_init(input_trig_init);
51 module_exit(input_trig_exit);
53 MODULE_AUTHOR("Phil Elwell <phil@raspberrypi.org>");
54 MODULE_DESCRIPTION("Set LED GPIO to Input \"trigger\"");
55 MODULE_LICENSE("GPL");