timer: Split out timer function call

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Wednesday, May 19, 2010 - 5:59 pm

Gitweb:     http://git.kernel.org/linus/576da126a6c7364d70dfd58d0bbe43d05cf5859f
Commit:     576da126a6c7364d70dfd58d0bbe43d05cf5859f
Parent:     06f71b922ce5a05352acd706564ca4ae1f2add0e
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Fri Mar 12 21:10:29 2010 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri Mar 12 22:40:43 2010 +0100

    timer: Split out timer function call
    
    The ident level is starting to be annoying. More white space than
    actual code. Split out the timer function call into its own function.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/timer.c |   72 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/kernel/timer.c b/kernel/timer.c
index f82f4bf..4522969 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -953,6 +953,41 @@ static int cascade(struct tvec_base *base, struct tvec *tv, int index)
 	return index;
 }
 
+static void call_timer_fn(struct timer_list *timer, void (*fn)(unsigned long),
+			  unsigned long data)
+{
+	int preempt_count = preempt_count();
+
+#ifdef CONFIG_LOCKDEP
+	/*
+	 * It is permissible to free the timer from inside the
+	 * function that is called from it, this we need to take into
+	 * account for lockdep too. To avoid bogus "held lock freed"
+	 * warnings as well as problems when looking into
+	 * timer->lockdep_map, make a copy and use that here.
+	 */
+	struct lockdep_map lockdep_map = timer->lockdep_map;
+#endif
+	/*
+	 * Couple the lock chain with the lock chain at
+	 * del_timer_sync() by acquiring the lock_map around the fn()
+	 * call here and in del_timer_sync().
+	 */
+	lock_map_acquire(&lockdep_map);
+
+	trace_timer_expire_entry(timer);
+	fn(data);
+	trace_timer_expire_exit(timer);
+
+	lock_map_release(&lockdep_map);
+
+	if (preempt_count != preempt_count()) {
+		printk(KERN_ERR "timer: %pF preempt leak: %08x -> %08x\n",
+		       fn, preempt_count, preempt_count());
+		BUG();
+	}
+}
+
 #define INDEX(N) ((base->timer_jiffies >> (TVR_BITS + (N) * TVN_BITS)) & TVN_MASK)
 
 /**
@@ -996,42 +1031,7 @@ static inline void __run_timers(struct tvec_base *base)
 			detach_timer(timer, 1);
 
 			spin_unlock_irq(&base->lock);
-			{
-				int preempt_count = preempt_count();
-
-#ifdef CONFIG_LOCKDEP
-				/*
-				 * It is permissible to free the timer from
-				 * inside the function that is called from
-				 * it, this we need to take into account for
-				 * lockdep too. To avoid bogus "held lock
-				 * freed" warnings as well as problems when
-				 * looking into timer->lockdep_map, make a
-				 * copy and use that here.
-				 */
-				struct lockdep_map lockdep_map =
-					timer->lockdep_map;
-#endif
-				/*
-				 * Couple the lock chain with the lock chain at
-				 * del_timer_sync() by acquiring the lock_map
-				 * around the fn() call here and in
-				 * del_timer_sync().
-				 */
-				lock_map_acquire(&lockdep_map);
-
-				trace_timer_expire_entry(timer);
-				fn(data);
-				trace_timer_expire_exit(timer);
-
-				lock_map_release(&lockdep_map);
-
-				if (preempt_count != preempt_count()) {
-					printk(KERN_ERR "timer: %pF preempt leak: %08x -> %08x\n",
-					       fn, preempt_count, preempt_count());
-					BUG();
-				}
-			}
+			call_timer_fn(timer, fn, data);
 			spin_lock_irq(&base->lock);
 		}
 	}
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
timer: Split out timer function call, Linux Kernel Mailing ..., (Wed May 19, 5:59 pm)