diff mbox series

[RFC,02/31] lmb: staticize __lmb_alloc_base()

Message ID 20240607185240.1892031-3-sughosh.ganu@linaro.org
State Superseded
Headers show
Series Make U-Boot memory reservations coherent | expand

Commit Message

Sughosh Ganu June 7, 2024, 6:52 p.m. UTC
The __lmb_alloc_base() function is only called from within the lmb
module. Moreover, the lmb_alloc() and lmb_alloc_base() API's are good
enough for the allocation API calls. Make the __lmb_alloc_base()
function static.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
 include/lmb.h |  2 --
 lib/lmb.c     | 39 ++++++++++++++++++++-------------------
 2 files changed, 20 insertions(+), 21 deletions(-)

Comments

Ilias Apalodimas June 10, 2024, 9:37 a.m. UTC | #1
On Fri, 7 Jun 2024 at 21:53, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
>
> The __lmb_alloc_base() function is only called from within the lmb
> module. Moreover, the lmb_alloc() and lmb_alloc_base() API's are good
> enough for the allocation API calls. Make the __lmb_alloc_base()
> function static.
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> ---
>  include/lmb.h |  2 --
>  lib/lmb.c     | 39 ++++++++++++++++++++-------------------
>  2 files changed, 20 insertions(+), 21 deletions(-)
>
> diff --git a/include/lmb.h b/include/lmb.h
> index 6c50d93e83..7b87181b9e 100644
> --- a/include/lmb.h
> +++ b/include/lmb.h
> @@ -112,8 +112,6 @@ long lmb_reserve_flags(struct lmb *lmb, phys_addr_t base,
>  phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align);
>  phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
>                            phys_addr_t max_addr);
> -phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
> -                            phys_addr_t max_addr);
>  phys_addr_t lmb_alloc_addr(struct lmb *lmb, phys_addr_t base, phys_size_t size);
>  phys_size_t lmb_get_free_size(struct lmb *lmb, phys_addr_t addr);
>
> diff --git a/lib/lmb.c b/lib/lmb.c
> index adc3abd5b4..4d39c0d1f9 100644
> --- a/lib/lmb.c
> +++ b/lib/lmb.c
> @@ -435,30 +435,13 @@ static long lmb_overlaps_region(struct lmb_region *rgn, phys_addr_t base,
>         return (i < rgn->cnt) ? i : -1;
>  }
>
> -phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align)
> -{
> -       return lmb_alloc_base(lmb, size, align, LMB_ALLOC_ANYWHERE);
> -}
> -
> -phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, phys_addr_t max_addr)
> -{
> -       phys_addr_t alloc;
> -
> -       alloc = __lmb_alloc_base(lmb, size, align, max_addr);
> -
> -       if (alloc == 0)
> -               printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n",
> -                      (ulong)size, (ulong)max_addr);
> -
> -       return alloc;
> -}
> -
>  static phys_addr_t lmb_align_down(phys_addr_t addr, phys_size_t size)
>  {
>         return addr & ~(size - 1);
>  }
>
> -phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, phys_addr_t max_addr)
> +static phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size,
> +                                   ulong align, phys_addr_t max_addr)
>  {
>         long i, rgn;
>         phys_addr_t base = 0;
> @@ -499,6 +482,24 @@ phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, phy
>         return 0;
>  }
>
> +phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align)
> +{
> +       return lmb_alloc_base(lmb, size, align, LMB_ALLOC_ANYWHERE);
> +}
> +
> +phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, phys_addr_t max_addr)
> +{
> +       phys_addr_t alloc;
> +
> +       alloc = __lmb_alloc_base(lmb, size, align, max_addr);
> +
> +       if (alloc == 0)
> +               printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n",
> +                      (ulong)size, (ulong)max_addr);
> +
> +       return alloc;
> +}
> +
>  /*
>   * Try to allocate a specific address range: must be in defined memory but not
>   * reserved
> --
> 2.34.1
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff mbox series

Patch

diff --git a/include/lmb.h b/include/lmb.h
index 6c50d93e83..7b87181b9e 100644
--- a/include/lmb.h
+++ b/include/lmb.h
@@ -112,8 +112,6 @@  long lmb_reserve_flags(struct lmb *lmb, phys_addr_t base,
 phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align);
 phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
 			   phys_addr_t max_addr);
-phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
-			     phys_addr_t max_addr);
 phys_addr_t lmb_alloc_addr(struct lmb *lmb, phys_addr_t base, phys_size_t size);
 phys_size_t lmb_get_free_size(struct lmb *lmb, phys_addr_t addr);
 
diff --git a/lib/lmb.c b/lib/lmb.c
index adc3abd5b4..4d39c0d1f9 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -435,30 +435,13 @@  static long lmb_overlaps_region(struct lmb_region *rgn, phys_addr_t base,
 	return (i < rgn->cnt) ? i : -1;
 }
 
-phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align)
-{
-	return lmb_alloc_base(lmb, size, align, LMB_ALLOC_ANYWHERE);
-}
-
-phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, phys_addr_t max_addr)
-{
-	phys_addr_t alloc;
-
-	alloc = __lmb_alloc_base(lmb, size, align, max_addr);
-
-	if (alloc == 0)
-		printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n",
-		       (ulong)size, (ulong)max_addr);
-
-	return alloc;
-}
-
 static phys_addr_t lmb_align_down(phys_addr_t addr, phys_size_t size)
 {
 	return addr & ~(size - 1);
 }
 
-phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, phys_addr_t max_addr)
+static phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size,
+				    ulong align, phys_addr_t max_addr)
 {
 	long i, rgn;
 	phys_addr_t base = 0;
@@ -499,6 +482,24 @@  phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, phy
 	return 0;
 }
 
+phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align)
+{
+	return lmb_alloc_base(lmb, size, align, LMB_ALLOC_ANYWHERE);
+}
+
+phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, phys_addr_t max_addr)
+{
+	phys_addr_t alloc;
+
+	alloc = __lmb_alloc_base(lmb, size, align, max_addr);
+
+	if (alloc == 0)
+		printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n",
+		       (ulong)size, (ulong)max_addr);
+
+	return alloc;
+}
+
 /*
  * Try to allocate a specific address range: must be in defined memory but not
  * reserved