2 * s390 arch random implementation.
4 * Copyright IBM Corp. 2017
5 * Author(s): Harald Freudenberger <freude@de.ibm.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License (version 2 only)
9 * as published by the Free Software Foundation.
13 #include <linux/kernel.h>
14 #include <linux/atomic.h>
15 #include <linux/static_key.h>
16 #include <asm/cpacf.h>
18 DEFINE_STATIC_KEY_FALSE(s390_arch_random_available);
20 atomic64_t s390_arch_random_counter = ATOMIC64_INIT(0);
21 EXPORT_SYMBOL(s390_arch_random_counter);
23 static int __init s390_arch_random_init(void)
25 /* check if subfunction CPACF_PRNO_TRNG is available */
26 if (cpacf_query_func(CPACF_PRNO, CPACF_PRNO_TRNG))
27 static_branch_enable(&s390_arch_random_available);
31 arch_initcall(s390_arch_random_init);