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

@ -22,7 +22,7 @@ struct spi_mcux_config {
SPI_Type *base;
char *clock_name;
clock_control_subsys_t clock_subsys;
void (*irq_config_func)(struct device *dev);
void (*irq_config_func)(const struct device *dev);
uint32_t pcs_sck_delay;
uint32_t sck_pcs_delay;
uint32_t transfer_delay;
@ -34,7 +34,7 @@ struct spi_mcux_data {
size_t transfer_len;
};
static int spi_mcux_transfer_next_packet(struct device *dev)
static int spi_mcux_transfer_next_packet(const struct device *dev)
{
const struct spi_mcux_config *config = dev->config;
struct spi_mcux_data *data = dev->data;
@ -105,7 +105,7 @@ static int spi_mcux_transfer_next_packet(struct device *dev)
static void spi_mcux_isr(void *arg)
{
struct device *dev = (struct device *)arg;
const struct device *dev = (const struct device *)arg;
const struct spi_mcux_config *config = dev->config;
struct spi_mcux_data *data = dev->data;
SPI_Type *base = config->base;
@ -116,7 +116,7 @@ static void spi_mcux_isr(void *arg)
static void spi_mcux_master_transfer_callback(SPI_Type *base,
dspi_master_handle_t *handle, status_t status, void *userData)
{
struct device *dev = userData;
const struct device *dev = userData;
struct spi_mcux_data *data = dev->data;
spi_context_update_tx(&data->ctx, 1, data->transfer_len);
@ -125,14 +125,14 @@ static void spi_mcux_master_transfer_callback(SPI_Type *base,
spi_mcux_transfer_next_packet(dev);
}
static int spi_mcux_configure(struct device *dev,
static int spi_mcux_configure(const struct device *dev,
const struct spi_config *spi_cfg)
{
const struct spi_mcux_config *config = dev->config;
struct spi_mcux_data *data = dev->data;
SPI_Type *base = config->base;
dspi_master_config_t master_config;
struct device *clock_dev;
const struct device *clock_dev;
uint32_t clock_freq;
uint32_t word_size;
@ -204,7 +204,7 @@ static int spi_mcux_configure(struct device *dev,
return 0;
}
static int transceive(struct device *dev,
static int transceive(const struct device *dev,
const struct spi_config *spi_cfg,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs,
@ -237,7 +237,7 @@ out:
return ret;
}
static int spi_mcux_transceive(struct device *dev,
static int spi_mcux_transceive(const struct device *dev,
const struct spi_config *spi_cfg,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs)
@ -246,7 +246,7 @@ static int spi_mcux_transceive(struct device *dev,
}
#ifdef CONFIG_SPI_ASYNC
static int spi_mcux_transceive_async(struct device *dev,
static int spi_mcux_transceive_async(const struct device *dev,
const struct spi_config *spi_cfg,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs,
@ -256,8 +256,8 @@ static int spi_mcux_transceive_async(struct device *dev,
}
#endif /* CONFIG_SPI_ASYNC */
static int spi_mcux_release(struct device *dev,
const struct spi_config *spi_cfg)
static int spi_mcux_release(const struct device *dev,
const struct spi_config *spi_cfg)
{
struct spi_mcux_data *data = dev->data;
@ -266,7 +266,7 @@ static int spi_mcux_release(struct device *dev,
return 0;
}
static int spi_mcux_init(struct device *dev)
static int spi_mcux_init(const struct device *dev)
{
const struct spi_mcux_config *config = dev->config;
struct spi_mcux_data *data = dev->data;