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
|
@ -22,7 +22,7 @@
|
|||
|
||||
LOG_MODULE_REGISTER(LSM9DS0_GYRO, CONFIG_SENSOR_LOG_LEVEL);
|
||||
|
||||
static inline int lsm9ds0_gyro_power_ctrl(struct device *dev, int power,
|
||||
static inline int lsm9ds0_gyro_power_ctrl(const struct device *dev, int power,
|
||||
int x_en, int y_en, int z_en)
|
||||
{
|
||||
struct lsm9ds0_gyro_data *data = dev->data;
|
||||
|
@ -41,7 +41,7 @@ static inline int lsm9ds0_gyro_power_ctrl(struct device *dev, int power,
|
|||
state);
|
||||
}
|
||||
|
||||
static int lsm9ds0_gyro_set_fs_raw(struct device *dev, uint8_t fs)
|
||||
static int lsm9ds0_gyro_set_fs_raw(const struct device *dev, uint8_t fs)
|
||||
{
|
||||
struct lsm9ds0_gyro_data *data = dev->data;
|
||||
const struct lsm9ds0_gyro_config *config = dev->config;
|
||||
|
@ -68,7 +68,7 @@ static const struct {
|
|||
{500, 1},
|
||||
{2000, 2} };
|
||||
|
||||
static int lsm9ds0_gyro_set_fs(struct device *dev, int fs)
|
||||
static int lsm9ds0_gyro_set_fs(const struct device *dev, int fs)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -82,7 +82,8 @@ static int lsm9ds0_gyro_set_fs(struct device *dev, int fs)
|
|||
}
|
||||
#endif
|
||||
|
||||
static inline int lsm9ds0_gyro_set_odr_raw(struct device *dev, uint8_t odr)
|
||||
static inline int lsm9ds0_gyro_set_odr_raw(const struct device *dev,
|
||||
uint8_t odr)
|
||||
{
|
||||
struct lsm9ds0_gyro_data *data = dev->data;
|
||||
const struct lsm9ds0_gyro_config *config = dev->config;
|
||||
|
@ -102,7 +103,7 @@ static const struct {
|
|||
{380, 2},
|
||||
{760, 3} };
|
||||
|
||||
static int lsm9ds0_gyro_set_odr(struct device *dev, int odr)
|
||||
static int lsm9ds0_gyro_set_odr(const struct device *dev, int odr)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -118,7 +119,7 @@ static int lsm9ds0_gyro_set_odr(struct device *dev, int odr)
|
|||
}
|
||||
#endif
|
||||
|
||||
static int lsm9ds0_gyro_sample_fetch(struct device *dev,
|
||||
static int lsm9ds0_gyro_sample_fetch(const struct device *dev,
|
||||
enum sensor_channel chan)
|
||||
{
|
||||
struct lsm9ds0_gyro_data *data = dev->data;
|
||||
|
@ -192,7 +193,7 @@ static inline int lsm9ds0_gyro_get_channel(enum sensor_channel chan,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lsm9ds0_gyro_channel_get(struct device *dev,
|
||||
static int lsm9ds0_gyro_channel_get(const struct device *dev,
|
||||
enum sensor_channel chan,
|
||||
struct sensor_value *val)
|
||||
{
|
||||
|
@ -218,7 +219,7 @@ static int lsm9ds0_gyro_channel_get(struct device *dev,
|
|||
}
|
||||
|
||||
#if defined(LSM9DS0_GYRO_SET_ATTR)
|
||||
static int lsm9ds0_gyro_attr_set(struct device *dev,
|
||||
static int lsm9ds0_gyro_attr_set(const struct device *dev,
|
||||
enum sensor_channel chan,
|
||||
enum sensor_attribute attr,
|
||||
const struct sensor_value *val)
|
||||
|
@ -259,7 +260,7 @@ static const struct sensor_driver_api lsm9ds0_gyro_api_funcs = {
|
|||
#endif
|
||||
};
|
||||
|
||||
static int lsm9ds0_gyro_init_chip(struct device *dev)
|
||||
static int lsm9ds0_gyro_init_chip(const struct device *dev)
|
||||
{
|
||||
struct lsm9ds0_gyro_data *data = dev->data;
|
||||
const struct lsm9ds0_gyro_config *config = dev->config;
|
||||
|
@ -315,7 +316,7 @@ err_poweroff:
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
static int lsm9ds0_gyro_init(struct device *dev)
|
||||
static int lsm9ds0_gyro_init(const struct device *dev)
|
||||
{
|
||||
const struct lsm9ds0_gyro_config * const config = dev->config;
|
||||
struct lsm9ds0_gyro_data *data = dev->data;
|
||||
|
|
|
@ -221,7 +221,7 @@ struct lsm9ds0_gyro_config {
|
|||
};
|
||||
|
||||
struct lsm9ds0_gyro_data {
|
||||
struct device *i2c_master;
|
||||
const struct device *i2c_master;
|
||||
|
||||
#if defined(CONFIG_LSM9DS0_GYRO_TRIGGERS)
|
||||
struct k_sem sem;
|
||||
|
@ -231,9 +231,9 @@ struct lsm9ds0_gyro_data {
|
|||
K_KERNEL_STACK_MEMBER(thread_stack,
|
||||
CONFIG_LSM9DS0_GYRO_THREAD_STACK_SIZE);
|
||||
struct k_thread thread;
|
||||
struct device *dev;
|
||||
const struct device *dev;
|
||||
|
||||
struct device *gpio_drdy;
|
||||
const struct device *gpio_drdy;
|
||||
struct gpio_callback gpio_cb;
|
||||
struct sensor_trigger trigger_drdy;
|
||||
sensor_trigger_handler_t handler_drdy;
|
||||
|
@ -247,11 +247,11 @@ struct lsm9ds0_gyro_data {
|
|||
};
|
||||
|
||||
#if defined(CONFIG_LSM9DS0_GYRO_TRIGGER_DRDY)
|
||||
int lsm9ds0_gyro_trigger_set(struct device *dev,
|
||||
int lsm9ds0_gyro_trigger_set(const struct device *dev,
|
||||
const struct sensor_trigger *trig,
|
||||
sensor_trigger_handler_t handler);
|
||||
|
||||
int lsm9ds0_gyro_init_interrupt(struct device *dev);
|
||||
int lsm9ds0_gyro_init_interrupt(const struct device *dev);
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_DRIVERS_SENSOR_LSM9DS0_GYRO_LSM9DS0_GYRO_H_ */
|
||||
|
|
|
@ -20,7 +20,7 @@ extern struct lsm9ds0_gyro_data lsm9ds0_gyro_data;
|
|||
|
||||
LOG_MODULE_DECLARE(LSM9DS0_GYRO, CONFIG_SENSOR_LOG_LEVEL);
|
||||
|
||||
static inline void setup_drdy(struct device *dev,
|
||||
static inline void setup_drdy(const struct device *dev,
|
||||
bool enable)
|
||||
{
|
||||
struct lsm9ds0_gyro_data *data = dev->data;
|
||||
|
@ -33,7 +33,7 @@ static inline void setup_drdy(struct device *dev,
|
|||
: GPIO_INT_DISABLE);
|
||||
}
|
||||
|
||||
int lsm9ds0_gyro_trigger_set(struct device *dev,
|
||||
int lsm9ds0_gyro_trigger_set(const struct device *dev,
|
||||
const struct sensor_trigger *trig,
|
||||
sensor_trigger_handler_t handler)
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ int lsm9ds0_gyro_trigger_set(struct device *dev,
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static void lsm9ds0_gyro_gpio_drdy_callback(struct device *dev,
|
||||
static void lsm9ds0_gyro_gpio_drdy_callback(const struct device *dev,
|
||||
struct gpio_callback *cb, uint32_t pins)
|
||||
{
|
||||
struct lsm9ds0_gyro_data *data =
|
||||
|
@ -83,7 +83,7 @@ static void lsm9ds0_gyro_gpio_drdy_callback(struct device *dev,
|
|||
|
||||
static void lsm9ds0_gyro_thread_main(void *arg1, void *arg2, void *arg3)
|
||||
{
|
||||
struct device *dev = (struct device *) arg1;
|
||||
const struct device *dev = (const struct device *) arg1;
|
||||
struct lsm9ds0_gyro_data *data = dev->data;
|
||||
|
||||
while (1) {
|
||||
|
@ -97,7 +97,7 @@ static void lsm9ds0_gyro_thread_main(void *arg1, void *arg2, void *arg3)
|
|||
}
|
||||
}
|
||||
|
||||
int lsm9ds0_gyro_init_interrupt(struct device *dev)
|
||||
int lsm9ds0_gyro_init_interrupt(const struct device *dev)
|
||||
{
|
||||
const struct lsm9ds0_gyro_config * const config =
|
||||
dev->config;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue