040-backport_leds-convert-IDE-trigger-to-common-disk-trigger.patch 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. This patch converts the IDE specific LED trigger to a generic disk
  9. activity LED trigger. The libata core is now a trigger source just
  10. like before the IDE disk driver. It's merely a replacement of the
  11. string ide by disk.
  12. The patch is taken from http://dev.gentoo.org/~josejx/ata.patch and is
  13. widely used by any ibook/powerbook owners with great satisfaction.
  14. Likewise, it is very often used successfully on different ARM platforms.
  15. Unlike the original patch, the existing 'ide-disk' trigger is still
  16. available for backward compatibility. That reduce the amount of patches
  17. in affected device trees out of the mainline kernel. For further
  18. development, the new name 'disk-activity' should be used.
  19. Cc: Joseph Jezak <josejx@gentoo.org>
  20. Cc: Jörg Sommer <joerg@alea.gnuu.de>
  21. Cc: Richard Purdie <rpurdie@rpsys.net>
  22. Signed-off-by: Stephan Linz <linz@li-pro.net>
  23. Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
  24. ---
  25. drivers/ata/libata-core.c | 4 ++++
  26. drivers/ide/ide-disk.c | 2 +-
  27. drivers/leds/trigger/Kconfig | 8 +++----
  28. drivers/leds/trigger/Makefile | 2 +-
  29. drivers/leds/trigger/ledtrig-disk.c | 41 +++++++++++++++++++++++++++++++++
  30. drivers/leds/trigger/ledtrig-ide-disk.c | 36 -----------------------------
  31. include/linux/leds.h | 6 ++---
  32. 8 files changed, 55 insertions(+), 46 deletions(-)
  33. create mode 100644 drivers/leds/trigger/ledtrig-disk.c
  34. delete mode 100644 drivers/leds/trigger/ledtrig-ide-disk.c
  35. --- a/drivers/ata/libata-core.c
  36. +++ b/drivers/ata/libata-core.c
  37. @@ -67,6 +67,7 @@
  38. #include <asm/byteorder.h>
  39. #include <linux/cdrom.h>
  40. #include <linux/ratelimit.h>
  41. +#include <linux/leds.h>
  42. #include <linux/pm_runtime.h>
  43. #include <linux/platform_device.h>
  44. @@ -4949,6 +4950,9 @@ void ata_qc_complete(struct ata_queued_c
  45. {
  46. struct ata_port *ap = qc->ap;
  47. + /* Trigger the LED (if available) */
  48. + ledtrig_disk_activity();
  49. +
  50. /* XXX: New EH and old EH use different mechanisms to
  51. * synchronize EH with regular execution path.
  52. *
  53. --- a/drivers/ide/ide-disk.c
  54. +++ b/drivers/ide/ide-disk.c
  55. @@ -186,7 +186,7 @@ static ide_startstop_t ide_do_rw_disk(id
  56. BUG_ON(drive->dev_flags & IDE_DFLAG_BLOCKED);
  57. BUG_ON(rq->cmd_type != REQ_TYPE_FS);
  58. - ledtrig_ide_activity();
  59. + ledtrig_disk_activity();
  60. pr_debug("%s: %sing: block=%llu, sectors=%u\n",
  61. drive->name, rq_data_dir(rq) == READ ? "read" : "writ",
  62. --- a/drivers/leds/trigger/Kconfig
  63. +++ b/drivers/leds/trigger/Kconfig
  64. @@ -33,12 +33,12 @@ config LEDS_TRIGGER_ONESHOT
  65. If unsure, say Y.
  66. -config LEDS_TRIGGER_IDE_DISK
  67. - bool "LED IDE Disk Trigger"
  68. - depends on IDE_GD_ATA
  69. +config LEDS_TRIGGER_DISK
  70. + bool "LED Disk Trigger"
  71. + depends on IDE_GD_ATA || ATA
  72. depends on LEDS_TRIGGERS
  73. help
  74. - This allows LEDs to be controlled by IDE disk activity.
  75. + This allows LEDs to be controlled by disk activity.
  76. If unsure, say Y.
  77. config LEDS_TRIGGER_HEARTBEAT
  78. --- a/drivers/leds/trigger/Makefile
  79. +++ b/drivers/leds/trigger/Makefile
  80. @@ -1,6 +1,6 @@
  81. obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
  82. obj-$(CONFIG_LEDS_TRIGGER_ONESHOT) += ledtrig-oneshot.o
  83. -obj-$(CONFIG_LEDS_TRIGGER_IDE_DISK) += ledtrig-ide-disk.o
  84. +obj-$(CONFIG_LEDS_TRIGGER_DISK) += ledtrig-disk.o
  85. obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT) += ledtrig-heartbeat.o
  86. obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o
  87. obj-$(CONFIG_LEDS_TRIGGER_GPIO) += ledtrig-gpio.o
  88. --- /dev/null
  89. +++ b/drivers/leds/trigger/ledtrig-disk.c
  90. @@ -0,0 +1,41 @@
  91. +/*
  92. + * LED Disk Activity Trigger
  93. + *
  94. + * Copyright 2006 Openedhand Ltd.
  95. + *
  96. + * Author: Richard Purdie <rpurdie@openedhand.com>
  97. + *
  98. + * This program is free software; you can redistribute it and/or modify
  99. + * it under the terms of the GNU General Public License version 2 as
  100. + * published by the Free Software Foundation.
  101. + *
  102. + */
  103. +
  104. +#include <linux/kernel.h>
  105. +#include <linux/init.h>
  106. +#include <linux/leds.h>
  107. +
  108. +#define BLINK_DELAY 30
  109. +
  110. +DEFINE_LED_TRIGGER(ledtrig_disk);
  111. +DEFINE_LED_TRIGGER(ledtrig_ide);
  112. +
  113. +void ledtrig_disk_activity(void)
  114. +{
  115. + unsigned long blink_delay = BLINK_DELAY;
  116. +
  117. + led_trigger_blink_oneshot(ledtrig_disk,
  118. + &blink_delay, &blink_delay, 0);
  119. + led_trigger_blink_oneshot(ledtrig_ide,
  120. + &blink_delay, &blink_delay, 0);
  121. +}
  122. +EXPORT_SYMBOL(ledtrig_disk_activity);
  123. +
  124. +static int __init ledtrig_disk_init(void)
  125. +{
  126. + led_trigger_register_simple("disk-activity", &ledtrig_disk);
  127. + led_trigger_register_simple("ide-disk", &ledtrig_ide);
  128. +
  129. + return 0;
  130. +}
  131. +device_initcall(ledtrig_disk_init);
  132. --- a/drivers/leds/trigger/ledtrig-ide-disk.c
  133. +++ /dev/null
  134. @@ -1,47 +0,0 @@
  135. -/*
  136. - * LED IDE-Disk Activity Trigger
  137. - *
  138. - * Copyright 2006 Openedhand Ltd.
  139. - *
  140. - * Author: Richard Purdie <rpurdie@openedhand.com>
  141. - *
  142. - * This program is free software; you can redistribute it and/or modify
  143. - * it under the terms of the GNU General Public License version 2 as
  144. - * published by the Free Software Foundation.
  145. - *
  146. - */
  147. -
  148. -#include <linux/module.h>
  149. -#include <linux/kernel.h>
  150. -#include <linux/init.h>
  151. -#include <linux/leds.h>
  152. -
  153. -#define BLINK_DELAY 30
  154. -
  155. -DEFINE_LED_TRIGGER(ledtrig_ide);
  156. -static unsigned long ide_blink_delay = BLINK_DELAY;
  157. -
  158. -void ledtrig_ide_activity(void)
  159. -{
  160. - led_trigger_blink_oneshot(ledtrig_ide,
  161. - &ide_blink_delay, &ide_blink_delay, 0);
  162. -}
  163. -EXPORT_SYMBOL(ledtrig_ide_activity);
  164. -
  165. -static int __init ledtrig_ide_init(void)
  166. -{
  167. - led_trigger_register_simple("ide-disk", &ledtrig_ide);
  168. - return 0;
  169. -}
  170. -
  171. -static void __exit ledtrig_ide_exit(void)
  172. -{
  173. - led_trigger_unregister_simple(ledtrig_ide);
  174. -}
  175. -
  176. -module_init(ledtrig_ide_init);
  177. -module_exit(ledtrig_ide_exit);
  178. -
  179. -MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
  180. -MODULE_DESCRIPTION("LED IDE Disk Activity Trigger");
  181. -MODULE_LICENSE("GPL");
  182. --- a/include/linux/leds.h
  183. +++ b/include/linux/leds.h
  184. @@ -308,10 +308,10 @@ static inline void *led_get_trigger_data
  185. #endif /* CONFIG_LEDS_TRIGGERS */
  186. /* Trigger specific functions */
  187. -#ifdef CONFIG_LEDS_TRIGGER_IDE_DISK
  188. -extern void ledtrig_ide_activity(void);
  189. +#ifdef CONFIG_LEDS_TRIGGER_DISK
  190. +extern void ledtrig_disk_activity(void);
  191. #else
  192. -static inline void ledtrig_ide_activity(void) {}
  193. +static inline void ledtrig_disk_activity(void) {}
  194. #endif
  195. #if defined(CONFIG_LEDS_TRIGGER_CAMERA) || defined(CONFIG_LEDS_TRIGGER_CAMERA_MODULE)