Merge tag 'xtensa-20180225' of git://github.com/jcmvbkbc/linux-xtensa
[cris-mirror.git] / arch / s390 / crypto / arch_random.c
blob8720e9203ecfb07beac7c878aedfc925e2b0db1b
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * s390 arch random implementation.
5 * Copyright IBM Corp. 2017
6 * Author(s): Harald Freudenberger <freude@de.ibm.com>
7 */
9 #include <linux/kernel.h>
10 #include <linux/atomic.h>
11 #include <linux/random.h>
12 #include <linux/static_key.h>
13 #include <asm/cpacf.h>
15 DEFINE_STATIC_KEY_FALSE(s390_arch_random_available);
17 atomic64_t s390_arch_random_counter = ATOMIC64_INIT(0);
18 EXPORT_SYMBOL(s390_arch_random_counter);
20 static int __init s390_arch_random_init(void)
22 /* check if subfunction CPACF_PRNO_TRNG is available */
23 if (cpacf_query_func(CPACF_PRNO, CPACF_PRNO_TRNG))
24 static_branch_enable(&s390_arch_random_available);
26 return 0;
28 arch_initcall(s390_arch_random_init);