[COMMON] soc: samsung: seclog: Change for loop with NR_CPUS to for_each_possible_cpu()
authorJunho Choi <junhosj.choi@samsung.com>
Wed, 14 Mar 2018 06:22:55 +0000 (15:22 +0900)
committerJunho Choi <junhosj.choi@samsung.com>
Wed, 23 May 2018 23:53:41 +0000 (08:53 +0900)
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 <junhosj.choi@samsung.com>
drivers/soc/samsung/exynos-seclog.c

index 101a5a6a6f3b8c23089b8966fb2a9567885f4d1c..5e70fd14403287cd7b8cf258cf3531542c7fe7a0 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/workqueue.h>
 #include <linux/debugfs.h>
 #include <linux/smc.h>
+#include <linux/cpumask.h>
 
 #include <soc/samsung/exynos-seclog.h>
 
@@ -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,