WIP FPC-III support
[linux/fpc-iii.git] / arch / s390 / include / asm / archrandom.h
blob5dc712fde3c7f078ca4d26910cd9ff3b130964d7
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Kernel interface for the s390 arch_random_* functions
5 * Copyright IBM Corp. 2017, 2020
7 * Author: Harald Freudenberger <freude@de.ibm.com>
9 */
11 #ifndef _ASM_S390_ARCHRANDOM_H
12 #define _ASM_S390_ARCHRANDOM_H
14 #ifdef CONFIG_ARCH_RANDOM
16 #include <linux/static_key.h>
17 #include <linux/atomic.h>
19 DECLARE_STATIC_KEY_FALSE(s390_arch_random_available);
20 extern atomic64_t s390_arch_random_counter;
22 bool s390_arch_get_random_long(unsigned long *v);
23 bool s390_arch_random_generate(u8 *buf, unsigned int nbytes);
25 static inline bool __must_check arch_get_random_long(unsigned long *v)
27 if (static_branch_likely(&s390_arch_random_available))
28 return s390_arch_get_random_long(v);
29 return false;
32 static inline bool __must_check arch_get_random_int(unsigned int *v)
34 return false;
37 static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
39 if (static_branch_likely(&s390_arch_random_available)) {
40 return s390_arch_random_generate((u8 *)v, sizeof(*v));
42 return false;
45 static inline bool __must_check arch_get_random_seed_int(unsigned int *v)
47 if (static_branch_likely(&s390_arch_random_available)) {
48 return s390_arch_random_generate((u8 *)v, sizeof(*v));
50 return false;
53 #endif /* CONFIG_ARCH_RANDOM */
54 #endif /* _ASM_S390_ARCHRANDOM_H */