linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] greybus: timesync: replace init_timer with setup_timer
@ 2016-12-13 14:39 Xie Qirong
  2017-01-02  9:54 ` Johan Hovold
  0 siblings, 1 reply; 2+ messages in thread
From: Xie Qirong @ 2016-12-13 14:39 UTC (permalink / raw)
  To: Bryan O'Donoghue
  Cc: Johan Hovold, Alex Elder, Greg Kroah-Hartman, devel,
	linux-kernel, Bryan O'Donoghue, Xie Qirong

The combination of init_timer and setting up the data and function field
manually is equivalent to calling setup_timer(). This is an api 
consolidation only and improves readability.

Signed-off-by: Xie Qirong <xieqr16@lzu.edu.cn>
---

 setup_timer.cocci suggested the following improvement:
 drivers/staging/greybus/timesync.c:1058:1-11: Use setup_timer function 
 for function on line 1059.

 Patch was compile checked with: x86_64_defconfig + CONFIG_STAGING=y, 
 CONFIG_GREYBUS=m

 Kernel version: 4.9.0 (localversion-next is next-20161213)

 drivers/staging/greybus/timesync.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/greybus/timesync.c b/drivers/staging/greybus/timesync.c
index 29e6c1c..af83e12 100644
--- a/drivers/staging/greybus/timesync.c
+++ b/drivers/staging/greybus/timesync.c
@@ -1055,10 +1055,9 @@ int gb_timesync_svc_add(struct gb_svc *svc)
 		goto done;
 	}
 
-	init_timer(&timesync_svc->ktime_timer);
-	timesync_svc->ktime_timer.function = gb_timesync_ktime_timer_fn;
+	setup_timer(&timesync_svc->ktime_timer, gb_timesync_ktime_timer_fn,
+		(unsigned long)timesync_svc);
 	timesync_svc->ktime_timer.expires = jiffies + GB_TIMESYNC_KTIME_UPDATE;
-	timesync_svc->ktime_timer.data = (unsigned long)timesync_svc;
 	add_timer(&timesync_svc->ktime_timer);
 done:
 	mutex_unlock(&gb_timesync_svc_list_mutex);
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] greybus: timesync: replace init_timer with setup_timer
  2016-12-13 14:39 [PATCH] greybus: timesync: replace init_timer with setup_timer Xie Qirong
@ 2017-01-02  9:54 ` Johan Hovold
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2017-01-02  9:54 UTC (permalink / raw)
  To: Xie Qirong
  Cc: Bryan O'Donoghue, Johan Hovold, Alex Elder,
	Greg Kroah-Hartman, devel, linux-kernel, Bryan O'Donoghue

On Tue, Dec 13, 2016 at 10:39:57PM +0800, Xie Qirong wrote:
> The combination of init_timer and setting up the data and function field
> manually is equivalent to calling setup_timer(). This is an api 
> consolidation only and improves readability.
> 
> Signed-off-by: Xie Qirong <xieqr16@lzu.edu.cn>
> ---
> 
>  setup_timer.cocci suggested the following improvement:
>  drivers/staging/greybus/timesync.c:1058:1-11: Use setup_timer function 
>  for function on line 1059.
> 
>  Patch was compile checked with: x86_64_defconfig + CONFIG_STAGING=y, 
>  CONFIG_GREYBUS=m
> 
>  Kernel version: 4.9.0 (localversion-next is next-20161213)
> 
>  drivers/staging/greybus/timesync.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/greybus/timesync.c b/drivers/staging/greybus/timesync.c
> index 29e6c1c..af83e12 100644
> --- a/drivers/staging/greybus/timesync.c
> +++ b/drivers/staging/greybus/timesync.c
> @@ -1055,10 +1055,9 @@ int gb_timesync_svc_add(struct gb_svc *svc)
>  		goto done;
>  	}
>  
> -	init_timer(&timesync_svc->ktime_timer);
> -	timesync_svc->ktime_timer.function = gb_timesync_ktime_timer_fn;
> +	setup_timer(&timesync_svc->ktime_timer, gb_timesync_ktime_timer_fn,
> +		(unsigned long)timesync_svc);

Please make sure to align the continuation line to the open parenthesis
(which is the style followed in this file).

>  	timesync_svc->ktime_timer.expires = jiffies + GB_TIMESYNC_KTIME_UPDATE;
> -	timesync_svc->ktime_timer.data = (unsigned long)timesync_svc;
>  	add_timer(&timesync_svc->ktime_timer);
>  done:
>  	mutex_unlock(&gb_timesync_svc_list_mutex);

When resending you can add my

Reviewed-by: Johan Hovold <johan@kernel.org>

Thanks,
Johan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-02  9:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-13 14:39 [PATCH] greybus: timesync: replace init_timer with setup_timer Xie Qirong
2017-01-02  9:54 ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).