From patchwork Fri Jan 26 19:15:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 10186875 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 E2961601D5 for ; Fri, 26 Jan 2018 19:19:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D308B29679 for ; Fri, 26 Jan 2018 19:19:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C74B7297ED; Fri, 26 Jan 2018 19:19:00 +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 77BE729679 for ; Fri, 26 Jan 2018 19:19:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752984AbeAZTSo (ORCPT ); Fri, 26 Jan 2018 14:18:44 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:45205 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751971AbeAZTSP (ORCPT ); Fri, 26 Jan 2018 14:18:15 -0500 Received: by mail-wr0-f196.google.com with SMTP id 16so1387692wry.12; Fri, 26 Jan 2018 11:18:14 -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=g8IfwhVYNUEUgKu85ioBXaFL9OKO9rWTugBCJeqpULU=; b=nswL9MroZZP0DFWZFFITp0rrNf9+Uwi01z4Tdi4OxstzjBrWFBfvQp/lZkqlYe1rNG /MJGhUoxFSYkLK7H5/2Cn0D37KCVhwW3JkZhipRJ0yFJ5GwupUy0TfLqZII3lrkot3bO 9vwCbI6uQLmWX0dU0qiAmKBqVnO/HFivil0pM5dr3mnF44rcYy7U8W6XCBWw5btIbgdV +c1Wb1+eqgB395hG8tvQAkIjtMiVYYnha3z6VuvlaR71u0V8Lrrx+c1IHNwG2buF5/cR XlpX4gfSRtb5ZVJwTBjNj6nPRLC3prAQlW7DVzSZSaZsRLJW73v0ArLxbBAfWhpcXd39 xUtg== 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=g8IfwhVYNUEUgKu85ioBXaFL9OKO9rWTugBCJeqpULU=; b=YPkZ7iREgXIRJQzs5taUKmR0ZjfoqdcRe6ex2GD70+jG6QZJefDbk0NV+dUZlyNNeH DjTlzx7DAEtJGaPQPgn0pkpRa02gKQn8i+S0BqWkyymwpXPwn0cyWzkVQpR1q7vtfvPM LRsaD2I8ku7D5iV/7NuyckWvJZLmkSPh2U2+0U6NBSc3Y9H+HZ5j4+dAOyHrJ8KdhAOV foyQk21VgC34xjoWbLNg7zu3+5Q7+PdkU7as1rS5NeqgCsKB6WF6X155368F3/1ir62m PHAx+/oCe/WJ6wGS7BmrxvTgeMTzHAr57L4bBDw/B8ErlxT+gPx672R5JR7bS9aPV/C4 CCvA== X-Gm-Message-State: AKwxytfCH2EtoRnl1wxmsnqX1cHrVYSRPGCK/uBW727WIQ/gyEvTi9XL BWuPYeglveoow9FlOqVlUKA= X-Google-Smtp-Source: AH8x224YkI9sXSC63/2URHN1cJB7muniS8IqCyC1qVg2kRxdLN6O68IP8B139PTnpFDZGjEV+C/Vzg== X-Received: by 10.223.165.25 with SMTP id i25mr13548589wrb.127.1516994293550; Fri, 26 Jan 2018 11:18:13 -0800 (PST) Received: from Red.local (LFbn-MAR-1-494-174.w2-15.abo.wanadoo.fr. [2.15.82.174]) by smtp.googlemail.com with ESMTPSA id k125sm7587510wmd.48.2018.01.26.11.18.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jan 2018 11:18:12 -0800 (PST) From: Corentin Labbe To: alexandre.torgue@st.com, arei.gonglei@huawei.com, corbet@lwn.net, davem@davemloft.net, herbert@gondor.apana.org.au, 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-doc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH v2 5/6] crypto: stm32-hash: convert to the new crypto engine API Date: Fri, 26 Jan 2018 20:15:33 +0100 Message-Id: <20180126191534.17569-6-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180126191534.17569-1-clabbe.montjoie@gmail.com> References: <20180126191534.17569-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 stm32-hash driver to the new crypto engine API. Signed-off-by: Corentin Labbe Tested-by: Fabien Dessenne --- drivers/crypto/stm32/stm32-hash.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c index 4ca4a264a833..89b0c2490d80 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_ctx enginectx; struct stm32_hash_dev *hdev; unsigned long flags; @@ -828,15 +829,19 @@ static int stm32_hash_hw_init(struct stm32_hash_dev *hdev, return 0; } +static int stm32_hash_one_request(struct crypto_engine *engine, void *areq); +static int stm32_hash_prepare_req(struct crypto_engine *engine, void *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); } -static int stm32_hash_prepare_req(struct crypto_engine *engine, - struct ahash_request *req) +static int stm32_hash_prepare_req(struct crypto_engine *engine, void *areq) { + struct ahash_request *req = container_of(areq, struct ahash_request, + base); 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; @@ -854,9 +859,10 @@ static int stm32_hash_prepare_req(struct crypto_engine *engine, return stm32_hash_hw_init(hdev, rctx); } -static int stm32_hash_one_request(struct crypto_engine *engine, - struct ahash_request *req) +static int stm32_hash_one_request(struct crypto_engine *engine, void *areq) { + struct ahash_request *req = container_of(areq, struct ahash_request, + base); 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 +1039,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 +1502,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;