diff mbox series

random: pull add_hwgenerator_randomness() declaration into random.h

Message ID 20220213152522.816777-1-Jason@zx2c4.com
State New
Headers show
Series random: pull add_hwgenerator_randomness() declaration into random.h | expand

Commit Message

Jason A. Donenfeld Feb. 13, 2022, 3:25 p.m. UTC
add_hwgenerator_randomness() is a function implemented and documented
inside of random.c. It is the way that hardware RNGs push data into it.
Therefore, it should be declared in random.h. Otherwise sparse complains
with:

random.c:1137:6: warning: symbol 'add_hwgenerator_randomness' was not declared. Should it be static?

The alternative would be to include hw_random.h into random.c, but that
wouldn't really be good for anything except slowing down compile time.

Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org
Cc: Kalle Valo <kvalo@kernel.org>
Cc: ath9k-devel@qca.qualcomm.com
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 drivers/char/hw_random/core.c        | 1 +
 drivers/net/wireless/ath/ath9k/rng.c | 1 +
 include/linux/hw_random.h            | 2 --
 include/linux/random.h               | 2 ++
 4 files changed, 4 insertions(+), 2 deletions(-)


base-commit: 1b057ea07bdc88c5ab77cb9a9bc46f8690492c81
prerequisite-patch-id: 722401baa02ea28022621588a48b701d116c0ad5
prerequisite-patch-id: 8da951eeda7c2b69ccf9de465f6e33b6a32d1b8a
prerequisite-patch-id: b252828d4fa0211224b7cac57b7a40a26847caf3
prerequisite-patch-id: ac9dc6b642ecfd8d42394b06d7757e4076da3a35
prerequisite-patch-id: aecaed912a18486ea6743ef94d86683d6ce35320
prerequisite-patch-id: 74e4aea70835f508339e5223f1b01266698f1173
prerequisite-patch-id: c315d7e54165666dae309e3ac6d5e666c6c97a33
prerequisite-patch-id: 9b8f505cf7f6b605ba5143c801e3487149481cde
prerequisite-patch-id: 7e48a52a3947c9d0d73a9867a7a3fb403e0e18ff
prerequisite-patch-id: 6c5c60bf502f7691087241c32c3a898135783ea0
prerequisite-patch-id: 80b04855c1ec5315d175cda682f528dab5db13ca
prerequisite-patch-id: 00ec3b71c3fe248d55b00f1b210f029a221f295a
prerequisite-patch-id: bac900c80e57d5fd5234b81a51359a76b378a9e9
prerequisite-patch-id: d2c04ce2d5667557c6d863fb26ad046a16b86f7b
prerequisite-patch-id: 4d98a7945c6dce30c3630f4668aa4b32ca53c971
prerequisite-patch-id: bd93293024b6ad54ffaf1ae5bee3d805961e310d
prerequisite-patch-id: e17118e66c1761f954fac49822231986f429e996
prerequisite-patch-id: dca680875ff2a505bc35d8999fa18832d6cc378e
prerequisite-patch-id: 798e5c78bbc4c0e1748a64496e4b139b6d5c85bf
prerequisite-patch-id: d41dada11f57459add7e28d4a8714929b9ed07f8
prerequisite-patch-id: a3159bc3b25f67ab0fb409dfc86373e3b6c3bc5e
prerequisite-patch-id: 6d069efe964e32e90ac052183360f3b8e78fd6bd
prerequisite-patch-id: 56253c1e4f608de542e26e5201f476a6e33c0166
prerequisite-patch-id: 4cdc3b96e517592d6fdf493baaa49e032f0788c9
prerequisite-patch-id: 4a7abc91a7dc1f6fdfb6a1bf310e0aeffee284ec

Comments

Kalle Valo Feb. 14, 2022, 11:43 a.m. UTC | #1
"Jason A. Donenfeld" <Jason@zx2c4.com> writes:

> add_hwgenerator_randomness() is a function implemented and documented
> inside of random.c. It is the way that hardware RNGs push data into it.
> Therefore, it should be declared in random.h. Otherwise sparse complains
> with:
>
> random.c:1137:6: warning: symbol 'add_hwgenerator_randomness' was not declared. Should it be static?
>
> The alternative would be to include hw_random.h into random.c, but that
> wouldn't really be good for anything except slowing down compile time.
>
> Cc: Dominik Brodowski <linux@dominikbrodowski.net>
> Cc: Matt Mackall <mpm@selenic.com>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Cc: linux-crypto@vger.kernel.org
> Cc: Kalle Valo <kvalo@kernel.org>
> Cc: ath9k-devel@qca.qualcomm.com
> Cc: Theodore Ts'o <tytso@mit.edu>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
>  drivers/char/hw_random/core.c        | 1 +
>  drivers/net/wireless/ath/ath9k/rng.c | 1 +

For ath9k:

Acked-by: Kalle Valo <kvalo@kernel.org>
Jason A. Donenfeld Feb. 16, 2022, 11:43 a.m. UTC | #2
Hi Kalle,

In light of https://lore.kernel.org/lkml/20220216113323.53332-1-Jason@zx2c4.com/
I'm going to drop the ath9k part of this patch here (and your Ack
along with it), so that there's no chance of merge conflict. It turns
out that the header that this patch added isn't 100% required because
it includes "hw.h" which includes <linux/if_ether.h> which includes
<linux/skbuff.h> which includes <linux/net.h> which includes
<linux/random.h>. So at least if there are a few commits between my
change going in and the driver rewrite from that other patch, the
build won't break.

Jason
Herbert Xu Feb. 18, 2022, 4:27 a.m. UTC | #3
On Sun, Feb 13, 2022 at 04:25:22PM +0100, Jason A. Donenfeld wrote:
> add_hwgenerator_randomness() is a function implemented and documented
> inside of random.c. It is the way that hardware RNGs push data into it.
> Therefore, it should be declared in random.h. Otherwise sparse complains
> with:
> 
> random.c:1137:6: warning: symbol 'add_hwgenerator_randomness' was not declared. Should it be static?
> 
> The alternative would be to include hw_random.h into random.c, but that
> wouldn't really be good for anything except slowing down compile time.
> 
> Cc: Dominik Brodowski <linux@dominikbrodowski.net>
> Cc: Matt Mackall <mpm@selenic.com>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Cc: linux-crypto@vger.kernel.org
> Cc: Kalle Valo <kvalo@kernel.org>
> Cc: ath9k-devel@qca.qualcomm.com
> Cc: Theodore Ts'o <tytso@mit.edu>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
>  drivers/char/hw_random/core.c        | 1 +
>  drivers/net/wireless/ath/ath9k/rng.c | 1 +
>  include/linux/hw_random.h            | 2 --
>  include/linux/random.h               | 2 ++
>  4 files changed, 4 insertions(+), 2 deletions(-)

Acked-by: Herbert Xu <herbert@gondor.apana.org.au>

Thanks,
diff mbox series

Patch

diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index a3db27916256..cfb085de876b 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -15,6 +15,7 @@ 
 #include <linux/err.h>
 #include <linux/fs.h>
 #include <linux/hw_random.h>
+#include <linux/random.h>
 #include <linux/kernel.h>
 #include <linux/kthread.h>
 #include <linux/sched/signal.h>
diff --git a/drivers/net/wireless/ath/ath9k/rng.c b/drivers/net/wireless/ath/ath9k/rng.c
index f9d3d6eedd3c..aae2bd3cac69 100644
--- a/drivers/net/wireless/ath/ath9k/rng.c
+++ b/drivers/net/wireless/ath/ath9k/rng.c
@@ -15,6 +15,7 @@ 
  */
 
 #include <linux/hw_random.h>
+#include <linux/random.h>
 #include <linux/kthread.h>
 
 #include "ath9k.h"
diff --git a/include/linux/hw_random.h b/include/linux/hw_random.h
index 1a9fc38f8938..aa1d4da03538 100644
--- a/include/linux/hw_random.h
+++ b/include/linux/hw_random.h
@@ -60,7 +60,5 @@  extern int devm_hwrng_register(struct device *dev, struct hwrng *rng);
 /** Unregister a Hardware Random Number Generator driver. */
 extern void hwrng_unregister(struct hwrng *rng);
 extern void devm_hwrng_unregister(struct device *dve, struct hwrng *rng);
-/** Feed random bits into the pool. */
-extern void add_hwgenerator_randomness(const void *buffer, size_t count, size_t entropy);
 
 #endif /* LINUX_HWRANDOM_H_ */
diff --git a/include/linux/random.h b/include/linux/random.h
index 37e1e8c43d7e..d7354de9351e 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -32,6 +32,8 @@  static inline void add_latent_entropy(void) {}
 extern void add_input_randomness(unsigned int type, unsigned int code,
 				 unsigned int value) __latent_entropy;
 extern void add_interrupt_randomness(int irq) __latent_entropy;
+extern void add_hwgenerator_randomness(const void *buffer, size_t count,
+				       size_t entropy);
 
 extern void get_random_bytes(void *buf, size_t nbytes);
 extern int wait_for_random_bytes(void);