Skip to content

Instantly share code, notes, and snippets.

Created May 9, 2016 08:57
Show Gist options
  • Save anonymous/eb928acbda17e7cb0be2dae0f25cfcff to your computer and use it in GitHub Desktop.
Save anonymous/eb928acbda17e7cb0be2dae0f25cfcff to your computer and use it in GitHub Desktop.
stdin
diff --git a/package/kernel/linux/modules/leds.mk b/package/kernel/linux/modules/leds.mk
index c4261d3..c416e5c 100644
--- a/package/kernel/linux/modules/leds.mk
+++ b/package/kernel/linux/modules/leds.mk
@@ -105,6 +105,20 @@ endef
$(eval $(call KernelPackage,ledtrig-netfilter))
+define KernelPackage/ledtrig-sata-disk
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED SATA activity Trigger
+ DEPENDS:=kmod-ata-core
+ KCONFIG:=CONFIG_LEDS_TRIGGER_SATA_DISK=y
+endef
+
+define KernelPackage/ledtrig-sata-disk/description
+ Kernel module to drive LEDs based on SATA activity
+endef
+
+$(eval $(call KernelPackage,ledtrig-sata-disk))
+
+
define KernelPackage/ledtrig-usbdev
SUBMENU:=$(LEDS_MENU)
TITLE:=LED USB device Trigger
diff --git a/target/linux/mvebu/patches-4.1/902-sata-disk-trigger.patch b/target/linux/mvebu/patches-4.1/902-sata-disk-trigger.patch
new file mode 100644
index 0000000..3dbd166
--- /dev/null
+++ b/target/linux/mvebu/patches-4.1/902-sata-disk-trigger.patch
@@ -0,0 +1,107 @@
+--- /dev/null
++++ b/drivers/leds/ledtrig-sata-disk.c
+@@ -0,0 +1,49 @@
++/*
++ * LED SATA-Disk Activity Trigger
++ *
++ * Derived from ledtrig-ide-disk.c, below notes are from there.
++ *
++ * Copyright 2006 Openedhand Ltd.
++ *
++ * Author: Richard Purdie <rpurdie@openedhand.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ *
++ */
++
++#include <linux/module.h>
++#include <linux/kernel.h>
++#include <linux/init.h>
++#include <linux/leds.h>
++
++#define BLINK_DELAY 30
++
++DEFINE_LED_TRIGGER(ledtrig_sata);
++static unsigned long sata_blink_delay = BLINK_DELAY;
++
++void ledtrig_sata_activity(void)
++{
++ led_trigger_blink_oneshot(ledtrig_sata,
++ &sata_blink_delay, &sata_blink_delay, 0);
++}
++EXPORT_SYMBOL(ledtrig_sata_activity);
++
++static int __init ledtrig_sata_init(void)
++{
++ led_trigger_register_simple("sata-disk", &ledtrig_sata);
++ return 0;
++}
++
++static void __exit ledtrig_sata_exit(void)
++{
++ led_trigger_unregister_simple(ledtrig_sata);
++}
++
++module_init(ledtrig_sata_init);
++module_exit(ledtrig_sata_exit);
++
++MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
++MODULE_DESCRIPTION("LED SATA Disk Activity Trigger");
++MODULE_LICENSE("GPL");
+--- a/drivers/leds/Makefile
++++ b/drivers/leds/Makefile
+@@ -75,3 +75,4 @@ obj-$(CONFIG_LEDS_TRIGGERS) += trigger/
+ obj-$(CONFIG_LEDS_TRIGGER_MORSE) += ledtrig-morse.o
+ obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o
+ obj-$(CONFIG_LEDS_TRIGGER_USBDEV) += ledtrig-usbdev.o
++obj-$(CONFIG_LEDS_TRIGGER_SATA_DISK) += ledtrig-sata-disk.o
+--- a/include/linux/leds.h
++++ b/include/linux/leds.h
+@@ -316,6 +316,12 @@ static inline void ledtrig_flash_ctrl(bo
+ static inline void ledtrig_torch_ctrl(bool on) {}
+ #endif
+
++#ifdef CONFIG_LEDS_TRIGGER_SATA_DISK
++extern void ledtrig_sata_activity(void);
++#else
++#define ledtrig_sata_activity() do {} while(0)
++#endif
++
+ /*
+ * Generic LED platform data for describing LED names and default triggers.
+ */
+--- a/drivers/leds/trigger/Kconfig
++++ b/drivers/leds/trigger/Kconfig
+@@ -126,4 +126,11 @@ config LEDS_TRIGGER_USBDEV
+ This allows LEDs to be controlled by the presence/activity of
+ an USB device. If unsure, say N.
+
++config LEDS_TRIGGER_SATA_DISK
++ bool "LED SATA Disk Trigger"
++ depends on ATA && LEDS_TRIGGERS
++ help
++ This allows LEDs to be controlled by SATA disk activity.
++ If unsure, say Y.
++
+ endif # LEDS_TRIGGERS
+--- a/drivers/ata/libahci.c
++++ b/drivers/ata/libahci.c
+@@ -45,6 +45,7 @@
+ #include <linux/libata.h>
+ #include "ahci.h"
+ #include "libata.h"
++#include <linux/leds.h>
+
+ static int ahci_skip_host_reset;
+ int ahci_ignore_sss;
+@@ -1973,6 +1974,8 @@ unsigned int ahci_qc_issue(struct ata_qu
+
+ ahci_sw_activity(qc->dev->link);
+
++ ledtrig_sata_activity();
++
+ return 0;
+ }
+ EXPORT_SYMBOL_GPL(ahci_qc_issue);
diff --git a/target/linux/mvebu/patches-4.4/902-sata-disk-trigger.patch b/target/linux/mvebu/patches-4.4/902-sata-disk-trigger.patch
new file mode 100644
index 0000000..3dbd166
--- /dev/null
+++ b/target/linux/mvebu/patches-4.4/902-sata-disk-trigger.patch
@@ -0,0 +1,107 @@
+--- /dev/null
++++ b/drivers/leds/ledtrig-sata-disk.c
+@@ -0,0 +1,49 @@
++/*
++ * LED SATA-Disk Activity Trigger
++ *
++ * Derived from ledtrig-ide-disk.c, below notes are from there.
++ *
++ * Copyright 2006 Openedhand Ltd.
++ *
++ * Author: Richard Purdie <rpurdie@openedhand.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ *
++ */
++
++#include <linux/module.h>
++#include <linux/kernel.h>
++#include <linux/init.h>
++#include <linux/leds.h>
++
++#define BLINK_DELAY 30
++
++DEFINE_LED_TRIGGER(ledtrig_sata);
++static unsigned long sata_blink_delay = BLINK_DELAY;
++
++void ledtrig_sata_activity(void)
++{
++ led_trigger_blink_oneshot(ledtrig_sata,
++ &sata_blink_delay, &sata_blink_delay, 0);
++}
++EXPORT_SYMBOL(ledtrig_sata_activity);
++
++static int __init ledtrig_sata_init(void)
++{
++ led_trigger_register_simple("sata-disk", &ledtrig_sata);
++ return 0;
++}
++
++static void __exit ledtrig_sata_exit(void)
++{
++ led_trigger_unregister_simple(ledtrig_sata);
++}
++
++module_init(ledtrig_sata_init);
++module_exit(ledtrig_sata_exit);
++
++MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
++MODULE_DESCRIPTION("LED SATA Disk Activity Trigger");
++MODULE_LICENSE("GPL");
+--- a/drivers/leds/Makefile
++++ b/drivers/leds/Makefile
+@@ -75,3 +75,4 @@ obj-$(CONFIG_LEDS_TRIGGERS) += trigger/
+ obj-$(CONFIG_LEDS_TRIGGER_MORSE) += ledtrig-morse.o
+ obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o
+ obj-$(CONFIG_LEDS_TRIGGER_USBDEV) += ledtrig-usbdev.o
++obj-$(CONFIG_LEDS_TRIGGER_SATA_DISK) += ledtrig-sata-disk.o
+--- a/include/linux/leds.h
++++ b/include/linux/leds.h
+@@ -316,6 +316,12 @@ static inline void ledtrig_flash_ctrl(bo
+ static inline void ledtrig_torch_ctrl(bool on) {}
+ #endif
+
++#ifdef CONFIG_LEDS_TRIGGER_SATA_DISK
++extern void ledtrig_sata_activity(void);
++#else
++#define ledtrig_sata_activity() do {} while(0)
++#endif
++
+ /*
+ * Generic LED platform data for describing LED names and default triggers.
+ */
+--- a/drivers/leds/trigger/Kconfig
++++ b/drivers/leds/trigger/Kconfig
+@@ -126,4 +126,11 @@ config LEDS_TRIGGER_USBDEV
+ This allows LEDs to be controlled by the presence/activity of
+ an USB device. If unsure, say N.
+
++config LEDS_TRIGGER_SATA_DISK
++ bool "LED SATA Disk Trigger"
++ depends on ATA && LEDS_TRIGGERS
++ help
++ This allows LEDs to be controlled by SATA disk activity.
++ If unsure, say Y.
++
+ endif # LEDS_TRIGGERS
+--- a/drivers/ata/libahci.c
++++ b/drivers/ata/libahci.c
+@@ -45,6 +45,7 @@
+ #include <linux/libata.h>
+ #include "ahci.h"
+ #include "libata.h"
++#include <linux/leds.h>
+
+ static int ahci_skip_host_reset;
+ int ahci_ignore_sss;
+@@ -1973,6 +1974,8 @@ unsigned int ahci_qc_issue(struct ata_qu
+
+ ahci_sw_activity(qc->dev->link);
+
++ ledtrig_sata_activity();
++
+ return 0;
+ }
+ EXPORT_SYMBOL_GPL(ahci_qc_issue);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment