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:
parent
c8906fef79
commit
e18fcbba5a
1426 changed files with 9356 additions and 8368 deletions
|
@ -29,18 +29,19 @@ struct i2c_nrfx_twi_config {
|
|||
nrfx_twi_config_t config;
|
||||
};
|
||||
|
||||
static inline struct i2c_nrfx_twi_data *get_dev_data(struct device *dev)
|
||||
static inline struct i2c_nrfx_twi_data *get_dev_data(const struct device *dev)
|
||||
{
|
||||
return dev->data;
|
||||
}
|
||||
|
||||
static inline
|
||||
const struct i2c_nrfx_twi_config *get_dev_config(struct device *dev)
|
||||
const struct i2c_nrfx_twi_config *get_dev_config(const struct device *dev)
|
||||
{
|
||||
return dev->config;
|
||||
}
|
||||
|
||||
static int i2c_nrfx_twi_transfer(struct device *dev, struct i2c_msg *msgs,
|
||||
static int i2c_nrfx_twi_transfer(const struct device *dev,
|
||||
struct i2c_msg *msgs,
|
||||
uint8_t num_msgs, uint16_t addr)
|
||||
{
|
||||
int ret = 0;
|
||||
|
@ -143,7 +144,7 @@ static int i2c_nrfx_twi_transfer(struct device *dev, struct i2c_msg *msgs,
|
|||
|
||||
static void event_handler(nrfx_twi_evt_t const *p_event, void *p_context)
|
||||
{
|
||||
struct device *dev = p_context;
|
||||
const struct device *dev = p_context;
|
||||
struct i2c_nrfx_twi_data *dev_data = get_dev_data(dev);
|
||||
|
||||
switch (p_event->type) {
|
||||
|
@ -164,7 +165,8 @@ static void event_handler(nrfx_twi_evt_t const *p_event, void *p_context)
|
|||
k_sem_give(&dev_data->completion_sync);
|
||||
}
|
||||
|
||||
static int i2c_nrfx_twi_configure(struct device *dev, uint32_t dev_config)
|
||||
static int i2c_nrfx_twi_configure(const struct device *dev,
|
||||
uint32_t dev_config)
|
||||
{
|
||||
nrfx_twi_t const *inst = &(get_dev_config(dev)->twi);
|
||||
|
||||
|
@ -193,7 +195,7 @@ static const struct i2c_driver_api i2c_nrfx_twi_driver_api = {
|
|||
.transfer = i2c_nrfx_twi_transfer,
|
||||
};
|
||||
|
||||
static int init_twi(struct device *dev)
|
||||
static int init_twi(const struct device *dev)
|
||||
{
|
||||
nrfx_err_t result = nrfx_twi_init(&get_dev_config(dev)->twi,
|
||||
&get_dev_config(dev)->config,
|
||||
|
@ -211,7 +213,8 @@ static int init_twi(struct device *dev)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
|
||||
static int twi_nrfx_pm_control(struct device *dev, uint32_t ctrl_command,
|
||||
static int twi_nrfx_pm_control(const struct device *dev,
|
||||
uint32_t ctrl_command,
|
||||
void *context, device_pm_cb cb, void *arg)
|
||||
{
|
||||
int ret = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue