diff mbox

[2/2] crypto: mcryptd - use list_first_entry_or_null()

Message ID d6b0e641f72c3f72a759a7266dd103dcd0b19886.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 mcryptd_opportunistic_flush() with list_first_entry_or_null().

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 crypto/mcryptd.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

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

Patch applied.  Thanks.
diff mbox

Patch

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;
 		}