From f903ec90d438d24007b5aa4cc1a46344228bbea9 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 27 Aug 2021 13:45:05 +0200 Subject: [PATCH] drivers/flashpage: flashpage_page() takes a const argument All addresses to flashpage_page() must be in flash. Flash memory is `const`, therefore this function must also take `const` pointers. --- cpu/stm32/periph/flashpage.c | 2 +- drivers/include/periph/flashpage.h | 6 +++--- drivers/periph_common/flashpage.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cpu/stm32/periph/flashpage.c b/cpu/stm32/periph/flashpage.c index 4a559167a0..50cd060783 100644 --- a/cpu/stm32/periph/flashpage.c +++ b/cpu/stm32/periph/flashpage.c @@ -329,7 +329,7 @@ size_t flashpage_size(unsigned page) } } -unsigned flashpage_page(void *addr) +unsigned flashpage_page(const void *addr) { /* Calculates the flashpage number based on the address for the * non-homogeneous flashpage stm32 series. diff --git a/drivers/include/periph/flashpage.h b/drivers/include/periph/flashpage.h index 60e190ebf1..c7cc85bca3 100644 --- a/drivers/include/periph/flashpage.h +++ b/drivers/include/periph/flashpage.h @@ -190,7 +190,7 @@ static inline void *flashpage_addr(unsigned page) * * @return page containing the given address */ -static inline unsigned flashpage_page(void *addr) +static inline unsigned flashpage_page(const void *addr) { return (((intptr_t)addr - CPU_FLASH_BASE) / FLASHPAGE_SIZE); } @@ -200,7 +200,7 @@ static inline unsigned flashpage_page(void *addr) /* Bare prototypes for the above functions. See above for the documentation */ size_t flashpage_size(unsigned page); void *flashpage_addr(unsigned page); -unsigned flashpage_page(void *addr); +unsigned flashpage_page(const void *addr); #endif @@ -319,7 +319,7 @@ static inline void *flashpage_rwwee_addr(unsigned page) * * @return RWWEE page containing the given address */ -static inline int flashpage_rwwee_page(void *addr) +static inline int flashpage_rwwee_page(const void *addr) { return (int)(((int)addr - CPU_FLASH_RWWEE_BASE) / FLASHPAGE_SIZE); } diff --git a/drivers/periph_common/flashpage.c b/drivers/periph_common/flashpage.c index f9457c213f..05252e1f6e 100644 --- a/drivers/periph_common/flashpage.c +++ b/drivers/periph_common/flashpage.c @@ -118,7 +118,7 @@ void *flashpage_addr(unsigned page) #endif /* PERIPH_FLASHPAGE_NEEDS_FLASHPAGE_ADDR */ #ifdef PERIPH_FLASHPAGE_NEEDS_FLASHPAGE_PAGE -unsigned flashpage_page(void *addr) +unsigned flashpage_page(const void *addr) { unsigned page = 0;