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

@ -16,7 +16,8 @@
#define STM32F7X_SECTOR_MASK ((uint32_t) 0xFFFFFF07)
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)
{
ARG_UNUSED(write);
@ -24,7 +25,7 @@ bool flash_stm32_valid_range(struct device *dev, off_t offset, uint32_t len,
return flash_stm32_range_exists(dev, offset, len);
}
static int write_byte(struct device *dev, off_t offset, uint8_t val)
static int write_byte(const struct device *dev, off_t offset, uint8_t val)
{
FLASH_TypeDef *regs = FLASH_STM32_REGS(dev);
int rc;
@ -56,7 +57,7 @@ static int write_byte(struct device *dev, off_t offset, uint8_t val)
return rc;
}
static int erase_sector(struct device *dev, uint32_t sector)
static int erase_sector(const struct device *dev, uint32_t sector)
{
FLASH_TypeDef *regs = FLASH_STM32_REGS(dev);
int rc;
@ -100,7 +101,8 @@ static int erase_sector(struct device *dev, uint32_t sector)
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)
{
struct flash_pages_info info;
@ -129,7 +131,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;
@ -205,7 +207,7 @@ static const struct flash_pages_layout stm32f7_flash_layout_dual_bank[] = {
#error "Unknown flash layout"
#endif/* !defined(FLASH_SECTOR_TOTAL) */
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)
{