Skip to contentSkip to conversation

crypto: Replace kernel.h with the necessary inclusions

PATCH Superseded Andy Shevchenko 3 participants 5 messages Dec 10, 2021 – Dec 17, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: Replace kernel.h with the necessary inclusions

When kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.

Replace kernel.h inclusion with the list of what is really being used.

---
 include/crypto/aead.h        | 4 +++-
 include/crypto/algapi.h      | 5 ++++-
 include/crypto/blake2b.h     | 1 -
 include/crypto/blake2s.h     | 2 +-
 include/crypto/cryptd.h      | 3 ++-
 include/crypto/engine.h      | 6 +++++-
 include/crypto/pcrypt.h      | 2 +-
 include/crypto/scatterwalk.h | 3 ++-
 include/crypto/skcipher.h    | 6 +++++-
 9 files changed, 23 insertions(+), 9 deletions(-)
include/crypto/aead.h +3 -1
index 5af914c1ab8e..14db3bee0519 100644
@@ -8,9 +8,10 @@
 #ifndef _CRYPTO_AEAD_H
 #define _CRYPTO_AEAD_H
 
+#include <linux/container_of.h>
 #include <linux/crypto.h>
-#include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/types.h>
 
 /**
  * DOC: Authenticated Encryption With Associated Data (AEAD) Cipher API
@@ -73,6 +74,7 @@
  */
 
 struct crypto_aead;
+struct scatterlist;
 
 /**
  *	struct aead_request - AEAD request
include/crypto/algapi.h +4 -1
index 5f6841c73e5a..f76ec723ceae 100644
@@ -7,9 +7,11 @@
 #ifndef _CRYPTO_ALGAPI_H
 #define _CRYPTO_ALGAPI_H
 
+#include <linux/align.h>
 #include <linux/crypto.h>
+#include <linux/kconfig.h>
 #include <linux/list.h>
-#include <linux/kernel.h>
+#include <linux/types.h>
 
 /*
  * Maximum values for blocksize and alignmask, used to allocate
@@ -24,6 +26,7 @@
 struct crypto_aead;
 struct crypto_instance;
 struct module;
+struct notifier_block;
 struct rtattr;
 struct seq_file;
 struct sk_buff;
include/crypto/blake2b.h +0 -1
index 18875f16f8ca..0c0176285349 100644
@@ -5,7 +5,6 @@
 
 #include <linux/bug.h>
 #include <linux/types.h>
-#include <linux/kernel.h>
 #include <linux/string.h>
 
 enum blake2b_lengths {
include/crypto/blake2s.h +1 -1
index bc3fb59442ce..df3c6c2f9553 100644
@@ -7,8 +7,8 @@
 #define _CRYPTO_BLAKE2S_H
 
 #include <linux/bug.h>
+#include <linux/kconfig.h>
 #include <linux/types.h>
-#include <linux/kernel.h>
 #include <linux/string.h>
 
 enum blake2s_lengths {
include/crypto/cryptd.h +2 -1
index 23169f4d87e6..796d986e58e1 100644
@@ -13,7 +13,8 @@
 #ifndef _CRYPTO_CRYPT_H
 #define _CRYPTO_CRYPT_H
 
-#include <linux/kernel.h>
+#include <linux/types.h>
+
 #include <crypto/aead.h>
 #include <crypto/hash.h>
 #include <crypto/skcipher.h>
include/crypto/engine.h +5 -1
index fd4f2fa23f51..ae133e98d813 100644
@@ -9,8 +9,10 @@
 
 #include <linux/crypto.h>
 #include <linux/list.h>
-#include <linux/kernel.h>
 #include <linux/kthread.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
+
 #include <crypto/algapi.h>
 #include <crypto/aead.h>
 #include <crypto/akcipher.h>
@@ -18,6 +20,8 @@
 #include <crypto/skcipher.h>
 #include <crypto/kpp.h>
 
+struct device;
+
 #define ENGINE_NAME_LEN	30
 /*
  * struct crypto_engine - crypto hardware engine
include/crypto/pcrypt.h +1 -1
index b9bc3436196a..234d7cf3cf5e 100644
@@ -9,8 +9,8 @@
 #ifndef _CRYPTO_PCRYPT_H
 #define _CRYPTO_PCRYPT_H
 
+#include <linux/container_of.h>
 #include <linux/crypto.h>
-#include <linux/kernel.h>
 #include <linux/padata.h>
 
 struct pcrypt_request {
include/crypto/scatterwalk.h +2 -1
index 7af08174a721..6407b4b61350 100644
@@ -12,8 +12,9 @@
 #define _CRYPTO_SCATTERWALK_H
 
 #include <crypto/algapi.h>
+
 #include <linux/highmem.h>
-#include <linux/kernel.h>
+#include <linux/mm.h>
 #include <linux/scatterlist.h>
 
 static inline void scatterwalk_crypto_chain(struct scatterlist *head,
include/crypto/skcipher.h +5 -1
index ef0fc9ed4342..39f5b67c3069 100644
@@ -8,9 +8,13 @@
 #ifndef _CRYPTO_SKCIPHER_H
 #define _CRYPTO_SKCIPHER_H
 
+#include <linux/container_of.h>
 #include <linux/crypto.h>
-#include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/types.h>
+
+struct scatterlist;
 
 /**
  *	struct skcipher_request - Symmetric key cipher request
Signature · 1 line
2.33.0
#1 lore raw
Quoted 4 lines · Andy Shevchenko

When kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.

Replace kernel.h inclusion with the list of what is really being used.

Any comments on this?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 9 lines · Andy Shevchenko
Quoted 4 lines · Andy Shevchenko

When kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.

Replace kernel.h inclusion with the list of what is really being used.

Any comments on this?

I am not crazy about the need for forward declarations of struct scatterlist and struct device. Other than that, I think this is an improvement

maintainer
#3 lore raw
In reply to Andy Shevchenko
Quoted 7 lines · Andy Shevchenko
Quoted 4 lines · Andy Shevchenko

When kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.

Replace kernel.h inclusion with the list of what is really being used.

Any comments on this?

I'm happy with this patch and will be applying it.

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
maintainer
#4 lore raw
In reply to Andy Shevchenko
Quoted 6 lines · Andy Shevchenko

When kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.

Replace kernel.h inclusion with the list of what is really being used.

Quoted 11 lines
---
 include/crypto/aead.h        | 4 +++-
 include/crypto/algapi.h      | 5 ++++-
 include/crypto/blake2b.h     | 1 -
 include/crypto/blake2s.h     | 2 +-
 include/crypto/cryptd.h      | 3 ++-
 include/crypto/engine.h      | 6 +++++-
 include/crypto/pcrypt.h      | 2 +-
 include/crypto/scatterwalk.h | 3 ++-
 include/crypto/skcipher.h    | 6 +++++-
 9 files changed, 23 insertions(+), 9 deletions(-)

Patch applied. 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