2015-06-01 04:58:51

by Vaishali Thakkar

[permalink] [raw]
Subject: [PATCH] xen-netfront: Use setup_timer

Use the timer API function setup_timer instead of structure field
assignments to initialize a timer.

A simplified version of the Coccinelle semantic patch that performs
this transformation is as follows:

@change@
expression e, func, da;
@@

-init_timer (&e);
+setup_timer (&e, func, da);
-e.data = da;
-e.function = func;

Signed-off-by: Vaishali Thakkar <[email protected]>
---
drivers/net/xen-netfront.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 3f45afd..10a087a 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1560,9 +1560,8 @@ static int xennet_init_queue(struct netfront_queue *queue)
spin_lock_init(&queue->tx_lock);
spin_lock_init(&queue->rx_lock);

- init_timer(&queue->rx_refill_timer);
- queue->rx_refill_timer.data = (unsigned long)queue;
- queue->rx_refill_timer.function = rx_refill_timeout;
+ setup_timer(&queue->rx_refill_timer, rx_refill_timeout,
+ (unsigned long)queue);

snprintf(queue->name, sizeof(queue->name), "%s-q%u",
queue->info->netdev->name, queue->id);
--
1.9.1


2015-06-01 05:45:34

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] xen-netfront: Use setup_timer

From: Vaishali Thakkar <[email protected]>
Date: Mon, 1 Jun 2015 10:28:37 +0530

> Use the timer API function setup_timer instead of structure field
> assignments to initialize a timer.
>
> A simplified version of the Coccinelle semantic patch that performs
> this transformation is as follows:
>
> @change@
> expression e, func, da;
> @@
>
> -init_timer (&e);
> +setup_timer (&e, func, da);
> -e.data = da;
> -e.function = func;
>
> Signed-off-by: Vaishali Thakkar <[email protected]>

Applied, thanks.