1 From eb25cb9956cc9384b7fa0d75dec908c9fac8c444 Mon Sep 17 00:00:00 2001
2 From: Stephan Linz <linz@li-pro.net>
3 Date: Fri, 10 Jun 2016 07:59:56 +0200
4 Subject: [PATCH] leds: convert IDE trigger to common disk trigger
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 This patch converts the IDE specific LED trigger to a generic disk
10 activity LED trigger. The libata core is now a trigger source just
11 like before the IDE disk driver. It's merely a replacement of the
14 The patch is taken from http://dev.gentoo.org/~josejx/ata.patch and is
15 widely used by any ibook/powerbook owners with great satisfaction.
16 Likewise, it is very often used successfully on different ARM platforms.
18 Unlike the original patch, the existing 'ide-disk' trigger is still
19 available for backward compatibility. That reduce the amount of patches
20 in affected device trees out of the mainline kernel. For further
21 development, the new name 'disk-activity' should be used.
23 Cc: Joseph Jezak <josejx@gentoo.org>
24 Cc: Jörg Sommer <joerg@alea.gnuu.de>
25 Cc: Richard Purdie <rpurdie@rpsys.net>
26 Signed-off-by: Stephan Linz <linz@li-pro.net>
27 Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
29 drivers/ata/libata-core.c | 4 ++++
30 drivers/ide/ide-disk.c | 2 +-
31 drivers/leds/trigger/Kconfig | 8 +++----
32 drivers/leds/trigger/Makefile | 2 +-
33 drivers/leds/trigger/ledtrig-disk.c | 41 +++++++++++++++++++++++++++++++++
34 drivers/leds/trigger/ledtrig-ide-disk.c | 36 -----------------------------
35 include/linux/leds.h | 6 ++---
36 8 files changed, 55 insertions(+), 46 deletions(-)
37 create mode 100644 drivers/leds/trigger/ledtrig-disk.c
38 delete mode 100644 drivers/leds/trigger/ledtrig-ide-disk.c
40 --- a/drivers/ata/libata-core.c
41 +++ b/drivers/ata/libata-core.c
43 #include <asm/byteorder.h>
44 #include <linux/cdrom.h>
45 #include <linux/ratelimit.h>
46 +#include <linux/leds.h>
47 #include <linux/pm_runtime.h>
48 #include <linux/platform_device.h>
50 @@ -4942,6 +4943,9 @@ void ata_qc_complete(struct ata_queued_c
52 struct ata_port *ap = qc->ap;
54 + /* Trigger the LED (if available) */
55 + ledtrig_disk_activity();
57 /* XXX: New EH and old EH use different mechanisms to
58 * synchronize EH with regular execution path.
60 --- a/drivers/ide/ide-disk.c
61 +++ b/drivers/ide/ide-disk.c
62 @@ -186,7 +186,7 @@ static ide_startstop_t ide_do_rw_disk(id
63 BUG_ON(drive->dev_flags & IDE_DFLAG_BLOCKED);
64 BUG_ON(rq->cmd_type != REQ_TYPE_FS);
66 - ledtrig_ide_activity();
67 + ledtrig_disk_activity();
69 pr_debug("%s: %sing: block=%llu, sectors=%u\n",
70 drive->name, rq_data_dir(rq) == READ ? "read" : "writ",
71 --- a/drivers/leds/trigger/Kconfig
72 +++ b/drivers/leds/trigger/Kconfig
73 @@ -33,12 +33,12 @@ config LEDS_TRIGGER_ONESHOT
77 -config LEDS_TRIGGER_IDE_DISK
78 - bool "LED IDE Disk Trigger"
79 - depends on IDE_GD_ATA
80 +config LEDS_TRIGGER_DISK
81 + bool "LED Disk Trigger"
82 + depends on IDE_GD_ATA || ATA
83 depends on LEDS_TRIGGERS
85 - This allows LEDs to be controlled by IDE disk activity.
86 + This allows LEDs to be controlled by disk activity.
89 config LEDS_TRIGGER_HEARTBEAT
90 --- a/drivers/leds/trigger/Makefile
91 +++ b/drivers/leds/trigger/Makefile
93 obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
94 obj-$(CONFIG_LEDS_TRIGGER_ONESHOT) += ledtrig-oneshot.o
95 -obj-$(CONFIG_LEDS_TRIGGER_IDE_DISK) += ledtrig-ide-disk.o
96 +obj-$(CONFIG_LEDS_TRIGGER_DISK) += ledtrig-disk.o
97 obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT) += ledtrig-heartbeat.o
98 obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o
99 obj-$(CONFIG_LEDS_TRIGGER_GPIO) += ledtrig-gpio.o
101 +++ b/drivers/leds/trigger/ledtrig-disk.c
104 + * LED Disk Activity Trigger
106 + * Copyright 2006 Openedhand Ltd.
108 + * Author: Richard Purdie <rpurdie@openedhand.com>
110 + * This program is free software; you can redistribute it and/or modify
111 + * it under the terms of the GNU General Public License version 2 as
112 + * published by the Free Software Foundation.
116 +#include <linux/kernel.h>
117 +#include <linux/init.h>
118 +#include <linux/leds.h>
120 +#define BLINK_DELAY 30
122 +DEFINE_LED_TRIGGER(ledtrig_disk);
123 +DEFINE_LED_TRIGGER(ledtrig_ide);
125 +void ledtrig_disk_activity(void)
127 + unsigned long blink_delay = BLINK_DELAY;
129 + led_trigger_blink_oneshot(ledtrig_disk,
130 + &blink_delay, &blink_delay, 0);
131 + led_trigger_blink_oneshot(ledtrig_ide,
132 + &blink_delay, &blink_delay, 0);
134 +EXPORT_SYMBOL(ledtrig_disk_activity);
136 +static int __init ledtrig_disk_init(void)
138 + led_trigger_register_simple("disk-activity", &ledtrig_disk);
139 + led_trigger_register_simple("ide-disk", &ledtrig_ide);
143 +device_initcall(ledtrig_disk_init);
144 --- a/drivers/leds/trigger/ledtrig-ide-disk.c
148 - * LED IDE-Disk Activity Trigger
150 - * Copyright 2006 Openedhand Ltd.
152 - * Author: Richard Purdie <rpurdie@openedhand.com>
154 - * This program is free software; you can redistribute it and/or modify
155 - * it under the terms of the GNU General Public License version 2 as
156 - * published by the Free Software Foundation.
160 -#include <linux/module.h>
161 -#include <linux/kernel.h>
162 -#include <linux/init.h>
163 -#include <linux/leds.h>
165 -#define BLINK_DELAY 30
167 -DEFINE_LED_TRIGGER(ledtrig_ide);
168 -static unsigned long ide_blink_delay = BLINK_DELAY;
170 -void ledtrig_ide_activity(void)
172 - led_trigger_blink_oneshot(ledtrig_ide,
173 - &ide_blink_delay, &ide_blink_delay, 0);
175 -EXPORT_SYMBOL(ledtrig_ide_activity);
177 -static int __init ledtrig_ide_init(void)
179 - led_trigger_register_simple("ide-disk", &ledtrig_ide);
183 -static void __exit ledtrig_ide_exit(void)
185 - led_trigger_unregister_simple(ledtrig_ide);
188 -module_init(ledtrig_ide_init);
189 -module_exit(ledtrig_ide_exit);
191 -MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
192 -MODULE_DESCRIPTION("LED IDE Disk Activity Trigger");
193 -MODULE_LICENSE("GPL");
194 --- a/include/linux/leds.h
195 +++ b/include/linux/leds.h
196 @@ -308,10 +308,10 @@ static inline void *led_get_trigger_data
197 #endif /* CONFIG_LEDS_TRIGGERS */
199 /* Trigger specific functions */
200 -#ifdef CONFIG_LEDS_TRIGGER_IDE_DISK
201 -extern void ledtrig_ide_activity(void);
202 +#ifdef CONFIG_LEDS_TRIGGER_DISK
203 +extern void ledtrig_disk_activity(void);
205 -static inline void ledtrig_ide_activity(void) {}
206 +static inline void ledtrig_disk_activity(void) {}
209 #if defined(CONFIG_LEDS_TRIGGER_CAMERA) || defined(CONFIG_LEDS_TRIGGER_CAMERA_MODULE)