crypto: Move akcipher_request_cast helper to crypto header
Subsystems (4)
PATCH 1/1 crypto: Move akcipher_request_cast helper to crypto header
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.
--- 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(-)
drivers/crypto/aspeed/aspeed-acry.c +0 -6
@@ -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);
drivers/crypto/ccp/ccp-crypto-rsa.c +0 -6
@@ -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) {
include/crypto/akcipher.h +7 -0
@@ -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
Signature · 1 line
2.41.0
Quoted 11 lines
-----Original Message-----
From: Corentin Labbe <[email protected]>
Sent: Monday, October 2, 2023 4:14 AM
To: andrew at aj.id.au; davem at davemloft.net; herbert at gondor.apana.org.au; joel at jms.id.au; john.allen at amd.com; Neal Liu <[email protected]>; thomas.lendacky at amd.com
Cc: linux-arm-kernel at lists.infradead.org; linux-aspeed at lists.ozlabs.org; linux-crypto at vger.kernel.org; linux-kernel at vger.kernel.org; Corentin Labbe <[email protected]>
Subject: [PATCH] crypto: Moveakcipher_request_casthelper to crypto header
Quoted 6 lines
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 <[email protected]>
Thanks.
Quoted 56 lines
--- 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(-)drivers/crypto/aspeed/aspeed-acry.c +0
-6@@ -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.cb/drivers/crypto/ccp/ccp-crypto-rsa.cindexa14f85512cf4..32c9f524f3d5100644drivers/crypto/ccp/ccp-crypto-rsa.c +0
-6@@ -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) {include/crypto/akcipher.h index renamed from include/crypto/akcipher.h +0
-0
670508f1dca1..4b6e610db18d100644include/crypto/akcipher.h +5
-1@@ -498,4 +498,11 @@ static inline int crypto_akcipher_set_priv_key(structcrypto_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 --2.41.0
Quoted 6 lines · Corentin Labbe
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 <[email protected]>
Minor style question below...
Quoted 45 lines
--- 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(-)drivers/crypto/aspeed/aspeed-acry.c +0
-6@@ -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);drivers/crypto/ccp/ccp-crypto-rsa.c +0
-6@@ -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) {include/crypto/akcipher.h +0
-0
include/crypto/akcipher.h static inline int crypto_akcipher_set_priv_key(struct crypto_akcipher *tfm, · line 503
Quoted 6 lines
include/crypto/akcipher.h +3
-0@@ -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)
Should this really be indented since it is the function name? I would think it should look like:
static inline struct akcipher_request * akcipher_request_cast(struct crypto_async_request *req) {
Thanks,
Tom
Quoted 5 lines
include/crypto/akcipher.h +4
-0+{ + return container_of(req, struct akcipher_request, base); +} +#endif
Herbert Xu
maintainerQuoted 6 lines · Corentin Labbe
include/crypto/akcipher.h +0
-0
include/crypto/akcipher.h static inline int crypto_akcipher_set_priv_key(struct crypto_akcipher *tfm, · line 506
Quoted 9 lines
include/crypto/akcipher.h +6
-0@@ -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); +}
Please move this to include/crypto/internal/akcipher.h.
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt