cregit-Linux how code gets into the kernel

Release 4.11 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 Purdie3992.86%250.00%
Johannes Berg24.76%125.00%
Sven 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 Purdie5362.35%342.86%
Shuah Khan1618.82%114.29%
Johan Hovold67.06%114.29%
Márton Németh67.06%114.29%
Johannes 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 Purdie3992.86%250.00%
Johannes Berg24.76%125.00%
Sven 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 Purdie5261.18%342.86%
Shuah Khan1618.82%114.29%
Márton Németh78.24%114.29%
Johan Hovold67.06%114.29%
Johannes 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 Purdie3943.33%228.57%
Jeff Garzik2831.11%114.29%
Esben Haabendal1516.67%114.29%
Márton Németh33.33%114.29%
Johannes Berg33.33%114.29%
Shuah 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 Purdie3667.92%233.33%
Shuah Khan815.09%233.33%
Rodolfo Giometti59.43%116.67%
Johannes 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 Purdie16100.00%1100.00%
Total16100.00%1100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Richard 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 Purdie37973.17%323.08%
Shuah Khan428.11%323.08%
Jeff Garzik285.41%17.69%
Johannes Berg193.67%17.69%
Márton Németh163.09%17.69%
Esben Haabendal152.90%17.69%
Johan Hovold122.32%17.69%
Rodolfo Giometti50.97%17.69%
Sven 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.
Created with cregit.