diff mbox series

[RFC,v3,10/18] block: Call LED trigger init/cleanup functions

Message ID 20210819025053.222710-11-arequipeno@gmail.com
State New
Headers show
Series Add block device LED trigger | expand

Commit Message

Ian Pilcher Aug. 19, 2021, 2:50 a.m. UTC
Call ledtrig_blkdev_disk_init() from __device_add_disk() to ensure that
gendisk's ledtrig field is initialized

Call ledtrig_blkdev_disk_cleanup() from del_gendisk() to clean up any
references to the device from the block device LED trigger

Signed-off-by: Ian Pilcher <arequipeno@gmail.com>
---
 block/genhd.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/block/genhd.c b/block/genhd.c
index e6d7bb709d62..091b954ddab3 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -24,6 +24,7 @@ 
 #include <linux/log2.h>
 #include <linux/pm_runtime.h>
 #include <linux/badblocks.h>
+#include <linux/leds.h>
 
 #include "blk.h"
 
@@ -539,6 +540,7 @@  static void __device_add_disk(struct device *parent, struct gendisk *disk,
 
 	disk_add_events(disk);
 	blk_integrity_add(disk);
+	ledtrig_blkdev_disk_init(disk);
 }
 
 void device_add_disk(struct device *parent, struct gendisk *disk,
@@ -581,6 +583,7 @@  void del_gendisk(struct gendisk *disk)
 	if (WARN_ON_ONCE(!disk->queue))
 		return;
 
+	ledtrig_blkdev_disk_cleanup(disk);
 	blk_integrity_del(disk);
 	disk_del_events(disk);