Received: by 10.223.176.46 with SMTP id f43csp1069953wra; Fri, 26 Jan 2018 11:20:19 -0800 (PST) X-Google-Smtp-Source: AH8x225PYTXM9SHLTCYa+nx40ctzir9E4E+Ij+HiWXvSWrmFCt3UPl3gczF22DfJpOQYbkixUPM9 X-Received: by 2002:a17:902:8491:: with SMTP id c17-v6mr15239963plo.105.1516994419781; Fri, 26 Jan 2018 11:20:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516994419; cv=none; d=google.com; s=arc-20160816; b=r7G6DLElFW4dqtf9XF0OhpBdOhjaICmNF9wzEbhbVSFBzAy41Ib+8cQzqOe0pv2E8F qrABSf5dKKYleomISzj3TCN31+5FjC7s+PkJ67TyOcYdJGM4Fx18LNDjAkx+ULVsZJ6d ch+WeJ32amvOnFBJ/j/A0Y/epphJUZxkS5R47Fwi2kUq5sIcZcYrnFXf7b7LoInwZjkT +008y+S29ys1Z5R3UziZMEskSRoK81bM8IUtFGx/sVKgTBLD2crxA4b3ezoye9iSs7dK eE2vyxOwmav1R1RnzuV9NeW6oDH5iOXErMpRp6U48ZTPuj6wUTyNLW/YbtnKNIruSTMM LRiw== 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=wv+dPFqjk5IWhOL8OWcdQ49KKQAZR3xzLbQRHu1/NzA=; b=dod2zrFKs7xd2fW4uncHtWMTPI6jxxP+tPvZBLbO4h9m+DfVqb53UflOHv3lbTdF6s VDYHlZAmkgPA/+eJAKmwtODvNe6ys4XyjQvc6uhEp7oIXE1bf0jhHLFKA25BLOhg4Rlb J1pSnNf4JoRYRmHVDp5+WsLUtrm8LuKsbR2/9HYk/Lxyv1Cvi1gyx2tPkuQEORySA3sk 3K2lPe3WRnCzfmEJuc/Nw95X9DC3ew69+3x6U77fFN7gqSJvMrVQE0Rm1zh3wE7N1gTi NdKP0O+gG56fbeVn6fKA8KsMPFFzFNywdhZc9qe5N2ja2dAGA8lyx+hFnoemT7p7XpmO Tlww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RhqILsdf; 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 z7si6751614pfa.360.2018.01.26.11.20.05; Fri, 26 Jan 2018 11:20:19 -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=RhqILsdf; 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 S1753066AbeAZTTM (ORCPT + 99 others); Fri, 26 Jan 2018 14:19:12 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:39831 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752750AbeAZTSJ (ORCPT ); Fri, 26 Jan 2018 14:18:09 -0500 Received: by mail-wr0-f193.google.com with SMTP id z48so1404948wrz.6; Fri, 26 Jan 2018 11:18:08 -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=wv+dPFqjk5IWhOL8OWcdQ49KKQAZR3xzLbQRHu1/NzA=; b=RhqILsdfcySVkb9ePOBzmpckezg4ILEdz7PIPKlpnb6sH9Vq0DLKa30Nl422Ob7MRe T4LHX42SI/st6c83zfrKm+M9AiytrgaY9O4Lcl3PSDtJTEuMNUzHLO1VtnJc2Qo9LbPB fV6RlMM4HzadIB6hATJuxhlSUTkuf8TwdQJC1SPMboIi/efv2Fc6DiekouqtZCS6SmxT X++RXoK9kAz51oFCIYgWRcDKutYhA4ESmTeGX18RYD85UhgglhLyQCbx5mP+zS78pA8+ tZRv/u952Su+odBcai5FqKCk9QExFpEhpc1/Zh7AwS6Inaa60Drn3vuUH8jS+NLP4rIu PW6Q== 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=wv+dPFqjk5IWhOL8OWcdQ49KKQAZR3xzLbQRHu1/NzA=; b=lo3wUdPGca85QG07N4rGvVUG/FbpUZ0O0N5vazyceCZD4gHEkMw55yw/Ygqe42jjuG GDna7GruqK8W/D5/ix2o6LVbz6AeA6wNwj/Oq2lRMtLC3I814pUFxE3TA9puKbNhnbC0 yDSx74D1rwwLUegGDw7/XY5b4dDyQFWqXd2jr7ptZ/Meh8ruY3nnadvbVVThL3Pxx4S/ NX2J0o8lgCHZuWqo24bHHhO5+o2OVoNUWuJgEljIu384B07uqozp6CEQ12WwAdLu/8SO m+HEha8sguDqiz2xP+qJukjvz9S/Owgf8ruAGQz1x6WdAb4jEQ+ik58VU/dEU8QVLL8M Nqug== X-Gm-Message-State: AKwxyteLeY1qw0870KfJmVgb0hLAs8Z6t6GgSBc+67Qj9InDkTOx9DEd NdLs1k+dDM5Bb3aosgMHl+o= X-Received: by 10.223.156.197 with SMTP id h5mr12146230wre.17.1516994287951; Fri, 26 Jan 2018 11:18:07 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jan 2018 11:18:07 -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 3/6] crypto: omap: convert to new crypto engine API Date: Fri, 26 Jan 2018 20:15:31 +0100 Message-Id: <20180126191534.17569-4-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-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(-) diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index fbec0a2e76dd..5bd383ed3dec 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_ablkcipher_request(dd->engine, req, 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_ablkcipher_request_to_engine(dd->engine, req); return 0; } 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..fc3b46a85809 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_ctx 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..eb95b0d7f184 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_ctx 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_ablkcipher_request(dd->engine, req, 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_ablkcipher_request_to_engine(dd->engine, req); return 0; } 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; -- 2.13.6