new file mode 100644
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+/*
+ * Block device LED triggers
+ *
+ * Copyright 2021 Ian Pilcher <arequipeno@gmail.com>
+ */
+
+#ifndef _BLOCK_BLK_LEDTRIG_H
+#define _BLOCK_BLK_LEDTRIG_H
+
+#ifdef CONFIG_BLK_LED_TRIGGERS
+
+static inline void blk_ledtrig_disk_init(struct gendisk *const disk)
+{
+ RCU_INIT_POINTER(disk->led, NULL);
+}
+
+#else // CONFIG_BLK_LED_TRIGGERS
+
+static inline void blk_ledtrig_disk_init(const struct gendisk *disk) {}
+
+#endif // CONFIG_BLK_LED_TRIGGERS
+
+#endif // _BLOCK_BLK_LEDTRIG_H
@@ -26,6 +26,7 @@
#include <linux/badblocks.h>
#include "blk.h"
+#include "blk-ledtrig.h"
static struct kobject *block_depr;
@@ -539,6 +540,7 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
disk_add_events(disk);
blk_integrity_add(disk);
+ blk_ledtrig_disk_init(disk);
}
void device_add_disk(struct device *parent, struct gendisk *disk,
@@ -168,6 +168,10 @@ struct gendisk {
#endif /* CONFIG_BLK_DEV_INTEGRITY */
#if IS_ENABLED(CONFIG_CDROM)
struct cdrom_device_info *cdi;
+#endif
+#ifdef CONFIG_BLK_LED_TRIGGERS
+ struct blk_ledtrig_led __rcu *led;
+ struct list_head led_dev_list_node;
#endif
int node_id;
struct badblocks *bb;
Add header (blk-ledtrig.h) for LED trigger-related declarations Add (inline) function to ensure trigger pointer is initialized (to NULL) and call it from __device_add_disk() Signed-off-by: Ian Pilcher <arequipeno@gmail.com> --- block/blk-ledtrig.h | 25 +++++++++++++++++++++++++ block/genhd.c | 2 ++ include/linux/genhd.h | 4 ++++ 3 files changed, 31 insertions(+) create mode 100644 block/blk-ledtrig.h