[PATCH] random: Use cpumask_next_wrap() in try_to_generate_entropy()

Fushuai Wang posted 1 patch 1 month, 4 weeks ago
drivers/char/random.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[PATCH] random: Use cpumask_next_wrap() in try_to_generate_entropy()
Posted by Fushuai Wang 1 month, 4 weeks ago
Replace the manual sequence of cpumask_next() and cpumask_first()
with a single call to cpumask_next_wrap() in try_to_generate_entropy().

Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
---
 drivers/char/random.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index b8b24b6ed3fe..f85f35777c9b 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1336,9 +1336,7 @@ static void __cold try_to_generate_entropy(void)
 
 			/* Basic CPU round-robin, which avoids the current CPU. */
 			do {
-				cpu = cpumask_next(cpu, &timer_cpus);
-				if (cpu >= nr_cpu_ids)
-					cpu = cpumask_first(&timer_cpus);
+				cpu = cpumask_next_wrap(cpu, &timer_cpus);
 			} while (cpu == smp_processor_id() && num_cpus > 1);
 
 			/* Expiring the timer at `jiffies` means it's the next tick. */
-- 
2.36.1