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
|
@ -88,7 +88,7 @@ static int lsm6dso_gyro_range_to_fs_val(int32_t range)
|
|||
}
|
||||
#endif
|
||||
|
||||
static inline int lsm6dso_reboot(struct device *dev)
|
||||
static inline int lsm6dso_reboot(const struct device *dev)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
||||
|
@ -102,7 +102,7 @@ static inline int lsm6dso_reboot(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lsm6dso_accel_set_fs_raw(struct device *dev, uint8_t fs)
|
||||
static int lsm6dso_accel_set_fs_raw(const struct device *dev, uint8_t fs)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
||||
|
@ -115,7 +115,7 @@ static int lsm6dso_accel_set_fs_raw(struct device *dev, uint8_t fs)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lsm6dso_accel_set_odr_raw(struct device *dev, uint8_t odr)
|
||||
static int lsm6dso_accel_set_odr_raw(const struct device *dev, uint8_t odr)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
||||
|
@ -128,7 +128,7 @@ static int lsm6dso_accel_set_odr_raw(struct device *dev, uint8_t odr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lsm6dso_gyro_set_fs_raw(struct device *dev, uint8_t fs)
|
||||
static int lsm6dso_gyro_set_fs_raw(const struct device *dev, uint8_t fs)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
||||
|
@ -139,7 +139,7 @@ static int lsm6dso_gyro_set_fs_raw(struct device *dev, uint8_t fs)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lsm6dso_gyro_set_odr_raw(struct device *dev, uint8_t odr)
|
||||
static int lsm6dso_gyro_set_odr_raw(const struct device *dev, uint8_t odr)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
||||
|
@ -151,7 +151,7 @@ static int lsm6dso_gyro_set_odr_raw(struct device *dev, uint8_t odr)
|
|||
}
|
||||
|
||||
#ifdef LSM6DSO_ACCEL_ODR_RUNTIME
|
||||
static int lsm6dso_accel_odr_set(struct device *dev, uint16_t freq)
|
||||
static int lsm6dso_accel_odr_set(const struct device *dev, uint16_t freq)
|
||||
{
|
||||
int odr;
|
||||
|
||||
|
@ -170,7 +170,7 @@ static int lsm6dso_accel_odr_set(struct device *dev, uint16_t freq)
|
|||
#endif
|
||||
|
||||
#ifdef LSM6DSO_ACCEL_FS_RUNTIME
|
||||
static int lsm6dso_accel_range_set(struct device *dev, int32_t range)
|
||||
static int lsm6dso_accel_range_set(const struct device *dev, int32_t range)
|
||||
{
|
||||
int fs;
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
@ -190,9 +190,10 @@ static int lsm6dso_accel_range_set(struct device *dev, int32_t range)
|
|||
}
|
||||
#endif
|
||||
|
||||
static int lsm6dso_accel_config(struct device *dev, enum sensor_channel chan,
|
||||
enum sensor_attribute attr,
|
||||
const struct sensor_value *val)
|
||||
static int lsm6dso_accel_config(const struct device *dev,
|
||||
enum sensor_channel chan,
|
||||
enum sensor_attribute attr,
|
||||
const struct sensor_value *val)
|
||||
{
|
||||
switch (attr) {
|
||||
#ifdef LSM6DSO_ACCEL_FS_RUNTIME
|
||||
|
@ -212,7 +213,7 @@ static int lsm6dso_accel_config(struct device *dev, enum sensor_channel chan,
|
|||
}
|
||||
|
||||
#ifdef LSM6DSO_GYRO_ODR_RUNTIME
|
||||
static int lsm6dso_gyro_odr_set(struct device *dev, uint16_t freq)
|
||||
static int lsm6dso_gyro_odr_set(const struct device *dev, uint16_t freq)
|
||||
{
|
||||
int odr;
|
||||
|
||||
|
@ -231,7 +232,7 @@ static int lsm6dso_gyro_odr_set(struct device *dev, uint16_t freq)
|
|||
#endif
|
||||
|
||||
#ifdef LSM6DSO_GYRO_FS_RUNTIME
|
||||
static int lsm6dso_gyro_range_set(struct device *dev, int32_t range)
|
||||
static int lsm6dso_gyro_range_set(const struct device *dev, int32_t range)
|
||||
{
|
||||
int fs;
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
@ -251,9 +252,10 @@ static int lsm6dso_gyro_range_set(struct device *dev, int32_t range)
|
|||
}
|
||||
#endif
|
||||
|
||||
static int lsm6dso_gyro_config(struct device *dev, enum sensor_channel chan,
|
||||
enum sensor_attribute attr,
|
||||
const struct sensor_value *val)
|
||||
static int lsm6dso_gyro_config(const struct device *dev,
|
||||
enum sensor_channel chan,
|
||||
enum sensor_attribute attr,
|
||||
const struct sensor_value *val)
|
||||
{
|
||||
switch (attr) {
|
||||
#ifdef LSM6DSO_GYRO_FS_RUNTIME
|
||||
|
@ -272,9 +274,10 @@ static int lsm6dso_gyro_config(struct device *dev, enum sensor_channel chan,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lsm6dso_attr_set(struct device *dev, enum sensor_channel chan,
|
||||
enum sensor_attribute attr,
|
||||
const struct sensor_value *val)
|
||||
static int lsm6dso_attr_set(const struct device *dev,
|
||||
enum sensor_channel chan,
|
||||
enum sensor_attribute attr,
|
||||
const struct sensor_value *val)
|
||||
{
|
||||
switch (chan) {
|
||||
case SENSOR_CHAN_ACCEL_XYZ:
|
||||
|
@ -295,7 +298,7 @@ static int lsm6dso_attr_set(struct device *dev, enum sensor_channel chan,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lsm6dso_sample_fetch_accel(struct device *dev)
|
||||
static int lsm6dso_sample_fetch_accel(const struct device *dev)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
union axis3bit16_t buf;
|
||||
|
@ -312,7 +315,7 @@ static int lsm6dso_sample_fetch_accel(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lsm6dso_sample_fetch_gyro(struct device *dev)
|
||||
static int lsm6dso_sample_fetch_gyro(const struct device *dev)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
union axis3bit16_t buf;
|
||||
|
@ -330,7 +333,7 @@ static int lsm6dso_sample_fetch_gyro(struct device *dev)
|
|||
}
|
||||
|
||||
#if defined(CONFIG_LSM6DSO_ENABLE_TEMP)
|
||||
static int lsm6dso_sample_fetch_temp(struct device *dev)
|
||||
static int lsm6dso_sample_fetch_temp(const struct device *dev)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
union axis1bit16_t buf;
|
||||
|
@ -347,7 +350,7 @@ static int lsm6dso_sample_fetch_temp(struct device *dev)
|
|||
#endif
|
||||
|
||||
#if defined(CONFIG_LSM6DSO_SENSORHUB)
|
||||
static int lsm6dso_sample_fetch_shub(struct device *dev)
|
||||
static int lsm6dso_sample_fetch_shub(const struct device *dev)
|
||||
{
|
||||
if (lsm6dso_shub_fetch_external_devs(dev) < 0) {
|
||||
LOG_DBG("failed to read ext shub devices");
|
||||
|
@ -358,7 +361,8 @@ static int lsm6dso_sample_fetch_shub(struct device *dev)
|
|||
}
|
||||
#endif /* CONFIG_LSM6DSO_SENSORHUB */
|
||||
|
||||
static int lsm6dso_sample_fetch(struct device *dev, enum sensor_channel chan)
|
||||
static int lsm6dso_sample_fetch(const struct device *dev,
|
||||
enum sensor_channel chan)
|
||||
{
|
||||
switch (chan) {
|
||||
case SENSOR_CHAN_ACCEL_XYZ:
|
||||
|
@ -625,7 +629,7 @@ static inline void lsm6dso_temp_convert(struct sensor_value *val,
|
|||
}
|
||||
#endif
|
||||
|
||||
static int lsm6dso_channel_get(struct device *dev,
|
||||
static int lsm6dso_channel_get(const struct device *dev,
|
||||
enum sensor_channel chan,
|
||||
struct sensor_value *val)
|
||||
{
|
||||
|
@ -685,7 +689,7 @@ static const struct sensor_driver_api lsm6dso_api_funcs = {
|
|||
.channel_get = lsm6dso_channel_get,
|
||||
};
|
||||
|
||||
static int lsm6dso_init_chip(struct device *dev)
|
||||
static int lsm6dso_init_chip(const struct device *dev)
|
||||
{
|
||||
struct lsm6dso_data *lsm6dso = dev->data;
|
||||
uint8_t chip_id;
|
||||
|
@ -787,7 +791,7 @@ static const struct lsm6dso_config lsm6dso_config = {
|
|||
#endif /* CONFIG_LSM6DSO_TRIGGER */
|
||||
};
|
||||
|
||||
static int lsm6dso_init(struct device *dev)
|
||||
static int lsm6dso_init(const struct device *dev)
|
||||
{
|
||||
const struct lsm6dso_config * const config = dev->config;
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
|
|
@ -93,7 +93,7 @@ union axis1bit16_t {
|
|||
|
||||
struct lsm6dso_config {
|
||||
char *bus_name;
|
||||
int (*bus_init)(struct device *dev);
|
||||
int (*bus_init)(const struct device *dev);
|
||||
#ifdef CONFIG_LSM6DSO_TRIGGER
|
||||
const char *int_gpio_port;
|
||||
uint8_t int_gpio_pin;
|
||||
|
@ -138,7 +138,7 @@ struct lsm6dso_tf {
|
|||
#define LSM6DSO_SHUB_MAX_NUM_SLVS 2
|
||||
|
||||
struct lsm6dso_data {
|
||||
struct device *bus;
|
||||
const struct device *bus;
|
||||
int16_t acc[3];
|
||||
uint32_t acc_gain;
|
||||
int16_t gyro[3];
|
||||
|
@ -172,12 +172,12 @@ struct lsm6dso_data {
|
|||
uint8_t gyro_fs;
|
||||
|
||||
#ifdef CONFIG_LSM6DSO_TRIGGER
|
||||
struct device *gpio;
|
||||
const struct device *gpio;
|
||||
struct gpio_callback gpio_cb;
|
||||
sensor_trigger_handler_t handler_drdy_acc;
|
||||
sensor_trigger_handler_t handler_drdy_gyr;
|
||||
sensor_trigger_handler_t handler_drdy_temp;
|
||||
struct device *dev;
|
||||
const struct device *dev;
|
||||
|
||||
#if defined(CONFIG_LSM6DSO_TRIGGER_OWN_THREAD)
|
||||
K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_LSM6DSO_THREAD_STACK_SIZE);
|
||||
|
@ -193,23 +193,23 @@ struct lsm6dso_data {
|
|||
#endif
|
||||
};
|
||||
|
||||
int lsm6dso_spi_init(struct device *dev);
|
||||
int lsm6dso_i2c_init(struct device *dev);
|
||||
int lsm6dso_spi_init(const struct device *dev);
|
||||
int lsm6dso_i2c_init(const struct device *dev);
|
||||
#if defined(CONFIG_LSM6DSO_SENSORHUB)
|
||||
int lsm6dso_shub_init(struct device *dev);
|
||||
int lsm6dso_shub_fetch_external_devs(struct device *dev);
|
||||
int lsm6dso_shub_init(const struct device *dev);
|
||||
int lsm6dso_shub_fetch_external_devs(const struct device *dev);
|
||||
int lsm6dso_shub_get_idx(enum sensor_channel type);
|
||||
int lsm6dso_shub_config(struct device *dev, enum sensor_channel chan,
|
||||
int lsm6dso_shub_config(const struct device *dev, enum sensor_channel chan,
|
||||
enum sensor_attribute attr,
|
||||
const struct sensor_value *val);
|
||||
#endif /* CONFIG_LSM6DSO_SENSORHUB */
|
||||
|
||||
#ifdef CONFIG_LSM6DSO_TRIGGER
|
||||
int lsm6dso_trigger_set(struct device *dev,
|
||||
int lsm6dso_trigger_set(const struct device *dev,
|
||||
const struct sensor_trigger *trig,
|
||||
sensor_trigger_handler_t handler);
|
||||
|
||||
int lsm6dso_init_interrupt(struct device *dev);
|
||||
int lsm6dso_init_interrupt(const struct device *dev);
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_DRIVERS_SENSOR_LSM6DSO_LSM6DSO_H_ */
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
LOG_MODULE_DECLARE(LSM6DSO, CONFIG_SENSOR_LOG_LEVEL);
|
||||
|
||||
static int lsm6dso_i2c_read(struct device *dev, uint8_t reg_addr,
|
||||
static int lsm6dso_i2c_read(const struct device *dev, uint8_t reg_addr,
|
||||
uint8_t *value, uint8_t len)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
@ -30,7 +30,7 @@ static int lsm6dso_i2c_read(struct device *dev, uint8_t reg_addr,
|
|||
reg_addr, value, len);
|
||||
}
|
||||
|
||||
static int lsm6dso_i2c_write(struct device *dev, uint8_t reg_addr,
|
||||
static int lsm6dso_i2c_write(const struct device *dev, uint8_t reg_addr,
|
||||
uint8_t *value, uint8_t len)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
@ -40,7 +40,7 @@ static int lsm6dso_i2c_write(struct device *dev, uint8_t reg_addr,
|
|||
reg_addr, value, len);
|
||||
}
|
||||
|
||||
int lsm6dso_i2c_init(struct device *dev)
|
||||
int lsm6dso_i2c_init(const struct device *dev)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
||||
|
|
|
@ -677,7 +677,7 @@ int lsm6dso_shub_get_idx(enum sensor_channel type)
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
int lsm6dso_shub_fetch_external_devs(struct device *dev)
|
||||
int lsm6dso_shub_fetch_external_devs(const struct device *dev)
|
||||
{
|
||||
uint8_t n;
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
@ -701,7 +701,7 @@ int lsm6dso_shub_fetch_external_devs(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int lsm6dso_shub_config(struct device *dev, enum sensor_channel chan,
|
||||
int lsm6dso_shub_config(const struct device *dev, enum sensor_channel chan,
|
||||
enum sensor_attribute attr,
|
||||
const struct sensor_value *val)
|
||||
{
|
||||
|
@ -729,7 +729,7 @@ int lsm6dso_shub_config(struct device *dev, enum sensor_channel chan,
|
|||
return sp->dev_conf(data, sp->ext_i2c_addr, chan, attr, val);
|
||||
}
|
||||
|
||||
int lsm6dso_shub_init(struct device *dev)
|
||||
int lsm6dso_shub_init(const struct device *dev)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
uint8_t i, n = 0, regn;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
LOG_MODULE_DECLARE(LSM6DSO, CONFIG_SENSOR_LOG_LEVEL);
|
||||
|
||||
static int lsm6dso_spi_read(struct device *dev, uint8_t reg_addr,
|
||||
static int lsm6dso_spi_read(const struct device *dev, uint8_t reg_addr,
|
||||
uint8_t *value, uint8_t len)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
@ -62,7 +62,7 @@ static int lsm6dso_spi_read(struct device *dev, uint8_t reg_addr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lsm6dso_spi_write(struct device *dev, uint8_t reg_addr,
|
||||
static int lsm6dso_spi_write(const struct device *dev, uint8_t reg_addr,
|
||||
uint8_t *value, uint8_t len)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
@ -96,7 +96,7 @@ static int lsm6dso_spi_write(struct device *dev, uint8_t reg_addr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int lsm6dso_spi_init(struct device *dev)
|
||||
int lsm6dso_spi_init(const struct device *dev)
|
||||
{
|
||||
struct lsm6dso_data *data = dev->data;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ LOG_MODULE_DECLARE(LSM6DSO, CONFIG_SENSOR_LOG_LEVEL);
|
|||
/**
|
||||
* lsm6dso_enable_t_int - TEMP enable selected int pin to generate interrupt
|
||||
*/
|
||||
static int lsm6dso_enable_t_int(struct device *dev, int enable)
|
||||
static int lsm6dso_enable_t_int(const struct device *dev, int enable)
|
||||
{
|
||||
const struct lsm6dso_config *cfg = dev->config;
|
||||
struct lsm6dso_data *lsm6dso = dev->data;
|
||||
|
@ -51,7 +51,7 @@ static int lsm6dso_enable_t_int(struct device *dev, int enable)
|
|||
/**
|
||||
* lsm6dso_enable_xl_int - XL enable selected int pin to generate interrupt
|
||||
*/
|
||||
static int lsm6dso_enable_xl_int(struct device *dev, int enable)
|
||||
static int lsm6dso_enable_xl_int(const struct device *dev, int enable)
|
||||
{
|
||||
const struct lsm6dso_config *cfg = dev->config;
|
||||
struct lsm6dso_data *lsm6dso = dev->data;
|
||||
|
@ -87,7 +87,7 @@ static int lsm6dso_enable_xl_int(struct device *dev, int enable)
|
|||
/**
|
||||
* lsm6dso_enable_g_int - Gyro enable selected int pin to generate interrupt
|
||||
*/
|
||||
static int lsm6dso_enable_g_int(struct device *dev, int enable)
|
||||
static int lsm6dso_enable_g_int(const struct device *dev, int enable)
|
||||
{
|
||||
const struct lsm6dso_config *cfg = dev->config;
|
||||
struct lsm6dso_data *lsm6dso = dev->data;
|
||||
|
@ -122,7 +122,7 @@ static int lsm6dso_enable_g_int(struct device *dev, int enable)
|
|||
/**
|
||||
* lsm6dso_trigger_set - link external trigger to event data ready
|
||||
*/
|
||||
int lsm6dso_trigger_set(struct device *dev,
|
||||
int lsm6dso_trigger_set(const struct device *dev,
|
||||
const struct sensor_trigger *trig,
|
||||
sensor_trigger_handler_t handler)
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ int lsm6dso_trigger_set(struct device *dev,
|
|||
*/
|
||||
static void lsm6dso_handle_interrupt(void *arg)
|
||||
{
|
||||
struct device *dev = arg;
|
||||
const struct device *dev = arg;
|
||||
struct lsm6dso_data *lsm6dso = dev->data;
|
||||
struct sensor_trigger drdy_trigger = {
|
||||
.type = SENSOR_TRIG_DATA_READY,
|
||||
|
@ -204,7 +204,7 @@ static void lsm6dso_handle_interrupt(void *arg)
|
|||
GPIO_INT_EDGE_TO_ACTIVE);
|
||||
}
|
||||
|
||||
static void lsm6dso_gpio_callback(struct device *dev,
|
||||
static void lsm6dso_gpio_callback(const struct device *dev,
|
||||
struct gpio_callback *cb, uint32_t pins)
|
||||
{
|
||||
struct lsm6dso_data *lsm6dso =
|
||||
|
@ -226,7 +226,7 @@ static void lsm6dso_gpio_callback(struct device *dev,
|
|||
#ifdef CONFIG_LSM6DSO_TRIGGER_OWN_THREAD
|
||||
static void lsm6dso_thread(int dev_ptr, int unused)
|
||||
{
|
||||
struct device *dev = INT_TO_POINTER(dev_ptr);
|
||||
const struct device *dev = INT_TO_POINTER(dev_ptr);
|
||||
struct lsm6dso_data *lsm6dso = dev->data;
|
||||
|
||||
ARG_UNUSED(unused);
|
||||
|
@ -248,7 +248,7 @@ static void lsm6dso_work_cb(struct k_work *work)
|
|||
}
|
||||
#endif /* CONFIG_LSM6DSO_TRIGGER_GLOBAL_THREAD */
|
||||
|
||||
int lsm6dso_init_interrupt(struct device *dev)
|
||||
int lsm6dso_init_interrupt(const struct device *dev)
|
||||
{
|
||||
struct lsm6dso_data *lsm6dso = dev->data;
|
||||
const struct lsm6dso_config *cfg = dev->config;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue