From 9f760bf796e76f0f5fcae42cca97be3fa5656c23 Mon Sep 17 00:00:00 2001 From: Junho Choi Date: Wed, 14 Mar 2018 15:22:55 +0900 Subject: [PATCH] [COMMON] soc: samsung: seclog: Change for loop with NR_CPUS to for_each_possible_cpu() Kernel checkpatch recommends that using for_each_possible_cpu() is better than NR_CPUS because NR_CPUS is often wrong. Change-Id: I7f73d46add74f3b7335b22f4c1acf6303064ba94 Signed-off-by: Junho Choi --- drivers/soc/samsung/exynos-seclog.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/soc/samsung/exynos-seclog.c b/drivers/soc/samsung/exynos-seclog.c index 101a5a6a6f3b..5e70fd144032 100644 --- a/drivers/soc/samsung/exynos-seclog.c +++ b/drivers/soc/samsung/exynos-seclog.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -79,7 +80,7 @@ static void exynos_seclog_worker(struct work_struct *work) pr_debug("%s: Start seclog_worker\n", __func__); /* Print log message in a message buffer */ - for (cpu = 0; cpu < NR_CPUS; cpu++) { + for_each_possible_cpu(cpu) { v_log_addr = SECLOG_PHYS_TO_VIRT(sec_log[cpu]->start_log_addr); while (sec_log[cpu]->log_read_cnt != sec_log[cpu]->log_write_cnt) { @@ -144,7 +145,7 @@ static irqreturn_t exynos_seclog_irq_handler(int irq, void *dev_id) schedule_work(&slog_ctx.work); } else { /* Skip all log messages */ - for (cpu = 0; cpu < NR_CPUS; cpu++) { + for_each_possible_cpu(cpu) { sec_log[cpu]->log_read_cnt = sec_log[cpu]->log_write_cnt; sec_log[cpu]->log_return_cnt = 0; } @@ -310,7 +311,7 @@ static int exynos_seclog_probe(struct platform_device *pdev) detect_ldfw_err: /* Setup virtual address of message buffer of each core */ - for (i = 0; i < NR_CPUS; i++) { + for_each_possible_cpu(i) { sec_log[i] = (struct sec_log_info *)((unsigned long)ldata.virt_addr + (SECLOG_LOG_BUF_SIZE * i)); dev_dbg(&pdev->dev, -- 2.20.1