Thread (25 messages) flat view 25 messages, 6 authors, 2021-07-30
STALE1865d

Revision rfc of 2 in this series.

Revisions (2)
  1. rfc current
  2. v2 [diff vs current]

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

From: Ian Pilcher <hidden>
Date: 2021-07-29 01:54:45
Also in: linux-block, linux-leds, lkml
Subsystem: block layer, the rest · Maintainers: Jens Axboe, Linus Torvalds

* Initialize trigger info when device is added.

Signed-off-by: Ian Pilcher <redacted>
---
 block/blk-ledtrig.h   | 7 +++++++
 block/genhd.c         | 1 +
 include/linux/genhd.h | 4 ++++
 3 files changed, 12 insertions(+)
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;
-- 
2.31.1


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help