1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:12:57 +01:00

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.
This commit is contained in:
Benjamin Valentin 2021-08-27 13:45:05 +02:00
parent de768b5d23
commit f903ec90d4
3 changed files with 5 additions and 5 deletions

View File

@ -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.

View File

@ -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);
}

View File

@ -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;