crypto: mcryptd - use list_first_entry_or_null()
authorGeliang Tang <geliangtang@163.com>
Mon, 16 Nov 2015 14:37:15 +0000 (22:37 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 23 Nov 2015 12:55:51 +0000 (20:55 +0800)
Simplify mcryptd_opportunistic_flush() with list_first_entry_or_null().

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/mcryptd.c

index fe5b495a434d3c1d5efc2e5b211c7d3863078726..f78d4fc4e38a3fb842463229b3fa013d7c0a903c 100644 (file)
@@ -128,13 +128,9 @@ static void mcryptd_opportunistic_flush(void)
        flist = per_cpu_ptr(mcryptd_flist, smp_processor_id());
        while (single_task_running()) {
                mutex_lock(&flist->lock);
-               if (list_empty(&flist->list)) {
-                       mutex_unlock(&flist->lock);
-                       return;
-               }
-               cstate = list_entry(flist->list.next,
+               cstate = list_first_entry_or_null(&flist->list,
                                struct mcryptd_alg_cstate, flush_list);
-               if (!cstate->flusher_engaged) {
+               if (!cstate || !cstate->flusher_engaged) {
                        mutex_unlock(&flist->lock);
                        return;
                }