diff options
Diffstat (limited to 'drivers/leds/trigger/ledtrig-timer.c')
-rw-r--r-- | drivers/leds/trigger/ledtrig-timer.c | 58 |
1 files changed, 16 insertions, 42 deletions
diff --git a/drivers/leds/trigger/ledtrig-timer.c b/drivers/leds/trigger/ledtrig-timer.c index 8d09327b5719..7c14983781ee 100644 --- a/drivers/leds/trigger/ledtrig-timer.c +++ b/drivers/leds/trigger/ledtrig-timer.c @@ -8,7 +8,6 @@ * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. - * */ #include <linux/module.h> @@ -21,7 +20,7 @@ static ssize_t led_delay_on_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct led_classdev *led_cdev = dev_get_drvdata(dev); + struct led_classdev *led_cdev = led_trigger_get_led(dev); return sprintf(buf, "%lu\n", led_cdev->blink_delay_on); } @@ -29,7 +28,7 @@ static ssize_t led_delay_on_show(struct device *dev, static ssize_t led_delay_on_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { - struct led_classdev *led_cdev = dev_get_drvdata(dev); + struct led_classdev *led_cdev = led_trigger_get_led(dev); unsigned long state; ssize_t ret = -EINVAL; @@ -46,7 +45,7 @@ static ssize_t led_delay_on_store(struct device *dev, static ssize_t led_delay_off_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct led_classdev *led_cdev = dev_get_drvdata(dev); + struct led_classdev *led_cdev = led_trigger_get_led(dev); return sprintf(buf, "%lu\n", led_cdev->blink_delay_off); } @@ -54,7 +53,7 @@ static ssize_t led_delay_off_show(struct device *dev, static ssize_t led_delay_off_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { - struct led_classdev *led_cdev = dev_get_drvdata(dev); + struct led_classdev *led_cdev = led_trigger_get_led(dev); unsigned long state; ssize_t ret = -EINVAL; @@ -71,37 +70,23 @@ static ssize_t led_delay_off_store(struct device *dev, static DEVICE_ATTR(delay_on, 0644, led_delay_on_show, led_delay_on_store); static DEVICE_ATTR(delay_off, 0644, led_delay_off_show, led_delay_off_store); -static void timer_trig_activate(struct led_classdev *led_cdev) -{ - int rc; - - led_cdev->trigger_data = NULL; - - rc = device_create_file(led_cdev->dev, &dev_attr_delay_on); - if (rc) - return; - rc = device_create_file(led_cdev->dev, &dev_attr_delay_off); - if (rc) - goto err_out_delayon; +static struct attribute *timer_trig_attrs[] = { + &dev_attr_delay_on.attr, + &dev_attr_delay_off.attr, + NULL +}; +ATTRIBUTE_GROUPS(timer_trig); +static int timer_trig_activate(struct led_classdev *led_cdev) +{ led_blink_set(led_cdev, &led_cdev->blink_delay_on, &led_cdev->blink_delay_off); - led_cdev->activated = true; - return; - -err_out_delayon: - device_remove_file(led_cdev->dev, &dev_attr_delay_on); + return 0; } static void timer_trig_deactivate(struct led_classdev *led_cdev) { - if (led_cdev->activated) { - device_remove_file(led_cdev->dev, &dev_attr_delay_on); - device_remove_file(led_cdev->dev, &dev_attr_delay_off); - led_cdev->activated = false; - } - /* Stop blinking */ led_set_brightness(led_cdev, LED_OFF); } @@ -110,21 +95,10 @@ static struct led_trigger timer_led_trigger = { .name = "timer", .activate = timer_trig_activate, .deactivate = timer_trig_deactivate, + .groups = timer_trig_groups, }; - -static int __init timer_trig_init(void) -{ - return led_trigger_register(&timer_led_trigger); -} - -static void __exit timer_trig_exit(void) -{ - led_trigger_unregister(&timer_led_trigger); -} - -module_init(timer_trig_init); -module_exit(timer_trig_exit); +module_led_trigger(timer_led_trigger); MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>"); MODULE_DESCRIPTION("Timer LED trigger"); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); |