[PATCH 04/11] lib: sbi_domain: Introduce sbi_domain_find_by_name() function

Pawandeep Oza pawandeep.oza at oss.qualcomm.com
Tue Oct 13 12:46:17 PDT 2026


On Tue, Sep 22, 2026 at 8:24 PM Anup Patel <anup.patel at oss.qualcomm.com> wrote:
>
> 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 at oss.qualcomm.com>
> ---
>  include/sbi/sbi_domain.h |  7 +++++++
>  lib/sbi/sbi_domain.c     | 19 ++++++++++++++++++-
>  2 files changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h
> index 1f773e41..394e7ddf 100644
> --- a/include/sbi/sbi_domain.h
> +++ b/include/sbi/sbi_domain.h
> @@ -323,6 +323,13 @@ bool sbi_domain_check_addr_range(const struct sbi_domain *dom,
>                                  unsigned long mode,
>                                  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 */
>  void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix);
>
> diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
> index b3f5892d..f5c62509 100644
> --- a/lib/sbi/sbi_domain.c
> +++ b/lib/sbi/sbi_domain.c
> @@ -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;
>         }
>
> --
> 2.43.0
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi

Reviewed-by: Pawandeep Oza <pawandeep.oza at oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza at oss.qualcomm.com>



More information about the opensbi mailing list