Skip to content

Commit e561e47

Browse files
zx2c4mpe
authored andcommitted
powerpc/pseries: wire up rng during setup_arch()
The platform's RNG must be available before random_init() in order to be useful for initial seeding, which in turn means that it needs to be called from setup_arch(), rather than from an init call. Fortunately, each platform already has a setup_arch function pointer, which means it's easy to wire this up. This commit also removes some noisy log messages that don't add much. Fixes: a489043 ("powerpc/pseries: Implement arch_get_random_long() based on H_RANDOM") Cc: [email protected] # v3.13+ Signed-off-by: Jason A. Donenfeld <[email protected]> Reviewed-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 20a9689 commit e561e47

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

arch/powerpc/platforms/pseries/pseries.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,6 @@ void pseries_lpar_read_hblkrm_characteristics(void);
122122
static inline void pseries_lpar_read_hblkrm_characteristics(void) { }
123123
#endif
124124

125+
void pseries_rng_init(void);
126+
125127
#endif /* _PSERIES_PSERIES_H */

arch/powerpc/platforms/pseries/rng.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <asm/archrandom.h>
1111
#include <asm/machdep.h>
1212
#include <asm/plpar_wrappers.h>
13+
#include "pseries.h"
1314

1415

1516
static int pseries_get_random_long(unsigned long *v)
@@ -24,19 +25,13 @@ static int pseries_get_random_long(unsigned long *v)
2425
return 0;
2526
}
2627

27-
static __init int rng_init(void)
28+
void __init pseries_rng_init(void)
2829
{
2930
struct device_node *dn;
3031

3132
dn = of_find_compatible_node(NULL, NULL, "ibm,random");
3233
if (!dn)
33-
return -ENODEV;
34-
35-
pr_info("Registering arch random hook.\n");
36-
34+
return;
3735
ppc_md.get_random_seed = pseries_get_random_long;
38-
3936
of_node_put(dn);
40-
return 0;
4137
}
42-
machine_subsys_initcall(pseries, rng_init);

arch/powerpc/platforms/pseries/setup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@ static void __init pSeries_setup_arch(void)
839839
}
840840

841841
ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
842+
pseries_rng_init();
842843
}
843844

844845
static void pseries_panic(char *str)

0 commit comments

Comments
 (0)