4e0be8d5adb4b395521ef63a46e3725c1c8a58a1
[openwrt/staging/wigyori.git] /
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
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
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
12 string ide by disk.
13
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.
17
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.
22
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>
28 ---
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
39
40 --- a/drivers/ata/libata-core.c
41 +++ b/drivers/ata/libata-core.c
42 @@ -67,6 +67,7 @@
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>
49
50 @@ -4914,6 +4915,9 @@ void ata_qc_complete(struct ata_queued_c
51 {
52 struct ata_port *ap = qc->ap;
53
54 + /* Trigger the LED (if available) */
55 + ledtrig_disk_activity();
56 +
57 /* XXX: New EH and old EH use different mechanisms to
58 * synchronize EH with regular execution path.
59 *
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);
65
66 - ledtrig_ide_activity();
67 + ledtrig_disk_activity();
68
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
74
75 If unsure, say Y.
76
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
84 help
85 - This allows LEDs to be controlled by IDE disk activity.
86 + This allows LEDs to be controlled by disk activity.
87 If unsure, say Y.
88
89 config LEDS_TRIGGER_HEARTBEAT
90 --- a/drivers/leds/trigger/Makefile
91 +++ b/drivers/leds/trigger/Makefile
92 @@ -1,6 +1,6 @@
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
100 --- /dev/null
101 +++ b/drivers/leds/trigger/ledtrig-disk.c
102 @@ -0,0 +1,41 @@
103 +/*
104 + * LED Disk Activity Trigger
105 + *
106 + * Copyright 2006 Openedhand Ltd.
107 + *
108 + * Author: Richard Purdie <rpurdie@openedhand.com>
109 + *
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.
113 + *
114 + */
115 +
116 +#include <linux/kernel.h>
117 +#include <linux/init.h>
118 +#include <linux/leds.h>
119 +
120 +#define BLINK_DELAY 30
121 +
122 +DEFINE_LED_TRIGGER(ledtrig_disk);
123 +DEFINE_LED_TRIGGER(ledtrig_ide);
124 +
125 +void ledtrig_disk_activity(void)
126 +{
127 + unsigned long blink_delay = BLINK_DELAY;
128 +
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);
133 +}
134 +EXPORT_SYMBOL(ledtrig_disk_activity);
135 +
136 +static int __init ledtrig_disk_init(void)
137 +{
138 + led_trigger_register_simple("disk-activity", &ledtrig_disk);
139 + led_trigger_register_simple("ide-disk", &ledtrig_ide);
140 +
141 + return 0;
142 +}
143 +device_initcall(ledtrig_disk_init);
144 --- a/drivers/leds/trigger/ledtrig-ide-disk.c
145 +++ /dev/null
146 @@ -1,47 +0,0 @@
147 -/*
148 - * LED IDE-Disk Activity Trigger
149 - *
150 - * Copyright 2006 Openedhand Ltd.
151 - *
152 - * Author: Richard Purdie <rpurdie@openedhand.com>
153 - *
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.
157 - *
158 - */
159 -
160 -#include <linux/module.h>
161 -#include <linux/kernel.h>
162 -#include <linux/init.h>
163 -#include <linux/leds.h>
164 -
165 -#define BLINK_DELAY 30
166 -
167 -DEFINE_LED_TRIGGER(ledtrig_ide);
168 -static unsigned long ide_blink_delay = BLINK_DELAY;
169 -
170 -void ledtrig_ide_activity(void)
171 -{
172 - led_trigger_blink_oneshot(ledtrig_ide,
173 - &ide_blink_delay, &ide_blink_delay, 0);
174 -}
175 -EXPORT_SYMBOL(ledtrig_ide_activity);
176 -
177 -static int __init ledtrig_ide_init(void)
178 -{
179 - led_trigger_register_simple("ide-disk", &ledtrig_ide);
180 - return 0;
181 -}
182 -
183 -static void __exit ledtrig_ide_exit(void)
184 -{
185 - led_trigger_unregister_simple(ledtrig_ide);
186 -}
187 -
188 -module_init(ledtrig_ide_init);
189 -module_exit(ledtrig_ide_exit);
190 -
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 @@ -302,10 +302,10 @@ static inline void *led_get_trigger_data
197 #endif /* CONFIG_LEDS_TRIGGERS */
198
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);
204 #else
205 -static inline void ledtrig_ide_activity(void) {}
206 +static inline void ledtrig_disk_activity(void) {}
207 #endif
208
209 #if defined(CONFIG_LEDS_TRIGGER_CAMERA) || defined(CONFIG_LEDS_TRIGGER_CAMERA_MODULE)