From patchwork Wed Jan 3 20:11:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 10143281 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 048BE6034B for ; Wed, 3 Jan 2018 20:29:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAC1D290EA for ; Wed, 3 Jan 2018 20:29:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB9B32928B; Wed, 3 Jan 2018 20:29:01 +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=unavailable 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 7C0F6290EA for ; Wed, 3 Jan 2018 20:29:01 +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=YXRHS7x0VkFCDLLRKGTP0Qz29LQlKqW8xSU2rS9GPc8=; b=MdumizxTbbQLtsEJZkHuKGz6xd t6eP73RJDXooobftgr7mqdn+bwLUMjzuuNLwTxkPDaongaFXhXHy/JuSFWwQMqDo5gr6V+emW30z7 8fKOYGE4CkK2zsuxW2ejO7n0FUaZlD5zIhXkLCXcQZQWMQIkAuKU9I/roLucjr9WmOcPMCXq0NAkD kUl4JSz08WyauvNvViPLfRioVIlGnRxkt0KYbr5tyjlrCjqGINDrTk3I1O9SVFcnSpP9e8Z9n1Fg0 HpYRKmXAnCTjgnNZZI+CsDFjYIsYilxy3KxjaQsco3Q9OJpITrkMvkiENk2cdNvi1QdapLpAzoeEY lxfX9OkQ==; 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 1eWpeh-0001Bb-JA; Wed, 03 Jan 2018 20:28:55 +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 1eWpPw-00062K-OH for linux-arm-kernel@bombadil.infradead.org; Wed, 03 Jan 2018 20:13:41 +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=jshDj9h+QKs88X5CaYnVSG6+6y6vGaTUjoZiRW7EPS4=; b=EeWpyNyZRbOMuX81XTDKtZlXW EbXBuk/neBH6zMvHtyZ4skw776TAYD/woQRZ5Qr6igPSur+Bi6fJKn+yIS2IfgXkkRtWQHG/v+CvL 3qYFivBqapSo3lrbLLnkYtOHl6Gmg+nMy6Phz/zyA3zFpO9moTaMU5sstglh79aUMBvi84m5Zhl90 iSInIuzlqzFXEzvC8RjwqIR7AUNcRsf5bceLyEI1I4YUW9aub3C961GY/+rV21uz6htTqRw0SOLx+ /2wXalLVa7nder6yoZoV6u5KI/2XIr46FS55mDmps05dkmLLt7eVfAsOtQGj+SnIllqtWngtNixTB B3rJ4rPYA==; Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by merlin.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eWpPt-0005eC-PM for linux-arm-kernel@lists.infradead.org; Wed, 03 Jan 2018 20:13:38 +0000 Received: by mail-wr0-x241.google.com with SMTP id f8so2846382wre.4 for ; Wed, 03 Jan 2018 12:13:25 -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=jshDj9h+QKs88X5CaYnVSG6+6y6vGaTUjoZiRW7EPS4=; b=L2Jz0CabB/kZkazZAVZ3DKN/rt9WLneRWnwyxgnpmcsTp/PVkjfeUjxWdQRFAu4Wd+ rpVVAI3PXL3VynwNhtxikZwE7yEKCDd+BAgotOljAxxRe9JrcIS78C1s0/27I7xL1UoW RK+fwkp0pfhEXhfpdzvVamzCpWVgDxsbK4xOvGq9ZDZbsR0URlinbFAhCZa27z/W8kE/ ZvQPLVRdtJaLyvI4V+akBQMUyMr26HFRTJOrvzc2/QNkCxjXckgt45vfjkl7B0waseer JxwR5FHx1YnikOUIWTyUgLwlmJnRd+acDwoHb+ToZSGLaSdyARMau/Bf55cPaP4iGIfE 2G4Q== 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=jshDj9h+QKs88X5CaYnVSG6+6y6vGaTUjoZiRW7EPS4=; b=GD1o1/scRgzxSkORqu7SuaZRDceiooJ3kSXpivOYpb0eN3PbuYiJbnR00UbkylMDoF TVimq9Noc848cLMgQWdBDDK67wr9mZBiU6pGSKhVLaZ7ZGLDbpzf31ja6APw0e8faI9+ oV7hVG+/hKe3x1IxEBM/GN9u8n4vHaXRWb3PWcuHhwmCElD3fJa8h+e3BtHr/ij19l75 HBOit3lW8NYgjV4i9Ge/+lr46wQhbrvHYVw8USM5D0TH2Jj/UBbvSSOaTbD7Pxox323o NAiDfO+TUhCzJh3p3lHwP6tEesyY++xqUFNP7ibdR3ktCKjlEZ1AFny8OUUmI44NLWtk eW1g== X-Gm-Message-State: AKGB3mJCMftB3WecIjLcb49RFcsYRg+L/wJQFhiHwEG0fu4tBxfSv5xk hx4qDs/fzOr1Gw4ExxR48zk= X-Google-Smtp-Source: ACJfBouH65xKZOcyCy3jltMSGCfCt7nmqM/12HzYfchDGghwC8nThgwzWK3C+T126QzM/D4FIudL+A== X-Received: by 10.223.157.135 with SMTP id p7mr2735228wre.204.1515010403796; Wed, 03 Jan 2018 12:13:23 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 12:13:23 -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 3/6] crypto: omap: convert to new crypto engine API Date: Wed, 3 Jan 2018 21:11:06 +0100 Message-Id: <20180103201109.16077-4-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 driver to the new crypto engine API. Signed-off-by: Corentin Labbe --- drivers/crypto/omap-aes.c | 17 +++++++++++++---- drivers/crypto/omap-aes.h | 3 +++ drivers/crypto/omap-des.c | 20 ++++++++++++++++---- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index fbec0a2e76dd..518b94628166 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c @@ -414,8 +414,9 @@ static int omap_aes_handle_queue(struct omap_aes_dev *dd, } static int omap_aes_prepare_req(struct crypto_engine *engine, - struct ablkcipher_request *req) + void *areq) { + struct ablkcipher_request *req = container_of(areq, struct ablkcipher_request, base); struct omap_aes_ctx *ctx = crypto_ablkcipher_ctx( crypto_ablkcipher_reqtfm(req)); struct omap_aes_reqctx *rctx = ablkcipher_request_ctx(req); @@ -468,8 +469,9 @@ static int omap_aes_prepare_req(struct crypto_engine *engine, } static int omap_aes_crypt_req(struct crypto_engine *engine, - struct ablkcipher_request *req) + void *areq) { + struct ablkcipher_request *req = container_of(areq, struct ablkcipher_request, base); struct omap_aes_reqctx *rctx = ablkcipher_request_ctx(req); struct omap_aes_dev *dd = rctx->dd; @@ -601,6 +603,11 @@ static int omap_aes_ctr_decrypt(struct ablkcipher_request *req) return omap_aes_crypt(req, FLAGS_CTR); } +static int omap_aes_prepare_req(struct crypto_engine *engine, + void *req); +static int omap_aes_crypt_req(struct crypto_engine *engine, + void *req); + static int omap_aes_cra_init(struct crypto_tfm *tfm) { const char *name = crypto_tfm_alg_name(tfm); @@ -616,6 +623,10 @@ static int omap_aes_cra_init(struct crypto_tfm *tfm) tfm->crt_ablkcipher.reqsize = sizeof(struct omap_aes_reqctx); + ctx->enginectx.op.prepare_request = omap_aes_prepare_req; + ctx->enginectx.op.unprepare_request = NULL; + ctx->enginectx.op.do_one_request = omap_aes_crypt_req; + return 0; } @@ -1119,8 +1130,6 @@ static int omap_aes_probe(struct platform_device *pdev) goto err_engine; } - dd->engine->prepare_cipher_request = omap_aes_prepare_req; - dd->engine->cipher_one_request = omap_aes_crypt_req; err = crypto_engine_start(dd->engine); if (err) goto err_engine; diff --git a/drivers/crypto/omap-aes.h b/drivers/crypto/omap-aes.h index 8906342e2b9a..f6ce94907ade 100644 --- a/drivers/crypto/omap-aes.h +++ b/drivers/crypto/omap-aes.h @@ -13,6 +13,8 @@ #ifndef __OMAP_AES_H__ #define __OMAP_AES_H__ +#include + #define DST_MAXBURST 4 #define DMA_MIN (DST_MAXBURST * sizeof(u32)) @@ -95,6 +97,7 @@ struct omap_aes_gcm_result { }; struct omap_aes_ctx { + struct crypto_engine_reqctx enginectx; int keylen; u32 key[AES_KEYSIZE_256 / sizeof(u32)]; u8 nonce[4]; diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index ebc5c0f11f03..c6a3b0490616 100644 --- a/drivers/crypto/omap-des.c +++ b/drivers/crypto/omap-des.c @@ -86,6 +86,7 @@ #define FLAGS_OUT_DATA_ST_SHIFT 10 struct omap_des_ctx { + struct crypto_engine_reqctx enginectx; struct omap_des_dev *dd; int keylen; @@ -526,8 +527,9 @@ static int omap_des_handle_queue(struct omap_des_dev *dd, } static int omap_des_prepare_req(struct crypto_engine *engine, - struct ablkcipher_request *req) + void *areq) { + struct ablkcipher_request *req = container_of(areq, struct ablkcipher_request, base); struct omap_des_ctx *ctx = crypto_ablkcipher_ctx( crypto_ablkcipher_reqtfm(req)); struct omap_des_dev *dd = omap_des_find_dev(ctx); @@ -582,8 +584,9 @@ static int omap_des_prepare_req(struct crypto_engine *engine, } static int omap_des_crypt_req(struct crypto_engine *engine, - struct ablkcipher_request *req) + void *areq) { + struct ablkcipher_request *req = container_of(areq, struct ablkcipher_request, base); struct omap_des_ctx *ctx = crypto_ablkcipher_ctx( crypto_ablkcipher_reqtfm(req)); struct omap_des_dev *dd = omap_des_find_dev(ctx); @@ -695,12 +698,23 @@ static int omap_des_cbc_decrypt(struct ablkcipher_request *req) return omap_des_crypt(req, FLAGS_CBC); } +static int omap_des_prepare_req(struct crypto_engine *engine, + void *areq); +static int omap_des_crypt_req(struct crypto_engine *engine, + void *areq); + static int omap_des_cra_init(struct crypto_tfm *tfm) { + struct omap_des_ctx *ctx = crypto_tfm_ctx(tfm); + pr_debug("enter\n"); tfm->crt_ablkcipher.reqsize = sizeof(struct omap_des_reqctx); + ctx->enginectx.op.prepare_request = omap_des_prepare_req; + ctx->enginectx.op.unprepare_request = NULL; + ctx->enginectx.op.do_one_request = omap_des_crypt_req; + return 0; } @@ -1046,8 +1060,6 @@ static int omap_des_probe(struct platform_device *pdev) goto err_engine; } - dd->engine->prepare_cipher_request = omap_des_prepare_req; - dd->engine->cipher_one_request = omap_des_crypt_req; err = crypto_engine_start(dd->engine); if (err) goto err_engine;