[RFC PATCH 5/8] block: Add block device LED trigger info to struct genhd
Ian Pilcher
arequipeno at gmail.com
Wed Jul 28 21:53:41 EDT 2021
* Initialize trigger info when device is added.
Signed-off-by: Ian Pilcher <arequipeno at gmail.com>
---
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
More information about the Kernelnewbies
mailing list