lightnvm: Convert timers to use timer_setup()
authorKees Cook <keescook@chromium.org>
Wed, 18 Oct 2017 04:10:19 +0000 (21:10 -0700)
committerKees Cook <keescook@chromium.org>
Tue, 21 Nov 2017 23:46:44 +0000 (15:46 -0800)
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Matias Bjorling <mb@lightnvm.io>
Cc: linux-block@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
drivers/lightnvm/pblk-core.c
drivers/lightnvm/pblk-gc.c
drivers/lightnvm/pblk-init.c
drivers/lightnvm/pblk-rl.c
drivers/lightnvm/pblk.h
drivers/lightnvm/rrpc.c

index ce90213a42faea35805a5d964739a54c835a00d3..76516ee84e9adb63ecc6c670aad17f30edc72fb2 100644 (file)
@@ -270,9 +270,9 @@ static void pblk_write_kick(struct pblk *pblk)
        mod_timer(&pblk->wtimer, jiffies + msecs_to_jiffies(1000));
 }
 
-void pblk_write_timer_fn(unsigned long data)
+void pblk_write_timer_fn(struct timer_list *t)
 {
-       struct pblk *pblk = (struct pblk *)data;
+       struct pblk *pblk = from_timer(pblk, t, wtimer);
 
        /* kick the write thread every tick to flush outstanding data */
        pblk_write_kick(pblk);
index 00d5698d64a9a58852b2f91dcc1d4bac6c395320..9c8e114c8a545ca45cbea56660a2838f4a67e812 100644 (file)
@@ -442,9 +442,9 @@ next_gc_group:
                goto next_gc_group;
 }
 
-static void pblk_gc_timer(unsigned long data)
+static void pblk_gc_timer(struct timer_list *t)
 {
-       struct pblk *pblk = (struct pblk *)data;
+       struct pblk *pblk = from_timer(pblk, t, gc.gc_timer);
 
        pblk_gc_kick(pblk);
 }
@@ -601,7 +601,7 @@ int pblk_gc_init(struct pblk *pblk)
                goto fail_free_writer_kthread;
        }
 
-       setup_timer(&gc->gc_timer, pblk_gc_timer, (unsigned long)pblk);
+       timer_setup(&gc->gc_timer, pblk_gc_timer, 0);
        mod_timer(&gc->gc_timer, jiffies + msecs_to_jiffies(GC_TIME_MSECS));
 
        gc->gc_active = 0;
index f62112ba5482a345e33fa4bddb537b25d3c2db95..695826a06b5d2f87150f63348db49c67d96f38eb 100644 (file)
@@ -866,7 +866,7 @@ fail:
 
 static int pblk_writer_init(struct pblk *pblk)
 {
-       setup_timer(&pblk->wtimer, pblk_write_timer_fn, (unsigned long)pblk);
+       timer_setup(&pblk->wtimer, pblk_write_timer_fn, 0);
        mod_timer(&pblk->wtimer, jiffies + msecs_to_jiffies(100));
 
        pblk->writer_ts = kthread_create(pblk_write_ts, pblk, "pblk-writer-t");
index abae31fd434e5bd667e3ba761ace2189f250397a..dacc71922260b8bd2ccb80e2732338b09a73bb2d 100644 (file)
@@ -158,9 +158,9 @@ int pblk_rl_max_io(struct pblk_rl *rl)
        return rl->rb_max_io;
 }
 
-static void pblk_rl_u_timer(unsigned long data)
+static void pblk_rl_u_timer(struct timer_list *t)
 {
-       struct pblk_rl *rl = (struct pblk_rl *)data;
+       struct pblk_rl *rl = from_timer(rl, t, u_timer);
 
        /* Release user I/O state. Protect from GC */
        smp_store_release(&rl->rb_user_active, 0);
@@ -202,7 +202,7 @@ void pblk_rl_init(struct pblk_rl *rl, int budget)
        atomic_set(&rl->rb_gc_cnt, 0);
        atomic_set(&rl->rb_space, -1);
 
-       setup_timer(&rl->u_timer, pblk_rl_u_timer, (unsigned long)rl);
+       timer_setup(&rl->u_timer, pblk_rl_u_timer, 0);
 
        rl->rb_user_active = 0;
        rl->rb_gc_active = 0;
index 90961033a79fcd2af5c8ec425aec3978c29e9fa5..59a64d461a5dcf1e25c07000293fab0a7642a7ee 100644 (file)
@@ -797,7 +797,7 @@ void pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry,
  * pblk write thread
  */
 int pblk_write_ts(void *data);
-void pblk_write_timer_fn(unsigned long data);
+void pblk_write_timer_fn(struct timer_list *t);
 void pblk_write_should_kick(struct pblk *pblk);
 
 /*
index 267f01ae87e447b6fba7e2fe47f39a1a926416f4..0993c14be86011c63d91373bada4c9e8363865ec 100644 (file)
@@ -267,9 +267,9 @@ static void rrpc_gc_kick(struct rrpc *rrpc)
 /*
  * timed GC every interval.
  */
-static void rrpc_gc_timer(unsigned long data)
+static void rrpc_gc_timer(struct timer_list *t)
 {
-       struct rrpc *rrpc = (struct rrpc *)data;
+       struct rrpc *rrpc = from_timer(rrpc, t, gc_timer);
 
        rrpc_gc_kick(rrpc);
        mod_timer(&rrpc->gc_timer, jiffies + msecs_to_jiffies(10));
@@ -1063,7 +1063,7 @@ static int rrpc_gc_init(struct rrpc *rrpc)
        if (!rrpc->kgc_wq)
                return -ENOMEM;
 
-       setup_timer(&rrpc->gc_timer, rrpc_gc_timer, (unsigned long)rrpc);
+       timer_setup(&rrpc->gc_timer, rrpc_gc_timer, 0);
 
        return 0;
 }