device: Const-ify all device driver instance pointers

Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2020-04-30 20:33:38 +02:00 committed by Carles Cufí
commit e18fcbba5a
1426 changed files with 9356 additions and 8368 deletions

View file

@ -24,7 +24,8 @@ LOG_MODULE_REGISTER(LOG_DOMAIN);
* offset and len must be aligned on 8 for write,
* positive and not beyond end of flash
*/
bool flash_stm32_valid_range(struct device *dev, off_t offset, uint32_t len,
bool flash_stm32_valid_range(const struct device *dev, off_t offset,
uint32_t len,
bool write)
{
return (!write || (offset % 8 == 0 && len % 8 == 0U)) &&
@ -39,7 +40,7 @@ static unsigned int get_page(off_t offset)
return offset >> STM32G4X_PAGE_SHIFT;
}
static int write_dword(struct device *dev, off_t offset, uint64_t val)
static int write_dword(const struct device *dev, off_t offset, uint64_t val)
{
volatile uint32_t *flash = (uint32_t *)(offset + CONFIG_FLASH_BASE_ADDRESS);
FLASH_TypeDef *regs = FLASH_STM32_REGS(dev);
@ -84,7 +85,7 @@ static int write_dword(struct device *dev, off_t offset, uint64_t val)
return rc;
}
static int erase_page(struct device *dev, unsigned int page)
static int erase_page(const struct device *dev, unsigned int page)
{
FLASH_TypeDef *regs = FLASH_STM32_REGS(dev);
uint32_t tmp;
@ -144,7 +145,8 @@ static int erase_page(struct device *dev, unsigned int page)
return rc;
}
int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset,
int flash_stm32_block_erase_loop(const struct device *dev,
unsigned int offset,
unsigned int len)
{
int i, rc = 0;
@ -160,7 +162,7 @@ int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset,
return rc;
}
int flash_stm32_write_range(struct device *dev, unsigned int offset,
int flash_stm32_write_range(const struct device *dev, unsigned int offset,
const void *data, unsigned int len)
{
int i, rc = 0;
@ -175,7 +177,7 @@ int flash_stm32_write_range(struct device *dev, unsigned int offset,
return rc;
}
void flash_stm32_page_layout(struct device *dev,
void flash_stm32_page_layout(const struct device *dev,
const struct flash_pages_layout **layout,
size_t *layout_size)
{