From patchwork Wed Nov 29 08:41:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 10081593 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DDFD260353 for ; Wed, 29 Nov 2017 08:44:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCE1A295D6 for ; Wed, 29 Nov 2017 08:44:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1396296E7; Wed, 29 Nov 2017 08:44:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74175295D6 for ; Wed, 29 Nov 2017 08:44:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753676AbdK2In7 (ORCPT ); Wed, 29 Nov 2017 03:43:59 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:36733 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753686AbdK2Inv (ORCPT ); Wed, 29 Nov 2017 03:43:51 -0500 Received: by mail-wr0-f194.google.com with SMTP id v105so2622497wrc.3; Wed, 29 Nov 2017 00:43:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MrdKqTiQmuOfevQVvtq82E9mHKdrHfboMevxIkOPurM=; b=t/RmWAqt4SXnR+XJwOrg0m8gXDnVBz7usPT6rxYTXrx2OqsLSr8AJxiYX+cZx07H6+ gqGD59xUeG4WcbQ72x3MMqoIKV4lL2IwXjFsmOnro/bo2kb4bZ4I1Dptb9bS7I0vA/oG 3ZNBkT/q6IHHafPMC051rJJ7WMX0zArM6/WmEDUl+7RYwN7FZr6o35b48S7mSmkq1EjO VUrn8Bd95qyzQj+NNiWIMMCRMcNQFEOXzSQl+atnM0mCAYjHu+uRV5mOvwMizv+E4Vjr 6n8L3SMWKNpq8xFq3selfjOOdO1N0xn4ZW8O6ONVeLu4NwWF/MF9xCoV0nS3Ja+QDu7C dMWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MrdKqTiQmuOfevQVvtq82E9mHKdrHfboMevxIkOPurM=; b=Qvzwnj2j7l8L8i6Oq0a8vuClQHW71UmK+1gcps3wWaohglCDCCsqe2ip9Re+weMooT UiX07bO0pzihzc5JpsBXQigTj9PRFcCyE950rDoN6/FLjnVYwXv/ux75m1p19Ha2ey9z Emku1ZiENUVJxlZobbRw4UkMJfXmTN3J0mVIXgMP6ugE4u+xGcgFFaYlQwY8SWNgoJrO ywsqRm1pQCEG5udy5jGvpMfQi3WW1Ed/qe34DGfJACogh7lMI02rZfRqaqZ51kU9fAPG ItQwjzNEbpneFYKYKMSYDyJdoOe3YjlM6GY0UPit7uUYGoMxhV+wg+Jd+3YMzWUXmOyN f1Qg== X-Gm-Message-State: AJaThX7h/VNOIl+3FBEjrFCKtLEtjEKkHIzLb4tW4aKuY/OCXROmoFpM GVy7tGZairiT9WuLki6sijU= X-Google-Smtp-Source: AGs4zMblxlW7EzOXbcf77RQTuKLoLm03YctJt9X18S6f+03bylzBCoDsFMFFLq62K9oWjqu7WRHMww== X-Received: by 10.223.172.115 with SMTP id v106mr1755174wrc.195.1511945030522; Wed, 29 Nov 2017 00:43:50 -0800 (PST) Received: from Red.local (LFbn-MAR-1-580-204.w90-118.abo.wanadoo.fr. [90.118.159.204]) by smtp.googlemail.com with ESMTPSA id 19sm1947398wmv.41.2017.11.29.00.43.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 00:43:49 -0800 (PST) From: Corentin Labbe To: herbert@gondor.apana.org.au, alexandre.torgue@st.com, arei.gonglei@huawei.com, davem@davemloft.net, jasowang@redhat.com, mcoquelin.stm32@gmail.com, mst@redhat.com, fabien.dessenne@st.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Corentin Labbe Subject: [PATCH RFC 4/4] crypto: stm32: convert to the new crypto engine API Date: Wed, 29 Nov 2017 09:41:21 +0100 Message-Id: <20171129084121.9385-5-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171129084121.9385-1-clabbe.montjoie@gmail.com> References: <20171129084121.9385-1-clabbe.montjoie@gmail.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch convert the driver to the new crypto engine API. Signed-off-by: Corentin Labbe Tested-by: Fabien Dessenne --- drivers/crypto/stm32/stm32-hash.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c index 4ca4a264a833..e3f9f7b04ce2 100644 --- a/drivers/crypto/stm32/stm32-hash.c +++ b/drivers/crypto/stm32/stm32-hash.c @@ -122,6 +122,7 @@ enum stm32_hash_data_format { #define HASH_DMA_THRESHOLD 50 struct stm32_hash_ctx { + struct crypto_engine_reqctx enginectx; struct stm32_hash_dev *hdev; unsigned long flags; @@ -811,7 +812,7 @@ static void stm32_hash_finish_req(struct ahash_request *req, int err) rctx->flags |= HASH_FLAGS_ERRORS; } - crypto_finalize_hash_request(hdev->engine, req, err); + crypto_finalize_request(hdev->engine, &req->base, err); } static int stm32_hash_hw_init(struct stm32_hash_dev *hdev, @@ -828,15 +829,21 @@ static int stm32_hash_hw_init(struct stm32_hash_dev *hdev, return 0; } +static int stm32_hash_one_request(struct crypto_engine *engine, + struct crypto_async_request *areq); +static int stm32_hash_prepare_req(struct crypto_engine *engine, + struct crypto_async_request *areq); + static int stm32_hash_handle_queue(struct stm32_hash_dev *hdev, struct ahash_request *req) { - return crypto_transfer_hash_request_to_engine(hdev->engine, req); + return crypto_transfer_request_to_engine(hdev->engine, &req->base); } static int stm32_hash_prepare_req(struct crypto_engine *engine, - struct ahash_request *req) + struct crypto_async_request *areq) { + struct ahash_request *req = ahash_request_cast(areq); struct stm32_hash_ctx *ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req)); struct stm32_hash_dev *hdev = stm32_hash_find_dev(ctx); struct stm32_hash_request_ctx *rctx; @@ -855,8 +862,9 @@ static int stm32_hash_prepare_req(struct crypto_engine *engine, } static int stm32_hash_one_request(struct crypto_engine *engine, - struct ahash_request *req) + struct crypto_async_request *areq) { + struct ahash_request *req = ahash_request_cast(areq); struct stm32_hash_ctx *ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req)); struct stm32_hash_dev *hdev = stm32_hash_find_dev(ctx); struct stm32_hash_request_ctx *rctx; @@ -1033,6 +1041,9 @@ static int stm32_hash_cra_init_algs(struct crypto_tfm *tfm, if (algs_hmac_name) ctx->flags |= HASH_FLAGS_HMAC; + ctx->enginectx.op.do_one_request = stm32_hash_one_request; + ctx->enginectx.op.prepare_request = stm32_hash_prepare_req; + ctx->enginectx.op.unprepare_request = NULL; return 0; } @@ -1493,9 +1504,6 @@ static int stm32_hash_probe(struct platform_device *pdev) goto err_engine; } - hdev->engine->prepare_hash_request = stm32_hash_prepare_req; - hdev->engine->hash_one_request = stm32_hash_one_request; - ret = crypto_engine_start(hdev->engine); if (ret) goto err_engine_start;