Merge tag 'v5.15.57' into rpi-5.15.y
[platform/kernel/linux-rpi.git] / drivers / leds / trigger / ledtrig-input.c
1 /*
2  * Set LED GPIO to Input "Trigger"
3  *
4  * Copyright 2015 Phil Elwell <phil@raspberrypi.org>
5  *
6  * Based on Nick Forbes's ledtrig-default-on.c.
7  *
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.
11  *
12  */
13
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>
19 #include "../leds.h"
20
21 static int input_trig_activate(struct led_classdev *led_cdev)
22 {
23         led_cdev->flags |= SET_GPIO_INPUT;
24         led_set_brightness(led_cdev, 0);
25         return 0;
26 }
27
28 static void input_trig_deactivate(struct led_classdev *led_cdev)
29 {
30         led_cdev->flags |= SET_GPIO_OUTPUT;
31         led_set_brightness(led_cdev, 0);
32 }
33
34 static struct led_trigger input_led_trigger = {
35         .name     = "input",
36         .activate = input_trig_activate,
37         .deactivate = input_trig_deactivate,
38 };
39
40 static int __init input_trig_init(void)
41 {
42         return led_trigger_register(&input_led_trigger);
43 }
44
45 static void __exit input_trig_exit(void)
46 {
47         led_trigger_unregister(&input_led_trigger);
48 }
49
50 module_init(input_trig_init);
51 module_exit(input_trig_exit);
52
53 MODULE_AUTHOR("Phil Elwell <phil@raspberrypi.org>");
54 MODULE_DESCRIPTION("Set LED GPIO to Input \"trigger\"");
55 MODULE_LICENSE("GPL");