[PATCH v2 07/28] ARM: mmu: Separate index and address in create_sections()
Andrey Smirnov
andrew.smirnov at gmail.com
Wed May 16 13:00:15 PDT 2018
Both TTB index and address used to fill that entry are derived from
the same variable 'addr' which requires shifting right and left by 20
and somewhat confusing.
Split the counter used to iterate over elements of TTB into a
separate variable to make this code a bit easier to read.
Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
---
arch/arm/cpu/mmu.h | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/arm/cpu/mmu.h b/arch/arm/cpu/mmu.h
index 59f72049f..d71cd7e38 100644
--- a/arch/arm/cpu/mmu.h
+++ b/arch/arm/cpu/mmu.h
@@ -1,6 +1,8 @@
#ifndef __ARM_MMU_H
#define __ARM_MMU_H
+#include <linux/sizes.h>
+
#ifdef CONFIG_MMU
void __mmu_cache_on(void);
void __mmu_cache_off(void);
@@ -28,8 +30,12 @@ static inline void
create_sections(uint32_t *ttb, unsigned long addr,
int size_m, unsigned int flags)
{
- for (addr >>= 20; addr < size_m; addr++)
- ttb[addr] = (addr << 20) | flags;
+ unsigned long ttb_start = addr >> 20;
+ unsigned long ttb_end = ttb_start + size_m;
+ unsigned int i;
+
+ for (i = ttb_start; i < ttb_end; i++, addr += SZ_1M)
+ ttb[i] = addr | flags;
}
--
2.17.0
More information about the barebox
mailing list