[PATCH v2 10/14] lmb: Avoid long for loop counters and function returns
Simon Glass
sjg at chromium.org
Fri Sep 1 03:13:48 CEST 2023
Use int for loop counters since it is more common. Do the same with the
return value of some internal functions.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
(no changes since v1)
lib/lmb.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/lib/lmb.c b/lib/lmb.c
index 862b1cd04953..579f98baef87 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -53,8 +53,8 @@ void lmb_dump_all(struct lmb *lmb)
#endif
}
-static long lmb_addrs_overlap(phys_addr_t base1, phys_size_t size1,
- phys_addr_t base2, phys_size_t size2)
+static int lmb_addrs_overlap(phys_addr_t base1, phys_size_t size1,
+ phys_addr_t base2, phys_size_t size2)
{
const phys_addr_t base1_end = base1 + size1 - 1;
const phys_addr_t base2_end = base2 + size2 - 1;
@@ -62,8 +62,8 @@ static long lmb_addrs_overlap(phys_addr_t base1, phys_size_t size1,
return base1 <= base2_end && base2 <= base1_end;
}
-static long lmb_addrs_adjacent(phys_addr_t base1, phys_size_t size1,
- phys_addr_t base2, phys_size_t size2)
+static int lmb_addrs_adjacent(phys_addr_t base1, phys_size_t size1,
+ phys_addr_t base2, phys_size_t size2)
{
if (base2 == base1 + size1)
return 1;
@@ -73,7 +73,7 @@ static long lmb_addrs_adjacent(phys_addr_t base1, phys_size_t size1,
return 0;
}
-static long lmb_areas_adjacent(struct lmb_region *rgn, ulong a1, ulong a2)
+static int lmb_areas_adjacent(struct lmb_region *rgn, ulong a1, ulong a2)
{
phys_addr_t base1 = rgn->area[a1].base;
phys_size_t size1 = rgn->area[a1].size;
@@ -85,7 +85,7 @@ static long lmb_areas_adjacent(struct lmb_region *rgn, ulong a1, ulong a2)
static void lmb_remove_area(struct lmb_region *rgn, unsigned long area)
{
- unsigned long i;
+ uint i;
for (i = area; i < rgn->cnt - 1; i++)
rgn->area[i] = rgn->area[i + 1];
@@ -221,11 +221,11 @@ void lmb_init_and_reserve_range(struct lmb *lmb, phys_addr_t base,
}
/* This routine called with relocation disabled. */
-static long lmb_add_area_flags(struct lmb_region *rgn, phys_addr_t base,
- phys_size_t size, enum lmb_flags flags)
+static int lmb_add_area_flags(struct lmb_region *rgn, phys_addr_t base,
+ phys_size_t size, enum lmb_flags flags)
{
- unsigned long coalesced = 0;
- long adjacent, i;
+ uint coalesced = 0;
+ int adjacent, i;
if (rgn->cnt == 0) {
rgn->area[0].base = base;
@@ -308,8 +308,8 @@ static long lmb_add_area_flags(struct lmb_region *rgn, phys_addr_t base,
return 0;
}
-static long lmb_add_area(struct lmb_region *rgn, phys_addr_t base,
- phys_size_t size)
+static int lmb_add_area(struct lmb_region *rgn, phys_addr_t base,
+ phys_size_t size)
{
return lmb_add_area_flags(rgn, base, size, LMB_NONE);
}
@@ -386,10 +386,10 @@ long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size)
return lmb_reserve_flags(lmb, base, size, LMB_NONE);
}
-static long lmb_overlaps_region(struct lmb_region *rgn, phys_addr_t base,
- phys_size_t size)
+static int lmb_overlaps_region(struct lmb_region *rgn, phys_addr_t base,
+ phys_size_t size)
{
- unsigned long i;
+ uint i;
for (i = 0; i < rgn->cnt; i++) {
phys_addr_t abase = rgn->area[i].base;
@@ -429,7 +429,7 @@ static phys_addr_t lmb_align_down(phys_addr_t addr, phys_size_t size)
phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
phys_addr_t max_addr)
{
- long i, area;
+ int i, area;
phys_addr_t base = 0;
phys_addr_t res_base;
--
2.42.0.283.g2d96d420d3-goog
More information about the U-Boot
mailing list