libata: add ledtrig support
PATCH v2 1/1 libata: add ledtrig support
This adds a LED trigger for each ATA port indicating disk activity.
As this is needed only on specific platforms (NAS SoCs and such), these platforms should define ARCH_WANTS_LIBATA_LEDS if there are boards with LED(s) intended to indicate ATA disk activity and need the OS to take care of that.
In that way, if not selected, LED trigger support not will be included in libata-core and both, codepaths and structures remain untouched.
I'm currently deploying this for the oxnas target in OpenWrt
https://dev.openwrt.org/changeset/43675/
v2: rebased to kernel/git/tj/libata.git
plus small corrections and comments added
---
If there is anything fundamentally wrong with that approach, I'd be glad for some advise on how to do it better.
I conciously choose an #ifdev approach to make sure performance will not be affected for non-users of that code.
Thanks
Daniel
--- drivers/ata/Kconfig | 16 ++++++++++++++ drivers/ata/libata-core.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/libata.h | 7 ++++++ 3 files changed, 79 insertions(+)
drivers/ata/Kconfig +16 -0
@@ -46,6 +46,22 @@ config ATA_VERBOSE_ERROR If unsure, say Y. +config ARCH_WANT_LIBATA_LEDS + bool + +config ATA_LEDS + bool "support ATA port LED triggers" + depends on ARCH_WANT_LIBATA_LEDS + select NEW_LEDS + select LEDS_CLASS + select LEDS_TRIGGERS + default y + help + This option adds a LED trigger for each registered ATA port. + It is used to drive disk activity leds connected via GPIO. + + If unsure, say N. + config ATA_ACPI bool "ATA ACPI Support" depends on ACPI && PCI
drivers/ata/libata-core.c +56 -0
92 lines not on this page · raw message
include/linux/libata.h +7 -0
@@ -38,6 +38,7 @@#include <linux/acpi.h> #include <linux/cdrom.h> #include <linux/sched.h> +#include <linux/leds.h> /* * Define if arch has non-standard setup. This is a _PCI_ standard
@@ -861,6 +862,12 @@ struct ata_port {#ifdef CONFIG_ATA_ACPI struct ata_acpi_gtm __acpi_init_gtm;/* use ata_acpi_init_gtm() */ #endif + +#ifdef CONFIG_ATA_LEDS +struct led_trigger *ledtrig; +char ledtrig_name[8 ]; +#endif +/* owned by EH */ u8 sector_buf[ATA_SECT_SIZE ]____cacheline_aligned ; };
Signature · 1 line
2.1.3