From: Grant Likely <grant.likely@secretlab.ca>
To: Bill Gatliff <bgat@billgatliff.com>
Cc: linux-embedded@vger.kernel.org
Subject: Re: [PWM 05/10] LED "dim" trigger based on PWM control of the LED
Date: Sat, 16 Oct 2010 02:00:26 -0600 [thread overview]
Message-ID: <20101016080026.GF653@angua.secretlab.ca> (raw)
In-Reply-To: <1285946271-17728-5-git-send-email-bgat@billgatliff.com>
On Fri, Oct 01, 2010 at 10:17:46AM -0500, Bill Gatliff wrote:
> Signed-off-by: Bill Gatliff <bgat@billgatliff.com>
Ditto on description
Otherwise pretty straight forward. Looks okay to me.
g.
> ---
> drivers/leds/ledtrig-dim.c | 96 ++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 96 insertions(+), 0 deletions(-)
> create mode 100644 drivers/leds/ledtrig-dim.c
>
> diff --git a/drivers/leds/ledtrig-dim.c b/drivers/leds/ledtrig-dim.c
> new file mode 100644
> index 0000000..8f93f44
> --- /dev/null
> +++ b/drivers/leds/ledtrig-dim.c
> @@ -0,0 +1,96 @@
> +/*
> + * LED Dim Trigger
> + *
> + * Copyright (C) 2010 Bill Gatliff <bgat@billgatliff.com>
> + *
> + * "Dims" an LED based on system load. Derived from Atsushi Nemoto's
> + * ledtrig-heartbeat.c.
> + *
> + * 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/slab.h>
> +#include <linux/init.h>
> +#include <linux/timer.h>
> +#include <linux/sched.h>
> +#include <linux/leds.h>
> +
> +#include "leds.h"
> +
> +struct dim_trig_data {
> + struct timer_list timer;
> +};
> +
> +
> +static void
> +led_dim_function(unsigned long data)
> +{
> + struct led_classdev *led_cdev = (struct led_classdev *)data;
> + struct dim_trig_data *dim_data = led_cdev->trigger_data;
> + unsigned int brightness;
> +
> + brightness = ((LED_FULL - LED_OFF) * avenrun[0]) / EXP_1;
> + if (brightness > LED_FULL)
> + brightness = LED_FULL;
> +
> + led_set_brightness(led_cdev, brightness);
> + mod_timer(&dim_data->timer, jiffies + msecs_to_jiffies(500));
> +}
> +
> +
> +static void
> +dim_trig_activate(struct led_classdev *led_cdev)
> +{
> + struct dim_trig_data *dim_data;
> +
> + dim_data = kzalloc(sizeof(*dim_data), GFP_KERNEL);
> + if (!dim_data)
> + return;
> +
> + led_cdev->trigger_data = dim_data;
> + setup_timer(&dim_data->timer,
> + led_dim_function, (unsigned long)led_cdev);
> + led_dim_function(dim_data->timer.data);
> +}
> +
> +
> +static void
> +dim_trig_deactivate(struct led_classdev *led_cdev)
> +{
> + struct dim_trig_data *dim_data = led_cdev->trigger_data;
> +
> + if (dim_data) {
> + del_timer_sync(&dim_data->timer);
> + kfree(dim_data);
> + }
> +}
> +
> +
> +static struct led_trigger dim_led_trigger = {
> + .name = "dim",
> + .activate = dim_trig_activate,
> + .deactivate = dim_trig_deactivate,
> +};
> +
> +
> +static int __init dim_trig_init(void)
> +{
> + return led_trigger_register(&dim_led_trigger);
> +}
> +module_init(dim_trig_init);
> +
> +
> +static void __exit dim_trig_exit(void)
> +{
> + led_trigger_unregister(&dim_led_trigger);
> +}
> +module_exit(dim_trig_exit);
> +
> +
> +MODULE_AUTHOR("Bill Gatliff <bgat@billgatliff.com>");
> +MODULE_DESCRIPTION("Dim LED trigger");
> +MODULE_LICENSE("GPL");
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-10-16 8:00 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-01 15:17 [PWM 01/10] API to consolidate PWM devices behind a common user and kernel interface Bill Gatliff
2010-10-01 15:17 ` [PWM 02/10] Emulates PWM hardware using a high-resolution timer and a GPIO pin Bill Gatliff
2010-10-16 6:54 ` Grant Likely
2010-10-01 15:17 ` [PWM 03/10] Expunge old Atmel PWMC driver, replacing it with one that conforms to the PWM API Bill Gatliff
2010-10-16 7:50 ` Grant Likely
2010-10-01 15:17 ` [PWM 04/10] Implements PWM-based LED control Bill Gatliff
2010-10-16 7:58 ` Grant Likely
2010-10-01 15:17 ` [PWM 05/10] LED "dim" trigger based on PWM control of the LED Bill Gatliff
2010-10-16 8:00 ` Grant Likely [this message]
2010-10-01 15:17 ` [PWM 06/10] Incorporate PWM API code into KBuild Bill Gatliff
2010-10-16 8:02 ` Grant Likely
2010-10-19 2:17 ` Bill Gatliff
2010-10-01 15:17 ` [PWM 07/10] PWM API driver for MPC52xx GPT peripheral Bill Gatliff
2010-10-01 15:17 ` [PWM 08/10] Initial support for PXA PWM peripheral; compile-tested only Bill Gatliff
2010-10-01 15:17 ` Bill Gatliff
2010-10-01 15:17 ` [PWM 09/10] Build pwm.o only if CONFIG_GENERIC_PWM is set Bill Gatliff
2010-10-01 15:17 ` [PWM 10/10] Expunge previous driver for PXA PWM Bill Gatliff
2010-10-01 22:00 ` [PWM 01/10] API to consolidate PWM devices behind a common user and kernel interface Kevin Hilman
2010-10-02 5:13 ` Jason Kridner
2010-10-06 18:45 ` Bill Gatliff
2010-10-06 19:08 ` Kevin Hilman
2010-10-02 12:25 ` Hector Oron
2010-10-06 18:48 ` Bill Gatliff
2010-10-16 6:05 ` Grant Likely
2010-10-05 10:35 ` sugumar
2010-10-06 18:50 ` Bill Gatliff
2010-10-06 19:02 ` Grosen, Mark
2010-10-07 7:58 ` Sugumar Natarajan
2010-10-16 7:42 ` Grant Likely
2010-10-20 18:13 ` Bill Gatliff
2010-10-20 18:34 ` Grant Likely
2010-10-20 19:32 ` Bill Gatliff
2010-10-21 13:18 ` Bill Gatliff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101016080026.GF653@angua.secretlab.ca \
--to=grant.likely@secretlab.ca \
--cc=bgat@billgatliff.com \
--cc=linux-embedded@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.