From: Joe Perches <joe@perches.com>
To: "Gaël PORTAY" <g.portay@overkiz.com>
Cc: Rob Landley <rob@landley.net>, Bryan Wu <cooloney@gmail.com>,
Richard Purdie <rpurdie@rpsys.net>,
"Milo(Woogyom) Kim" <milo.kim@ti.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-leds@vger.kernel.org
Subject: Re: [RFC PATCH] led: add Cycle LED trigger.
Date: Tue, 18 Jun 2013 15:05:40 -0700 [thread overview]
Message-ID: <1371593140.2038.8.camel@joe-AO722> (raw)
In-Reply-To: <1371572663-10846-1-git-send-email-g.portay@overkiz.com>
On Tue, 2013-06-18 at 18:24 +0200, Gaël PORTAY wrote:
> Currently, none of available triggers supports playing with the LED brightness
> level. The cycle trigger provides a way to define custom brightness cycle.
> For example, it is easy to customize the cycle to mock up the rhythm of human
> breathing which is a nice cycle to tell the user the system is doing something.
I think maybe this is a userspace thing, but here's a
trivial comment or two
> +static int cycle_start(struct cycle_trig_data *data)
> +{
> + unsigned long flags;
> +
> + if (hrtimer_active(&data->timer))
> + return -EINVAL;
> +
> + spin_lock_irqsave(&data->lock, flags);
> + data->plot_index = 0;
> + data->cycle_count = 0;
> + hrtimer_start(&data->timer, ktime_get(), HRTIMER_MODE_ABS);
> + spin_unlock_irqrestore(&data->lock, flags);
> +
> + return 1;
Maybe return 0 on success
> +static ssize_t cycle_control_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t size)
> +{
> + struct led_classdev *led_cdev = dev_get_drvdata(dev);
> + struct cycle_trig_data *data = led_cdev->trigger_data;
> +
> + if (strncmp(buf, "start", sizeof("start") - 1) == 0)
> + cycle_start(data);
> + else if (strncmp(buf, "stop", sizeof("stop") - 1) == 0)
> + cycle_stop(data);
> + else if (strncmp(buf, "reset", sizeof("reset") - 1) == 0)
> + cycle_reset(data);
> + else if (strncmp(buf, "pause", sizeof("stop") - 1) == 0)
> + cycle_pause(data);
> + else if (strncmp(buf, "resume", sizeof("resume") - 1) == 0)
> + cycle_resume(data);
> + else
> + return -EINVAL;
I think strcasecmp better than strncmp
> +static ssize_t cycle_rawplot_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t size)
> +{
[]
+ plot = kzalloc(size, GFP_KERNEL);
+ if (plot) {
+ hrtimer_cancel(&data->timer);
Ick.
if (!plot)
return -ENOMEM;
etc...
next prev parent reply other threads:[~2013-06-18 22:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 16:24 Gaël PORTAY
2013-06-18 22:05 ` Joe Perches [this message]
2013-06-20 9:44 ` Gaël PORTAY
2013-06-20 17:58 ` Bryan Wu
2013-06-27 13:00 ` Gaël PORTAY
2013-06-20 18:12 ` Joe Perches
2013-06-22 11:26 ` Pavel Machek
2013-06-22 16:43 ` Sebastian Reichel
2013-06-22 19:45 ` Pavel Machek
2013-06-27 13:40 ` Gaël PORTAY
2013-06-23 9:53 ` Pavel Machek
2013-06-22 19:51 ` Geert Uytterhoeven
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=1371593140.2038.8.camel@joe-AO722 \
--to=joe@perches.com \
--cc=cooloney@gmail.com \
--cc=g.portay@overkiz.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=milo.kim@ti.com \
--cc=rob@landley.net \
--cc=rpurdie@rpsys.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®