diff mbox

[1/2] crypto: api - use list_first_entry_or_null and list_next_entry

Message ID 1c77a1fba395b9f7fa6fae64f639b98a5662735e.1447684469.git.geliangtang@163.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Geliang Tang Nov. 16, 2015, 2:37 p.m. UTC
Simplify crypto_more_spawns() with list_first_entry_or_null()
and list_next_entry().

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 crypto/algapi.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Herbert Xu Nov. 23, 2015, 1:01 p.m. UTC | #1
On Mon, Nov 16, 2015 at 10:37:14PM +0800, Geliang Tang wrote:
> Simplify crypto_more_spawns() with list_first_entry_or_null()
> and list_next_entry().
> 
> Signed-off-by: Geliang Tang <geliangtang@163.com>

Patch applied.  Thanks.
diff mbox

Patch

diff --git a/crypto/algapi.c b/crypto/algapi.c
index 59bf491..7be76aa 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -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);