[Devel] [PATCH 03/12] drop_monitor: use setup_timer

Alexander Mikhalitsyn alexander.mikhalitsyn at virtuozzo.com
Mon Jul 4 21:51:53 MSK 2022


From: Geliang Tang <geliangtang at gmail.com>

Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang <geliangtang at gmail.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
(cherry picked from commit 27303fcf5734d84c8d018b79d1db154ceaf88df8)

Combined with (partially):
e99e88a9d ("treewide: setup_timer() -> timer_setup()")
---
 net/core/drop_monitor.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 639b8692209e..7633d754e989 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -144,9 +144,9 @@ static void send_dm_alert(struct work_struct *work)
  * in the event that more drops will arrive during the
  * hysteresis period.
  */
-static void sched_send_work(unsigned long _data)
+static void sched_send_work(struct timer_list *t)
 {
-	struct per_cpu_dm_data *data = (struct per_cpu_dm_data *)_data;
+	struct per_cpu_dm_data *data = from_timer(data, t, send_timer);
 
 	schedule_work(&data->dm_alert_work);
 }
@@ -413,9 +413,7 @@ static int __init init_net_drop_monitor(void)
 	for_each_possible_cpu(cpu) {
 		data = &per_cpu(dm_cpu_data, cpu);
 		INIT_WORK(&data->dm_alert_work, send_dm_alert);
-		init_timer(&data->send_timer);
-		data->send_timer.data = (unsigned long)data;
-		data->send_timer.function = sched_send_work;
+		timer_setup(&data->send_timer, sched_send_work, 0);
 		spin_lock_init(&data->lock);
 		reset_per_cpu_data(data);
 	}
-- 
2.36.1



More information about the Devel mailing list