Message ID | 20150301194637.GA3441@vaishali-Ideapad-Z570 (mailing list archive) |
---|---|
State | Rejected |
Headers | show |
Le lundi 02 mars 2015 à 01:16 +0530, Vaishali Thakkar a écrit : > Use timer API functions setup_timer and mod_timer instead > of structure assignments as they are standard way to set > the timer and to update the expire field of an active timer > respectively. > > This is done using Coccinelle and semantic patch used for > this is as follows: > > // <smpl> > @@ > expression x,y,z,a,b; > @@ > > -init_timer (&x); > +setup_timer (&x, y, z); > +mod_timer (&a, b); > -x.function = y; > -x.data = z; > -x.expires = b; > -add_timer(&a); > // </smpl> > > Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com> > --- > drivers/infiniband/hw/ipath/ipath_driver.c | 9 +++------ > drivers/infiniband/hw/ipath/ipath_init_chip.c | 10 +++------- > drivers/infiniband/hw/ipath/ipath_verbs.c | 7 ++----- > 3 files changed, 8 insertions(+), 18 deletions(-) > [...] > diff --git a/drivers/infiniband/hw/ipath/ipath_init_chip.c b/drivers/infiniband/hw/ipath/ipath_init_chip.c > index be2a60e..34ffb43 100644 > --- a/drivers/infiniband/hw/ipath/ipath_init_chip.c > +++ b/drivers/infiniband/hw/ipath/ipath_init_chip.c > @@ -950,13 +950,9 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit) > * set up stats retrieval timer, even if we had errors > * in last portion of setup > */ > - init_timer(&dd->ipath_stats_timer); > - dd->ipath_stats_timer.function = ipath_get_faststats; > - dd->ipath_stats_timer.data = (unsigned long) dd; > - /* every 5 seconds; */ > - dd->ipath_stats_timer.expires = jiffies + 5 * HZ; > - /* takes ~16 seconds to overflow at full IB 4x bandwdith */ > - add_timer(&dd->ipath_stats_timer); > + setup_timer(&dd->ipath_stats_timer, ipath_get_faststats, > + (unsigned long)dd); > + mod_timer(&dd->ipath_stats_timer, jiffies + 5 * HZ); The code seems correct, but you remove the comments, loosing some useful information. Regards.
On Mon, Mar 2, 2015 at 10:17 PM, Yann Droneaud <ydroneaud@opteya.com> wrote: > Le lundi 02 mars 2015 à 01:16 +0530, Vaishali Thakkar a écrit : >> Use timer API functions setup_timer and mod_timer instead >> of structure assignments as they are standard way to set >> the timer and to update the expire field of an active timer >> respectively. >> >> This is done using Coccinelle and semantic patch used for >> this is as follows: >> >> // <smpl> >> @@ >> expression x,y,z,a,b; >> @@ >> >> -init_timer (&x); >> +setup_timer (&x, y, z); >> +mod_timer (&a, b); >> -x.function = y; >> -x.data = z; >> -x.expires = b; >> -add_timer(&a); >> // </smpl> >> >> Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com> >> --- >> drivers/infiniband/hw/ipath/ipath_driver.c | 9 +++------ >> drivers/infiniband/hw/ipath/ipath_init_chip.c | 10 +++------- >> drivers/infiniband/hw/ipath/ipath_verbs.c | 7 ++----- >> 3 files changed, 8 insertions(+), 18 deletions(-) >> > [...] >> diff --git a/drivers/infiniband/hw/ipath/ipath_init_chip.c b/drivers/infiniband/hw/ipath/ipath_init_chip.c >> index be2a60e..34ffb43 100644 >> --- a/drivers/infiniband/hw/ipath/ipath_init_chip.c >> +++ b/drivers/infiniband/hw/ipath/ipath_init_chip.c >> @@ -950,13 +950,9 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit) >> * set up stats retrieval timer, even if we had errors >> * in last portion of setup >> */ >> - init_timer(&dd->ipath_stats_timer); >> - dd->ipath_stats_timer.function = ipath_get_faststats; >> - dd->ipath_stats_timer.data = (unsigned long) dd; >> - /* every 5 seconds; */ >> - dd->ipath_stats_timer.expires = jiffies + 5 * HZ; >> - /* takes ~16 seconds to overflow at full IB 4x bandwdith */ >> - add_timer(&dd->ipath_stats_timer); >> + setup_timer(&dd->ipath_stats_timer, ipath_get_faststats, >> + (unsigned long)dd); >> + mod_timer(&dd->ipath_stats_timer, jiffies + 5 * HZ); > > The code seems correct, but you remove the comments, loosing some useful > information. Yes. I guess I missed that. Ok. I will send v2 with keeping these comments in a code. Thank You > Regards. > > -- > Yann Droneaud > OPTEYA > >
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c index bd0caed..3854a37 100644 --- a/drivers/infiniband/hw/ipath/ipath_driver.c +++ b/drivers/infiniband/hw/ipath/ipath_driver.c @@ -2300,12 +2300,9 @@ void ipath_set_led_override(struct ipath_devdata *dd, unsigned int val) */ if (atomic_inc_return(&dd->ipath_led_override_timer_active) == 1) { /* Need to start timer */ - init_timer(&dd->ipath_led_override_timer); - dd->ipath_led_override_timer.function = - ipath_run_led_override; - dd->ipath_led_override_timer.data = (unsigned long) dd; - dd->ipath_led_override_timer.expires = jiffies + 1; - add_timer(&dd->ipath_led_override_timer); + setup_timer(&dd->ipath_led_override_timer, + ipath_run_led_override, (unsigned long)dd); + mod_timer(&dd->ipath_led_override_timer, jiffies + 1); } else atomic_dec(&dd->ipath_led_override_timer_active); } diff --git a/drivers/infiniband/hw/ipath/ipath_init_chip.c b/drivers/infiniband/hw/ipath/ipath_init_chip.c index be2a60e..34ffb43 100644 --- a/drivers/infiniband/hw/ipath/ipath_init_chip.c +++ b/drivers/infiniband/hw/ipath/ipath_init_chip.c @@ -950,13 +950,9 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit) * set up stats retrieval timer, even if we had errors * in last portion of setup */ - init_timer(&dd->ipath_stats_timer); - dd->ipath_stats_timer.function = ipath_get_faststats; - dd->ipath_stats_timer.data = (unsigned long) dd; - /* every 5 seconds; */ - dd->ipath_stats_timer.expires = jiffies + 5 * HZ; - /* takes ~16 seconds to overflow at full IB 4x bandwdith */ - add_timer(&dd->ipath_stats_timer); + setup_timer(&dd->ipath_stats_timer, ipath_get_faststats, + (unsigned long)dd); + mod_timer(&dd->ipath_stats_timer, jiffies + 5 * HZ); dd->ipath_stats_timer_active = 1; } diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c index 44ea939..41929ea 100644 --- a/drivers/infiniband/hw/ipath/ipath_verbs.c +++ b/drivers/infiniband/hw/ipath/ipath_verbs.c @@ -1952,11 +1952,8 @@ static int enable_timer(struct ipath_devdata *dd) dd->ipath_gpio_mask); } - init_timer(&dd->verbs_timer); - dd->verbs_timer.function = __verbs_timer; - dd->verbs_timer.data = (unsigned long)dd; - dd->verbs_timer.expires = jiffies + 1; - add_timer(&dd->verbs_timer); + setup_timer(&dd->verbs_timer, __verbs_timer, (unsigned long)dd); + mod_timer(&dd->verbs_timer, jiffies + 1); return 0; }
Use timer API functions setup_timer and mod_timer instead of structure assignments as they are standard way to set the timer and to update the expire field of an active timer respectively. This is done using Coccinelle and semantic patch used for this is as follows: // <smpl> @@ expression x,y,z,a,b; @@ -init_timer (&x); +setup_timer (&x, y, z); +mod_timer (&a, b); -x.function = y; -x.data = z; -x.expires = b; -add_timer(&a); // </smpl> Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com> --- drivers/infiniband/hw/ipath/ipath_driver.c | 9 +++------ drivers/infiniband/hw/ipath/ipath_init_chip.c | 10 +++------- drivers/infiniband/hw/ipath/ipath_verbs.c | 7 ++----- 3 files changed, 8 insertions(+), 18 deletions(-)