From patchwork Mon Nov 16 14:37:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 7627871 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0C9B6BF90C for ; Mon, 16 Nov 2015 14:38:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 339EF20569 for ; Mon, 16 Nov 2015 14:38:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 18A3D205C4 for ; Mon, 16 Nov 2015 14:38:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752516AbbKPOit (ORCPT ); Mon, 16 Nov 2015 09:38:49 -0500 Received: from m50-133.163.com ([123.125.50.133]:36882 "EHLO m50-133.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752688AbbKPOhg (ORCPT ); Mon, 16 Nov 2015 09:37:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=CkB1nOy1zOeMft1RlO axP7EWdZtATiBFNO/HLljuOrU=; b=GeA4Ja8g0s0Hd26BKtl08PolJKNw29ZxxC lSUCOMOTuYnsa6j50x/dRDk5ATVcNqHWYDR6S21u4R5N4csSVIIbb8Vt/lFr4Ff6 y7yA7EBHwUOkEZFnbc+KJVVuT16iIYEjNo/0BUjPJtZB8oZF2rVj8KlrXFm028Ha PibSnAWQE= Received: from localhost (unknown [116.77.138.167]) by smtp3 (Coremail) with SMTP id DdGowEApol0c6klWROcAAA--.46S3; Mon, 16 Nov 2015 22:37:18 +0800 (CST) From: Geliang Tang To: Herbert Xu , "David S. Miller" Cc: Geliang Tang , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] crypto: api - use list_first_entry_or_null and list_next_entry Date: Mon, 16 Nov 2015 22:37:14 +0800 Message-Id: <1c77a1fba395b9f7fa6fae64f639b98a5662735e.1447684469.git.geliangtang@163.com> X-Mailer: git-send-email 2.5.0 X-CM-TRANSID: DdGowEApol0c6klWROcAAA--.46S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Jr4DuF18Kw4xCw43Zr1UWrg_yoWDtrg_Aa yIgrnYkr4j9F4fuw47GFWkWFy3WrZ3JFyDWw4IyryrJ3W3Gr45KF9Iqw17Jr9ru34rZFW5 Ca1kXr1xur1UXjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUjmhFDUUUUU== X-Originating-IP: [116.77.138.167] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/xtbByh+0mVO+f7hXQAAAsF Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Simplify crypto_more_spawns() with list_first_entry_or_null() and list_next_entry(). Signed-off-by: Geliang Tang --- crypto/algapi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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);