From patchwork Wed Nov 29 08:41:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 119932 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2782431qgn; Wed, 29 Nov 2017 00:44:03 -0800 (PST) X-Google-Smtp-Source: AGs4zMaL2hbwcS4lMOxJRH779bAveAsMTVamDlDHp6q137I/DJOHm2Qu/n2508/TmJxl91PI1maI X-Received: by 10.101.96.1 with SMTP id m1mr2079395pgu.38.1511945042985; Wed, 29 Nov 2017 00:44:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511945042; cv=none; d=google.com; s=arc-20160816; b=gPgazbmdryh7FhLAG+vIuA44pa2k2rCsJJf5rtICdPz7PJgwfd6wFxVg+GCxvC8XWT o0m4i3TJFNNApgpvgSrPHgVoCUFrqGI0e/T/g75tROLMDHa57gAbuBSfNH+4gpb+Jh+h wqkfOF3GQL764ymgs7bXrFDYThwI08vy0V9+dcY/daTfkXCQDgUcKqeLuV21wfiC7DgO CuN+PklmY2xbTsRtHQ7cZ39Ks7lut+fqcmZSVO1pODCwbbX5LGmeSewMkKa4D9c4l4nf d+YHCYvfQ5VuqPX6jifUaoWOGJi5jePyLsl3gdsxHW728j2YYOLpIMoyPxpyQoJn9Tvc zpOg== 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=MrdKqTiQmuOfevQVvtq82E9mHKdrHfboMevxIkOPurM=; b=EhxEF/s/77TL+w0F7XU1WG6cIr4GUFT4vQqe3bzEV+/IgqoKIk0gjROfKfvZKVSzwO 8hdf8PNP4jVsEIDNNaTAMtiYDMPz0jI1iiLJSEz/vzZGnBTF3sItdrWyqEXEAAXM/ctX T6+jtlv4F+LdG031DeC5kkE/6kHtnEIg/a8WSzBfeN+WiwyAbne/s0Bd83WpvMLGfI0R hNzn0DZaZ0u3hcEoEw0QCjinHbyv4S0/YSRE4VzgHaIOQsjF9YkCCaCQwbBed9WiXN4h NT/k9gZrwBQSvlb0UNay8pwg4eoxfgsJxlGgpcw9fwgSPXWPeK/kYas5mAJ8fpyUwTeJ soKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=t/RmWAqt; 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 p9si928807pls.471.2017.11.29.00.44.02; Wed, 29 Nov 2017 00:44:02 -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=t/RmWAqt; 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 S1753769AbdK2IoA (ORCPT + 28 others); Wed, 29 Nov 2017 03:44:00 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:36733 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753686AbdK2Inv (ORCPT ); Wed, 29 Nov 2017 03:43:51 -0500 Received: by mail-wr0-f194.google.com with SMTP id v105so2622497wrc.3; Wed, 29 Nov 2017 00:43:51 -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=MrdKqTiQmuOfevQVvtq82E9mHKdrHfboMevxIkOPurM=; b=t/RmWAqt4SXnR+XJwOrg0m8gXDnVBz7usPT6rxYTXrx2OqsLSr8AJxiYX+cZx07H6+ gqGD59xUeG4WcbQ72x3MMqoIKV4lL2IwXjFsmOnro/bo2kb4bZ4I1Dptb9bS7I0vA/oG 3ZNBkT/q6IHHafPMC051rJJ7WMX0zArM6/WmEDUl+7RYwN7FZr6o35b48S7mSmkq1EjO VUrn8Bd95qyzQj+NNiWIMMCRMcNQFEOXzSQl+atnM0mCAYjHu+uRV5mOvwMizv+E4Vjr 6n8L3SMWKNpq8xFq3selfjOOdO1N0xn4ZW8O6ONVeLu4NwWF/MF9xCoV0nS3Ja+QDu7C dMWA== 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=MrdKqTiQmuOfevQVvtq82E9mHKdrHfboMevxIkOPurM=; b=Qvzwnj2j7l8L8i6Oq0a8vuClQHW71UmK+1gcps3wWaohglCDCCsqe2ip9Re+weMooT UiX07bO0pzihzc5JpsBXQigTj9PRFcCyE950rDoN6/FLjnVYwXv/ux75m1p19Ha2ey9z Emku1ZiENUVJxlZobbRw4UkMJfXmTN3J0mVIXgMP6ugE4u+xGcgFFaYlQwY8SWNgoJrO ywsqRm1pQCEG5udy5jGvpMfQi3WW1Ed/qe34DGfJACogh7lMI02rZfRqaqZ51kU9fAPG ItQwjzNEbpneFYKYKMSYDyJdoOe3YjlM6GY0UPit7uUYGoMxhV+wg+Jd+3YMzWUXmOyN f1Qg== X-Gm-Message-State: AJaThX7h/VNOIl+3FBEjrFCKtLEtjEKkHIzLb4tW4aKuY/OCXROmoFpM GVy7tGZairiT9WuLki6sijU= X-Received: by 10.223.172.115 with SMTP id v106mr1755174wrc.195.1511945030522; Wed, 29 Nov 2017 00:43:50 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 00:43:49 -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 4/4] crypto: stm32: convert to the new crypto engine API Date: Wed, 29 Nov 2017 09:41:21 +0100 Message-Id: <20171129084121.9385-5-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/stm32/stm32-hash.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) -- 2.13.6 diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c index 4ca4a264a833..e3f9f7b04ce2 100644 --- a/drivers/crypto/stm32/stm32-hash.c +++ b/drivers/crypto/stm32/stm32-hash.c @@ -122,6 +122,7 @@ enum stm32_hash_data_format { #define HASH_DMA_THRESHOLD 50 struct stm32_hash_ctx { + struct crypto_engine_reqctx enginectx; struct stm32_hash_dev *hdev; unsigned long flags; @@ -811,7 +812,7 @@ static void stm32_hash_finish_req(struct ahash_request *req, int err) rctx->flags |= HASH_FLAGS_ERRORS; } - crypto_finalize_hash_request(hdev->engine, req, err); + crypto_finalize_request(hdev->engine, &req->base, err); } static int stm32_hash_hw_init(struct stm32_hash_dev *hdev, @@ -828,15 +829,21 @@ static int stm32_hash_hw_init(struct stm32_hash_dev *hdev, return 0; } +static int stm32_hash_one_request(struct crypto_engine *engine, + struct crypto_async_request *areq); +static int stm32_hash_prepare_req(struct crypto_engine *engine, + struct crypto_async_request *areq); + static int stm32_hash_handle_queue(struct stm32_hash_dev *hdev, struct ahash_request *req) { - return crypto_transfer_hash_request_to_engine(hdev->engine, req); + return crypto_transfer_request_to_engine(hdev->engine, &req->base); } static int stm32_hash_prepare_req(struct crypto_engine *engine, - struct ahash_request *req) + struct crypto_async_request *areq) { + struct ahash_request *req = ahash_request_cast(areq); struct stm32_hash_ctx *ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req)); struct stm32_hash_dev *hdev = stm32_hash_find_dev(ctx); struct stm32_hash_request_ctx *rctx; @@ -855,8 +862,9 @@ static int stm32_hash_prepare_req(struct crypto_engine *engine, } static int stm32_hash_one_request(struct crypto_engine *engine, - struct ahash_request *req) + struct crypto_async_request *areq) { + struct ahash_request *req = ahash_request_cast(areq); struct stm32_hash_ctx *ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req)); struct stm32_hash_dev *hdev = stm32_hash_find_dev(ctx); struct stm32_hash_request_ctx *rctx; @@ -1033,6 +1041,9 @@ static int stm32_hash_cra_init_algs(struct crypto_tfm *tfm, if (algs_hmac_name) ctx->flags |= HASH_FLAGS_HMAC; + ctx->enginectx.op.do_one_request = stm32_hash_one_request; + ctx->enginectx.op.prepare_request = stm32_hash_prepare_req; + ctx->enginectx.op.unprepare_request = NULL; return 0; } @@ -1493,9 +1504,6 @@ static int stm32_hash_probe(struct platform_device *pdev) goto err_engine; } - hdev->engine->prepare_hash_request = stm32_hash_prepare_req; - hdev->engine->hash_one_request = stm32_hash_one_request; - ret = crypto_engine_start(hdev->engine); if (ret) goto err_engine_start;