From patchwork Mon Aug 14 13:17:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 9898941 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 E729C60230 for ; Mon, 14 Aug 2017 13:20:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9F3328606 for ; Mon, 14 Aug 2017 13:20:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEE8928617; Mon, 14 Aug 2017 13:20:15 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B37DF28606 for ; Mon, 14 Aug 2017 13:20:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751977AbdHNNUC (ORCPT ); Mon, 14 Aug 2017 09:20:02 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:33599 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751313AbdHNNTi (ORCPT ); Mon, 14 Aug 2017 09:19:38 -0400 Received: by mail-wr0-f194.google.com with SMTP id y41so2084543wrd.0; Mon, 14 Aug 2017 06:19:37 -0700 (PDT) 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=A1QNco9Cb8/kiZ8L3i4xa+s/c//j4iGVvLndxkP5PlA=; b=HKeNyuVuyuzn9gstgXOvXEi2Z59fq+gGp0XelqUPp8tHd2CidOWxfWggrC4G9rP+MV XmHIxFjrP3uN2erzxsqxlZYnELsCCdrGCXu7k5vVvmZa/6rn6cF6nkGgXTh/Mavh01hh RN8CSjpLmRA5Tl2h77pAok9DKRlADp0gfXsus+XWhoXEEM7ojVi+frmCZT3tF3XDiZ4M r/eQPVTvJlxzaVkNGUjDdVt42N8BCw7cY1dbDjmqb/a4OyNbFDtCcKfvJnaTdJGjvaiG K6JeVMjE/s4HotRrgLCOMTtP77qw3cigF2WNvk39V38KNBjyWo0KzaAvBjKC3R8TYhiq Gyzw== 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=A1QNco9Cb8/kiZ8L3i4xa+s/c//j4iGVvLndxkP5PlA=; b=hV+S5Tv8+21QbhRu/XNYNdnmPuYUzjjd7s/0S4fdCecOrziV3cuILXFDnS5WTtZGSM lfT7Nz41x7PfZZ7l4DnoOlBCEjf4jTF9NLKpvtMOSRJkBNFEaP1a9vO+7T/TCEX6DHOJ mS/hEQaxSnRao1zkPGfxs5suJIkkOLQ0VlOyk058oHrjUCidSoTaiBS5+7+YwsonV8DF ZK9FYQl6pZyW0ZWmXYEo39HTr3xhpowbGSTBJdXAybrpGbMRu1zkgXTt1IeTB9ekrkHo jjnugPgdLoAlXS4ifIr8RPO9xS71VHPJgf2p/fzLfPM+M00gHPlGSEjM/bQwqxmcmi5C Csaw== X-Gm-Message-State: AHYfb5iDkYqSr7RxzI7CWtipzmIFBp9HIGCCbg+LPxC7f8FuA0y+URwW gEcThaxJhqXM7A== X-Received: by 10.223.153.195 with SMTP id y61mr1232787wrb.41.1502716777072; Mon, 14 Aug 2017 06:19:37 -0700 (PDT) Received: from Red.local (LFbn-1-7109-228.w90-116.abo.wanadoo.fr. [90.116.45.228]) by smtp.googlemail.com with ESMTPSA id x14sm13386675wmd.19.2017.08.14.06.19.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Aug 2017 06:19:36 -0700 (PDT) From: Corentin Labbe To: herbert@gondor.apana.org.au, davem@davemloft.net Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Corentin Labbe Subject: [PATCH 2/3] crypto: engine - find request type with cra_type Date: Mon, 14 Aug 2017 15:17:24 +0200 Message-Id: <20170814131725.9402-3-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170814131725.9402-1-clabbe.montjoie@gmail.com> References: <20170814131725.9402-1-clabbe.montjoie@gmail.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current method for finding request type is based on crypto_tfm_alg_type. But in case of skcipher, it is the same than ablkcipher. Using cra_type for this work permits to make the distinction between the two. Signed-off-by: Corentin Labbe --- crypto/crypto_engine.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index 61e7c4e02fd2..74b840749074 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -38,7 +38,8 @@ static void crypto_pump_requests(struct crypto_engine *engine, struct ablkcipher_request *breq; unsigned long flags; bool was_busy = false; - int ret, rtype; + int ret; + const struct crypto_type *cratype; spin_lock_irqsave(&engine->queue_lock, flags); @@ -94,7 +95,7 @@ static void crypto_pump_requests(struct crypto_engine *engine, spin_unlock_irqrestore(&engine->queue_lock, flags); - rtype = crypto_tfm_alg_type(engine->cur_req->tfm); + cratype = engine->cur_req->tfm->__crt_alg->cra_type; /* Until here we get the request need to be encrypted successfully */ if (!was_busy && engine->prepare_crypt_hardware) { ret = engine->prepare_crypt_hardware(engine); @@ -104,8 +105,7 @@ static void crypto_pump_requests(struct crypto_engine *engine, } } - switch (rtype) { - case CRYPTO_ALG_TYPE_AHASH: + if (cratype == &crypto_ahash_type) { hreq = ahash_request_cast(engine->cur_req); if (engine->prepare_hash_request) { ret = engine->prepare_hash_request(engine, hreq); @@ -122,7 +122,7 @@ static void crypto_pump_requests(struct crypto_engine *engine, goto req_err; } return; - case CRYPTO_ALG_TYPE_ABLKCIPHER: + } else if (cratype == &crypto_ablkcipher_type) { breq = ablkcipher_request_cast(engine->cur_req); if (engine->prepare_cipher_request) { ret = engine->prepare_cipher_request(engine, breq); @@ -139,21 +139,18 @@ static void crypto_pump_requests(struct crypto_engine *engine, goto req_err; } return; - default: + } else { dev_err(engine->dev, "failed to prepare request of unknown type\n"); return; } req_err: - switch (rtype) { - case CRYPTO_ALG_TYPE_AHASH: + if (cratype == &crypto_ahash_type) { hreq = ahash_request_cast(engine->cur_req); crypto_finalize_hash_request(engine, hreq, ret); - break; - case CRYPTO_ALG_TYPE_ABLKCIPHER: + } else if (cratype == &crypto_ablkcipher_type) { breq = ablkcipher_request_cast(engine->cur_req); crypto_finalize_cipher_request(engine, breq, ret); - break; } return;