* [PATCH] IB/ipatch: Use setup_timer and mod_timer
@ 2015-03-01 19:46 Vaishali Thakkar
2015-03-02 16:47 ` Yann Droneaud
0 siblings, 1 reply; 3+ messages in thread
From: Vaishali Thakkar @ 2015-03-01 19:46 UTC (permalink / raw)
To: Al Viro
Cc: Mike Marciniszyn, Roland Dreier, Sean Hefty, Hal Rosenstock,
linux-rdma-u79uwXL29TY76Z2rM5mHXA
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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
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_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;
}
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] IB/ipatch: Use setup_timer and mod_timer
2015-03-01 19:46 [PATCH] IB/ipatch: Use setup_timer and mod_timer Vaishali Thakkar
@ 2015-03-02 16:47 ` Yann Droneaud
[not found] ` <1425314856.3069.12.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Yann Droneaud @ 2015-03-02 16:47 UTC (permalink / raw)
To: Vaishali Thakkar
Cc: Al Viro, Mike Marciniszyn, Roland Dreier, Sean Hefty,
Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA
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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> 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.
--
Yann Droneaud
OPTEYA
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] IB/ipatch: Use setup_timer and mod_timer
[not found] ` <1425314856.3069.12.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
@ 2015-03-02 16:59 ` Vaishali Thakkar
0 siblings, 0 replies; 3+ messages in thread
From: Vaishali Thakkar @ 2015-03-02 16:59 UTC (permalink / raw)
To: Yann Droneaud
Cc: Al Viro, Mike Marciniszyn, Roland Dreier, Sean Hefty,
Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA
On Mon, Mar 2, 2015 at 10:17 PM, Yann Droneaud <ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org> 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>> 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
>
>
--
Vaishali
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-02 16:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-01 19:46 [PATCH] IB/ipatch: Use setup_timer and mod_timer Vaishali Thakkar
2015-03-02 16:47 ` Yann Droneaud
[not found] ` <1425314856.3069.12.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
2015-03-02 16:59 ` Vaishali Thakkar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox