From patchwork Wed Nov 29 08:41:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 119934 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2782619qgn; Wed, 29 Nov 2017 00:44:18 -0800 (PST) X-Google-Smtp-Source: AGs4zMb+JJ6+CFYEFQNGRS/GoicHkjvbFbEmo33tKuP1pj8iJDBazr1EW2kVvQcS4Wx5cjbJapgi X-Received: by 10.84.164.231 with SMTP id l36mr2072439plg.75.1511945058561; Wed, 29 Nov 2017 00:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511945058; cv=none; d=google.com; s=arc-20160816; b=N9ZSpsQ5WaNqd1o0syG4znX9hU8t+UOVwQpYhm21vaEWgcXALluYLBWmsNF1NkvT3N iYVrYoU5fc5VHY+FMR7/iz/Yq2gfZY3tH9Ph3ia2qdFeNQ5sSJojQsc87KE8QIYgyeMX PMVlVDosr+FWTeXe+DmRByljacZVGBW/Q6tBqQ4aYWj/OuR4Sv8CtSKJbXNp90sZUr9j pnlb3XUR5ivfLUByemOiHeBeAWFqlEL793Bh4GL/A4QJQ/1n4Ath+HIDY01YQ06kiLJb qDxXeWXhkn3Rt9OKJ1QK2E/eJgv7MWsMAohRyNbG7eExxtTBrD9Di/1F7CsHb9s4jJOX /T2Q== 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:dkim-signature:arc-authentication-results; bh=1w4KGYQ+mdxR4Ax3LxeNopLazazXn19Zt2HfGjgZul4=; b=fUUTCeKatpbFjIm2SCM5MZSuAd9Au8J9YVIUfjIzChHXMEMy88+OPUWB5JBoLeM2Ze +8Tl4hGSxDREDqTqruxEi4R6Ns6yylBjWUduytJjs4vHpjoICo+A6piFu1lNc5gK4z/t 3LudBVR2Bnl7NE8k6OF22FZlLaXiM+N5hvSDCYsEJ6aM3xk6YGqWUHYQgPczzflTTThj N4Kx84nZDFHyzDaY/VExOskuukSQjafVB+WVGHdo2N5aUReRKkEYWDOwa5e0dPo2ZRTP YJs8l/NGDhO6ie9zpjH6Dhawh6QkrBztIpxhOt8yFkKvvYB3r+cxn34dG+3aUjrwjuzd /Irg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AEiq/Oyh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m37si942893pla.205.2017.11.29.00.44.18; Wed, 29 Nov 2017 00:44:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AEiq/Oyh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753807AbdK2IoQ (ORCPT + 28 others); Wed, 29 Nov 2017 03:44:16 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33039 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753499AbdK2Int (ORCPT ); Wed, 29 Nov 2017 03:43:49 -0500 Received: by mail-wm0-f66.google.com with SMTP id g130so35269071wme.0; Wed, 29 Nov 2017 00:43:48 -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=1w4KGYQ+mdxR4Ax3LxeNopLazazXn19Zt2HfGjgZul4=; b=AEiq/OyhggVThlduvM/k2C6kjaZFPzUqoAauUleI8B8I1SdTWaGpajuUOqgEmyzEsw qNLdCCe9Vge7cmKi7XmnAl/i/fJYe9I2JXQ1E6tWPNyTDTPMItv3phz26Tp3EjXcMo5o UGhMRt+iIUYwt2JZ5An/hM0ju7uoUnmunYJeW02bBiMtfFM0Z7G3L8/NCk1TC/uP42vj ObMk1DSQU+MZcnv/QPhgdefh/9iIKFAwfZEzb/dvQZVx5KNF8Ad0N/qOv94cffHUZvYL j21q/nNllnHaGexpRUa7pFu71E/cUKq2i26htbZE3Qr7jIx5IOhFRoCSiJf+AporLVMR mHqA== 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=1w4KGYQ+mdxR4Ax3LxeNopLazazXn19Zt2HfGjgZul4=; b=OA+W5fSShKWMC6KUSIBunGdMFyYOvpitfzxORgbLR7q5pCHeBba8Lp2yt43f4NALDh B7Z9FEkytkSzwBysDd4CqC3lboO9NYweKX/Cpm8UyyTloK67+BLCmuBaI4W2HUgLo6+W PrOnOqSyXsNJGlCJVDmqU0iy+4vRxOUXRgTuZYNnN6UwCvE9hzJjclSJjoRZ9ZwNMIsq ao8/z+9S8aVECFwQAc8TgdbYJykIQ7BFPIQSX8hXIZpJTLOdnn0wxT6YLj6+n3XbjE3G tR88u4j9BQe1KQ3fdm8ufWmrD6EcOIOiH8dia2OvXq4GCB0z+Y+IVEW9xMIeOO3SsEER HzKg== X-Gm-Message-State: AJaThX74DM/wL2zlkVyuWmd0+N7GEVpc6FXe0qa040gjnSQ7r/kV91Oo EBNRb9rvtvTHJtt/lZsM3LA= X-Received: by 10.28.194.139 with SMTP id s133mr1686526wmf.14.1511945028269; Wed, 29 Nov 2017 00:43:48 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 00:43:47 -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 2/4] crypto: omap: convert to new crypto engine API Date: Wed, 29 Nov 2017 09:41:19 +0100 Message-Id: <20171129084121.9385-3-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch convert the driver to the new crypto engine API. Signed-off-by: Corentin Labbe --- drivers/crypto/omap-aes.c | 21 +++++++++++++++------ drivers/crypto/omap-aes.h | 3 +++ drivers/crypto/omap-des.c | 24 ++++++++++++++++++------ 3 files changed, 36 insertions(+), 12 deletions(-) -- 2.13.6 diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index fbec0a2e76dd..4a31bbfca9a4 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c @@ -388,7 +388,7 @@ static void omap_aes_finish_req(struct omap_aes_dev *dd, int err) pr_debug("err: %d\n", err); - crypto_finalize_cipher_request(dd->engine, req, err); + crypto_finalize_request(dd->engine, &req->base, err); pm_runtime_mark_last_busy(dd->dev); pm_runtime_put_autosuspend(dd->dev); @@ -408,14 +408,15 @@ static int omap_aes_handle_queue(struct omap_aes_dev *dd, struct ablkcipher_request *req) { if (req) - return crypto_transfer_cipher_request_to_engine(dd->engine, req); + return crypto_transfer_request_to_engine(dd->engine, &req->base); return 0; } static int omap_aes_prepare_req(struct crypto_engine *engine, - struct ablkcipher_request *req) + struct crypto_async_request *areq) { + struct ablkcipher_request *req = ablkcipher_request_cast(areq); 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) + struct crypto_async_request *areq) { + struct ablkcipher_request *req = ablkcipher_request_cast(areq); 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, + struct crypto_async_request *req); +static int omap_aes_crypt_req(struct crypto_engine *engine, + struct crypto_async_request *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..94212248159e 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; @@ -498,7 +499,7 @@ static void omap_des_finish_req(struct omap_des_dev *dd, int err) pr_debug("err: %d\n", err); - crypto_finalize_cipher_request(dd->engine, req, err); + crypto_finalize_request(dd->engine, &req->base, err); pm_runtime_mark_last_busy(dd->dev); pm_runtime_put_autosuspend(dd->dev); @@ -520,14 +521,15 @@ static int omap_des_handle_queue(struct omap_des_dev *dd, struct ablkcipher_request *req) { if (req) - return crypto_transfer_cipher_request_to_engine(dd->engine, req); + return crypto_transfer_request_to_engine(dd->engine, &req->base); return 0; } static int omap_des_prepare_req(struct crypto_engine *engine, - struct ablkcipher_request *req) + struct crypto_async_request *areq) { + struct ablkcipher_request *req = ablkcipher_request_cast(areq); 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) + struct crypto_async_request *areq) { + struct ablkcipher_request *req = ablkcipher_request_cast(areq); 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, + struct crypto_async_request *areq); +static int omap_des_crypt_req(struct crypto_engine *engine, + struct crypto_async_request *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;