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
|
@ -77,9 +77,9 @@ struct ds3231_config {
|
|||
};
|
||||
|
||||
struct ds3231_data {
|
||||
struct device *ds3231;
|
||||
struct device *i2c;
|
||||
struct device *isw;
|
||||
const struct device *ds3231;
|
||||
const struct device *i2c;
|
||||
const struct device *isw;
|
||||
struct register_map registers;
|
||||
|
||||
struct k_sem lock;
|
||||
|
@ -144,7 +144,7 @@ struct ds3231_data {
|
|||
*
|
||||
* Caches and returns the value with the changes applied.
|
||||
*/
|
||||
static int sc_ctrl(struct device *dev,
|
||||
static int sc_ctrl(const struct device *dev,
|
||||
uint8_t set,
|
||||
uint8_t clear)
|
||||
{
|
||||
|
@ -168,7 +168,7 @@ static int sc_ctrl(struct device *dev,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int maxim_ds3231_ctrl_update(struct device *dev,
|
||||
int maxim_ds3231_ctrl_update(const struct device *dev,
|
||||
uint8_t set_bits,
|
||||
uint8_t clear_bits)
|
||||
{
|
||||
|
@ -194,7 +194,7 @@ int maxim_ds3231_ctrl_update(struct device *dev,
|
|||
* Returns the value as originally read (disregarding the effect of
|
||||
* clears and sets).
|
||||
*/
|
||||
static inline int rsc_stat(struct device *dev,
|
||||
static inline int rsc_stat(const struct device *dev,
|
||||
uint8_t set,
|
||||
uint8_t clear)
|
||||
{
|
||||
|
@ -226,7 +226,7 @@ static inline int rsc_stat(struct device *dev,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int maxim_ds3231_stat_update(struct device *dev,
|
||||
int maxim_ds3231_stat_update(const struct device *dev,
|
||||
uint8_t set_bits,
|
||||
uint8_t clear_bits)
|
||||
{
|
||||
|
@ -245,7 +245,7 @@ int maxim_ds3231_stat_update(struct device *dev,
|
|||
* Look for current users of the interrupt/square-wave signal and
|
||||
* enable monitoring iff at least one consumer is active.
|
||||
*/
|
||||
static void validate_isw_monitoring(struct device *dev)
|
||||
static void validate_isw_monitoring(const struct device *dev)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
const struct ds3231_config *cfg = dev->config;
|
||||
|
@ -446,7 +446,7 @@ static uint32_t decode_rtc(struct ds3231_data *data)
|
|||
return data->rtc_registers;
|
||||
}
|
||||
|
||||
static int update_registers(struct device *dev)
|
||||
static int update_registers(const struct device *dev)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
const struct ds3231_config *cfg = dev->config;
|
||||
|
@ -467,7 +467,7 @@ static int update_registers(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int maxim_ds3231_get_alarm(struct device *dev,
|
||||
int maxim_ds3231_get_alarm(const struct device *dev,
|
||||
uint8_t id,
|
||||
struct maxim_ds3231_alarm *cp)
|
||||
{
|
||||
|
@ -514,7 +514,7 @@ out:
|
|||
return rv;
|
||||
}
|
||||
|
||||
static int cancel_alarm(struct device *dev,
|
||||
static int cancel_alarm(const struct device *dev,
|
||||
uint8_t id)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
|
@ -525,7 +525,7 @@ static int cancel_alarm(struct device *dev,
|
|||
return sc_ctrl(dev, 0, MAXIM_DS3231_ALARM1 << id);
|
||||
}
|
||||
|
||||
static int ds3231_counter_cancel_alarm(struct device *dev,
|
||||
static int ds3231_counter_cancel_alarm(const struct device *dev,
|
||||
uint8_t id)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
|
@ -552,7 +552,7 @@ out:
|
|||
return rv;
|
||||
}
|
||||
|
||||
static int set_alarm(struct device *dev,
|
||||
static int set_alarm(const struct device *dev,
|
||||
uint8_t id,
|
||||
const struct maxim_ds3231_alarm *cp)
|
||||
{
|
||||
|
@ -601,7 +601,7 @@ static int set_alarm(struct device *dev,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int maxim_ds3231_set_alarm(struct device *dev,
|
||||
int maxim_ds3231_set_alarm(const struct device *dev,
|
||||
uint8_t id,
|
||||
const struct maxim_ds3231_alarm *cp)
|
||||
{
|
||||
|
@ -616,7 +616,7 @@ int maxim_ds3231_set_alarm(struct device *dev,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int maxim_ds3231_check_alarms(struct device *dev)
|
||||
int maxim_ds3231_check_alarms(const struct device *dev)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
const struct register_map *rp = &data->registers;
|
||||
|
@ -638,7 +638,7 @@ int maxim_ds3231_check_alarms(struct device *dev)
|
|||
return rv;
|
||||
}
|
||||
|
||||
static int check_handled_alarms(struct device *dev)
|
||||
static int check_handled_alarms(const struct device *dev)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
const struct register_map *rp = &data->registers;
|
||||
|
@ -659,7 +659,7 @@ static int check_handled_alarms(struct device *dev)
|
|||
return rv;
|
||||
}
|
||||
|
||||
static void counter_alarm_forwarder(struct device *dev,
|
||||
static void counter_alarm_forwarder(const struct device *dev,
|
||||
uint8_t id,
|
||||
uint32_t syncclock,
|
||||
void *ud)
|
||||
|
@ -671,7 +671,7 @@ static void alarm_worker(struct k_work *work)
|
|||
{
|
||||
struct ds3231_data *data = CONTAINER_OF(work, struct ds3231_data,
|
||||
alarm_work);
|
||||
struct device *ds3231 = data->ds3231;
|
||||
const struct device *ds3231 = data->ds3231;
|
||||
const struct ds3231_config *cfg = ds3231->config;
|
||||
|
||||
k_sem_take(&data->lock, K_FOREVER);
|
||||
|
@ -747,7 +747,7 @@ static void sqw_worker(struct k_work *work)
|
|||
syncclock - data->isw_syncclock);
|
||||
}
|
||||
|
||||
static int read_time(struct device *dev,
|
||||
static int read_time(const struct device *dev,
|
||||
time_t *time)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
|
@ -765,7 +765,7 @@ static int read_time(struct device *dev,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int ds3231_counter_get_value(struct device *dev,
|
||||
static int ds3231_counter_get_value(const struct device *dev,
|
||||
uint32_t *ticks)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
|
@ -784,7 +784,7 @@ static int ds3231_counter_get_value(struct device *dev,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static void sync_finish(struct device *dev,
|
||||
static void sync_finish(const struct device *dev,
|
||||
int rc)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
|
@ -816,7 +816,7 @@ static void sync_finish(struct device *dev,
|
|||
}
|
||||
}
|
||||
|
||||
static void sync_prep_read(struct device *dev)
|
||||
static void sync_prep_read(const struct device *dev)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
int rc = sc_ctrl(dev, 0U, MAXIM_DS3231_REG_CTRL_INTCN
|
||||
|
@ -830,7 +830,7 @@ static void sync_prep_read(struct device *dev)
|
|||
validate_isw_monitoring(dev);
|
||||
}
|
||||
|
||||
static void sync_finish_read(struct device *dev)
|
||||
static void sync_finish_read(const struct device *dev)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
time_t time = 0;
|
||||
|
@ -851,7 +851,7 @@ static void sync_timer_handler(struct k_timer *tmr)
|
|||
k_work_submit(&data->sync_work);
|
||||
}
|
||||
|
||||
static void sync_prep_write(struct device *dev)
|
||||
static void sync_prep_write(const struct device *dev)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
uint32_t syncclock = maxim_ds3231_read_syncclock(dev);
|
||||
|
@ -883,7 +883,7 @@ static void sync_prep_write(struct device *dev)
|
|||
LOG_INF("sync %u in %u ms after %u", (uint32_t)when, rem_ms, syncclock);
|
||||
}
|
||||
|
||||
static void sync_finish_write(struct device *dev)
|
||||
static void sync_finish_write(const struct device *dev)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
const struct ds3231_config *cfg = dev->config;
|
||||
|
@ -967,7 +967,7 @@ static void sync_worker(struct k_work *work)
|
|||
}
|
||||
}
|
||||
|
||||
static void isw_gpio_callback(struct device *port,
|
||||
static void isw_gpio_callback(const struct device *port,
|
||||
struct gpio_callback *cb,
|
||||
uint32_t pins)
|
||||
{
|
||||
|
@ -984,7 +984,7 @@ static void isw_gpio_callback(struct device *port,
|
|||
}
|
||||
}
|
||||
|
||||
int z_impl_maxim_ds3231_get_syncpoint(struct device *dev,
|
||||
int z_impl_maxim_ds3231_get_syncpoint(const struct device *dev,
|
||||
struct maxim_ds3231_syncpoint *syncpoint)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
|
@ -1004,7 +1004,7 @@ int z_impl_maxim_ds3231_get_syncpoint(struct device *dev,
|
|||
return rv;
|
||||
}
|
||||
|
||||
int maxim_ds3231_synchronize(struct device *dev,
|
||||
int maxim_ds3231_synchronize(const struct device *dev,
|
||||
struct sys_notify *notify)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
|
@ -1042,7 +1042,7 @@ out:
|
|||
return rv;
|
||||
}
|
||||
|
||||
int z_impl_maxim_ds3231_req_syncpoint(struct device *dev,
|
||||
int z_impl_maxim_ds3231_req_syncpoint(const struct device *dev,
|
||||
struct k_poll_signal *sig)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
|
@ -1075,7 +1075,7 @@ out:
|
|||
return rv;
|
||||
}
|
||||
|
||||
int maxim_ds3231_set(struct device *dev,
|
||||
int maxim_ds3231_set(const struct device *dev,
|
||||
const struct maxim_ds3231_syncpoint *syncpoint,
|
||||
struct sys_notify *notify)
|
||||
{
|
||||
|
@ -1115,11 +1115,11 @@ out:
|
|||
return rv;
|
||||
}
|
||||
|
||||
static int ds3231_init(struct device *dev)
|
||||
static int ds3231_init(const struct device *dev)
|
||||
{
|
||||
struct ds3231_data *data = dev->data;
|
||||
const struct ds3231_config *cfg = dev->config;
|
||||
struct device *i2c = device_get_binding(cfg->bus_name);
|
||||
const struct device *i2c = device_get_binding(cfg->bus_name);
|
||||
int rc;
|
||||
|
||||
/* Initialize and take the lock */
|
||||
|
@ -1155,7 +1155,7 @@ static int ds3231_init(struct device *dev)
|
|||
*/
|
||||
|
||||
if (cfg->isw_gpios.ctrl != NULL) {
|
||||
struct device *gpio = device_get_binding(cfg->isw_gpios.ctrl);
|
||||
const struct device *gpio = device_get_binding(cfg->isw_gpios.ctrl);
|
||||
|
||||
if (gpio == NULL) {
|
||||
LOG_WRN("Failed to get INTn/SQW GPIO %s",
|
||||
|
@ -1199,17 +1199,17 @@ out:
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int ds3231_counter_start(struct device *dev)
|
||||
static int ds3231_counter_start(const struct device *dev)
|
||||
{
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
static int ds3231_counter_stop(struct device *dev)
|
||||
static int ds3231_counter_stop(const struct device *dev)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
int ds3231_counter_set_alarm(struct device *dev,
|
||||
int ds3231_counter_set_alarm(const struct device *dev,
|
||||
uint8_t id,
|
||||
const struct counter_alarm_cfg *alarm_cfg)
|
||||
{
|
||||
|
@ -1265,23 +1265,23 @@ out:
|
|||
return rc;
|
||||
}
|
||||
|
||||
static uint32_t ds3231_counter_get_top_value(struct device *dev)
|
||||
static uint32_t ds3231_counter_get_top_value(const struct device *dev)
|
||||
{
|
||||
return UINT32_MAX;
|
||||
}
|
||||
|
||||
static uint32_t ds3231_counter_get_pending_int(struct device *dev)
|
||||
static uint32_t ds3231_counter_get_pending_int(const struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ds3231_counter_set_top_value(struct device *dev,
|
||||
static int ds3231_counter_set_top_value(const struct device *dev,
|
||||
const struct counter_top_cfg *cfg)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static uint32_t ds3231_counter_get_max_relative_alarm(struct device *dev)
|
||||
static uint32_t ds3231_counter_get_max_relative_alarm(const struct device *dev)
|
||||
{
|
||||
return UINT32_MAX;
|
||||
}
|
||||
|
@ -1333,7 +1333,7 @@ DEVICE_AND_API_INIT(ds3231_0, DT_INST_LABEL(0),
|
|||
|
||||
#include <syscall_handler.h>
|
||||
|
||||
int z_vrfy_maxim_ds3231_get_syncpoint(struct device *dev,
|
||||
int z_vrfy_maxim_ds3231_get_syncpoint(const struct device *dev,
|
||||
struct maxim_ds3231_syncpoint *syncpoint)
|
||||
{
|
||||
struct maxim_ds3231_syncpoint value;
|
||||
|
@ -1353,7 +1353,7 @@ int z_vrfy_maxim_ds3231_get_syncpoint(struct device *dev,
|
|||
|
||||
#include <syscalls/maxim_ds3231_get_syncpoint_mrsh.c>
|
||||
|
||||
int z_vrfy_maxim_ds3231_req_syncpoint(struct device *dev,
|
||||
int z_vrfy_maxim_ds3231_req_syncpoint(const struct device *dev,
|
||||
struct k_poll_signal *sig)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_SPECIFIC_DRIVER(dev, K_OBJ_DRIVER_COUNTER, &ds3231_api));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue