From patchwork Tue Sep 5 12:38:56 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: 111684 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp2786282qge; Tue, 5 Sep 2017 05:43:35 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5WpM7spPKjjisL/zxP1qDe4JsC4eb3DhMeUJiEfc3wSSP7GdGZQAKnpJIIeAhu/C/PXaYD X-Received: by 10.84.131.100 with SMTP id 91mr4173742pld.247.1504615415737; Tue, 05 Sep 2017 05:43:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504615415; cv=none; d=google.com; s=arc-20160816; b=z/BVCv+Piko8bvnjx0DC18/szJjHu+Tg4AbiCQLO+BfSozWdRkz75qbtOE4N1s6gQ+ boCghRbflCYcWjsVey/JN6biTmUuI10U7HG0F57i3wKT4PZJVEZy0RcpD2ioTnQIJWdZ 3EM7Ckr5QkYpj1pHN9AZxcHGeE/FAOv/UBCt5DNlglNdKmyQglNGUILljzsqzwz9ADUD 4aV6ddPgNO/SKIMQuEpkGDTDNoZnvQ5MIM3Ul1c3fee9dlCL9pIDtuWL9+f0EKIQf6kY My2SdiYkT5VW9f8yXIdTlm+MViLgFOg2E4fvqMnGWAcjAbZBxka5BsWgQyqFX3M8hOFw 8/Fw== 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=j0NbDfkd4meCZQWpDXufl1Y1pw2jCvvo6+pNCMAZIZM=; b=bCcHoogjeEATYObfESnrz1iO4anMR4g7FARGt6bNGqEge1lDBxWYD8DFiTfSYHihx/ E1ayOVpaMcJZV5AZfehbsRzpDLbsPOTDlAfOrjrw/ONojsus6137XNFIVNp+NJdjomF9 kGDCTotyrF7LVsPWxIseZeuMIdZ7nW39hHMhR7k7lyq1KGD2wnmJ0kfobuRha6gj2bAn x1Rtt/ypQlHBWwrMEipnae5N7NL4JnuNT7pKRYPoLKBXLIWjZim6gNhGNa/iE7bAsSXt b9RmPm+VGAxcWl1WxUR6EsGQd25bA6vEM3tdTSSUEZoup1w47OLK4FhYokjwv0pNyTRM lORA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 m13si244475pfh.377.2017.09.05.05.43.35; Tue, 05 Sep 2017 05:43:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750731AbdIEMnd (ORCPT + 1 other); Tue, 5 Sep 2017 08:43:33 -0400 Received: from foss.arm.com ([217.140.101.70]:39866 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752182AbdIEMna (ORCPT ); Tue, 5 Sep 2017 08:43:30 -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 52B27165D; Tue, 5 Sep 2017 05:43:29 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.140]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 97D1F3F3E1; Tue, 5 Sep 2017 05:43:17 -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, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Steffen Klassert , Alexey Kuznetsov , Hideaki YOSHIFUJI , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , 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-raid@vger.kernel.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 Cc: Ofir Drang Subject: [PATCH v8 17/20] crypto: talitos: move to generic async completion Date: Tue, 5 Sep 2017 15:38:56 +0300 Message-Id: <1504615144-29770-18-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504615144-29770-1-git-send-email-gilad@benyossef.com> References: <1504615144-29770-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@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 --- drivers/crypto/talitos.c | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) -- 2.1.4 diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 79791c6..194a307 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -2037,22 +2037,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) { @@ -2060,10 +2044,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) @@ -2072,25 +2056,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;