diff options
Diffstat (limited to 'drivers/bootcount/bootcount.c')
| -rw-r--r-- | drivers/bootcount/bootcount.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/bootcount/bootcount.c b/drivers/bootcount/bootcount.c index 343b8a34414..2c0114d9705 100644 --- a/drivers/bootcount/bootcount.c +++ b/drivers/bootcount/bootcount.c @@ -19,7 +19,8 @@ __weak void bootcount_store(ulong a) uintptr_t flush_end; #if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD) - raw_bootcount_store(reg, (CONFIG_SYS_BOOTCOUNT_MAGIC & 0xffff0000) | a); + raw_bootcount_store(reg, (CONFIG_SYS_BOOTCOUNT_MAGIC & BOOTCOUNT_MAGIC_MASK) + | (a & BOOTCOUNT_COUNT_MASK)); flush_end = roundup(CONFIG_SYS_BOOTCOUNT_ADDR + 4, CONFIG_SYS_CACHELINE_SIZE); @@ -40,10 +41,10 @@ __weak ulong bootcount_load(void) #if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD) u32 tmp = raw_bootcount_load(reg); - if ((tmp & 0xffff0000) != (CONFIG_SYS_BOOTCOUNT_MAGIC & 0xffff0000)) + if ((tmp & BOOTCOUNT_MAGIC_MASK) != (CONFIG_SYS_BOOTCOUNT_MAGIC & BOOTCOUNT_MAGIC_MASK)) return 0; else - return (tmp & 0x0000ffff); + return (tmp & BOOTCOUNT_COUNT_MASK); #else if (raw_bootcount_load(reg + 4) != CONFIG_SYS_BOOTCOUNT_MAGIC) return 0; @@ -74,10 +75,10 @@ static int bootcount_mem_get(struct udevice *dev, u32 *a) if (priv->singleword) { u32 tmp = raw_bootcount_load(reg); - if ((tmp & 0xffff0000) != (magic & 0xffff0000)) + if ((tmp & BOOTCOUNT_MAGIC_MASK) != (magic & BOOTCOUNT_MAGIC_MASK)) return -ENODEV; - *a = (tmp & 0x0000ffff); + *a = (tmp & BOOTCOUNT_COUNT_MASK); } else { if (raw_bootcount_load(reg + 4) != magic) return -ENODEV; @@ -98,7 +99,8 @@ static int bootcount_mem_set(struct udevice *dev, const u32 a) uintptr_t flush_end; if (priv->singleword) { - raw_bootcount_store(reg, (magic & 0xffff0000) | a); + raw_bootcount_store(reg, (magic & BOOTCOUNT_MAGIC_MASK) + | (a & BOOTCOUNT_COUNT_MASK)); flush_end = roundup(priv->base + 4, CONFIG_SYS_CACHELINE_SIZE); } else { |
