The only remaining non-architecture usage of get_cycles() is to provide random_get_entropy().
Switch nios2 over to the new scheme of selecting ARCH_HAS_RANDOM_ENTROPY and providing random_get_entropy() in asm/random.h. Add 'asm/timex.h' includes to the relevant files, so the global include can be removed once all architectures are converted over. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Dinh Nguyen <[email protected]> --- arch/nios2/Kconfig | 1 + arch/nios2/include/asm/random.h | 14 ++++++++++++++ arch/nios2/include/asm/timex.h | 5 +---- arch/nios2/kernel/time.c | 4 ++-- 4 files changed, 18 insertions(+), 6 deletions(-) --- a/arch/nios2/Kconfig +++ b/arch/nios2/Kconfig @@ -7,6 +7,7 @@ config NIOS2 select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE select ARCH_HAS_DMA_SET_UNCACHED + select ARCH_HAS_RANDOM_ENTROPY select ARCH_NO_SWAP select COMMON_CLK select TIMER_OF --- /dev/null +++ b/arch/nios2/include/asm/random.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _ASM_NIOS2_RANDOM_H +#define _ASM_NIOS2_RANDOM_H + +#include <asm/timex.h> + +static inline unsigned long random_get_entropy(void) +{ + unsigned long c = get_cycles(); + + return c ? c : random_get_entropy_fallback(); +} + +#endif --- a/arch/nios2/include/asm/timex.h +++ b/arch/nios2/include/asm/timex.h @@ -5,9 +5,6 @@ #ifndef _ASM_NIOS2_TIMEX_H #define _ASM_NIOS2_TIMEX_H -extern cycles_t get_cycles(void); -#define get_cycles get_cycles - -#define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback()) +cycles_t get_cycles(void); #endif --- a/arch/nios2/kernel/time.c +++ b/arch/nios2/kernel/time.c @@ -7,7 +7,6 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. */ - #include <linux/export.h> #include <linux/interrupt.h> #include <linux/clockchips.h> @@ -19,6 +18,8 @@ #include <linux/io.h> #include <linux/slab.h> +#include <asm/timex.h> + #define ALTR_TIMER_COMPATIBLE "altr,timer-1.0" #define ALTERA_TIMER_STATUS_REG 0 @@ -112,7 +113,6 @@ cycles_t get_cycles(void) return nios2_timer_read(&nios2_cs.cs); return 0; } -EXPORT_SYMBOL(get_cycles); static void nios2_timer_start(struct nios2_timer *timer) {

