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: 123336 Delivered-To: patch@linaro.org Received: by 10.80.135.92 with SMTP id 28csp5925837edv; Wed, 3 Jan 2018 12:24:30 -0800 (PST) X-Google-Smtp-Source: ACJfBotMNFdOezaTeA6kAfBpjVs0fdX8v62glJ6XZXfIPLuate7eNPAmppP0bbMR2MlqTfuHgZo4 X-Received: by 10.159.216.139 with SMTP id s11mr2398347plp.266.1515011070862; Wed, 03 Jan 2018 12:24:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515011070; cv=none; d=google.com; s=arc-20160816; b=N9QEsg5sLNBIotrXKoO6OVY4cZoq+hD1hCBf9WtxENdLa/kl0WUrXB63uty3ujIInD 6VTLIx4WQq6WA7TcEbwqWnh0nSzsDHEiZfEqEhelhRaTnoS2sCYZNZyrJ88aUeBe7O4X J17nD28b6w/rkwpK7jMNViTFBRXIYUDf24cVJIgyvACOyy75383ZivJ88ARznlyAklLE 7OxX1zm38sQ6oqXoP3wCKL3CgH++dhlXU2QFJgTWHhbf9pxKNd21oHv+4oaW5EYIM2RP LSjq2JSR4znhhdSIlMaA2ZPWn4fVk9N+Dc9rSGlnhcqWDFfPQcwWLbomEbOJK8YGJ+0s 9lLw== 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=61Lz+UYQikoQOU/+WcGzqrLew7e/7oUvop+fw0jHhyE=; b=O5bnNM7O1Oqac9O68qRlbfIpenVXiKMuTH2PMxXQ1kLfhFxrMsoFbmTcnLm3IPrFtM R2bmXPp2uCAzKlLztpRjchGmV9m7di8rSNGT4UvcIkSRCH4isZuoQdQ0Ifd9zyDG+YPr W8NdDyRFwMcA7tJqOZonNVw0Adf3q6Q6vsWPNNfEmZHp7DPlNnArr6Yty4adSGrN5OcT LifMSResN7obYq4qlUaQqv/uQALwyw9OFjRBLOS5g3xoPIri4lzpTDDgzDLLCFFNQ/02 Ncxs0tqwp6lGEokMziXcV1ljUt0hA8kj1LwH1+t0fTW4vMHV3Wrilik/OPsYJIuSthrw TKzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ay41fxZb; 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 i2si1028956pgs.818.2018.01.03.12.24.30; Wed, 03 Jan 2018 12:24:30 -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=ay41fxZb; 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 S1752261AbeACUNf (ORCPT + 28 others); Wed, 3 Jan 2018 15:13:35 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:33126 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752143AbeACUN3 (ORCPT ); Wed, 3 Jan 2018 15:13:29 -0500 Received: by mail-wr0-f195.google.com with SMTP id p6so403775wrd.0; Wed, 03 Jan 2018 12:13:28 -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=geCsmGiOrSUsSySUgFYXuKG3K/4SHLkSEiM3XRxtabMixpGZlvltWgBNTUwjAx4NEb BgYnMhJ6cdpKX5QrZaPljhWZrEc4yt4r4+WSNgx2LocwvoIAU+UfWEuF+YcP6/1CIDdu 8yxAG2VHTDTor5Vdxsr+MdtPvhGAdX04yObdCVN+DRlqeR06Tzlnd66y0RUQ31LzmlzK TNu17BdxYJNaeu2ygTYLX2Wum8cKZFEzfCCnKyAnEZgw/xkqWEbuHKtTyOhgxl/32GR5 utZsrXK8pBcsBeyKOTizefTKgmWA1hNvFnBYPCLhHGPuAF8mqIM9Do5MwPAByJ00bk34 l/dA== X-Gm-Message-State: AKGB3mK2YGRI4sL7am0+x4eEPVtVb868qgCP8DWajYAtBOyKFxOYV9oU ChK/9YqTRzc9p1Kbk1mhrYuSkRL8 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 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, fabien.dessenne@st.com, Corentin Labbe 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch convert the stm32-cryp driver to the new crypto engine API. Signed-off-by: Corentin Labbe --- drivers/crypto/stm32/stm32-cryp.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) -- 2.13.6 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");