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

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

index 59bf491fe3d8606acc4016c53182182615d32a21..7be76aa315796dfad085ad74be5da35204bda9e6 100644 (file)
@@ -93,16 +93,15 @@ static struct list_head *crypto_more_spawns(struct crypto_alg *alg,
 {
        struct crypto_spawn *spawn, *n;
 
-       if (list_empty(stack))
+       spawn = list_first_entry_or_null(stack, struct crypto_spawn, list);
+       if (!spawn)
                return NULL;
 
-       spawn = list_first_entry(stack, struct crypto_spawn, list);
-       n = list_entry(spawn->list.next, struct crypto_spawn, list);
+       n = list_next_entry(spawn, list);
 
        if (spawn->alg && &n->list != stack && !n->alg)
                n->alg = (n->list.next == stack) ? alg :
-                        &list_entry(n->list.next, struct crypto_spawn,
-                                    list)->inst->alg;
+                        &list_next_entry(n, list)->inst->alg;
 
        list_move(&spawn->list, secondary_spawns);