Message ID | 20231001201357.2052949-1-clabbe@baylibre.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Herbert Xu |
Headers | show |
Series | crypto: Move akcipher_request_cast helper to crypto header | expand |
> -----Original Message----- > From: Corentin Labbe <clabbe@baylibre.com> > Sent: Monday, October 2, 2023 4:14 AM > To: andrew@aj.id.au; davem@davemloft.net; herbert@gondor.apana.org.au; > joel@jms.id.au; john.allen@amd.com; Neal Liu <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 > <clabbe@baylibre.com> > Subject: [PATCH] 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. > > Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Reviewed-by: Neal Liu <neal_liu@aspeedtech.com> Thanks. > --- > 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 > -- > 2.41.0
On 10/1/23 15:13, Corentin Labbe wrote: > 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 <clabbe@baylibre.com> Acked-by: Tom Lendacky <thomas.lendacky@amd.com> Minor style question below... > --- > 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) 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 > +{ > + return container_of(req, struct akcipher_request, base); > +} > + > #endif
On Sun, Oct 01, 2023 at 08:13:57PM +0000, Corentin Labbe wrote: > > 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); > +} Please move this to include/crypto/internal/akcipher.h. Thanks,
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
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 <clabbe@baylibre.com> --- 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(-)