Skip to content

Commit 20a9689

Browse files
zx2c4mpe
authored andcommitted
powerpc/microwatt: 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: c25769f ("powerpc/microwatt: Add support for hardware random number generator") Cc: [email protected] # v5.14+ 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 6cf06c1 commit 20a9689

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _MICROWATT_H
3+
#define _MICROWATT_H
4+
5+
void microwatt_rng_init(void);
6+
7+
#endif /* _MICROWATT_H */

arch/powerpc/platforms/microwatt/rng.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <asm/archrandom.h>
1212
#include <asm/cputable.h>
1313
#include <asm/machdep.h>
14+
#include "microwatt.h"
1415

1516
#define DARN_ERR 0xFFFFFFFFFFFFFFFFul
1617

@@ -29,20 +30,15 @@ static int microwatt_get_random_darn(unsigned long *v)
2930
return 1;
3031
}
3132

32-
static __init int rng_init(void)
33+
void __init microwatt_rng_init(void)
3334
{
3435
unsigned long val;
3536
int i;
3637

3738
for (i = 0; i < 10; i++) {
3839
if (microwatt_get_random_darn(&val)) {
3940
ppc_md.get_random_seed = microwatt_get_random_darn;
40-
return 0;
41+
return;
4142
}
4243
}
43-
44-
pr_warn("Unable to use DARN for get_random_seed()\n");
45-
46-
return -EIO;
4744
}
48-
machine_subsys_initcall(, rng_init);

arch/powerpc/platforms/microwatt/setup.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <asm/xics.h>
1717
#include <asm/udbg.h>
1818

19+
#include "microwatt.h"
20+
1921
static void __init microwatt_init_IRQ(void)
2022
{
2123
xics_init();
@@ -32,10 +34,16 @@ static int __init microwatt_populate(void)
3234
}
3335
machine_arch_initcall(microwatt, microwatt_populate);
3436

37+
static void __init microwatt_setup_arch(void)
38+
{
39+
microwatt_rng_init();
40+
}
41+
3542
define_machine(microwatt) {
3643
.name = "microwatt",
3744
.probe = microwatt_probe,
3845
.init_IRQ = microwatt_init_IRQ,
46+
.setup_arch = microwatt_setup_arch,
3947
.progress = udbg_progress,
4048
.calibrate_decr = generic_calibrate_decr,
4149
};

0 commit comments

Comments
 (0)