random32: move the pseudo-random 32-bit definitions to prandom.h
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 31 Jul 2020 05:51:14 +0000 (07:51 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 4 Aug 2020 06:24:26 +0000 (23:24 -0700)
commitc0842fbc1b18c7a044e6ff3e8fa78bfa822c7d1a
treeeb5d564bf982b85cfdc077a50202883ed3baee7f
parent2baa85d6927d11b8d946da2e4ad00dddca5b8da2
random32: move the pseudo-random 32-bit definitions to prandom.h

The addition of percpu.h to the list of includes in random.h revealed
some circular dependencies on arm64 and possibly other platforms.  This
include was added solely for the pseudo-random definitions, which have
nothing to do with the rest of the definitions in this file but are
still there for legacy reasons.

This patch moves the pseudo-random parts to linux/prandom.h and the
percpu.h include with it, which is now guarded by _LINUX_PRANDOM_H and
protected against recursive inclusion.

A further cleanup step would be to remove this from <linux/random.h>
entirely, and make people who use the prandom infrastructure include
just the new header file.  That's a bit of a churn patch, but grepping
for "prandom_" and "next_pseudo_random32" "struct rnd_state" should
catch most users.

But it turns out that that nice cleanup step is fairly painful, because
a _lot_ of code currently seems to depend on the implicit include of
<linux/random.h>, which can currently come in a lot of ways, including
such fairly core headfers as <linux/net.h>.

So the "nice cleanup" part may or may never happen.

Fixes: 1c9df907da83 ("random: fix circular include dependency on arm64 after addition of percpu.h")
Tested-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/prandom.h [new file with mode: 0644]
include/linux/random.h