Skip to content

Commit 2b358a3

Browse files
MaureenHelmAnas Nashif
authored andcommitted
arm: nxp: mpu: Return constant number of mpu regions
The original implementation of _get_num_regions() parsed the CESR[NRGD] register field to determine the number of mpu region descriptors implemented in hardware. There was a possible path in the code to return zero, which would cause underflow later on in arm_core_mpu_configure(). Coverity complained despite an assert to catch this condition. Instead, use a preprocessor macro from mcux that defines the number of mpu region descriptors. Coverity-CID: 169811 Jira: ZEP-2208 Signed-off-by: Maureen Helm <[email protected]>
1 parent e3917ce commit 2b358a3

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

arch/arm/core/cortex_m/mpu/nxp_mpu.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,7 @@ static inline u32_t _get_region_attr_by_type(u32_t type)
3838

3939
static inline u8_t _get_num_regions(void)
4040
{
41-
u32_t type = (SYSMPU->CESR & SYSMPU_CESR_NRGD_MASK)
42-
>> SYSMPU_CESR_NRGD_SHIFT;
43-
44-
switch (type) {
45-
case 0:
46-
return 8;
47-
case 1:
48-
return 12;
49-
case 2:
50-
return 16;
51-
default:
52-
__ASSERT(0, "Unsupported MPU configuration.");
53-
return 0;
54-
}
55-
56-
return NXP_MPU_REGION_NUMBER;
41+
return FSL_FEATURE_SYSMPU_DESCRIPTOR_COUNT;
5742
}
5843

5944
static void _region_init(u32_t index, u32_t region_base,

0 commit comments

Comments
 (0)