Received: by 10.223.176.46 with SMTP id f43csp1069202wra; Fri, 26 Jan 2018 11:19:27 -0800 (PST) X-Google-Smtp-Source: AH8x225mUstabFrPJmVLZXyVqlw0eNyDNubeweK5GeMbBPK0fw6ciE/xRdRt70skVo+pKfsJYsni X-Received: by 10.98.181.14 with SMTP id y14mr20119116pfe.216.1516994367421; Fri, 26 Jan 2018 11:19:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516994367; cv=none; d=google.com; s=arc-20160816; b=GBLZ2t/bJ3WuCccYo8QMbSDNrBMyWuhKhOoZIBQPTadRHRdRy6O8/9fVMMzVut6BxV 8v7LDmsYojGHBSM2uLuIKe88Or/4u2pnFkgHTDxxXL0yFflx84xtuUK0d/Xp4swcih5H 2XiLp9KISOMWd7lhIPmx3AYCkcKLbDZz0uqw9vPrBtDrcUdMom1hx3yqgTXpz2swJmk3 Vl5JT5R6GtC5FR80za2iEHC6JIMeLAsPTTOMqF3eiq9TW61cgK6cnpVweuooS1TzIvE7 Id/kDKejgg7yDb4FOby5wFy8uhqjHIaWAWp543/rDj/+31cOOVIOdZSw6MPL3I1d79pN P+sw== 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=r5FWrkyrJlKIEkOcQZLwsxQRDTtDYOADnKX3ux5o8rE=; b=dH/s4WJdT7jX/y3YP2FPBFoP9CaWov2QXtgMWzx1c07iWn+sN3YvoYgGD8Xz66tMWE aPlwTiFHNZTUxid4TPKLdIJZQma7l01qW4CiyXEfEg+K5xvkn67uSs1fhKn5uA3JrXBG lMG0NV7PliYmLlqOZKRmTZwQn40SDVfGNfYN5Y351wXFDZu2DsyOpAZUSG+lmZjVfBxd WBud9QlZPuKyUVLXCbIaNOMCbSxevoMwV7A82c+j1bCDIqXS5q94wumt6Bra9mCeYTd5 g40x1ZtMiG7N84kMJFxCSFAfjxxkaytAg6kzMieU5CqtjkwNCtAsU1YGkVWzq3QGgGEg umew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LwjpSsiQ; 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 v6-v6si4124144plg.575.2018.01.26.11.19.13; Fri, 26 Jan 2018 11:19:27 -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=LwjpSsiQ; 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 S1752935AbeAZTSY (ORCPT + 99 others); Fri, 26 Jan 2018 14:18:24 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34729 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752822AbeAZTSS (ORCPT ); Fri, 26 Jan 2018 14:18:18 -0500 Received: by mail-wm0-f68.google.com with SMTP id j21so27873840wmh.1; Fri, 26 Jan 2018 11:18:17 -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=r5FWrkyrJlKIEkOcQZLwsxQRDTtDYOADnKX3ux5o8rE=; b=LwjpSsiQb8oLwLRrSTFtej5tzRYADs76ct5sFgmmpW5qoZ1PU6kQko2E4RQnIIKPrH OCqdoTB7XxoaAKFb1VsifovdG7OdLCrqLz8fVSuG7I1iTA2ltw9i/2Ed58VYkUWr/4Uf iTBb/xs4wR4A0Z2BwzC8EhJkAlPQ9V5rLy2ecsuDLXg2Tk9VyGTQGEOUIWjUk4Mk16lu Q4CkwLQN/M4HL2kj6COwJOHw6lfSbr/rYHQVGfYjA1NitjteHvbOE/cUkULDCkbcad/a uyJf5ZaMbUfklSxE1MpAmP1YhekxLT3ZNvbe+7mpEq5hMXoY51TmIUtWdNlUWqoSTJhb KhQw== 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=r5FWrkyrJlKIEkOcQZLwsxQRDTtDYOADnKX3ux5o8rE=; b=fYR+wpNaAdVGm/j5syfuN0QIE6o7F4+uG//xQmaj7ToTTJypZIB4BVqvZKOvl/3CUu 2S7tX9nV7K6V2+K7VbWSJBiiZmlO3c8lXsDLJ5rvxjG4ixaGO8UeVQxm8xe0l2mzr9fF eATENVMvrFs1pYV/wvInnYrEbagq4sRvwg0A9mVe5+/Tj4+440nD92YxC01y5halEMmW ZPBP0/yXiEluoIRoAja13SFQBQ2WsOEeqVWt2z/C8K5efD+EizGYeOTytmMfJflsNDOE CbZr2HeLC00M0Y7hcI8cjVCessGTSbuF/nJTXtgYHkT8RNq1s2x6azjSLxmgSES0FCMY GsjA== X-Gm-Message-State: AKwxytcUGx9uWotM0sSWRxr8uDJgc9IzgqFjJqtRtjC3X7Ki9Injwl7u K8Sz5T184BmGpLRLoDu4tSr1uGxY X-Received: by 10.28.0.212 with SMTP id 203mr10638841wma.128.1516994296963; Fri, 26 Jan 2018 11:18:16 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jan 2018 11:18:16 -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 6/6] crypto: stm32-cryp: convert to the new crypto engine API Date: Fri, 26 Jan 2018 20:15:34 +0100 Message-Id: <20180126191534.17569-7-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 stm32-cryp driver to the new crypto engine API. Signed-off-by: Corentin Labbe Tested-by: Fabien Dessenne --- drivers/crypto/stm32/stm32-cryp.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/stm32/stm32-cryp.c b/drivers/crypto/stm32/stm32-cryp.c index cf1dddbeaa2c..a816b2ffcaad 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_ctx enginectx; struct stm32_cryp *cryp; int keylen; u32 key[AES_KEYSIZE_256 / sizeof(u32)]; @@ -478,7 +479,7 @@ static void stm32_cryp_finish_req(struct stm32_cryp *cryp) free_pages((unsigned long)buf_out, pages); } - crypto_finalize_cipher_request(cryp->engine, cryp->req, err); + crypto_finalize_ablkcipher_request(cryp->engine, cryp->req, err); cryp->req = NULL; memset(cryp->ctx->key, 0, cryp->ctx->keylen); @@ -494,10 +495,19 @@ 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; } @@ -513,7 +523,7 @@ static int stm32_cryp_crypt(struct ablkcipher_request *req, unsigned long mode) rctx->mode = mode; - return crypto_transfer_cipher_request_to_engine(cryp->engine, req); + return crypto_transfer_ablkcipher_request_to_engine(cryp->engine, req); } static int stm32_cryp_setkey(struct crypto_ablkcipher *tfm, const u8 *key, @@ -695,14 +705,20 @@ 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) +static int stm32_cryp_cipher_one_req(struct crypto_engine *engine, 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 +1120,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"); -- 2.13.6