From 3204d74486ecded839205be5a3bf0193aaca3547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Hern=C3=A1ndez=20M=C3=A9ndez?= Date: Mon, 21 Jul 2025 18:07:12 +0200 Subject: [PATCH] lib: sbi: pmu: Improve loop in pmu_ctr_find_hw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We do not need to iterate over all values in the loop, we can break the loop when we found a valid counter that is not started yet. Signed-off-by: Manuel Hernández Méndez Link: https://lore.kernel.org/r/20250721160712.8766-1-maherme.dev@gmail.com Signed-off-by: Anup Patel --- lib/sbi/sbi_pmu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c index 07a5c544..635cb0c7 100644 --- a/lib/sbi/sbi_pmu.c +++ b/lib/sbi/sbi_pmu.c @@ -780,6 +780,7 @@ static int pmu_ctr_find_hw(struct sbi_pmu_hart_state *phs, continue; /* We found a valid counter that is not started yet */ ctr_idx = cbase; + break; } }