Skip to contentSkip to conversation

Drivers: block: Use setup_timer

PATCH New Vaishali Thakkar 1 participant 1 message Jun 11, 2015 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Drivers: block: 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 e1, e2, a;
@@

-init_timer(&e1);
+setup_timer(&e1, a, 0UL);
... when != a = e2
-e1.function = a;

---
 drivers/block/umem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/umem.c +1 -2
index 4cf81b5..cd999a1 100644
@@ -738,8 +738,7 @@ static void check_all_batteries(unsigned long ptr)
 
 static void init_battery_timer(void)
 {
-	init_timer(&battery_timer);
-	battery_timer.function = check_all_batteries;
+	setup_timer(&battery_timer, check_all_batteries, 0UL);
 	battery_timer.expires = jiffies + (HZ * 60);
 	add_timer(&battery_timer);
 }
Signature · 1 line
1.9.1