From patchwork Wed Jan 3 20:11:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 10143209 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 33E3360594 for ; Wed, 3 Jan 2018 20:18:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27224283CB for ; Wed, 3 Jan 2018 20:18:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C01528D6F; Wed, 3 Jan 2018 20:18:57 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A24B5283CB for ; Wed, 3 Jan 2018 20:18:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rjdckNzCZcH/jhLRyEK/1dHN/q2RZyiz++FHu5EmfyA=; b=PSmGKV+6nKZjmW5olshxVfiWcr myq0PFuwQK0N5Wxx8Jpvc6pcZ/91QzumzZyiAjxLNt6I7EIqp9y7YuRsdd6Km95+VBavu/ySXaC52 eehiTMpKWL4a2JWMcR1zqoVi3MxdGTkp8SYgSfB5yHhGPgd9ZXU2+vnhH36sJgvnDoIXADwNPGTK+ PyZy3gjXW9lklAeiAV8u8hu3CBhRzFoiZp/dEMuwK6Vq7zZjEZTrdYFCnQiPuToAbN99b2X5FLe1T k1pe5PZxN73+O1pwcOuRzFwxNch8fvujX4F1yfDQXUbahE/Zw4QPxi3xrqLLhadsVAkRGi7Mry8sY Wo391jJA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eWpUz-0002a5-EK; Wed, 03 Jan 2018 20:18:53 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eWpPz-00064b-BZ for linux-arm-kernel@bombadil.infradead.org; Wed, 03 Jan 2018 20:13:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=61Lz+UYQikoQOU/+WcGzqrLew7e/7oUvop+fw0jHhyE=; b=cTsrzCp2AU756vKaZLJaJeBoR O8ae15nPJBtnrrUSSzDd4vvwKFoE4GSfwCy1lQph/gN7aepSkXSWao+ApXwoWA6VmTs4Z4euBUOOu Orcaf5UiUS+XH4SIeHdCTOQ4NL1rCz9+rCrWy26k/3pTfeX1aJp8++XKrbsAAVIe9eZkSuzAM0gnF vsMFP2J/dC7EizCMrZlmtEs4PE7DH7UpDRk97zr3iL/aW8P4qSKTvQDCcQtu6zR31MD96LUn98x8L ga6qzBCfgxP7jyphf50RbU9SGBOiDxisxzRKrLXmJ68G2kSRezp0JW9qnjMhI/COHuSbSOuLybgMf rzDIRma+Q==; Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by merlin.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eWpPw-0005eK-LC for linux-arm-kernel@lists.infradead.org; Wed, 03 Jan 2018 20:13:41 +0000 Received: by mail-wr0-x242.google.com with SMTP id g17so2833469wrd.13 for ; Wed, 03 Jan 2018 12:13:29 -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=61Lz+UYQikoQOU/+WcGzqrLew7e/7oUvop+fw0jHhyE=; b=ay41fxZbYE5Zw46uNNKp63irzsFepZiXoTrMLuNbQtC48YVC7xfasdf+6qaJsCSfAI 8dSVFUi7Z8564LvgjL1+DWPA4ciYxaMGlM1plHnJ4LODPWOAjlOdKiwzGuG0tWHHiu3g SWSH96OVMfnDIoyIh3PnMR5gKneHN0vH/YTFzv1lsHUQYoNvGA1NvWpFn6NEVKwzKxSJ 5ZrjIUnsYGOWmFARFj8IpfZ93yIQPinE8ATuW/kRk3zG0DX3HR3a4nWYZVvstrKGn8+Q mRn5i0ZMiQU+yKVFFU2z5MJ0P3DIkyisyQw4yByjz5g2w77aeArHySno7TorjCoHwfsU KSiw== 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=61Lz+UYQikoQOU/+WcGzqrLew7e/7oUvop+fw0jHhyE=; b=Ehwn9ka+OUx7lK8b8oUvfjXYQeUnM79xogYY0ndOmwUzK8EiFWI27Tuspa55BR7MKb YO1i42tW/+xXROe65CBt9L3DJwqISvblrEUYCcXALmDMGVB718AuHnM7XEvX2vF95mcF CwNrtuAbU9tufsobRhip5uM6Gb0azXnYeUvB/SynsRHjKphz006Egbrn5u1mrhS3hbzu Z3Y0C0CACnGXSlxoi813jw/5ls2pWomHjv06EumO8ZmnzUIE+S7QmHRbZRGO/OWGkjqP arADLsUknHefVUav0AET/9l6X54Cj2QX20ajcgZcIivCL/s3nBHZyQdXIuELIZwm6efM KNgw== X-Gm-Message-State: AKGB3mKbHhwQRbg3gbyitcXChXho77/L+aZLYpw584+D0WY25OS7Ua36 dVotV2rBPsIZpr/QvGTCL0E= X-Google-Smtp-Source: ACJfBovq07hgPZrprF61e4sYdH1op3tL3vwkD7sJ2ABv0bl8nCli56IHa/B6im+82gqTEmpf3bAABQ== X-Received: by 10.223.169.231 with SMTP id b94mr2747397wrd.63.1515010408190; Wed, 03 Jan 2018 12:13:28 -0800 (PST) Received: from Red.local (LFbn-1-6953-20.w90-116.abo.wanadoo.fr. [90.116.134.20]) by smtp.googlemail.com with ESMTPSA id p90sm1800627wmf.3.2018.01.03.12.13.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 12:13:27 -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 Subject: [PATCH 6/6] crypto: stm32-cryp: convert to the new crypto engine API Date: Wed, 3 Jan 2018 21:11:09 +0100 Message-Id: <20180103201109.16077-7-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180103201109.16077-1-clabbe.montjoie@gmail.com> References: <20180103201109.16077-1-clabbe.montjoie@gmail.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, fabien.dessenne@st.com, virtualization@lists.linux-foundation.org, Corentin Labbe , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch convert the stm32-cryp driver to the new crypto engine API. Signed-off-by: Corentin Labbe Tested-by: Fabien Dessenne --- drivers/crypto/stm32/stm32-cryp.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/stm32/stm32-cryp.c b/drivers/crypto/stm32/stm32-cryp.c index cf1dddbeaa2c..99e0473ef247 100644 --- a/drivers/crypto/stm32/stm32-cryp.c +++ b/drivers/crypto/stm32/stm32-cryp.c @@ -91,6 +91,7 @@ #define _walked_out (cryp->out_walk.offset - cryp->out_sg->offset) struct stm32_cryp_ctx { + struct crypto_engine_reqctx enginectx; struct stm32_cryp *cryp; int keylen; u32 key[AES_KEYSIZE_256 / sizeof(u32)]; @@ -494,10 +495,20 @@ static int stm32_cryp_cpu_start(struct stm32_cryp *cryp) return 0; } +static int stm32_cryp_cipher_one_req(struct crypto_engine *engine, + void *areq); +static int stm32_cryp_prepare_cipher_req(struct crypto_engine *engine, + void *areq); + static int stm32_cryp_cra_init(struct crypto_tfm *tfm) { + struct stm32_cryp_ctx *ctx = crypto_tfm_ctx(tfm); + tfm->crt_ablkcipher.reqsize = sizeof(struct stm32_cryp_reqctx); + ctx->enginectx.op.do_one_request = stm32_cryp_cipher_one_req; + ctx->enginectx.op.prepare_request = stm32_cryp_prepare_cipher_req; + ctx->enginectx.op.unprepare_request = NULL; return 0; } @@ -695,14 +706,17 @@ static int stm32_cryp_prepare_req(struct crypto_engine *engine, } static int stm32_cryp_prepare_cipher_req(struct crypto_engine *engine, - struct ablkcipher_request *req) + void *areq) { + struct ablkcipher_request *req = container_of(areq, struct ablkcipher_request, base); + return stm32_cryp_prepare_req(engine, req); } static int stm32_cryp_cipher_one_req(struct crypto_engine *engine, - struct ablkcipher_request *req) + void *areq) { + struct ablkcipher_request *req = container_of(areq, struct ablkcipher_request, base); struct stm32_cryp_ctx *ctx = crypto_ablkcipher_ctx( crypto_ablkcipher_reqtfm(req)); struct stm32_cryp *cryp = ctx->cryp; @@ -1104,9 +1118,6 @@ static int stm32_cryp_probe(struct platform_device *pdev) goto err_engine1; } - cryp->engine->prepare_cipher_request = stm32_cryp_prepare_cipher_req; - cryp->engine->cipher_one_request = stm32_cryp_cipher_one_req; - ret = crypto_engine_start(cryp->engine); if (ret) { dev_err(dev, "Could not start crypto engine\n");