Skip to content

Commit 9b13df3

Browse files
committed
timers: Rename del_timer_sync() to timer_delete_sync()
The timer related functions do not have a strict timer_ prefixed namespace which is really annoying. Rename del_timer_sync() to timer_delete_sync() and provide del_timer_sync() as a wrapper. Document that del_timer_sync() is not for new code. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Reviewed-by: Anna-Maria Behnsen <anna-maria@linutronix.de> Link: https://lore.kernel.org/r/20221123201624.954785441@linutronix.de
1 parent 168f6b6 commit 9b13df3

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

include/linux/timer.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,20 @@ extern int timer_reduce(struct timer_list *timer, unsigned long expires);
183183
extern void add_timer(struct timer_list *timer);
184184

185185
extern int try_to_del_timer_sync(struct timer_list *timer);
186-
extern int del_timer_sync(struct timer_list *timer);
186+
extern int timer_delete_sync(struct timer_list *timer);
187+
188+
/**
189+
* del_timer_sync - Delete a pending timer and wait for a running callback
190+
* @timer: The timer to be deleted
191+
*
192+
* See timer_delete_sync() for detailed explanation.
193+
*
194+
* Do not use in new code. Use timer_delete_sync() instead.
195+
*/
196+
static inline int del_timer_sync(struct timer_list *timer)
197+
{
198+
return timer_delete_sync(timer);
199+
}
187200

188201
extern void init_timers(void);
189202
struct hrtimer;

kernel/time/timer.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, unsigned int option
10831083
/*
10841084
* We are trying to schedule the timer on the new base.
10851085
* However we can't change timer's base while it is running,
1086-
* otherwise del_timer_sync() can't detect that the timer's
1086+
* otherwise timer_delete_sync() can't detect that the timer's
10871087
* handler yet has not finished. This also guarantees that the
10881088
* timer is serialized wrt itself.
10891089
*/
@@ -1261,7 +1261,7 @@ EXPORT_SYMBOL_GPL(add_timer_on);
12611261
* @timer: The timer to be deactivated
12621262
*
12631263
* The function only deactivates a pending timer, but contrary to
1264-
* del_timer_sync() it does not take into account whether the timer's
1264+
* timer_delete_sync() it does not take into account whether the timer's
12651265
* callback function is concurrently executed on a different CPU or not.
12661266
* It neither prevents rearming of the timer. If @timer can be rearmed
12671267
* concurrently then the return value of this function is meaningless.
@@ -1397,7 +1397,7 @@ static inline void del_timer_wait_running(struct timer_list *timer) { }
13971397
#endif
13981398

13991399
/**
1400-
* del_timer_sync - Deactivate a timer and wait for the handler to finish.
1400+
* timer_delete_sync - Deactivate a timer and wait for the handler to finish.
14011401
* @timer: The timer to be deactivated
14021402
*
14031403
* Synchronization rules: Callers must prevent restarting of the timer,
@@ -1419,10 +1419,10 @@ static inline void del_timer_wait_running(struct timer_list *timer) { }
14191419
* spin_lock_irq(somelock);
14201420
* <IRQ>
14211421
* spin_lock(somelock);
1422-
* del_timer_sync(mytimer);
1422+
* timer_delete_sync(mytimer);
14231423
* while (base->running_timer == mytimer);
14241424
*
1425-
* Now del_timer_sync() will never return and never release somelock.
1425+
* Now timer_delete_sync() will never return and never release somelock.
14261426
* The interrupt on the other CPU is waiting to grab somelock but it has
14271427
* interrupted the softirq that CPU0 is waiting to finish.
14281428
*
@@ -1435,7 +1435,7 @@ static inline void del_timer_wait_running(struct timer_list *timer) { }
14351435
* * %0 - The timer was not pending
14361436
* * %1 - The timer was pending and deactivated
14371437
*/
1438-
int del_timer_sync(struct timer_list *timer)
1438+
int timer_delete_sync(struct timer_list *timer)
14391439
{
14401440
int ret;
14411441

@@ -1475,7 +1475,7 @@ int del_timer_sync(struct timer_list *timer)
14751475

14761476
return ret;
14771477
}
1478-
EXPORT_SYMBOL(del_timer_sync);
1478+
EXPORT_SYMBOL(timer_delete_sync);
14791479

14801480
static void call_timer_fn(struct timer_list *timer,
14811481
void (*fn)(struct timer_list *),
@@ -1497,8 +1497,8 @@ static void call_timer_fn(struct timer_list *timer,
14971497
#endif
14981498
/*
14991499
* Couple the lock chain with the lock chain at
1500-
* del_timer_sync() by acquiring the lock_map around the fn()
1501-
* call here and in del_timer_sync().
1500+
* timer_delete_sync() by acquiring the lock_map around the fn()
1501+
* call here and in timer_delete_sync().
15021502
*/
15031503
lock_map_acquire(&lockdep_map);
15041504

0 commit comments

Comments
 (0)