perf tools: Don't clone maps from parent when synthesizing forks
[linux/fpc-iii.git] / drivers / leds / trigger / ledtrig-timer.c
blob7c14983781ee61db2aa1c7ecc0d620bfae8d9a20
1 /*
2 * LED Kernel Timer Trigger
4 * Copyright 2005-2006 Openedhand Ltd.
6 * Author: Richard Purdie <rpurdie@openedhand.com>
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.
13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/device.h>
17 #include <linux/ctype.h>
18 #include <linux/leds.h>
20 static ssize_t led_delay_on_show(struct device *dev,
21 struct device_attribute *attr, char *buf)
23 struct led_classdev *led_cdev = led_trigger_get_led(dev);
25 return sprintf(buf, "%lu\n", led_cdev->blink_delay_on);
28 static ssize_t led_delay_on_store(struct device *dev,
29 struct device_attribute *attr, const char *buf, size_t size)
31 struct led_classdev *led_cdev = led_trigger_get_led(dev);
32 unsigned long state;
33 ssize_t ret = -EINVAL;
35 ret = kstrtoul(buf, 10, &state);
36 if (ret)
37 return ret;
39 led_blink_set(led_cdev, &state, &led_cdev->blink_delay_off);
40 led_cdev->blink_delay_on = state;
42 return size;
45 static ssize_t led_delay_off_show(struct device *dev,
46 struct device_attribute *attr, char *buf)
48 struct led_classdev *led_cdev = led_trigger_get_led(dev);
50 return sprintf(buf, "%lu\n", led_cdev->blink_delay_off);
53 static ssize_t led_delay_off_store(struct device *dev,
54 struct device_attribute *attr, const char *buf, size_t size)
56 struct led_classdev *led_cdev = led_trigger_get_led(dev);
57 unsigned long state;
58 ssize_t ret = -EINVAL;
60 ret = kstrtoul(buf, 10, &state);
61 if (ret)
62 return ret;
64 led_blink_set(led_cdev, &led_cdev->blink_delay_on, &state);
65 led_cdev->blink_delay_off = state;
67 return size;
70 static DEVICE_ATTR(delay_on, 0644, led_delay_on_show, led_delay_on_store);
71 static DEVICE_ATTR(delay_off, 0644, led_delay_off_show, led_delay_off_store);
73 static struct attribute *timer_trig_attrs[] = {
74 &dev_attr_delay_on.attr,
75 &dev_attr_delay_off.attr,
76 NULL
78 ATTRIBUTE_GROUPS(timer_trig);
80 static int timer_trig_activate(struct led_classdev *led_cdev)
82 led_blink_set(led_cdev, &led_cdev->blink_delay_on,
83 &led_cdev->blink_delay_off);
85 return 0;
88 static void timer_trig_deactivate(struct led_classdev *led_cdev)
90 /* Stop blinking */
91 led_set_brightness(led_cdev, LED_OFF);
94 static struct led_trigger timer_led_trigger = {
95 .name = "timer",
96 .activate = timer_trig_activate,
97 .deactivate = timer_trig_deactivate,
98 .groups = timer_trig_groups,
100 module_led_trigger(timer_led_trigger);
102 MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
103 MODULE_DESCRIPTION("Timer LED trigger");
104 MODULE_LICENSE("GPL v2");