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: 10081639 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AA21E602BC for ; Wed, 29 Nov 2017 08:58:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B970295E9 for ; Wed, 29 Nov 2017 08:58:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F9DD29656; Wed, 29 Nov 2017 08:58:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3B4D0295E9 for ; Wed, 29 Nov 2017 08:58:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=jb++Jy4MGtFMMVt0mshi/AXC5ER6nmSLYl89DhTwHLA=; b=Bk2XPurxQNe47og2emXfrrHSGn 0qZFxop39p+c0bIq2g+qapAr4VzJ5ukL5HldDDFSmQifW9w00CH1AIno3dlzD75Xc87/HHUaifcrq IEtI/vFJm/YmutVKV+jzHjZENsvh6WuF5ejf2pXxHOAXpoVVgxEaz50aVxgOuxvmcrS1+IfBUzxFE MsYz8bsok5L2KHjYgBBPdhej7FemZ1FpEgYDst8cAZZYWs0la3czwezYG3acja9gJ5pb5ZicYOqsW 4jX7lfqoZG1JEgUdHcVB403M+K+b0OEsTAkmJdmHxeGa10I9h7s2MCZ7Y7CzIZHzzDbeltCYgMjFV vOSP5GDg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eJyCY-0005b3-TB; Wed, 29 Nov 2017 08:58:42 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eJxyW-0005ew-6n for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2017 08:44:14 +0000 Received: by mail-wr0-x242.google.com with SMTP id o2so2620385wro.5 for ; 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=ejb2eRRauTO8AlW/8J0sHJDbFBNnuEeWuo4BhfrCFBIelMerMBfXzrIghxW259yOWK xWyVujk4S1CKBPvV8RWYVrqosBO4oZUZRThnvlJM3al6WNIILLPa9pQEqwC/HccP+SKT R3SZOr4D05hAFjEvGNrGsAXqKIsFmWsjRjV5eFVJhzQ0IR7O57KbGFii3EgNHC7hW3/q 0T+etXLZJTv3n8wF0b01xI3VB4aRkjBBUScuvvV7QgOkYy5zSIsaC/wo0KNHrFPsDt0f sVprCLGQ+bcTVq2SFaxPgp9A4arGj3En7BqzsK9iGRFVul/lUkOwe6tDyj97FVqig00A mLxg== X-Gm-Message-State: AJaThX42tqxk0pgejO1ckX5/W9oqnwpU2/1feMCTwuiqMgZjgUKr5pyM MeM9UUF0d2VvagAy+JR1QbQ= X-Google-Smtp-Source: AGs4zMblxlW7EzOXbcf77RQTuKLoLm03YctJt9X18S6f+03bylzBCoDsFMFFLq62K9oWjqu7WRHMww== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171129_004412_405068_28A12C0E X-CRM114-Status: GOOD ( 13.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: virtualization@lists.linux-foundation.org, Corentin Labbe , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch convert the driver to the new crypto engine API. Signed-off-by: Corentin Labbe Tested-by: Fabien Dessenne --- drivers/crypto/stm32/stm32-hash.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) 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;