Browse Source

refactor(app): replace `driver_data` with `data`

See: https://docs.zephyrproject.org/latest/releases/release-notes-2.4.html
PR: #467
xmkb
innovaker 4 years ago committed by Pete Johanson
parent
commit
1411092a7b
  1. 6
      app/drivers/kscan/kscan_composite.c
  2. 14
      app/drivers/kscan/kscan_gpio_demux.c
  3. 12
      app/drivers/kscan/kscan_gpio_direct.c
  4. 14
      app/drivers/kscan/kscan_gpio_matrix.c
  5. 8
      app/drivers/kscan/kscan_mock.c
  6. 6
      app/drivers/sensor/battery_voltage_divider/battery_voltage_divider.c
  7. 8
      app/drivers/sensor/ec11/ec11.c
  8. 10
      app/drivers/sensor/ec11/ec11_trigger.c
  9. 12
      app/src/ext_power_generic.c

6
app/drivers/kscan/kscan_composite.c

@ -59,7 +59,7 @@ static void kscan_composite_child_callback(struct device *child_dev, uint32_t ro @@ -59,7 +59,7 @@ static void kscan_composite_child_callback(struct device *child_dev, uint32_t ro
bool pressed) {
// TODO: Ideally we can get this passed into our callback!
struct device *dev = device_get_binding(DT_INST_LABEL(0));
struct kscan_composite_data *data = dev->driver_data;
struct kscan_composite_data *data = dev->data;
for (int i = 0; i < ARRAY_SIZE(kscan_composite_children); i++) {
const struct kscan_composite_child_config *cfg = &kscan_composite_children[i];
@ -73,7 +73,7 @@ static void kscan_composite_child_callback(struct device *child_dev, uint32_t ro @@ -73,7 +73,7 @@ static void kscan_composite_child_callback(struct device *child_dev, uint32_t ro
}
static int kscan_composite_configure(struct device *dev, kscan_callback_t callback) {
struct kscan_composite_data *data = dev->driver_data;
struct kscan_composite_data *data = dev->data;
if (!callback) {
return -EINVAL;
@ -91,7 +91,7 @@ static int kscan_composite_configure(struct device *dev, kscan_callback_t callba @@ -91,7 +91,7 @@ static int kscan_composite_configure(struct device *dev, kscan_callback_t callba
}
static int kscan_composite_init(struct device *dev) {
struct kscan_composite_data *data = dev->driver_data;
struct kscan_composite_data *data = dev->data;
data->dev = dev;

14
app/drivers/kscan/kscan_gpio_demux.c

@ -69,7 +69,7 @@ struct kscan_gpio_item_config { @@ -69,7 +69,7 @@ struct kscan_gpio_item_config {
/* IO/GPIO SETUP */ \
/* gpio_input_devices are PHYSICAL IO devices */ \
static struct device **kscan_gpio_input_devices_##n(struct device *dev) { \
struct kscan_gpio_data_##n *data = dev->driver_data; \
struct kscan_gpio_data_##n *data = dev->data; \
return data->rows; \
} \
\
@ -80,7 +80,7 @@ struct kscan_gpio_item_config { @@ -80,7 +80,7 @@ struct kscan_gpio_item_config {
\
/* gpio_output_devices are PHYSICAL IO devices */ \
static struct device **kscan_gpio_output_devices_##n(struct device *dev) { \
struct kscan_gpio_data_##n *data = dev->driver_data; \
struct kscan_gpio_data_##n *data = dev->data; \
return data->cols; \
} \
\
@ -101,7 +101,7 @@ struct kscan_gpio_item_config { @@ -101,7 +101,7 @@ struct kscan_gpio_item_config {
/* This is the core matrix_scan func */ \
static int kscan_gpio_read_##n(struct device *dev) { \
bool submit_follow_up_read = false; \
struct kscan_gpio_data_##n *data = dev->driver_data; \
struct kscan_gpio_data_##n *data = dev->data; \
static bool read_state[INST_MATRIX_INPUTS(n)][INST_MATRIX_OUTPUTS(n)]; \
for (int o = 0; o < INST_MATRIX_OUTPUTS(n); o++) { \
/* Iterate over bits and set GPIOs accordingly */ \
@ -153,7 +153,7 @@ struct kscan_gpio_item_config { @@ -153,7 +153,7 @@ struct kscan_gpio_item_config {
/* KSCAN API configure function */ \
static int kscan_gpio_configure_##n(struct device *dev, kscan_callback_t callback) { \
LOG_DBG("KSCAN API configure"); \
struct kscan_gpio_data_##n *data = dev->driver_data; \
struct kscan_gpio_data_##n *data = dev->data; \
if (!callback) { \
return -EINVAL; \
} \
@ -165,7 +165,7 @@ struct kscan_gpio_item_config { @@ -165,7 +165,7 @@ struct kscan_gpio_item_config {
/* KSCAN API enable function */ \
static int kscan_gpio_enable_##n(struct device *dev) { \
LOG_DBG("KSCAN API enable"); \
struct kscan_gpio_data_##n *data = dev->driver_data; \
struct kscan_gpio_data_##n *data = dev->data; \
/* TODO: we might want a follow up to hook into the sleep state hooks in Zephyr, */ \
/* and disable this timer when we enter a sleep state */ \
k_timer_start(&data->poll_timer, K_MSEC(POLL_INTERVAL(n)), K_MSEC(POLL_INTERVAL(n))); \
@ -175,7 +175,7 @@ struct kscan_gpio_item_config { @@ -175,7 +175,7 @@ struct kscan_gpio_item_config {
/* KSCAN API disable function */ \
static int kscan_gpio_disable_##n(struct device *dev) { \
LOG_DBG("KSCAN API disable"); \
struct kscan_gpio_data_##n *data = dev->driver_data; \
struct kscan_gpio_data_##n *data = dev->data; \
k_timer_stop(&data->poll_timer); \
return 0; \
}; \
@ -183,7 +183,7 @@ struct kscan_gpio_item_config { @@ -183,7 +183,7 @@ struct kscan_gpio_item_config {
/* GPIO init function*/ \
static int kscan_gpio_init_##n(struct device *dev) { \
LOG_DBG("KSCAN GPIO init"); \
struct kscan_gpio_data_##n *data = dev->driver_data; \
struct kscan_gpio_data_##n *data = dev->data; \
int err; \
/* configure input devices*/ \
struct device **input_devices = kscan_gpio_input_devices_##n(dev); \

12
app/drivers/kscan/kscan_gpio_direct.c

@ -44,7 +44,7 @@ struct kscan_gpio_data { @@ -44,7 +44,7 @@ struct kscan_gpio_data {
};
static struct device **kscan_gpio_input_devices(struct device *dev) {
struct kscan_gpio_data *data = dev->driver_data;
struct kscan_gpio_data *data = dev->data;
return data->inputs;
}
@ -116,12 +116,12 @@ static void kscan_gpio_timer_handler(struct k_timer *timer) { @@ -116,12 +116,12 @@ static void kscan_gpio_timer_handler(struct k_timer *timer) {
}
static int kscan_gpio_direct_enable(struct device *dev) {
struct kscan_gpio_data *data = dev->driver_data;
struct kscan_gpio_data *data = dev->data;
k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10));
return 0;
}
static int kscan_gpio_direct_disable(struct device *dev) {
struct kscan_gpio_data *data = dev->driver_data;
struct kscan_gpio_data *data = dev->data;
k_timer_stop(&data->poll_timer);
return 0;
}
@ -129,7 +129,7 @@ static int kscan_gpio_direct_disable(struct device *dev) { @@ -129,7 +129,7 @@ static int kscan_gpio_direct_disable(struct device *dev) {
#endif /* defined(CONFIG_ZMK_KSCAN_DIRECT_POLLING) */
static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t callback) {
struct kscan_gpio_data *data = dev->driver_data;
struct kscan_gpio_data *data = dev->data;
if (!callback) {
return -EINVAL;
}
@ -138,7 +138,7 @@ static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t call @@ -138,7 +138,7 @@ static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t call
}
static int kscan_gpio_read(struct device *dev) {
struct kscan_gpio_data *data = dev->driver_data;
struct kscan_gpio_data *data = dev->data;
const struct kscan_gpio_config *cfg = dev->config;
uint32_t read_state = data->pin_state;
bool submit_follow_up_read = false;
@ -195,7 +195,7 @@ static const struct kscan_driver_api gpio_driver_api = { @@ -195,7 +195,7 @@ static const struct kscan_driver_api gpio_driver_api = {
static struct kscan_gpio_data kscan_gpio_data_##n = { \
.inputs = {[INST_INPUT_LEN(n) - 1] = NULL}}; \
static int kscan_gpio_init_##n(struct device *dev) { \
struct kscan_gpio_data *data = dev->driver_data; \
struct kscan_gpio_data *data = dev->data; \
const struct kscan_gpio_config *cfg = dev->config; \
int err; \
struct device **input_devices = kscan_gpio_input_devices(dev); \

14
app/drivers/kscan/kscan_gpio_matrix.c

@ -81,7 +81,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, @@ -81,7 +81,7 @@ static int kscan_gpio_config_interrupts(struct device **devices,
struct device *dev; \
}; \
static struct device **kscan_gpio_input_devices_##n(struct device *dev) { \
struct kscan_gpio_data_##n *data = dev->driver_data; \
struct kscan_gpio_data_##n *data = dev->data; \
return (COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (data->cols), \
(data->rows))); \
} \
@ -91,7 +91,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, @@ -91,7 +91,7 @@ static int kscan_gpio_config_interrupts(struct device **devices,
COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->cols), (cfg->rows)))); \
} \
static struct device **kscan_gpio_output_devices_##n(struct device *dev) { \
struct kscan_gpio_data_##n *data = dev->driver_data; \
struct kscan_gpio_data_##n *data = dev->data; \
return (COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (data->rows), \
(data->cols))); \
} \
@ -132,7 +132,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, @@ -132,7 +132,7 @@ static int kscan_gpio_config_interrupts(struct device **devices,
} \
static int kscan_gpio_read_##n(struct device *dev) { \
bool submit_follow_up_read = false; \
struct kscan_gpio_data_##n *data = dev->driver_data; \
struct kscan_gpio_data_##n *data = dev->data; \
static bool read_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \
/* Disable our interrupts temporarily while we scan, to avoid */ \
/* re-entry while we iterate columns and set them active one by one */ \
@ -197,7 +197,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, @@ -197,7 +197,7 @@ static int kscan_gpio_config_interrupts(struct device **devices,
static struct kscan_gpio_data_##n kscan_gpio_data_##n = { \
.rows = {[INST_MATRIX_ROWS(n) - 1] = NULL}, .cols = {[INST_MATRIX_COLS(n) - 1] = NULL}}; \
static int kscan_gpio_configure_##n(struct device *dev, kscan_callback_t callback) { \
struct kscan_gpio_data_##n *data = dev->driver_data; \
struct kscan_gpio_data_##n *data = dev->data; \
if (!callback) { \
return -EINVAL; \
} \
@ -207,14 +207,14 @@ static int kscan_gpio_config_interrupts(struct device **devices, @@ -207,14 +207,14 @@ static int kscan_gpio_config_interrupts(struct device **devices,
}; \
static int kscan_gpio_enable_##n(struct device *dev) { \
COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \
(struct kscan_gpio_data_##n *data = dev->driver_data; \
(struct kscan_gpio_data_##n *data = dev->data; \
k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10)); return 0;), \
(int err = kscan_gpio_enable_interrupts_##n(dev); \
if (err) { return err; } return kscan_gpio_read_##n(dev);)) \
}; \
static int kscan_gpio_disable_##n(struct device *dev) { \
COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \
(struct kscan_gpio_data_##n *data = dev->driver_data; \
(struct kscan_gpio_data_##n *data = dev->data; \
k_timer_stop(&data->poll_timer); return 0;), \
(return kscan_gpio_disable_interrupts_##n(dev);)) \
}; \
@ -226,7 +226,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, @@ -226,7 +226,7 @@ static int kscan_gpio_config_interrupts(struct device **devices,
}), \
()) \
static int kscan_gpio_init_##n(struct device *dev) { \
struct kscan_gpio_data_##n *data = dev->driver_data; \
struct kscan_gpio_data_##n *data = dev->data; \
int err; \
struct device **input_devices = kscan_gpio_input_devices_##n(dev); \
for (int i = 0; i < INST_INPUT_LEN(n); i++) { \

8
app/drivers/kscan/kscan_mock.c

@ -24,14 +24,14 @@ struct kscan_mock_data { @@ -24,14 +24,14 @@ struct kscan_mock_data {
};
static int kscan_mock_disable_callback(struct device *dev) {
struct kscan_mock_data *data = dev->driver_data;
struct kscan_mock_data *data = dev->data;
k_delayed_work_cancel(&data->work);
return 0;
}
static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) {
struct kscan_mock_data *data = dev->driver_data;
struct kscan_mock_data *data = dev->data;
if (!callback) {
return -EINVAL;
@ -49,7 +49,7 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) { @@ -49,7 +49,7 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) {
bool exit_after; \
}; \
static void kscan_mock_schedule_next_event_##n(struct device *dev) { \
struct kscan_mock_data *data = dev->driver_data; \
struct kscan_mock_data *data = dev->data; \
const struct kscan_mock_config_##n *cfg = dev->config; \
if (data->event_index < DT_INST_PROP_LEN(n, events)) { \
uint32_t ev = cfg->events[data->event_index]; \
@ -71,7 +71,7 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) { @@ -71,7 +71,7 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) {
data->event_index++; \
} \
static int kscan_mock_init_##n(struct device *dev) { \
struct kscan_mock_data *data = dev->driver_data; \
struct kscan_mock_data *data = dev->data; \
data->dev = dev; \
k_delayed_work_init(&data->work, kscan_mock_work_handler_##n); \
return 0; \

6
app/drivers/sensor/battery_voltage_divider/battery_voltage_divider.c

@ -56,7 +56,7 @@ static uint8_t lithium_ion_mv_to_pct(int16_t bat_mv) { @@ -56,7 +56,7 @@ static uint8_t lithium_ion_mv_to_pct(int16_t bat_mv) {
}
static int bvd_sample_fetch(struct device *dev, enum sensor_channel chan) {
struct bvd_data *drv_data = dev->driver_data;
struct bvd_data *drv_data = dev->data;
const struct bvd_config *drv_cfg = dev->config;
struct adc_sequence *as = &drv_data->as;
@ -114,7 +114,7 @@ static int bvd_sample_fetch(struct device *dev, enum sensor_channel chan) { @@ -114,7 +114,7 @@ static int bvd_sample_fetch(struct device *dev, enum sensor_channel chan) {
}
static int bvd_channel_get(struct device *dev, enum sensor_channel chan, struct sensor_value *val) {
struct bvd_data *drv_data = dev->driver_data;
struct bvd_data *drv_data = dev->data;
switch (chan) {
case SENSOR_CHAN_GAUGE_VOLTAGE:
@ -140,7 +140,7 @@ static const struct sensor_driver_api bvd_api = { @@ -140,7 +140,7 @@ static const struct sensor_driver_api bvd_api = {
};
static int bvd_init(struct device *dev) {
struct bvd_data *drv_data = dev->driver_data;
struct bvd_data *drv_data = dev->data;
const struct bvd_config *drv_cfg = dev->config;
drv_data->adc = device_get_binding(drv_cfg->io_channel.label);

8
app/drivers/sensor/ec11/ec11.c

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
LOG_MODULE_REGISTER(EC11, CONFIG_SENSOR_LOG_LEVEL);
static int ec11_get_ab_state(struct device *dev) {
struct ec11_data *drv_data = dev->driver_data;
struct ec11_data *drv_data = dev->data;
const struct ec11_config *drv_cfg = dev->config;
return (gpio_pin_get(drv_data->a, drv_cfg->a_pin) << 1) |
@ -27,7 +27,7 @@ static int ec11_get_ab_state(struct device *dev) { @@ -27,7 +27,7 @@ static int ec11_get_ab_state(struct device *dev) {
}
static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan) {
struct ec11_data *drv_data = dev->driver_data;
struct ec11_data *drv_data = dev->data;
const struct ec11_config *drv_cfg = dev->config;
uint8_t val;
int8_t delta;
@ -70,7 +70,7 @@ static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan) { @@ -70,7 +70,7 @@ static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan) {
static int ec11_channel_get(struct device *dev, enum sensor_channel chan,
struct sensor_value *val) {
struct ec11_data *drv_data = dev->driver_data;
struct ec11_data *drv_data = dev->data;
if (chan != SENSOR_CHAN_ROTATION) {
return -ENOTSUP;
@ -91,7 +91,7 @@ static const struct sensor_driver_api ec11_driver_api = { @@ -91,7 +91,7 @@ static const struct sensor_driver_api ec11_driver_api = {
};
int ec11_init(struct device *dev) {
struct ec11_data *drv_data = dev->driver_data;
struct ec11_data *drv_data = dev->data;
const struct ec11_config *drv_cfg = dev->config;
LOG_DBG("A: %s %d B: %s %d resolution %d", drv_cfg->a_label, drv_cfg->a_pin, drv_cfg->b_label,

10
app/drivers/sensor/ec11/ec11_trigger.c

@ -20,7 +20,7 @@ extern struct ec11_data ec11_driver; @@ -20,7 +20,7 @@ extern struct ec11_data ec11_driver;
LOG_MODULE_DECLARE(EC11, CONFIG_SENSOR_LOG_LEVEL);
static inline void setup_int(struct device *dev, bool enable) {
struct ec11_data *data = dev->driver_data;
struct ec11_data *data = dev->data;
const struct ec11_config *cfg = dev->config;
LOG_DBG("enabled %s", (enable ? "true" : "false"));
@ -66,7 +66,7 @@ static void ec11_b_gpio_callback(struct device *dev, struct gpio_callback *cb, u @@ -66,7 +66,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;
struct ec11_data *drv_data = dev->driver_data;
struct ec11_data *drv_data = dev->data;
drv_data->handler(dev, drv_data->trigger);
@ -76,7 +76,7 @@ static void ec11_thread_cb(void *arg) { @@ -76,7 +76,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);
struct ec11_data *drv_data = dev->driver_data;
struct ec11_data *drv_data = dev->data;
ARG_UNUSED(unused);
@ -99,7 +99,7 @@ static void ec11_work_cb(struct k_work *work) { @@ -99,7 +99,7 @@ static void ec11_work_cb(struct k_work *work) {
int ec11_trigger_set(struct device *dev, const struct sensor_trigger *trig,
sensor_trigger_handler_t handler) {
struct ec11_data *drv_data = dev->driver_data;
struct ec11_data *drv_data = dev->data;
setup_int(dev, false);
@ -114,7 +114,7 @@ int ec11_trigger_set(struct device *dev, const struct sensor_trigger *trig, @@ -114,7 +114,7 @@ int ec11_trigger_set(struct device *dev, const struct sensor_trigger *trig,
}
int ec11_init_interrupt(struct device *dev) {
struct ec11_data *drv_data = dev->driver_data;
struct ec11_data *drv_data = dev->data;
const struct ec11_config *drv_cfg = dev->config;
drv_data->dev = dev;

12
app/src/ext_power_generic.c

@ -37,7 +37,7 @@ struct ext_power_generic_data { @@ -37,7 +37,7 @@ struct ext_power_generic_data {
static void ext_power_save_state_work(struct k_work *work) {
char setting_path[40];
struct device *ext_power = device_get_binding(DT_INST_LABEL(0));
struct ext_power_generic_data *data = ext_power->driver_data;
struct ext_power_generic_data *data = ext_power->data;
snprintf(setting_path, 40, "ext_power/state/%s", DT_INST_LABEL(0));
settings_save_one(setting_path, &data->status, sizeof(data->status));
@ -56,7 +56,7 @@ int ext_power_save_state() { @@ -56,7 +56,7 @@ int ext_power_save_state() {
}
static int ext_power_generic_enable(struct device *dev) {
struct ext_power_generic_data *data = dev->driver_data;
struct ext_power_generic_data *data = dev->data;
const struct ext_power_generic_config *config = dev->config;
if (gpio_pin_set(data->gpio, config->pin, 1)) {
@ -68,7 +68,7 @@ static int ext_power_generic_enable(struct device *dev) { @@ -68,7 +68,7 @@ static int ext_power_generic_enable(struct device *dev) {
}
static int ext_power_generic_disable(struct device *dev) {
struct ext_power_generic_data *data = dev->driver_data;
struct ext_power_generic_data *data = dev->data;
const struct ext_power_generic_config *config = dev->config;
if (gpio_pin_set(data->gpio, config->pin, 0)) {
@ -80,7 +80,7 @@ static int ext_power_generic_disable(struct device *dev) { @@ -80,7 +80,7 @@ static int ext_power_generic_disable(struct device *dev) {
}
static int ext_power_generic_get(struct device *dev) {
struct ext_power_generic_data *data = dev->driver_data;
struct ext_power_generic_data *data = dev->data;
return data->status;
}
@ -92,7 +92,7 @@ static int ext_power_settings_set(const char *name, size_t len, settings_read_cb @@ -92,7 +92,7 @@ static int ext_power_settings_set(const char *name, size_t len, settings_read_cb
if (settings_name_steq(name, DT_INST_LABEL(0), &next) && !next) {
struct device *ext_power = device_get_binding(DT_INST_LABEL(0));
struct ext_power_generic_data *data = ext_power->driver_data;
struct ext_power_generic_data *data = ext_power->data;
if (len != sizeof(data->status)) {
return -EINVAL;
@ -125,7 +125,7 @@ struct settings_handler ext_power_conf = {.name = "ext_power/state", @@ -125,7 +125,7 @@ struct settings_handler ext_power_conf = {.name = "ext_power/state",
#endif
static int ext_power_generic_init(struct device *dev) {
struct ext_power_generic_data *data = dev->driver_data;
struct ext_power_generic_data *data = dev->data;
const struct ext_power_generic_config *config = dev->config;
data->gpio = device_get_binding(config->label);

Loading…
Cancel
Save