Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1434480 > unrolled thread
| Started by | Amitoj Kaur Chawla <amitoj1606@gmail.com> |
|---|---|
| First post | 2016-06-30 13:50 +0200 |
| Last post | 2016-06-30 14:20 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] bcache: Use setup_timer and mod_timer Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2016-06-30 13:50 +0200
Re: [PATCH] bcache: Use setup_timer and mod_timer Coly Li <colyli@suse.de> - 2016-06-30 14:20 +0200
| From | Amitoj Kaur Chawla <amitoj1606@gmail.com> |
|---|---|
| Date | 2016-06-30 13:50 +0200 |
| Subject | [PATCH] bcache: Use setup_timer and mod_timer |
| Message-ID | <rPIDL-Di-5@gated-at.bofh.it> |
Convert a call to init_timer and accompanying intializations of the timer's data and function fields to a call to setup_timer. The Coccinelle semantic patch that fixes one part of this issue is as follows: @@ expression t,d,f,e1; identifier x1; statement S1; @@ ( -t.data = d; | -t.function = f; | -init_timer(&t); +setup_timer(&t,f,d); | -init_timer_on_stack(&t); +setup_timer_on_stack(&t,f,d); ) <... when != S1 t.x1 = e1; ...> Also convert calls to add_timer and intialisation of timer's expire field to a call to mod_timer which is more compact. Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com> --- drivers/md/bcache/stats.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/md/bcache/stats.c b/drivers/md/bcache/stats.c index 0ca072c..094d6d6 100644 --- a/drivers/md/bcache/stats.c +++ b/drivers/md/bcache/stats.c @@ -233,9 +233,6 @@ void bch_cache_accounting_init(struct cache_accounting *acc, kobject_init(&acc->day.kobj, &bch_stats_ktype); closure_init(&acc->cl, parent); - init_timer(&acc->timer); - acc->timer.expires = jiffies + accounting_delay; - acc->timer.data = (unsigned long) acc; - acc->timer.function = scale_accounting; - add_timer(&acc->timer); + setup_timer(&acc->timer, scale_accounting, (unsigned long) acc); + mod_timer(&acc->timer, jiffies + accounting_delay); } -- 1.9.1
[toc] | [next] | [standalone]
| From | Coly Li <colyli@suse.de> |
|---|---|
| Date | 2016-06-30 14:20 +0200 |
| Message-ID | <rPJ6O-12j-15@gated-at.bofh.it> |
| In reply to | #1434480 |
在 16/6/30 下午7:45, Amitoj Kaur Chawla 写道: > Convert a call to init_timer and accompanying intializations of > the timer's data and function fields to a call to setup_timer. > > The Coccinelle semantic patch that fixes one part of this issue > is as follows: > @@ > expression t,d,f,e1; > identifier x1; > statement S1; > @@ > > ( > -t.data = d; > | > -t.function = f; > | > -init_timer(&t); > +setup_timer(&t,f,d); > | > -init_timer_on_stack(&t); > +setup_timer_on_stack(&t,f,d); > ) > <... when != S1 > t.x1 = e1; > ...> > > Also convert calls to add_timer and intialisation of timer's expire > field to a call to mod_timer which is more compact. > > Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com> > --- > drivers/md/bcache/stats.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/md/bcache/stats.c b/drivers/md/bcache/stats.c > index 0ca072c..094d6d6 100644 > --- a/drivers/md/bcache/stats.c > +++ b/drivers/md/bcache/stats.c > @@ -233,9 +233,6 @@ void bch_cache_accounting_init(struct cache_accounting *acc, > kobject_init(&acc->day.kobj, &bch_stats_ktype); > > closure_init(&acc->cl, parent); > - init_timer(&acc->timer); > - acc->timer.expires = jiffies + accounting_delay; > - acc->timer.data = (unsigned long) acc; > - acc->timer.function = scale_accounting; > - add_timer(&acc->timer); > + setup_timer(&acc->timer, scale_accounting, (unsigned long) acc); > + mod_timer(&acc->timer, jiffies + accounting_delay); > } > This patch uses new setup_timer() and mod_timer() interface to initialize acc->timer. No change in functionality. It is OK to me. Reviewed-by: Coly Li <colyli@suse.de> Coly
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web