diff mbox series

[RFC,5/8] block: Add block device LED trigger info to struct genhd

Message ID 20210729015344.3366750-6-arequipeno@gmail.com
State New
Headers show
Series Add configurable block device LED triggers | expand

Commit Message

Ian Pilcher July 29, 2021, 1:53 a.m. UTC
* Initialize trigger info when device is added.

Signed-off-by: Ian Pilcher <arequipeno@gmail.com>
---
 block/blk-ledtrig.h   | 7 +++++++
 block/genhd.c         | 1 +
 include/linux/genhd.h | 4 ++++
 3 files changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/block/blk-ledtrig.h b/block/blk-ledtrig.h
index 894843249deb..5854b21a210c 100644
--- a/block/blk-ledtrig.h
+++ b/block/blk-ledtrig.h
@@ -13,9 +13,16 @@ 
 
 void blk_ledtrig_init(void);
 
+static inline void blk_ledtrig_disk_init(struct gendisk *const gd)
+{
+	gd->ledtrig = NULL;
+	mutex_init(&gd->ledtrig_mutex);
+}
+
 #else	// CONFIG_BLK_LED_TRIGGERS
 
 static inline void blk_ledtrig_init(void) {}
+static inline void blk_ledtrig_disk_init(const struct gendisk *gd) {}
 
 #endif	// CONFIG_BLK_LED_TRIGGERS
 
diff --git a/block/genhd.c b/block/genhd.c
index d0b1d8f743ae..420325447c5d 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -540,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,
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 13b34177cc85..3409334c9b4c 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -169,6 +169,10 @@  struct gendisk {
 #if IS_ENABLED(CONFIG_CDROM)
 	struct cdrom_device_info *cdi;
 #endif
+#ifdef CONFIG_BLK_LED_TRIGGERS
+	struct blk_ledtrig *ledtrig;
+	struct mutex ledtrig_mutex;
+#endif	/* CONFIG_BLK_LED_TRIGGERS */
 	int node_id;
 	struct badblocks *bb;
 	struct lockdep_map lockdep_map;