[RFC PATCH v2 08/10] block: Add init function for block device LED trigger

From: Ian Pilcher
Date: Sun Aug 08 2021 - 23:33:17 EST


Register the blkdev LED trigger

Signed-off-by: Ian Pilcher <arequipeno@xxxxxxxxx>
---
block/blk-ledtrig.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)

diff --git a/block/blk-ledtrig.c b/block/blk-ledtrig.c
index d02f32205985..14b1d33a2953 100644
--- a/block/blk-ledtrig.c
+++ b/block/blk-ledtrig.c
@@ -406,3 +406,38 @@ static ssize_t blk_ledtrig_blink_store(struct device *const dev,

return count;
}
+
+
+/*
+ *
+ * Initialization - register the trigger
+ *
+ */
+
+static struct attribute *blk_ledtrig_attrs[] = {
+ &blk_ledtrig_attr_blink_on.attr,
+ &blk_ledtrig_attr_blink_off.attr,
+ NULL
+};
+
+static const struct attribute_group blk_ledtrig_attr_group = {
+ .attrs = blk_ledtrig_attrs,
+};
+
+static const struct attribute_group *blk_ledtrig_attr_groups[] = {
+ &blk_ledtrig_attr_group,
+ NULL
+};
+
+static struct led_trigger blk_ledtrig_trigger = {
+ .name = "blkdev",
+ .activate = blk_ledtrig_activate,
+ .deactivate = blk_ledtrig_deactivate,
+ .groups = blk_ledtrig_attr_groups,
+};
+
+static int __init blk_ledtrig_init(void)
+{
+ return led_trigger_register(&blk_ledtrig_trigger);
+}
+device_initcall(blk_ledtrig_init);
--
2.31.1