public inbox for opensbi@lists.infradead.org
 help / color / mirror / Atom feed
From: "Manuel Hernández Méndez" <maherme.dev@gmail.com>
To: opensbi@lists.infradead.org
Cc: "Manuel Hernández Méndez" <maherme.dev@gmail.com>
Subject: [PATCH] lib: sbi: pmu: Improve loop in pmu_ctr_find_hw
Date: Mon, 21 Jul 2025 18:07:12 +0200	[thread overview]
Message-ID: <20250721160712.8766-1-maherme.dev@gmail.com> (raw)

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 <maherme.dev@gmail.com>
---
 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;
 		}
 	}
 
-- 
2.34.1


-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

             reply	other threads:[~2025-07-21 17:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-21 16:07 Manuel Hernández Méndez [this message]
2025-08-26 11:15 ` [PATCH] lib: sbi: pmu: Improve loop in pmu_ctr_find_hw Anup Patel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250721160712.8766-1-maherme.dev@gmail.com \
    --to=maherme.dev@gmail.com \
    --cc=opensbi@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox