Normally ledtrig-ide-disk requires ide-disk.c to be compiled knowing that 
ledtrig-ide-disk is enabled.

This is less than optimal, since you should be able to add ledtrig targets 
later and/or separately.

So we work around this by having a hook that can be set, in the same way that 
netfilters and ip routing do.

Signed-off-by: Philip Prindeville <phil...@redfish-solutions.com>
Index: target/linux/x86/geos/target.mk
===================================================================
--- target/linux/x86/geos/target.mk     (revision 26880)
+++ target/linux/x86/geos/target.mk     (working copy)
@@ -13,6 +13,9 @@
             kmod-mppe kmod-pppoe kmod-pppoa kmod-pppol2tp \
             kmod-ath kmod-ath5k kmod-ath9k \
             kmod-cpu-msr \
+            kmod-ledtrig-heartbeat kmod-ledtrig-gpio kmod-ledtrig-ide-disk \
+            kmod-ledtrig-netdev kmod-ledtrig-netfilter \
+            kmod-ide-core \
             soloscli linux-atm br2684ctl bridge ppp ppp-mod-pppoa \
             libopenssl ocf-crypto-headers zlib hwclock hostapd \
             flashrom
Index: target/linux/x86/alix2/target.mk
===================================================================
--- target/linux/x86/alix2/target.mk    (revision 26880)
+++ target/linux/x86/alix2/target.mk    (working copy)
@@ -13,6 +13,10 @@
                        kmod-cfg80211 kmod-mac80211 \
                        kmod-mppe kmod-pppoe kmod-pppoa kmod-pppo2ltp \
                        kmod-ath kmod-ath5k kmod-ath9k \
+                       kmod-ledtrig-heartbeat kmod-ledtrig-gpio \
+                       kmod-ledtrig-ide-disk kmod-ledtrig-netdev \
+                       kmod-ledtrig-netfilter \
+                       kmod-ide-core \
                        bridge ppp ppp-mod-pppoa \
                        libopenssl ocf-crypto-headers zlib hwclock hostapd
 
Index: target/linux/generic/patches-2.6.38/240-ledtrig_ide_disk_tristate.patch
===================================================================
--- target/linux/generic/patches-2.6.38/240-ledtrig_ide_disk_tristate.patch     
(revision 0)
+++ target/linux/generic/patches-2.6.38/240-ledtrig_ide_disk_tristate.patch     
(revision 0)
@@ -0,0 +1,114 @@
+--- linux-2.6.38.2/drivers/leds/Kconfig.orig   2011-05-08 15:06:32.000000000 
-0600
++++ linux-2.6.38.2/drivers/leds/Kconfig        2011-05-08 17:16:13.000000000 
-0600
+@@ -391,7 +391,8 @@ config LEDS_TRIGGER_TIMER
+         If unsure, say Y.
+ 
+ config LEDS_TRIGGER_IDE_DISK
+-      bool "LED IDE Disk Trigger"
++      tristate "LED IDE Disk Trigger"
++      depends on (TREE_RCU || TREE_PREEMPT_RCU || TINY_RCU || 
TINY_PREEMPT_TCU)
+       depends on IDE_GD_ATA
+       depends on LEDS_TRIGGERS
+       help
+--- linux-2.6.38.2/include/linux/leds.h.orig   2011-03-27 12:37:20.000000000 
-0600
++++ linux-2.6.38.2/include/linux/leds.h        2011-05-14 16:12:49.000000000 
-0600
+@@ -157,13 +157,6 @@ extern void led_trigger_event(struct led
+ 
+ #endif
+ 
+-/* Trigger specific functions */
+-#ifdef CONFIG_LEDS_TRIGGER_IDE_DISK
+-extern void ledtrig_ide_activity(void);
+-#else
+-#define ledtrig_ide_activity() do {} while(0)
+-#endif
+-
+ /*
+  * Generic LED platform data for describing LED names and default triggers.
+  */
+--- linux-2.6.38.2/drivers/ide/ide-disk.c.orig 2011-03-27 12:37:20.000000000 
-0600
++++ linux-2.6.38.2/drivers/ide/ide-disk.c      2011-05-14 16:10:52.000000000 
-0600
+@@ -28,6 +28,7 @@
+ #include <linux/mutex.h>
+ #include <linux/leds.h>
+ #include <linux/ide.h>
++#include <linux/rcupdate.h>
+ 
+ #include <asm/byteorder.h>
+ #include <asm/irq.h>
+@@ -178,6 +179,10 @@ static ide_startstop_t __ide_do_rw_disk(
+  * 1073741822 == 549756 MB or 48bit addressing fake drive
+  */
+ 
++void __rcu (*ide_activity_hook)(void) __read_mostly = NULL;
++
++EXPORT_SYMBOL(ide_activity_hook);
++
+ static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
+                                     sector_t block)
+ {
+@@ -186,7 +191,16 @@ static ide_startstop_t ide_do_rw_disk(id
+       BUG_ON(drive->dev_flags & IDE_DFLAG_BLOCKED);
+       BUG_ON(rq->cmd_type != REQ_TYPE_FS);
+ 
+-      ledtrig_ide_activity();
++      {
++              void (*ide_activity)(void);
++
++              rcu_read_lock();
++              ide_activity = rcu_dereference(ide_activity_hook);
++
++              if (ide_activity)
++                      ide_activity();
++              rcu_read_unlock();
++      }
+ 
+       pr_debug("%s: %sing: block=%llu, sectors=%u, buffer=0x%08lx\n",
+                drive->name, rq_data_dir(rq) == READ ? "read" : "writ",
+--- linux-2.6.38.2/drivers/leds/ledtrig-ide-disk.c.orig        2011-03-27 
12:37:20.000000000 -0600
++++ linux-2.6.38.2/drivers/leds/ledtrig-ide-disk.c     2011-05-14 
16:11:24.000000000 -0600
+@@ -17,6 +17,7 @@
+ #include <linux/init.h>
+ #include <linux/timer.h>
+ #include <linux/leds.h>
++#include <linux/rcupdate.h>
+ 
+ static void ledtrig_ide_timerfunc(unsigned long data);
+ 
+@@ -25,13 +26,15 @@ static DEFINE_TIMER(ledtrig_ide_timer, l
+ static int ide_activity;
+ static int ide_lastactivity;
+ 
+-void ledtrig_ide_activity(void)
++/* made dependent on RCU? */
++extern void __rcu (*ide_activity_hook)(void) __read_mostly;
++
++static void ledtrig_ide_activity(void)
+ {
+       ide_activity++;
+       if (!timer_pending(&ledtrig_ide_timer))
+               mod_timer(&ledtrig_ide_timer, jiffies + msecs_to_jiffies(10));
+ }
+-EXPORT_SYMBOL(ledtrig_ide_activity);
+ 
+ static void ledtrig_ide_timerfunc(unsigned long data)
+ {
+@@ -47,6 +50,8 @@ static void ledtrig_ide_timerfunc(unsign
+ static int __init ledtrig_ide_init(void)
+ {
+       led_trigger_register_simple("ide-disk", &ledtrig_ide);
++
++      rcu_assign_pointer(ide_activity_hook, ledtrig_ide_activity);
+       return 0;
+ }
+ 
+@@ -54,6 +59,9 @@ static int __init ledtrig_ide_init(void)
+ 
+ static void __exit ledtrig_ide_exit(void)
+ {
++      rcu_assign_pointer(ide_activity_hook, NULL);
++      synchronize_rcu();
++
+       led_trigger_unregister_simple(ledtrig_ide);
+ }
+ 
Index: package/kernel/modules/leds.mk
===================================================================
--- package/kernel/modules/leds.mk      (revision 26891)
+++ package/kernel/modules/leds.mk      (working copy)
@@ -214,3 +214,24 @@
 endef
 
 $(eval $(call KernelPackage,ledtrig-usbdev))
+
+
+define KernelPackage/ledtrig-ide-disk
+  SUBMENU:=$(LEDS_MENU)
+  TITLE:=LED IDE disk Trigger
+  DEPENDS:=+kmod-ide-core
+  KCONFIG:=\
+       CONFIG_IDE \
+       CONFIG_IDE_GD \
+       CONFIG_IDE_GD_ATA=y \
+       CONFIG_IDE_GD_ATAPI=y \
+       CONFIG_LEDS_TRIGGER_IDE_DISK
+  FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-ide-disk.ko
+  AUTOLOAD:=$(call AutoLoad,50,ledtrig-ide-disk)
+endef
+
+define KernelPackage/ledtrig-ide-disk/description
+ Kernel module to drive LEDs based on IDE disk activity.
+endef
+
+$(eval $(call KernelPackage,ledtrig-ide-disk))
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to