mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-11-19 10:21:38 +00:00
lib: sbi_domain: Introduce sbi_domain_find_by_name() function
Add sbi_domain_find_by_name() to allow driver locate domain instance using domain name. This also means domain names must be unique. Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com> Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com> Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260923032359.4041876-5-anup.patel@oss.qualcomm.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
1 parent
db877c0908
commit
bdd7874991
2 files changed
+25
-1
No files matched your search
+18
-1
@@ -531,6 +531,21 @@ bool sbi_domain_check_addr_range(const struct sbi_domain *dom,
|
||||
return true;
|
||||
}
|
||||
|
||||
struct sbi_domain *sbi_domain_find_by_name(const char *name)
|
||||
{
|
||||
struct sbi_domain *dom;
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
sbi_domain_for_each(dom) {
|
||||
if (!sbi_strcmp(dom->name, name))
|
||||
return dom;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix)
|
||||
{
|
||||
u32 i, j, k;
|
||||
@@ -645,11 +660,13 @@ int sbi_domain_register(struct sbi_domain *dom)
|
||||
/*
|
||||
* Ensure that:
|
||||
* 1) Domain not already registered
|
||||
* 2) Domain name is unique
|
||||
* 2) Initialization order is unique
|
||||
*/
|
||||
sbi_domain_for_each(tdom) {
|
||||
if (tdom == dom ||
|
||||
tdom->init_order == dom->init_order)
|
||||
tdom->init_order == dom->init_order ||
|
||||
!sbi_strcmp(tdom->name, dom->name))
|
||||
return SBI_EALREADY;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user