async: simplify lowest_in_progress()
authorLai Jiangshan <laijs@cn.fujitsu.com>
Tue, 12 Mar 2013 20:59:13 +0000 (13:59 -0700)
committerTejun Heo <tj@kernel.org>
Tue, 12 Mar 2013 20:59:13 +0000 (13:59 -0700)
The code in lowest_in_progress() are duplicated in two branches,
simplify them.

tj: Minor indentation adjustment.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
kernel/async.c

index 8ddee2c3e5b04ac290f0d923fd21c60d2f85ffd2..ab99c92f6b6872774d191470ded3da759a9793f4 100644 (file)
@@ -84,24 +84,20 @@ static atomic_t entry_count;
 
 static async_cookie_t lowest_in_progress(struct async_domain *domain)
 {
-       struct async_entry *first = NULL;
+       struct list_head *pending;
        async_cookie_t ret = ASYNC_COOKIE_MAX;
        unsigned long flags;
 
        spin_lock_irqsave(&async_lock, flags);
 
-       if (domain) {
-               if (!list_empty(&domain->pending))
-                       first = list_first_entry(&domain->pending,
-                                       struct async_entry, domain_list);
-       } else {
-               if (!list_empty(&async_global_pending))
-                       first = list_first_entry(&async_global_pending,
-                                       struct async_entry, global_list);
-       }
+       if (domain)
+               pending = &domain->pending;
+       else
+               pending = &async_global_pending;
 
-       if (first)
-               ret = first->cookie;
+       if (!list_empty(pending))
+               ret = list_first_entry(pending, struct async_entry,
+                                      domain_list)->cookie;
 
        spin_unlock_irqrestore(&async_lock, flags);
        return ret;