Now that the ledtrig member has been added to struct gendisk, add the function bodies to ledtrig_blkdev_disk_init() and ledtrig_blkdev_disk_cleanup() Signed-off-by: Ian Pilcher <arequipeno@xxxxxxxxx> --- drivers/leds/trigger/ledtrig-blkdev-core.c | 15 +++++++++++++++ drivers/leds/trigger/ledtrig-blkdev.h | 3 +++ include/linux/leds.h | 1 + 3 files changed, 19 insertions(+) diff --git a/drivers/leds/trigger/ledtrig-blkdev-core.c b/drivers/leds/trigger/ledtrig-blkdev-core.c index f5b92d37f0df..102cdbe26d66 100644 --- a/drivers/leds/trigger/ledtrig-blkdev-core.c +++ b/drivers/leds/trigger/ledtrig-blkdev-core.c @@ -10,6 +10,13 @@ #include "ledtrig-blkdev.h" +DEFINE_MUTEX(ledtrig_blkdev_mutex); +EXPORT_SYMBOL_NS_GPL(ledtrig_blkdev_mutex, LEDTRIG_BLKDEV); + +/* Set when module is loaded (or trigger is initialized) */ +void (*__ledtrig_blkdev_disk_cleanup)(struct gendisk *gd) = NULL; +EXPORT_SYMBOL_NS_GPL(__ledtrig_blkdev_disk_cleanup, LEDTRIG_BLKDEV); + /** * ledtrig_blkdev_disk_cleanup - remove a block device from the blkdev LED * trigger @@ -17,4 +24,12 @@ */ void ledtrig_blkdev_disk_cleanup(struct gendisk *const gd) { + mutex_lock(&ledtrig_blkdev_mutex); + + if (gd->ledtrig != NULL) { + if (!WARN_ON(__ledtrig_blkdev_disk_cleanup == NULL)) + __ledtrig_blkdev_disk_cleanup(gd); + } + + mutex_unlock(&ledtrig_blkdev_mutex); } diff --git a/drivers/leds/trigger/ledtrig-blkdev.h b/drivers/leds/trigger/ledtrig-blkdev.h index 50b44461d4ab..914fb1523a2f 100644 --- a/drivers/leds/trigger/ledtrig-blkdev.h +++ b/drivers/leds/trigger/ledtrig-blkdev.h @@ -9,4 +9,7 @@ #ifndef __LEDTRIG_BLKDEV_H #define __LEDTRIG_BLKDEV_H +extern struct mutex ledtrig_blkdev_mutex; +extern void (*__ledtrig_blkdev_disk_cleanup)(struct gendisk *gd); + #endif /* __LEDTRIG_BLKDEV_H */ diff --git a/include/linux/leds.h b/include/linux/leds.h index 5d53921e4229..6cf3c5de5c93 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -613,6 +613,7 @@ static inline void ledtrig_audio_set(enum led_audio type, */ 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 */ -- 2.31.1