From patchwork Fri Jan 26 19:15:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 10186883 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 D2090601D5 for ; Fri, 26 Jan 2018 19:19:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3EA629679 for ; Fri, 26 Jan 2018 19:19:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7E0F297ED; Fri, 26 Jan 2018 19:19:27 +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 4478829679 for ; Fri, 26 Jan 2018 19:19:27 +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=IeHkrzM7pPe0WZx7XvZXaFqcAEr+PxflHpvpha0K2As=; b=Wg6aa5SLpBx6cpNNhVQw53nwNF SLoDXYh6WBqW2hTNxmb40GiGZsdOvpx9VIX/P8IMmKkMqKykFLkZkPm1+zzdT3tTQDXKIsgN0ujuz +EfhV9c208ZiOUmDSwh3nZHaum4MPLVYW5Aj8ZC3uHqcSn7dn51A/F5m+RzqdHuX9KabbuAhjW2nc KVo4QENo3g2TmkEoY2mCnQMh0Io71dJfRezr7P0S7ku05sqLpvkUcKJPPWDdkPrdFaGWv1M5b4x22 FNNSeMGItAf/J8JENreFT+O06AX7caKkw9ckV4TZL/gUn+HIKdeQV9ZoxQQTW4Rg0iv63vgVlQM4+ GlF2M4mQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ef9X2-00045s-Ae; Fri, 26 Jan 2018 19:19:24 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ef9W8-0002vY-JW for linux-arm-kernel@lists.infradead.org; Fri, 26 Jan 2018 19:18:30 +0000 Received: by mail-wm0-x242.google.com with SMTP id j21so27873838wmh.1 for ; Fri, 26 Jan 2018 11:18:18 -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=P5KF6P2/cZMkuK5sUjGP2amyeOTM4DtU6J2S3arn6ktkL18QtVcpHVVBSouQeWXXfI /SeWHLBWCQm7mMfmTqkZComuTeUZ40uljApxiW1IkH2z+pOf2JDTEiWvEPhPqNXP+yEa sBJ2KE2XMTTxN4pSnhxVayKSzIxEKR2fMhpcPtpTDOZaAh71WGwbxdcDlkGV8eeIFOtc 4eU5vWCYc7VB57Y+DHCcLFtyLw436f31+6w/wDGZI7BrM+Df1DEk5GANI0eDqnDXOUqv DPPP3kYjN3IY8mdM7laMd2AP5ZGeudK8RY8x0gy+NwtPwi/9iN8crKIeunmy1J+Xtc/s STBA== X-Gm-Message-State: AKwxytcosoe3izdrgshJFC15MBp5nJ65eteh9zZvV+e1PYDZR4Y/xgrU cEnuQIkAusJUjPOkjxciIkg= X-Google-Smtp-Source: AH8x224smuqD7Hty3uYwFgQKAaD1unD/PD8dqO+nD+5+RSoqLNzYA9S1HtT6YzSVRSsIdrYjyCbMoQ== 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 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> 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: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.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 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");