xref: /linux/arch/powerpc/include/asm/archrandom.h (revision 9592eef7c16ec5fb9f36c4d9abe8eeffc2e1d2f3)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_ARCHRANDOM_H
3 #define _ASM_POWERPC_ARCHRANDOM_H
4 
5 #include <asm/machdep.h>
6 
7 static inline bool __must_check arch_get_random_long(unsigned long *v)
8 {
9 	return false;
10 }
11 
12 static inline bool __must_check arch_get_random_int(unsigned int *v)
13 {
14 	return false;
15 }
16 
17 static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
18 {
19 	if (ppc_md.get_random_seed)
20 		return ppc_md.get_random_seed(v);
21 
22 	return false;
23 }
24 
25 static inline bool __must_check arch_get_random_seed_int(unsigned int *v)
26 {
27 	unsigned long val;
28 	bool rc;
29 
30 	rc = arch_get_random_seed_long(&val);
31 	if (rc)
32 		*v = val;
33 
34 	return rc;
35 }
36 
37 #ifdef CONFIG_PPC_POWERNV
38 int powernv_hwrng_present(void);
39 int powernv_get_random_long(unsigned long *v);
40 int powernv_get_random_real_mode(unsigned long *v);
41 #else
42 static inline int powernv_hwrng_present(void) { return 0; }
43 static inline int powernv_get_random_real_mode(unsigned long *v) { return 0; }
44 #endif
45 
46 #endif /* _ASM_POWERPC_ARCHRANDOM_H */
47