refactor(app): replace struct device * with const struct device *

Replaced with RegExp: /(?<!const )(struct device \*)/g

See: https://docs.zephyrproject.org/latest/releases/release-notes-2.4.html
PR: #467
This commit is contained in:
innovaker
2020-12-10 19:31:51 +00:00
committed by Pete Johanson
parent 1411092a7b
commit 00ca0d2f1c
41 changed files with 172 additions and 163 deletions

View File

@@ -33,8 +33,8 @@ struct bvd_config {
};
struct bvd_data {
struct device *adc;
struct device *gpio;
const struct device *adc;
const struct device *gpio;
struct adc_channel_cfg acc;
struct adc_sequence as;
uint16_t adc_raw;
@@ -55,7 +55,7 @@ static uint8_t lithium_ion_mv_to_pct(int16_t bat_mv) {
return bat_mv * 2 / 15 - 459;
}
static int bvd_sample_fetch(struct device *dev, enum sensor_channel chan) {
static int bvd_sample_fetch(const struct device *dev, enum sensor_channel chan) {
struct bvd_data *drv_data = dev->data;
const struct bvd_config *drv_cfg = dev->config;
struct adc_sequence *as = &drv_data->as;
@@ -113,7 +113,8 @@ static int bvd_sample_fetch(struct device *dev, enum sensor_channel chan) {
return rc;
}
static int bvd_channel_get(struct device *dev, enum sensor_channel chan, struct sensor_value *val) {
static int bvd_channel_get(const struct device *dev, enum sensor_channel chan,
struct sensor_value *val) {
struct bvd_data *drv_data = dev->data;
switch (chan) {
@@ -139,7 +140,7 @@ static const struct sensor_driver_api bvd_api = {
.channel_get = bvd_channel_get,
};
static int bvd_init(struct device *dev) {
static int bvd_init(const struct device *dev) {
struct bvd_data *drv_data = dev->data;
const struct bvd_config *drv_cfg = dev->config;

View File

@@ -18,7 +18,7 @@
LOG_MODULE_REGISTER(EC11, CONFIG_SENSOR_LOG_LEVEL);
static int ec11_get_ab_state(struct device *dev) {
static int ec11_get_ab_state(const struct device *dev) {
struct ec11_data *drv_data = dev->data;
const struct ec11_config *drv_cfg = dev->config;
@@ -26,7 +26,7 @@ static int ec11_get_ab_state(struct device *dev) {
gpio_pin_get(drv_data->b, drv_cfg->b_pin);
}
static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan) {
static int ec11_sample_fetch(const struct device *dev, enum sensor_channel chan) {
struct ec11_data *drv_data = dev->data;
const struct ec11_config *drv_cfg = dev->config;
uint8_t val;
@@ -68,7 +68,7 @@ static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan) {
return 0;
}
static int ec11_channel_get(struct device *dev, enum sensor_channel chan,
static int ec11_channel_get(const struct device *dev, enum sensor_channel chan,
struct sensor_value *val) {
struct ec11_data *drv_data = dev->data;
@@ -90,7 +90,7 @@ static const struct sensor_driver_api ec11_driver_api = {
.channel_get = ec11_channel_get,
};
int ec11_init(struct device *dev) {
int ec11_init(const struct device *dev) {
struct ec11_data *drv_data = dev->data;
const struct ec11_config *drv_cfg = dev->config;

View File

@@ -23,8 +23,8 @@ struct ec11_config {
};
struct ec11_data {
struct device *a;
struct device *b;
const struct device *a;
const struct device *b;
uint8_t ab_state;
int8_t pulses;
int8_t ticks;
@@ -33,7 +33,7 @@ struct ec11_data {
#ifdef CONFIG_EC11_TRIGGER
struct gpio_callback a_gpio_cb;
struct gpio_callback b_gpio_cb;
struct device *dev;
const struct device *dev;
sensor_trigger_handler_t handler;
const struct sensor_trigger *trigger;
@@ -51,8 +51,8 @@ struct ec11_data {
#ifdef CONFIG_EC11_TRIGGER
int ec11_trigger_set(struct device *dev, const struct sensor_trigger *trig,
int ec11_trigger_set(const struct device *dev, const struct sensor_trigger *trig,
sensor_trigger_handler_t handler);
int ec11_init_interrupt(struct device *dev);
int ec11_init_interrupt(const struct device *dev);
#endif

View File

@@ -19,7 +19,7 @@ extern struct ec11_data ec11_driver;
#include <logging/log.h>
LOG_MODULE_DECLARE(EC11, CONFIG_SENSOR_LOG_LEVEL);
static inline void setup_int(struct device *dev, bool enable) {
static inline void setup_int(const struct device *dev, bool enable) {
struct ec11_data *data = dev->data;
const struct ec11_config *cfg = dev->config;
@@ -36,7 +36,8 @@ static inline void setup_int(struct device *dev, bool enable) {
}
}
static void ec11_a_gpio_callback(struct device *dev, struct gpio_callback *cb, uint32_t pins) {
static void ec11_a_gpio_callback(const struct device *dev, struct gpio_callback *cb,
uint32_t pins) {
struct ec11_data *drv_data = CONTAINER_OF(cb, struct ec11_data, a_gpio_cb);
LOG_DBG("");
@@ -50,7 +51,8 @@ static void ec11_a_gpio_callback(struct device *dev, struct gpio_callback *cb, u
#endif
}
static void ec11_b_gpio_callback(struct device *dev, struct gpio_callback *cb, uint32_t pins) {
static void ec11_b_gpio_callback(const struct device *dev, struct gpio_callback *cb,
uint32_t pins) {
struct ec11_data *drv_data = CONTAINER_OF(cb, struct ec11_data, b_gpio_cb);
LOG_DBG("");
@@ -65,7 +67,7 @@ static void ec11_b_gpio_callback(struct device *dev, struct gpio_callback *cb, u
}
static void ec11_thread_cb(void *arg) {
struct device *dev = arg;
const struct device *dev = arg;
struct ec11_data *drv_data = dev->data;
drv_data->handler(dev, drv_data->trigger);
@@ -75,7 +77,7 @@ static void ec11_thread_cb(void *arg) {
#ifdef CONFIG_EC11_TRIGGER_OWN_THREAD
static void ec11_thread(int dev_ptr, int unused) {
struct device *dev = INT_TO_POINTER(dev_ptr);
const struct device *dev = INT_TO_POINTER(dev_ptr);
struct ec11_data *drv_data = dev->data;
ARG_UNUSED(unused);
@@ -97,7 +99,7 @@ static void ec11_work_cb(struct k_work *work) {
}
#endif
int ec11_trigger_set(struct device *dev, const struct sensor_trigger *trig,
int ec11_trigger_set(const struct device *dev, const struct sensor_trigger *trig,
sensor_trigger_handler_t handler) {
struct ec11_data *drv_data = dev->data;
@@ -113,7 +115,7 @@ int ec11_trigger_set(struct device *dev, const struct sensor_trigger *trig,
return 0;
}
int ec11_init_interrupt(struct device *dev) {
int ec11_init_interrupt(const struct device *dev) {
struct ec11_data *drv_data = dev->data;
const struct ec11_config *drv_cfg = dev->config;