lib: utils: fdt_pmu: Do not iterate over the fdt_pmu_evt_select table
authorYu Chien Peter Lin <peterlin@andestech.com>
Thu, 30 Nov 2023 12:42:11 +0000 (20:42 +0800)
committerAnup Patel <anup@brainfault.org>
Wed, 6 Dec 2023 12:47:08 +0000 (18:17 +0530)
The valid entry count is tracking by hw_event_count so there
is no need to check the whole table.

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/utils/fdt/fdt_pmu.c

index 684981eb9ba8ff0286f12061e9db09dc36480dec..e23e8223e6f605c6b560d7b6a3f83e5d64920a14 100644 (file)
@@ -26,7 +26,7 @@ uint64_t fdt_pmu_get_select_value(uint32_t event_idx)
        int i;
        struct fdt_pmu_hw_event_select_map *event;
 
-       for (i = 0; i < SBI_PMU_HW_EVENT_MAX; i++) {
+       for (i = 0; i < hw_event_count; i++) {
                event = &fdt_pmu_evt_select[i];
                if (event->eidx == event_idx)
                        return event->select;