From patchwork Wed Oct 18 07:00:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 116228 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp5746052qgn; Wed, 18 Oct 2017 00:06:08 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QnNRKHwcu8yU99oWB3Xr94gUPmwEw+L7XC5tYDhQFHZlnDP39ownZqkkd93AaqjhkJ1vej X-Received: by 10.84.128.99 with SMTP id 90mr4104976pla.171.1508310368663; Wed, 18 Oct 2017 00:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508310368; cv=none; d=google.com; s=arc-20160816; b=rzddeBCX7mJXnQXlC88mQWDjssgY0NDtHxaNawNrE5XsmdSUQ7Sl17fnrypjKZxjWf 9iVfkdqk7jfCePF/3CH5lZ57SULzevbW26gFM5KVy4Rq2dKDn+cIyn4B/wWNSIyydYkX CCRtSSOlgcW+/pR7Pr1BJGFsONX9A3X9zhlrPP59y+V1uYp6ONjFaR6SH5g54npKdRsU yexrT9HFqu+F5Zb11BS3t0O1PnWwALqq7IAH93Ct2gL3GgF4Q9HiDQKcahKw6eYquq2m 17fvAQjkhhLFuGIl93qJBmBimOD9RjFKCcBC7ZzvWVEaARt9OLTxOvKD+nooxEuFzS// u+cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=zcf4eRoEQo+FSDjzYup4ElRpo5mz7aTje8xWHWO8fIQ=; b=X36yySM2I29jJq0I+GY0jdwuj75ndcPyjg/EUtHcCDKn4eRD1eQg+DCU5R20GAgHEA ICsg7jXpGkhv4+eER8iIB6xGCWTTBAvztgwU7SdwUHB3wxucpyx/ixp1RA977R05soKZ WSh52SU7Ogh5mB3pzlKYiREelj3sRdlcQ9V/EX/6pBow9R9IcAxopMK5U1t2d8i7GlA0 bqhu8mFddKOlVSG9AoG2TXuPs2H37zt+ZYXkiKrlwPf+bX2yAG8CDCZwJzRSHVHdk5Qw hhYFP7LGvf8cQHGQ5r+l8ZGPadnzxmnAUqW0slrftMswi8NdjOBBAMSeyvtP0hOGDklR pecg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w24si6576163pge.245.2017.10.18.00.06.08; Wed, 18 Oct 2017 00:06:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966852AbdJRHGG (ORCPT + 27 others); Wed, 18 Oct 2017 03:06:06 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:34114 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761369AbdJRHGB (ORCPT ); Wed, 18 Oct 2017 03:06:01 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B726BF; Wed, 18 Oct 2017 00:06:00 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 713593F590; Wed, 18 Oct 2017 00:05:52 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Steffen Klassert , Alexey Kuznetsov , Hideaki YOSHIFUJI , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" Cc: Ofir Drang , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, netdev@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Subject: [PATCH v10 17/20] crypto: talitos: move to generic async completion Date: Wed, 18 Oct 2017 08:00:49 +0100 Message-Id: <1508310057-25369-18-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508310057-25369-1-git-send-email-gilad@benyossef.com> References: <1508310057-25369-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The talitos driver starts several async crypto ops and waits for their completions. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef Tested-by: Christophe Leroy --- drivers/crypto/talitos.c | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) -- 2.7.4 diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 5bd8191..9c80e0c 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -2160,22 +2160,6 @@ static int ahash_import(struct ahash_request *areq, const void *in) return 0; } -struct keyhash_result { - struct completion completion; - int err; -}; - -static void keyhash_complete(struct crypto_async_request *req, int err) -{ - struct keyhash_result *res = req->data; - - if (err == -EINPROGRESS) - return; - - res->err = err; - complete(&res->completion); -} - static int keyhash(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen, u8 *hash) { @@ -2183,10 +2167,10 @@ static int keyhash(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen, struct scatterlist sg[1]; struct ahash_request *req; - struct keyhash_result hresult; + struct crypto_wait wait; int ret; - init_completion(&hresult.completion); + crypto_init_wait(&wait); req = ahash_request_alloc(tfm, GFP_KERNEL); if (!req) @@ -2195,25 +2179,13 @@ static int keyhash(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen, /* Keep tfm keylen == 0 during hash of the long key */ ctx->keylen = 0; ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - keyhash_complete, &hresult); + crypto_req_done, &wait); sg_init_one(&sg[0], key, keylen); ahash_request_set_crypt(req, sg, hash, keylen); - ret = crypto_ahash_digest(req); - switch (ret) { - case 0: - break; - case -EINPROGRESS: - case -EBUSY: - ret = wait_for_completion_interruptible( - &hresult.completion); - if (!ret) - ret = hresult.err; - break; - default: - break; - } + ret = crypto_wait_req(crypto_ahash_digest(req), &wait); + ahash_request_free(req); return ret;