Skip to content

Commit 304e481

Browse files
geliangtangherbertx
authored andcommitted
crypto: api - use list_first_entry_or_null and list_next_entry
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>
1 parent 4f9ea86 commit 304e481

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎crypto/algapi.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,15 @@ static struct list_head *crypto_more_spawns(struct crypto_alg *alg,
9393
{
9494
struct crypto_spawn *spawn, *n;
9595

96-
if (list_empty(stack))
96+
spawn = list_first_entry_or_null(stack, struct crypto_spawn, list);
97+
if (!spawn)
9798
return NULL;
9899

99-
spawn = list_first_entry(stack, struct crypto_spawn, list);
100-
n = list_entry(spawn->list.next, struct crypto_spawn, list);
100+
n = list_next_entry(spawn, list);
101101

102102
if (spawn->alg && &n->list != stack && !n->alg)
103103
n->alg = (n->list.next == stack) ? alg :
104-
&list_entry(n->list.next, struct crypto_spawn,
105-
list)->inst->alg;
104+
&list_next_entry(n, list)->inst->alg;
106105

107106
list_move(&spawn->list, secondary_spawns);
108107

0 commit comments

Comments
 (0)