From patchwork Sun Oct 1 20:13:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin LABBE X-Patchwork-Id: 147189 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1181807vqb; Sun, 1 Oct 2023 21:06:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcgWH6IVJo8AIvPCxGr7sK9RMalDjWN+Ms0v+fzgQGAPmjWbiqPsufb4Q2UBXjN7QgSDSx X-Received: by 2002:a67:f80e:0:b0:44e:d6c3:51d4 with SMTP id l14-20020a67f80e000000b0044ed6c351d4mr7195798vso.18.1696219603813; Sun, 01 Oct 2023 21:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696219603; cv=none; d=google.com; s=arc-20160816; b=aNhfiRigOtGn1IC8x94v1xwE5Kqc+kv4q0MRrtSjHmRhgyUh5Ted8TnwJG2xb+NAzf PGZEl5Z0//G5Ps6bZDVp4gmobZIzHAvHdVfhEJ2nBLr4rXRYA5PcB9Nhs9dn6M6fH7TD guZQBzGRJnDupifiDF0Ar29v1q8wleRAnHn1mscWMdyv29KerSOXCHu7dQPZXWByi0Y6 DU3HPFeCDG6oqB+kYOC3yTknlV0qD5KwHv+CaxwkzAKDmH/xczjjAtSwiTA9teOb8PRg KKex1++5YKqSypHdJ2zWljiIeasll9G2OejvvF7IjAKAIkTk2WvUA41B4FvbjxDgRhh5 yHyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=S5gdKKBRI8HMjzMvfQFYDp6loku3qgrG9OQcfyEaG8Y=; fh=KceVNXvzI0OqVSX6huLPHayQNsRj6iF9yN5TaVnnl64=; b=IoqbbLAP4JklpI7JIFTwFJwVtkl/LPuYxdvqcgFsNEBWYt/ZpUNUX3AJjoikbHOKMO D/gGgN9xzjzlAF8uIDr4AvMeWLR33HdUC0VNU/YrbHf3DwZXgRjoHUyKklrKs3gNdHJa Bpxu0r2Zth17mDyshz4hIZlpvaXLFCj17B63jXv2HVVIsKEv+v1jkUvRXxqSlXqwDWDx yMQQTgTnutFhTVDOkIqPhXIOWTPScI1/10o76VvlGC1eU2VtOB1z3eQ7gO2hyGYW1V6G QfA/culQEQ0CTLl4Qst853CecvpKp2E+TBXs1aKsiC9WVoAS3keDQwkvHdiU45jrcZ0g eRag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=ENJDV8FQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id u191-20020a6385c8000000b005774978dd75si7069619pgd.175.2023.10.01.21.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 21:06:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=ENJDV8FQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 383C48089853; Sun, 1 Oct 2023 13:21:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235368AbjJAUOL (ORCPT + 18 others); Sun, 1 Oct 2023 16:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235346AbjJAUOJ (ORCPT ); Sun, 1 Oct 2023 16:14:09 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 344B0D3 for ; Sun, 1 Oct 2023 13:14:06 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-32799639a2aso936198f8f.3 for ; Sun, 01 Oct 2023 13:14:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1696191244; x=1696796044; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=S5gdKKBRI8HMjzMvfQFYDp6loku3qgrG9OQcfyEaG8Y=; b=ENJDV8FQI78y78EglS69TxeGxUl/zickH6M2Iw6RqqbDpzVNH7ywqOc5FryAzAQdfo ZuP6zHwaHwnf9HCfsz5CXh+tLxz8PoFvscwLEhbefPx5QVjoqX1KmXP9n66dKz6ryxYH tCBDYgkx/1R4SI9HKVh7zok8NHyvmXXBhttmuKc2StwabPKDrwAu4t+zMA+MnSGPHcbN /FDW1HCcs3EItuOQZMIUejk/TFYTXVC8XTMOe2/xCNarO96Cby/kcjhqiFRQAIUG3o/m aLACJyFofk8zJxiqT66akr6qKK844hmkDnJtn3RluPm/n3jIbt6JmDgtmIkfKdkxSSMo VLTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696191244; x=1696796044; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S5gdKKBRI8HMjzMvfQFYDp6loku3qgrG9OQcfyEaG8Y=; b=ipMb1OlVwwCBhwdZ57E/doAEuVM3MGbvESODCv9t+Zuflcszo1weXNq7GYWi3R5l0u b3YhdWz0okZ92ni3aQMwXQt8VVo86LOvG9cLnKvHiCPkQs4jx7GkjAaE1+9vX0vvU7j/ DIF62JoGvTeA4XJNw/VAkcCqfJ05K7J6ebhK+ngczbiNRmqTtYqxhV8SryEBftWbFZAp dGq6l2orEMtCUahNR579qr+k5VsHH1cBD1H+ImCkKVqtftrvN+1Q/wI8O1lGbFCh1LnX PIxV/owjkgxauyIW0cX9ROUdfaSRSv1ZZkyQCCqFUVjIbg+esvcNuN6ggN5G6MLrlpbR dWrg== X-Gm-Message-State: AOJu0YzgA8y9srz5JLyX7f9f6qFTMXU4GAVLANrIzPqBaQXCYyHw+WDb h+Ool6n44/Hq98EkasmFoztd6Q== X-Received: by 2002:a5d:63cb:0:b0:319:6e3f:d5f0 with SMTP id c11-20020a5d63cb000000b003196e3fd5f0mr9162433wrw.44.1696191244674; Sun, 01 Oct 2023 13:14:04 -0700 (PDT) Received: from arnold.baylibre (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id j6-20020a5d6046000000b003259b068ba6sm6141665wrt.7.2023.10.01.13.14.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 13:14:03 -0700 (PDT) From: Corentin Labbe To: andrew@aj.id.au, davem@davemloft.net, herbert@gondor.apana.org.au, joel@jms.id.au, john.allen@amd.com, neal_liu@aspeedtech.com, thomas.lendacky@amd.com Cc: linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Corentin Labbe Subject: [PATCH] crypto: Move akcipher_request_cast helper to crypto header Date: Sun, 1 Oct 2023 20:13:57 +0000 Message-Id: <20231001201357.2052949-1-clabbe@baylibre.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 01 Oct 2023 13:21:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778615167401338340 X-GMAIL-MSGID: 1778615167401338340 There is already 2 driver implementing their own akcipher_request_cast. In the future there will be also rockchip and allwinner driver that will need this. This is sufficient to move it in crypto headers. Signed-off-by: Corentin Labbe Reviewed-by: Neal Liu Acked-by: Tom Lendacky --- drivers/crypto/aspeed/aspeed-acry.c | 6 ------ drivers/crypto/ccp/ccp-crypto-rsa.c | 6 ------ include/crypto/akcipher.h | 7 +++++++ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/crypto/aspeed/aspeed-acry.c b/drivers/crypto/aspeed/aspeed-acry.c index 247c568aa8df..ecb6e984367b 100644 --- a/drivers/crypto/aspeed/aspeed-acry.c +++ b/drivers/crypto/aspeed/aspeed-acry.c @@ -137,12 +137,6 @@ enum aspeed_rsa_key_mode { ASPEED_RSA_DATA_MODE, }; -static inline struct akcipher_request * - akcipher_request_cast(struct crypto_async_request *req) -{ - return container_of(req, struct akcipher_request, base); -} - static int aspeed_acry_do_fallback(struct akcipher_request *req) { struct crypto_akcipher *cipher = crypto_akcipher_reqtfm(req); diff --git a/drivers/crypto/ccp/ccp-crypto-rsa.c b/drivers/crypto/ccp/ccp-crypto-rsa.c index a14f85512cf4..32c9f524f3d5 100644 --- a/drivers/crypto/ccp/ccp-crypto-rsa.c +++ b/drivers/crypto/ccp/ccp-crypto-rsa.c @@ -19,12 +19,6 @@ #include "ccp-crypto.h" -static inline struct akcipher_request *akcipher_request_cast( - struct crypto_async_request *req) -{ - return container_of(req, struct akcipher_request, base); -} - static inline int ccp_copy_and_save_keypart(u8 **kpbuf, unsigned int *kplen, const u8 *buf, size_t sz) { diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h index 670508f1dca1..4b6e610db18d 100644 --- a/include/crypto/akcipher.h +++ b/include/crypto/akcipher.h @@ -498,4 +498,11 @@ static inline int crypto_akcipher_set_priv_key(struct crypto_akcipher *tfm, return alg->set_priv_key(tfm, key, keylen); } + +static inline struct akcipher_request * + akcipher_request_cast(struct crypto_async_request *req) +{ + return container_of(req, struct akcipher_request, base); +} + #endif