Skip to content

Commit eb25cb9

Browse files
rexutjanaszewski
authored andcommitted
leds: convert IDE trigger to common disk trigger
This patch converts the IDE specific LED trigger to a generic disk activity LED trigger. The libata core is now a trigger source just like before the IDE disk driver. It's merely a replacement of the string ide by disk. The patch is taken from http://dev.gentoo.org/~josejx/ata.patch and is widely used by any ibook/powerbook owners with great satisfaction. Likewise, it is very often used successfully on different ARM platforms. Unlike the original patch, the existing 'ide-disk' trigger is still available for backward compatibility. That reduce the amount of patches in affected device trees out of the mainline kernel. For further development, the new name 'disk-activity' should be used. Cc: Joseph Jezak <[email protected]> Cc: Jörg Sommer <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Stephan Linz <[email protected]> Signed-off-by: Jacek Anaszewski <[email protected]>
1 parent fa4191a commit eb25cb9

File tree

7 files changed

+26
-17
lines changed

7 files changed

+26
-17
lines changed

drivers/ata/libata-core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include <asm/unaligned.h>
7070
#include <linux/cdrom.h>
7171
#include <linux/ratelimit.h>
72+
#include <linux/leds.h>
7273
#include <linux/pm_runtime.h>
7374
#include <linux/platform_device.h>
7475

@@ -5072,6 +5073,9 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
50725073
{
50735074
struct ata_port *ap = qc->ap;
50745075

5076+
/* Trigger the LED (if available) */
5077+
ledtrig_disk_activity();
5078+
50755079
/* XXX: New EH and old EH use different mechanisms to
50765080
* synchronize EH with regular execution path.
50775081
*

drivers/ide/ide-disk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
186186
BUG_ON(drive->dev_flags & IDE_DFLAG_BLOCKED);
187187
BUG_ON(rq->cmd_type != REQ_TYPE_FS);
188188

189-
ledtrig_ide_activity();
189+
ledtrig_disk_activity();
190190

191191
pr_debug("%s: %sing: block=%llu, sectors=%u\n",
192192
drive->name, rq_data_dir(rq) == READ ? "read" : "writ",

drivers/leds/leds-hp6xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static struct led_classdev hp6xx_red_led = {
5050

5151
static struct led_classdev hp6xx_green_led = {
5252
.name = "hp6xx:green",
53-
.default_trigger = "ide-disk",
53+
.default_trigger = "disk-activity",
5454
.brightness_set = hp6xxled_green_set,
5555
.flags = LED_CORE_SUSPENDRESUME,
5656
};

drivers/leds/trigger/Kconfig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ config LEDS_TRIGGER_ONESHOT
3333

3434
If unsure, say Y.
3535

36-
config LEDS_TRIGGER_IDE_DISK
37-
bool "LED IDE Disk Trigger"
38-
depends on IDE_GD_ATA
36+
config LEDS_TRIGGER_DISK
37+
bool "LED Disk Trigger"
38+
depends on IDE_GD_ATA || ATA
3939
depends on LEDS_TRIGGERS
4040
help
41-
This allows LEDs to be controlled by IDE disk activity.
41+
This allows LEDs to be controlled by disk activity.
4242
If unsure, say Y.
4343

4444
config LEDS_TRIGGER_MTD

drivers/leds/trigger/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
22
obj-$(CONFIG_LEDS_TRIGGER_ONESHOT) += ledtrig-oneshot.o
3-
obj-$(CONFIG_LEDS_TRIGGER_IDE_DISK) += ledtrig-ide-disk.o
3+
obj-$(CONFIG_LEDS_TRIGGER_DISK) += ledtrig-disk.o
44
obj-$(CONFIG_LEDS_TRIGGER_MTD) += ledtrig-mtd.o
55
obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT) += ledtrig-heartbeat.o
66
obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o

drivers/leds/trigger/ledtrig-ide-disk.c renamed to drivers/leds/trigger/ledtrig-disk.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* LED IDE-Disk Activity Trigger
2+
* LED Disk Activity Trigger
33
*
44
* Copyright 2006 Openedhand Ltd.
55
*
@@ -17,20 +17,25 @@
1717

1818
#define BLINK_DELAY 30
1919

20+
DEFINE_LED_TRIGGER(ledtrig_disk);
2021
DEFINE_LED_TRIGGER(ledtrig_ide);
2122

22-
void ledtrig_ide_activity(void)
23+
void ledtrig_disk_activity(void)
2324
{
24-
unsigned long ide_blink_delay = BLINK_DELAY;
25+
unsigned long blink_delay = BLINK_DELAY;
2526

27+
led_trigger_blink_oneshot(ledtrig_disk,
28+
&blink_delay, &blink_delay, 0);
2629
led_trigger_blink_oneshot(ledtrig_ide,
27-
&ide_blink_delay, &ide_blink_delay, 0);
30+
&blink_delay, &blink_delay, 0);
2831
}
29-
EXPORT_SYMBOL(ledtrig_ide_activity);
32+
EXPORT_SYMBOL(ledtrig_disk_activity);
3033

31-
static int __init ledtrig_ide_init(void)
34+
static int __init ledtrig_disk_init(void)
3235
{
36+
led_trigger_register_simple("disk-activity", &ledtrig_disk);
3337
led_trigger_register_simple("ide-disk", &ledtrig_ide);
38+
3439
return 0;
3540
}
36-
device_initcall(ledtrig_ide_init);
41+
device_initcall(ledtrig_disk_init);

include/linux/leds.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,10 @@ static inline void *led_get_trigger_data(struct led_classdev *led_cdev)
325325
#endif /* CONFIG_LEDS_TRIGGERS */
326326

327327
/* Trigger specific functions */
328-
#ifdef CONFIG_LEDS_TRIGGER_IDE_DISK
329-
extern void ledtrig_ide_activity(void);
328+
#ifdef CONFIG_LEDS_TRIGGER_DISK
329+
extern void ledtrig_disk_activity(void);
330330
#else
331-
static inline void ledtrig_ide_activity(void) {}
331+
static inline void ledtrig_disk_activity(void) {}
332332
#endif
333333

334334
#ifdef CONFIG_LEDS_TRIGGER_MTD

0 commit comments

Comments
 (0)