@@ -544,3 +544,27 @@ ssize_t blk_ledtrig_devattr_show(struct device *const dev,
return (ssize_t)(name_len + 1);
}
+
+
+/*
+ *
+ * Try to blink an LED
+ *
+ */
+
+void __blk_ledtrig_try_blink(struct gendisk *const gd)
+{
+ if (mutex_trylock(&gd->ledtrig_mutex)) {
+
+ if (gd->ledtrig != NULL) {
+
+ unsigned long delay_on = 75;
+ unsigned long delay_off = 25;
+
+ led_trigger_blink_oneshot(&gd->ledtrig->trigger,
+ &delay_on, &delay_off, 0);
+ }
+
+ mutex_unlock(&gd->ledtrig_mutex);
+ }
+}
@@ -27,10 +27,19 @@ ssize_t blk_ledtrig_devattr_show(struct device *const dev,
struct device_attribute *const attr,
char *const buf);
+void __blk_ledtrig_try_blink(struct gendisk *gd);
+
+static inline void blk_ledtrig_try_blink(struct gendisk *const gd)
+{
+ if (gd != NULL)
+ __blk_ledtrig_try_blink(gd);
+}
+
#else // CONFIG_BLK_LED_TRIGGERS
static inline void blk_ledtrig_init(void) {}
static inline void blk_ledtrig_disk_init(const struct gendisk *gd) {}
+static inline void blk_ledtrig_try_blink(const struct gendisk *gd) {}
// Real function (declared in include/linux/blk-ledtrig.h) returns a bool.
// This is only here for del_gendisk() (in genhd.c), which doesn't check
@@ -40,6 +40,7 @@
#include "blk-stat.h"
#include "blk-mq-sched.h"
#include "blk-rq-qos.h"
+#include "blk-ledtrig.h"
static DEFINE_PER_CPU(struct llist_head, blk_cpu_done);
@@ -1381,6 +1382,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list,
switch (ret) {
case BLK_STS_OK:
queued++;
+ blk_ledtrig_try_blink(rq->rq_disk);
break;
case BLK_STS_RESOURCE:
case BLK_STS_DEV_RESOURCE:
* Don't wait to lock the device's LED trigger mutex; just don't blink the LED this time if it can't be locked right away, i.e. if mutex_trylock() fails. Signed-off-by: Ian Pilcher <arequipeno@gmail.com> --- block/blk-ledtrig.c | 24 ++++++++++++++++++++++++ block/blk-ledtrig.h | 9 +++++++++ block/blk-mq.c | 2 ++ 3 files changed, 35 insertions(+)