linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabio Baltieri <fabio.baltieri@gmail.com>
To: Bryan Wu <bryan.wu@canonical.com>
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
	Richard Purdie <rpurdie@rpsys.net>,
	Fabio Baltieri <fabio.baltieri@gmail.com>
Subject: [PATCH 2/3] ledtrig-ide-disk: use generic one-shot blink api
Date: Sun, 27 May 2012 01:19:23 +0200	[thread overview]
Message-ID: <1338074364-1829-2-git-send-email-fabio.baltieri@gmail.com> (raw)
In-Reply-To: <1338074364-1829-1-git-send-email-fabio.baltieri@gmail.com>

Convert ledtrig-ide-disk code to use the generic API for one-shot LED
blinking.

This patch changes slightly the behaviour of the trigger, as while the
original version kept the LED on under heavy activity, the new one keeps
a constant on-off blink at 1 / (2 * BLINK_DELAY) Hz.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
Cc: Bryan Wu <bryan.wu@canonical.com>
---
 drivers/leds/ledtrig-ide-disk.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/drivers/leds/ledtrig-ide-disk.c b/drivers/leds/ledtrig-ide-disk.c
index ec099fc..0ff16fb 100644
--- a/drivers/leds/ledtrig-ide-disk.c
+++ b/drivers/leds/ledtrig-ide-disk.c
@@ -18,33 +18,18 @@
 #include <linux/timer.h>
 #include <linux/leds.h>
 
-static void ledtrig_ide_timerfunc(unsigned long data);
+#define BLINK_DELAY 30
 
 DEFINE_LED_TRIGGER(ledtrig_ide);
-static DEFINE_TIMER(ledtrig_ide_timer, ledtrig_ide_timerfunc, 0, 0);
-static int ide_activity;
-static int ide_lastactivity;
+static unsigned long ide_blink_delay = BLINK_DELAY;
 
 void ledtrig_ide_activity(void)
 {
-	ide_activity++;
-	if (!timer_pending(&ledtrig_ide_timer))
-		mod_timer(&ledtrig_ide_timer, jiffies + msecs_to_jiffies(10));
+	led_trigger_blink_oneshot(ledtrig_ide,
+				  &ide_blink_delay, &ide_blink_delay, 0);
 }
 EXPORT_SYMBOL(ledtrig_ide_activity);
 
-static void ledtrig_ide_timerfunc(unsigned long data)
-{
-	if (ide_lastactivity != ide_activity) {
-		ide_lastactivity = ide_activity;
-		/* INT_MAX will set each LED to its maximum brightness */
-		led_trigger_event(ledtrig_ide, INT_MAX);
-		mod_timer(&ledtrig_ide_timer, jiffies + msecs_to_jiffies(10));
-	} else {
-		led_trigger_event(ledtrig_ide, LED_OFF);
-	}
-}
-
 static int __init ledtrig_ide_init(void)
 {
 	led_trigger_register_simple("ide-disk", &ledtrig_ide);
-- 
1.7.10.2.520.g6a4a482.dirty


  reply	other threads:[~2012-05-26 23:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-26 23:19 [PATCH v2 1/3] leds: add oneshot blink functions Fabio Baltieri
2012-05-26 23:19 ` Fabio Baltieri [this message]
2012-06-05  7:20   ` [PATCH 2/3] ledtrig-ide-disk: use generic one-shot blink api Bryan Wu
2012-05-26 23:19 ` [PATCH 3/3] led: add oneshot trigger Fabio Baltieri
2012-05-27 16:09   ` Shuah Khan
2012-05-31 21:01     ` Fabio Baltieri
2012-06-05  7:37       ` Bryan Wu
2012-06-05 20:55         ` Fabio Baltieri
2012-05-27 16:13 ` [PATCH v2 1/3] leds: add oneshot blink functions Shuah Khan
2012-05-31 21:08   ` Fabio Baltieri
2012-06-01 15:39     ` Shuah Khan
2012-06-04 21:37       ` Fabio Baltieri
2012-06-04 23:12         ` Shuah Khan
2012-06-05  3:05           ` Bryan Wu
2012-06-05 14:59             ` Shuah Khan
2012-06-06  2:44               ` Bryan Wu

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=1338074364-1829-2-git-send-email-fabio.baltieri@gmail.com \
    --to=fabio.baltieri@gmail.com \
    --cc=bryan.wu@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).