@@ -281,3 +281,34 @@ static void blkdev_disk_delete(struct ledtrig_blkdev_led *const led,
exit_unlock:
mutex_unlock(&ledtrig_blkdev_mutex);
}
+
+
+/*
+ *
+ * Disassociate all LEDs from a block device (because it's going away)
+ *
+ */
+
+/**
+ * ledtrig_blkdev_disk_cleanup - remove a block device from the blkdev LED
+ * trigger
+ * @disk: the disk to be removed
+ */
+void ledtrig_blkdev_disk_cleanup(struct gendisk *const gd)
+{
+ struct ledtrig_blkdev_link *link;
+ struct hlist_node *next;
+
+ mutex_lock(&ledtrig_blkdev_mutex);
+
+ if (gd->ledtrig != NULL) {
+
+ hlist_for_each_entry_safe(link, next,
+ &gd->ledtrig->leds, disk_leds_node) {
+ blkdev_disk_del_locked(link->led, link, gd->ledtrig);
+ }
+ }
+
+ mutex_unlock(&ledtrig_blkdev_mutex);
+}
+EXPORT_SYMBOL_GPL(ledtrig_blkdev_disk_cleanup);
@@ -609,10 +609,14 @@ static inline void ledtrig_blkdev_disk_init(struct gendisk *const gd)
{
gd->ledtrig = NULL;
}
+void ledtrig_blkdev_disk_cleanup(struct gendisk *const gd);
#else /* CONFIG_LEDS_TRIGGER_BLKDEV */
static inline void ledtrig_blkdev_disk_init(const struct gendisk *gd)
{
}
+static inline void ledtrig_blkdev_disk_cleanup(const struct gendisk *gd)
+{
+}
#endif /* CONFIG_LEDS_TRIGGER_BLKDEV */
#endif /* __LINUX_LEDS_H_INCLUDED */
Called when block device is being removed Signed-off-by: Ian Pilcher <arequipeno@gmail.com> --- drivers/leds/trigger/ledtrig-blkdev.c | 31 +++++++++++++++++++++++++++ include/linux/leds.h | 4 ++++ 2 files changed, 35 insertions(+)