mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-11-20 10:32:19 +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
@@ -323,6 +323,13 @@ bool sbi_domain_check_addr_range(const struct sbi_domain *dom,
|
|||||||
unsigned long mode,
|
unsigned long mode,
|
||||||
unsigned long access_flags);
|
unsigned long access_flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a domain by name
|
||||||
|
* @param name Name of the domain
|
||||||
|
* @return pointer to the domain or NULL upon failure
|
||||||
|
*/
|
||||||
|
struct sbi_domain *sbi_domain_find_by_name(const char *name);
|
||||||
|
|
||||||
/** Dump domain details on the console */
|
/** Dump domain details on the console */
|
||||||
void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix);
|
void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix);
|
||||||
|
|
||||||
|
|||||||
+18
-1
@@ -531,6 +531,21 @@ bool sbi_domain_check_addr_range(const struct sbi_domain *dom,
|
|||||||
return true;
|
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)
|
void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix)
|
||||||
{
|
{
|
||||||
u32 i, j, k;
|
u32 i, j, k;
|
||||||
@@ -645,11 +660,13 @@ int sbi_domain_register(struct sbi_domain *dom)
|
|||||||
/*
|
/*
|
||||||
* Ensure that:
|
* Ensure that:
|
||||||
* 1) Domain not already registered
|
* 1) Domain not already registered
|
||||||
|
* 2) Domain name is unique
|
||||||
* 2) Initialization order is unique
|
* 2) Initialization order is unique
|
||||||
*/
|
*/
|
||||||
sbi_domain_for_each(tdom) {
|
sbi_domain_for_each(tdom) {
|
||||||
if (tdom == dom ||
|
if (tdom == dom ||
|
||||||
tdom->init_order == dom->init_order)
|
tdom->init_order == dom->init_order ||
|
||||||
|
!sbi_strcmp(tdom->name, dom->name))
|
||||||
return SBI_EALREADY;
|
return SBI_EALREADY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user