Skip to content

Commit

Permalink
arch: arm: remove redundant flag
Browse files Browse the repository at this point in the history
This commit removes the arm_mpu_enabled status flag in the ARM
MPU driver. This flag is not needed, because the value of the
MPU_CTRL register stays the same while the MPU is enabled, and
is cleared to 0 when the MPU is disabled. Therefore, we do not
need to prevent from having the enable or the disable operation
to be called multiple times.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
  • Loading branch information
ioannisg authored and nashif committed Jun 11, 2018
1 parent dbede45 commit 61439b0
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions arch/arm/core/cortex_m/mpu/arm_mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

#define ARM_MPU_DEV ((volatile struct arm_mpu *) ARM_MPU_BASE)

/* ARM MPU Enabled state */
static u8_t arm_mpu_enabled;

/**
* The attributes referenced in this function are described at:
* https://goo.gl/hMry3r
Expand Down Expand Up @@ -248,27 +245,19 @@ static inline int _is_user_accessible_region(u32_t r_index, int write)
*/
void arm_core_mpu_enable(void)
{
if (arm_mpu_enabled == 0) {
/* Enable MPU and use the default memory map as a
* background region for privileged software access.
*/
ARM_MPU_DEV->ctrl = ARM_MPU_ENABLE | ARM_MPU_PRIVDEFENA;

arm_mpu_enabled = 1;
}
/* Enable MPU and use the default memory map as a
* background region for privileged software access.
*/
ARM_MPU_DEV->ctrl = ARM_MPU_ENABLE | ARM_MPU_PRIVDEFENA;
}

/**
* @brief disable the MPU
*/
void arm_core_mpu_disable(void)
{
if (arm_mpu_enabled == 1) {
/* Disable MPU */
ARM_MPU_DEV->ctrl = 0;

arm_mpu_enabled = 0;
}
/* Disable MPU */
ARM_MPU_DEV->ctrl = 0;
}

/**
Expand Down Expand Up @@ -488,8 +477,6 @@ static void _arm_mpu_config(void)
*/
ARM_MPU_DEV->ctrl = ARM_MPU_ENABLE | ARM_MPU_PRIVDEFENA;

arm_mpu_enabled = 1;

/* Make sure that all the registers are set before proceeding */
__DSB();
__ISB();
Expand Down

0 comments on commit 61439b0

Please sign in to comment.