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

@ -175,12 +175,12 @@ void can_stm32_tx_isr_handler(CAN_TypeDef *can, struct can_stm32_data *data)
static void can_stm32_isr(void *arg)
{
struct device *dev;
const struct device *dev;
struct can_stm32_data *data;
const struct can_stm32_config *cfg;
CAN_TypeDef *can;
dev = (struct device *)arg;
dev = (const struct device *)arg;
data = DEV_DATA(dev);
cfg = DEV_CFG(dev);
can = cfg->can;
@ -197,12 +197,12 @@ static void can_stm32_isr(void *arg)
static void can_stm32_rx_isr(void *arg)
{
struct device *dev;
const struct device *dev;
struct can_stm32_data *data;
const struct can_stm32_config *cfg;
CAN_TypeDef *can;
dev = (struct device *)arg;
dev = (const struct device *)arg;
data = DEV_DATA(dev);
cfg = DEV_CFG(dev);
can = cfg->can;
@ -212,12 +212,12 @@ static void can_stm32_rx_isr(void *arg)
static void can_stm32_tx_isr(void *arg)
{
struct device *dev;
const struct device *dev;
struct can_stm32_data *data;
const struct can_stm32_config *cfg;
CAN_TypeDef *can;
dev = (struct device *)arg;
dev = (const struct device *)arg;
data = DEV_DATA(dev);
cfg = DEV_CFG(dev);
can = cfg->can;
@ -227,12 +227,12 @@ static void can_stm32_tx_isr(void *arg)
static void can_stm32_state_change_isr(void *arg)
{
struct device *dev;
const struct device *dev;
struct can_stm32_data *data;
const struct can_stm32_config *cfg;
CAN_TypeDef *can;
dev = (struct device *)arg;
dev = (const struct device *)arg;
data = DEV_DATA(dev);
cfg = DEV_CFG(dev);
can = cfg->can;
@ -297,14 +297,14 @@ static int can_leave_sleep_mode(CAN_TypeDef *can)
return 0;
}
int can_stm32_runtime_configure(struct device *dev, enum can_mode mode,
int can_stm32_runtime_configure(const struct device *dev, enum can_mode mode,
uint32_t bitrate)
{
CAN_HandleTypeDef hcan;
const struct can_stm32_config *cfg = DEV_CFG(dev);
CAN_TypeDef *can = cfg->can;
struct can_stm32_data *data = DEV_DATA(dev);
struct device *clock;
const struct device *clock;
uint32_t clock_rate;
uint32_t prescaler;
uint32_t reg_mode;
@ -383,7 +383,7 @@ done:
return ret;
}
static int can_stm32_init(struct device *dev)
static int can_stm32_init(const struct device *dev)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
struct can_stm32_data *data = DEV_DATA(dev);
@ -391,7 +391,7 @@ static int can_stm32_init(struct device *dev)
#if DT_NODE_HAS_STATUS(DT_NODELABEL(can2), okay)
CAN_TypeDef *master_can = cfg->master_can;
#endif
struct device *clock;
const struct device *clock;
int ret;
k_mutex_init(&data->inst_mutex);
@ -458,7 +458,7 @@ static int can_stm32_init(struct device *dev)
return 0;
}
static void can_stm32_register_state_change_isr(struct device *dev,
static void can_stm32_register_state_change_isr(const struct device *dev,
can_state_change_isr_t isr)
{
struct can_stm32_data *data = DEV_DATA(dev);
@ -474,7 +474,7 @@ static void can_stm32_register_state_change_isr(struct device *dev,
}
}
static enum can_state can_stm32_get_state(struct device *dev,
static enum can_state can_stm32_get_state(const struct device *dev,
struct can_bus_err_cnt *err_cnt)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
@ -500,7 +500,7 @@ static enum can_state can_stm32_get_state(struct device *dev,
}
#ifndef CONFIG_CAN_AUTO_BUS_OFF_RECOVERY
int can_stm32_recover(struct device *dev, k_timeout_t timeout)
int can_stm32_recover(const struct device *dev, k_timeout_t timeout)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
struct can_stm32_data *data = DEV_DATA(dev);
@ -541,7 +541,7 @@ done:
#endif /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */
int can_stm32_send(struct device *dev, const struct zcan_frame *msg,
int can_stm32_send(const struct device *dev, const struct zcan_frame *msg,
k_timeout_t timeout, can_tx_callback_t callback,
void *callback_arg)
{
@ -951,7 +951,8 @@ done:
return filter_nr;
}
static inline int can_stm32_attach(struct device *dev, can_rx_callback_t cb,
static inline int can_stm32_attach(const struct device *dev,
can_rx_callback_t cb,
void *cb_arg,
const struct zcan_filter *filter)
{
@ -970,7 +971,7 @@ static inline int can_stm32_attach(struct device *dev, can_rx_callback_t cb,
return filter_nr;
}
int can_stm32_attach_isr(struct device *dev, can_rx_callback_t isr,
int can_stm32_attach_isr(const struct device *dev, can_rx_callback_t isr,
void *cb_arg,
const struct zcan_filter *filter)
{
@ -983,7 +984,7 @@ int can_stm32_attach_isr(struct device *dev, can_rx_callback_t isr,
return filter_nr;
}
void can_stm32_detach(struct device *dev, int filter_nr)
void can_stm32_detach(const struct device *dev, int filter_nr)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
struct can_stm32_data *data = DEV_DATA(dev);
@ -1103,9 +1104,9 @@ static void config_can_1_irq(CAN_TypeDef *can)
#include "socket_can_generic.h"
static int socket_can_init_1(struct device *dev)
static int socket_can_init_1(const struct device *dev)
{
struct device *can_dev = DEVICE_GET(can_stm32_1);
const struct device *can_dev = DEVICE_GET(can_stm32_1);
struct socket_can_context *socket_context = dev->data;
LOG_DBG("Init socket CAN device %p (%s) for dev %p (%s)",
@ -1186,9 +1187,9 @@ static void config_can_2_irq(CAN_TypeDef *can)
#include "socket_can_generic.h"
static int socket_can_init_2(struct device *dev)
static int socket_can_init_2(const struct device *dev)
{
struct device *can_dev = DEVICE_GET(can_stm32_2);
const struct device *can_dev = DEVICE_GET(can_stm32_2);
struct socket_can_context *socket_context = dev->data;
LOG_DBG("Init socket CAN device %p (%s) for dev %p (%s)",