From patchwork Mon Nov 16 14:37:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 7627821 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 520BF9F2EC for ; Mon, 16 Nov 2015 14:38:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88E3B20588 for ; Mon, 16 Nov 2015 14:38:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BED2520569 for ; Mon, 16 Nov 2015 14:38:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752535AbbKPOhm (ORCPT ); Mon, 16 Nov 2015 09:37:42 -0500 Received: from m50-138.163.com ([123.125.50.138]:44902 "EHLO m50-138.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752531AbbKPOhg (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=beRieMyTEwCSU1+yXU XlvlbKBASWU/rbzhvC2jHX/oo=; b=lCNBj1B+Kj5MyAnyVg0AYrVo665sFDsuM+ hB2f36zwpphDdHdTk7v4YonH9/MiUJu2ou1JyxLoL8BG9OfYHvr65Ak5cJVJsgsI qn2Wtx5DIwVfDm3lLEaVxWX3GGhq0wALarnH4wDUYP+CWfyQIFpafgqdMFst3xY4 HmCYnlIeU= Received: from localhost (unknown [116.77.138.167]) by smtp1 (Coremail) with SMTP id C9GowACHNEYg6klWGZuuAA--.421S3; Mon, 16 Nov 2015 22:37:22 +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 2/2] crypto: mcryptd - use list_first_entry_or_null() Date: Mon, 16 Nov 2015 22:37:15 +0800 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: <1c77a1fba395b9f7fa6fae64f639b98a5662735e.1447684469.git.geliangtang@163.com> References: <1c77a1fba395b9f7fa6fae64f639b98a5662735e.1447684469.git.geliangtang@163.com> In-Reply-To: <1c77a1fba395b9f7fa6fae64f639b98a5662735e.1447684469.git.geliangtang@163.com> References: <1c77a1fba395b9f7fa6fae64f639b98a5662735e.1447684469.git.geliangtang@163.com> X-CM-TRANSID: C9GowACHNEYg6klWGZuuAA--.421S3 X-Coremail-Antispam: 1Uf129KBjvdXoWruF43Ary8ZFWxtF4fJr1rCrg_yoWfZrX_Ga yvqrWrWw4UJw4kWrs5C3yft3s5uw4rZryfWr4xtFyUK3W3uFs8WFy3Xa9xGryxur4fWrZ5 Wr4DXFyrur1UXjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUUdOz3UUUUU== X-Originating-IP: [116.77.138.167] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiMAK0mVWBSfCA5gAAsU 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 mcryptd_opportunistic_flush() with list_first_entry_or_null(). Signed-off-by: Geliang Tang --- crypto/mcryptd.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/crypto/mcryptd.c b/crypto/mcryptd.c index fe5b495a..f78d4fc 100644 --- a/crypto/mcryptd.c +++ b/crypto/mcryptd.c @@ -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; }