#include <linux/mm.h>
 #include <linux/gfp.h>
 #include <linux/kernel.h>
+#include <linux/workqueue.h>
 
 #include <asm/mce.h>
 
 /* Amount of errors after which we offline */
 static unsigned int count_threshold = COUNT_MASK;
 
-/*
- * The timer "decays" element count each timer_interval which is 24hrs by
- * default.
- */
-
-#define CEC_TIMER_DEFAULT_INTERVAL     24 * 60 * 60    /* 24 hrs */
-#define CEC_TIMER_MIN_INTERVAL          1 * 60 * 60    /* 1h */
-#define CEC_TIMER_MAX_INTERVAL    30 * 24 * 60 * 60    /* one month */
-static struct timer_list cec_timer;
-static u64 timer_interval = CEC_TIMER_DEFAULT_INTERVAL;
+/* Each element "decays" each decay_interval which is 24hrs by default. */
+#define CEC_DECAY_DEFAULT_INTERVAL     24 * 60 * 60    /* 24 hrs */
+#define CEC_DECAY_MIN_INTERVAL          1 * 60 * 60    /* 1h */
+#define CEC_DECAY_MAX_INTERVAL    30 * 24 * 60 * 60    /* one month */
+static struct delayed_work cec_work;
+static u64 decay_interval = CEC_DECAY_DEFAULT_INTERVAL;
 
 /*
  * Decrement decay value. We're using DECAY_BITS bits to denote decay of an
 /*
  * @interval in seconds
  */
-static void cec_mod_timer(struct timer_list *t, unsigned long interval)
+static void cec_mod_work(unsigned long interval)
 {
        unsigned long iv;
 
-       iv = interval * HZ + jiffies;
-
-       mod_timer(t, round_jiffies(iv));
+       iv = interval * HZ;
+       mod_delayed_work(system_wq, &cec_work, round_jiffies(iv));
 }
 
-static void cec_timer_fn(struct timer_list *unused)
+static void cec_work_fn(struct work_struct *work)
 {
+       mutex_lock(&ce_mutex);
        do_spring_cleaning(&ce_arr);
+       mutex_unlock(&ce_mutex);
 
-       cec_mod_timer(&cec_timer, timer_interval);
+       cec_mod_work(decay_interval);
 }
 
 /*
 {
        *(u64 *)data = val;
 
-       if (val < CEC_TIMER_MIN_INTERVAL)
+       if (val < CEC_DECAY_MIN_INTERVAL)
                return -EINVAL;
 
-       if (val > CEC_TIMER_MAX_INTERVAL)
+       if (val > CEC_DECAY_MAX_INTERVAL)
                return -EINVAL;
 
-       timer_interval = val;
+       decay_interval = val;
 
-       cec_mod_timer(&cec_timer, timer_interval);
+       cec_mod_work(decay_interval);
        return 0;
 }
 DEFINE_DEBUGFS_ATTRIBUTE(decay_interval_ops, u64_get, decay_interval_set, "%lld\n");
 
        seq_printf(m, "Flags: 0x%x\n", ca->flags);
 
-       seq_printf(m, "Timer interval: %lld seconds\n", timer_interval);
+       seq_printf(m, "Decay interval: %lld seconds\n", decay_interval);
        seq_printf(m, "Decays: %lld\n", ca->decays_done);
 
        seq_printf(m, "Action threshold: %d\n", count_threshold);
        }
 
        decay = debugfs_create_file("decay_interval", S_IRUSR | S_IWUSR, d,
-                                   &timer_interval, &decay_interval_ops);
+                                   &decay_interval, &decay_interval_ops);
        if (!decay) {
                pr_warn("Error creating decay_interval debugfs node!\n");
                goto err;
        if (create_debugfs_nodes())
                return;
 
-       timer_setup(&cec_timer, cec_timer_fn, 0);
-       cec_mod_timer(&cec_timer, CEC_TIMER_DEFAULT_INTERVAL);
+       INIT_DELAYED_WORK(&cec_work, cec_work_fn);
+       schedule_delayed_work(&cec_work, CEC_DECAY_DEFAULT_INTERVAL);
 
        pr_info("Correctable Errors collector initialized.\n");
 }