cregit-Linux how code gets into the kernel

Release 4.7 drivers/leds/trigger/ledtrig-timer.c

/*
 * LED Kernel Timer Trigger
 *
 * Copyright 2005-2006 Openedhand Ltd.
 *
 * Author: Richard Purdie <rpurdie@openedhand.com>
 *
 * 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>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/ctype.h>
#include <linux/leds.h>


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); return sprintf(buf, "%lu\n", led_cdev->blink_delay_on); }

Contributors

PersonTokensPropCommitsCommitProp
richard purdierichard purdie3992.86%250.00%
johannes bergjohannes berg24.76%125.00%
sven wegenersven wegener12.38%125.00%
Total42100.00%4100.00%


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); unsigned long state; ssize_t ret = -EINVAL; ret = kstrtoul(buf, 10, &state); if (ret) return ret; led_blink_set(led_cdev, &state, &led_cdev->blink_delay_off); led_cdev->blink_delay_on = state; return size; }

Contributors

PersonTokensPropCommitsCommitProp
richard purdierichard purdie5362.35%342.86%
shuah khanshuah khan1618.82%114.29%
johan hovoldjohan hovold67.06%114.29%
marton nemethmarton nemeth67.06%114.29%
johannes bergjohannes berg44.71%114.29%
Total85100.00%7100.00%


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); return sprintf(buf, "%lu\n", led_cdev->blink_delay_off); }

Contributors

PersonTokensPropCommitsCommitProp
richard purdierichard purdie3992.86%250.00%
johannes bergjohannes berg24.76%125.00%
sven wegenersven wegener12.38%125.00%
Total42100.00%4100.00%


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); unsigned long state; ssize_t ret = -EINVAL; ret = kstrtoul(buf, 10, &state); if (ret) return ret; led_blink_set(led_cdev, &led_cdev->blink_delay_on, &state); led_cdev->blink_delay_off = state; return size; }

Contributors

PersonTokensPropCommitsCommitProp
richard purdierichard purdie5261.18%342.86%
shuah khanshuah khan1618.82%114.29%
marton nemethmarton nemeth78.24%114.29%
johan hovoldjohan hovold67.06%114.29%
johannes bergjohannes berg44.71%114.29%
Total85100.00%7100.00%

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; 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); }

Contributors

PersonTokensPropCommitsCommitProp
richard purdierichard purdie3943.33%228.57%
jeff garzikjeff garzik2831.11%114.29%
esben haabendalesben haabendal1516.67%114.29%
johannes bergjohannes berg33.33%114.29%
marton nemethmarton nemeth33.33%114.29%
shuah khanshuah khan22.22%114.29%
Total90100.00%7100.00%


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); }

Contributors

PersonTokensPropCommitsCommitProp
richard purdierichard purdie3667.92%233.33%
shuah khanshuah khan815.09%233.33%
rodolfo giomettirodolfo giometti59.43%116.67%
johannes bergjohannes berg47.55%116.67%
Total53100.00%6100.00%

static struct led_trigger timer_led_trigger = { .name = "timer", .activate = timer_trig_activate, .deactivate = timer_trig_deactivate, };
static int __init timer_trig_init(void) { return led_trigger_register(&timer_led_trigger); }

Contributors

PersonTokensPropCommitsCommitProp
richard purdierichard purdie16100.00%1100.00%
Total16100.00%1100.00%


static void __exit timer_trig_exit(void) { led_trigger_unregister(&timer_led_trigger); }

Contributors

PersonTokensPropCommitsCommitProp
richard purdierichard purdie15100.00%1100.00%
Total15100.00%1100.00%

module_init(timer_trig_init); module_exit(timer_trig_exit); MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>"); MODULE_DESCRIPTION("Timer LED trigger"); MODULE_LICENSE("GPL");

Overall Contributors

PersonTokensPropCommitsCommitProp
richard purdierichard purdie37973.17%323.08%
shuah khanshuah khan428.11%323.08%
jeff garzikjeff garzik285.41%17.69%
johannes bergjohannes berg193.67%17.69%
marton nemethmarton nemeth163.09%17.69%
esben haabendalesben haabendal152.90%17.69%
johan hovoldjohan hovold122.32%17.69%
rodolfo giomettirodolfo giometti50.97%17.69%
sven wegenersven wegener20.39%17.69%
Total518100.00%13100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}