This patch series adds a new "blkdev" LED trigger for disk (or other block device) activity LEDs. It has the following functionality. * Supports all types of block devices, including virtual devices (unlike the existing disk trigger which only works with ATA devices). * LEDs can be configured to show read activity, write activity, or both. * Supports multiple devices and multiple LEDs in arbitrary many-to-many configurations. For example, it is possible to configure multiple devices with device-specific read activity LEDs and a shared write activity LED. (See Documentation/leds/ledtrig-blkdev.rst in the first patch.) * Doesn't add any overhead in the I/O path. Like the netdev LED trigger, it periodically checks the configured devices for activity and blinks its LEDs as appropriate. * Blink duration (per LED) and interval between activity checks (global) are configurable. * Requires minimal changes to the block subsystem. - Adds 1 pointer to struct gendisk, - Adds (inline function) call in device_add_disk() to ensure that the pointer is initialized to NULL (as protection against any drivers that allocate a gendisk themselves and don't use kzalloc()), and - Adds call in del_gendisk() to remove a device from the trigger when that device is being removed. These changes are all in patch #4, "block: Add block device LED trigger integrations." * The trigger can be mostly built as a module. When the trigger is modular, a small portion is built in to provide a "stub" function which can be called from del_gendisk(). The stub calls into the modular code via a function pointer when needed. The trigger also needs the ability to find gendisk's by name, which requires access to the un-exported block_class and disk_type symbols. NOTES: * This patch series applies cleanly to the linux-block and linux-next (20210903) trees. All patches other than the block subsystem patch (patch #4) apply cleanly to the linux-leds tree. * All patches compile (modulo warnings) with the trigger disabled, modular, or built-in. Ian Pilcher (18): docs: Add block device (blkdev) LED trigger documentation ledtrig-blkdev: Add build infra for block device LED trigger ledtrig-blkdev: Add function placeholders needed by block changes block: Add block device LED trigger integrations ledtrig-blkdev: Implement functions called from block subsystem ledtrig-blkdev: Add function to get gendisk by name ledtrig-blkdev: Add constants, data types, and global variables ledtrig-blkdev: Add miscellaneous helper functions ledtrig-blkdev: Periodically check devices for activity & blink LEDs ledtrig-blkdev: Add function to associate the trigger with an LED ledtrig-blkdev: Add function to associate a device with an LED ledtrig-blkdev: Add function to remove LED/device association ledtrig-blkdev: Add function to disassociate a device from all LEDs ledtrig-blkdev: Add function to disassociate an LED from the trigger ledtrig-blkdev: Add sysfs attributes to [un]link LEDs & devices ledtrig-blkdev: Add blink_time & interval sysfs attributes ledtrig-blkdev: Add mode (read/write/rw) sysfs attributue ledtrig-blkdev: Add initialization & exit functions Documentation/ABI/testing/sysfs-block | 9 + .../testing/sysfs-class-led-trigger-blkdev | 48 ++ Documentation/leds/index.rst | 1 + Documentation/leds/ledtrig-blkdev.rst | 144 ++++ block/genhd.c | 4 + drivers/leds/trigger/Kconfig | 18 + drivers/leds/trigger/Makefile | 2 + drivers/leds/trigger/ledtrig-blkdev-core.c | 78 ++ drivers/leds/trigger/ledtrig-blkdev.c | 767 ++++++++++++++++++ drivers/leds/trigger/ledtrig-blkdev.h | 27 + include/linux/genhd.h | 3 + include/linux/leds.h | 20 + 12 files changed, 1121 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-led-trigger-blkdev create mode 100644 Documentation/leds/ledtrig-blkdev.rst create mode 100644 drivers/leds/trigger/ledtrig-blkdev-core.c create mode 100644 drivers/leds/trigger/ledtrig-blkdev.c create mode 100644 drivers/leds/trigger/ledtrig-blkdev.h -- 2.31.1