Browse Source

refactor(app): replace `config_info` with `config`

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
3d7376d2e5
  1. 4
      app/drivers/kscan/kscan_gpio_demux.c
  2. 8
      app/drivers/kscan/kscan_gpio_direct.c
  3. 4
      app/drivers/kscan/kscan_gpio_matrix.c
  4. 4
      app/drivers/kscan/kscan_mock.c
  5. 4
      app/drivers/sensor/battery_voltage_divider/battery_voltage_divider.c
  6. 6
      app/drivers/sensor/ec11/ec11.c
  7. 4
      app/drivers/sensor/ec11/ec11_trigger.c
  8. 2
      app/src/behaviors/behavior_hold_tap.c
  9. 2
      app/src/behaviors/behavior_reset.c
  10. 2
      app/src/behaviors/behavior_sticky_key.c
  11. 6
      app/src/ext_power_generic.c

4
app/drivers/kscan/kscan_gpio_demux.c

@ -74,7 +74,7 @@ struct kscan_gpio_item_config {
} \ } \
\ \
static const struct kscan_gpio_item_config *kscan_gpio_input_configs_##n(struct device *dev) { \ static const struct kscan_gpio_item_config *kscan_gpio_input_configs_##n(struct device *dev) { \
const struct kscan_gpio_config_##n *cfg = dev->config_info; \ const struct kscan_gpio_config_##n *cfg = dev->config; \
return cfg->rows; \ return cfg->rows; \
} \ } \
\ \
@ -86,7 +86,7 @@ struct kscan_gpio_item_config {
\ \
static const struct kscan_gpio_item_config *kscan_gpio_output_configs_##n( \ static const struct kscan_gpio_item_config *kscan_gpio_output_configs_##n( \
struct device *dev) { \ struct device *dev) { \
const struct kscan_gpio_config_##n *cfg = dev->config_info; \ const struct kscan_gpio_config_##n *cfg = dev->config; \
/* If row2col, rows = outputs & cols = inputs */ \ /* If row2col, rows = outputs & cols = inputs */ \
return cfg->cols; \ return cfg->cols; \
} \ } \

8
app/drivers/kscan/kscan_gpio_direct.c

@ -49,7 +49,7 @@ static struct device **kscan_gpio_input_devices(struct device *dev) {
} }
static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct device *dev) { static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct device *dev) {
const struct kscan_gpio_config *cfg = dev->config_info; const struct kscan_gpio_config *cfg = dev->config;
return cfg->inputs; return cfg->inputs;
} }
@ -72,7 +72,7 @@ struct kscan_gpio_irq_callback {
}; };
static int kscan_gpio_config_interrupts(struct device *dev, gpio_flags_t flags) { static int kscan_gpio_config_interrupts(struct device *dev, gpio_flags_t flags) {
const struct kscan_gpio_config *cfg = dev->config_info; const struct kscan_gpio_config *cfg = dev->config;
struct device **devices = kscan_gpio_input_devices(dev); struct device **devices = kscan_gpio_input_devices(dev);
const struct kscan_gpio_item_config *configs = kscan_gpio_input_configs(dev); const struct kscan_gpio_item_config *configs = kscan_gpio_input_configs(dev);
@ -139,7 +139,7 @@ static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t call
static int kscan_gpio_read(struct device *dev) { static int kscan_gpio_read(struct device *dev) {
struct kscan_gpio_data *data = dev->driver_data; struct kscan_gpio_data *data = dev->driver_data;
const struct kscan_gpio_config *cfg = dev->config_info; const struct kscan_gpio_config *cfg = dev->config;
uint32_t read_state = data->pin_state; uint32_t read_state = data->pin_state;
bool submit_follow_up_read = false; bool submit_follow_up_read = false;
for (int i = 0; i < cfg->num_of_inputs; i++) { for (int i = 0; i < cfg->num_of_inputs; i++) {
@ -196,7 +196,7 @@ static const struct kscan_driver_api gpio_driver_api = {
.inputs = {[INST_INPUT_LEN(n) - 1] = NULL}}; \ .inputs = {[INST_INPUT_LEN(n) - 1] = NULL}}; \
static int kscan_gpio_init_##n(struct device *dev) { \ static int kscan_gpio_init_##n(struct device *dev) { \
struct kscan_gpio_data *data = dev->driver_data; \ struct kscan_gpio_data *data = dev->driver_data; \
const struct kscan_gpio_config *cfg = dev->config_info; \ const struct kscan_gpio_config *cfg = dev->config; \
int err; \ int err; \
struct device **input_devices = kscan_gpio_input_devices(dev); \ struct device **input_devices = kscan_gpio_input_devices(dev); \
for (int i = 0; i < cfg->num_of_inputs; i++) { \ for (int i = 0; i < cfg->num_of_inputs; i++) { \

4
app/drivers/kscan/kscan_gpio_matrix.c

@ -86,7 +86,7 @@ static int kscan_gpio_config_interrupts(struct device **devices,
(data->rows))); \ (data->rows))); \
} \ } \
static const struct kscan_gpio_item_config *kscan_gpio_input_configs_##n(struct device *dev) { \ static const struct kscan_gpio_item_config *kscan_gpio_input_configs_##n(struct device *dev) { \
const struct kscan_gpio_config_##n *cfg = dev->config_info; \ const struct kscan_gpio_config_##n *cfg = dev->config; \
return (( \ return (( \
COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->cols), (cfg->rows)))); \ COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->cols), (cfg->rows)))); \
} \ } \
@ -97,7 +97,7 @@ static int kscan_gpio_config_interrupts(struct device **devices,
} \ } \
static const struct kscan_gpio_item_config *kscan_gpio_output_configs_##n( \ static const struct kscan_gpio_item_config *kscan_gpio_output_configs_##n( \
struct device *dev) { \ struct device *dev) { \
const struct kscan_gpio_config_##n *cfg = dev->config_info; \ const struct kscan_gpio_config_##n *cfg = dev->config; \
return ( \ return ( \
COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \ COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \
} \ } \

4
app/drivers/kscan/kscan_mock.c

@ -50,7 +50,7 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) {
}; \ }; \
static void kscan_mock_schedule_next_event_##n(struct device *dev) { \ 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->driver_data; \
const struct kscan_mock_config_##n *cfg = dev->config_info; \ const struct kscan_mock_config_##n *cfg = dev->config; \
if (data->event_index < DT_INST_PROP_LEN(n, events)) { \ if (data->event_index < DT_INST_PROP_LEN(n, events)) { \
uint32_t ev = cfg->events[data->event_index]; \ uint32_t ev = cfg->events[data->event_index]; \
LOG_DBG("delaying next keypress: %d", ZMK_MOCK_MSEC(ev)); \ LOG_DBG("delaying next keypress: %d", ZMK_MOCK_MSEC(ev)); \
@ -62,7 +62,7 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) {
} \ } \
static void kscan_mock_work_handler_##n(struct k_work *work) { \ static void kscan_mock_work_handler_##n(struct k_work *work) { \
struct kscan_mock_data *data = CONTAINER_OF(work, struct kscan_mock_data, work); \ struct kscan_mock_data *data = CONTAINER_OF(work, struct kscan_mock_data, work); \
const struct kscan_mock_config_##n *cfg = data->dev->config_info; \ const struct kscan_mock_config_##n *cfg = data->dev->config; \
uint32_t ev = cfg->events[data->event_index]; \ uint32_t ev = cfg->events[data->event_index]; \
LOG_DBG("ev %u row %d column %d state %d\n", ev, ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), \ LOG_DBG("ev %u row %d column %d state %d\n", ev, ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), \
ZMK_MOCK_IS_PRESS(ev)); \ ZMK_MOCK_IS_PRESS(ev)); \

4
app/drivers/sensor/battery_voltage_divider/battery_voltage_divider.c

@ -57,7 +57,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) { 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->driver_data;
const struct bvd_config *drv_cfg = dev->config_info; const struct bvd_config *drv_cfg = dev->config;
struct adc_sequence *as = &drv_data->as; struct adc_sequence *as = &drv_data->as;
// Make sure selected channel is supported // Make sure selected channel is supported
@ -141,7 +141,7 @@ static const struct sensor_driver_api bvd_api = {
static int bvd_init(struct device *dev) { static int bvd_init(struct device *dev) {
struct bvd_data *drv_data = dev->driver_data; struct bvd_data *drv_data = dev->driver_data;
const struct bvd_config *drv_cfg = dev->config_info; const struct bvd_config *drv_cfg = dev->config;
drv_data->adc = device_get_binding(drv_cfg->io_channel.label); drv_data->adc = device_get_binding(drv_cfg->io_channel.label);

6
app/drivers/sensor/ec11/ec11.c

@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(EC11, CONFIG_SENSOR_LOG_LEVEL);
static int ec11_get_ab_state(struct device *dev) { static int ec11_get_ab_state(struct device *dev) {
struct ec11_data *drv_data = dev->driver_data; struct ec11_data *drv_data = dev->driver_data;
const struct ec11_config *drv_cfg = dev->config_info; const struct ec11_config *drv_cfg = dev->config;
return (gpio_pin_get(drv_data->a, drv_cfg->a_pin) << 1) | return (gpio_pin_get(drv_data->a, drv_cfg->a_pin) << 1) |
gpio_pin_get(drv_data->b, drv_cfg->b_pin); gpio_pin_get(drv_data->b, drv_cfg->b_pin);
@ -28,7 +28,7 @@ static int ec11_get_ab_state(struct device *dev) {
static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan) { 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->driver_data;
const struct ec11_config *drv_cfg = dev->config_info; const struct ec11_config *drv_cfg = dev->config;
uint8_t val; uint8_t val;
int8_t delta; int8_t delta;
@ -92,7 +92,7 @@ static const struct sensor_driver_api ec11_driver_api = {
int ec11_init(struct device *dev) { int ec11_init(struct device *dev) {
struct ec11_data *drv_data = dev->driver_data; struct ec11_data *drv_data = dev->driver_data;
const struct ec11_config *drv_cfg = dev->config_info; 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, LOG_DBG("A: %s %d B: %s %d resolution %d", drv_cfg->a_label, drv_cfg->a_pin, drv_cfg->b_label,
drv_cfg->b_pin, drv_cfg->resolution); drv_cfg->b_pin, drv_cfg->resolution);

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

@ -21,7 +21,7 @@ LOG_MODULE_DECLARE(EC11, CONFIG_SENSOR_LOG_LEVEL);
static inline void setup_int(struct device *dev, bool enable) { static inline void setup_int(struct device *dev, bool enable) {
struct ec11_data *data = dev->driver_data; struct ec11_data *data = dev->driver_data;
const struct ec11_config *cfg = dev->config_info; const struct ec11_config *cfg = dev->config;
LOG_DBG("enabled %s", (enable ? "true" : "false")); LOG_DBG("enabled %s", (enable ? "true" : "false"));
@ -115,7 +115,7 @@ int ec11_trigger_set(struct device *dev, const struct sensor_trigger *trig,
int ec11_init_interrupt(struct device *dev) { int ec11_init_interrupt(struct device *dev) {
struct ec11_data *drv_data = dev->driver_data; struct ec11_data *drv_data = dev->driver_data;
const struct ec11_config *drv_cfg = dev->config_info; const struct ec11_config *drv_cfg = dev->config;
drv_data->dev = dev; drv_data->dev = dev;
/* setup gpio interrupt */ /* setup gpio interrupt */

2
app/src/behaviors/behavior_hold_tap.c

@ -305,7 +305,7 @@ static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_mome
static int on_hold_tap_binding_pressed(struct zmk_behavior_binding *binding, static int on_hold_tap_binding_pressed(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) { struct zmk_behavior_binding_event event) {
struct device *dev = device_get_binding(binding->behavior_dev); struct device *dev = device_get_binding(binding->behavior_dev);
const struct behavior_hold_tap_config *cfg = dev->config_info; const struct behavior_hold_tap_config *cfg = dev->config;
if (undecided_hold_tap != NULL) { if (undecided_hold_tap != NULL) {
LOG_DBG("ERROR another hold-tap behavior is undecided."); LOG_DBG("ERROR another hold-tap behavior is undecided.");

2
app/src/behaviors/behavior_reset.c

@ -24,7 +24,7 @@ static int behavior_reset_init(struct device *dev) { return 0; };
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) { struct zmk_behavior_binding_event event) {
struct device *dev = device_get_binding(binding->behavior_dev); struct device *dev = device_get_binding(binding->behavior_dev);
const struct behavior_reset_config *cfg = dev->config_info; const struct behavior_reset_config *cfg = dev->config;
// TODO: Correct magic code for going into DFU? // TODO: Correct magic code for going into DFU?
// See // See

2
app/src/behaviors/behavior_sticky_key.c

@ -128,7 +128,7 @@ static int stop_timer(struct active_sticky_key *sticky_key) {
static int on_sticky_key_binding_pressed(struct zmk_behavior_binding *binding, static int on_sticky_key_binding_pressed(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) { struct zmk_behavior_binding_event event) {
struct device *dev = device_get_binding(binding->behavior_dev); struct device *dev = device_get_binding(binding->behavior_dev);
const struct behavior_sticky_key_config *cfg = dev->config_info; const struct behavior_sticky_key_config *cfg = dev->config;
struct active_sticky_key *sticky_key; struct active_sticky_key *sticky_key;
sticky_key = find_sticky_key(event.position); sticky_key = find_sticky_key(event.position);
if (sticky_key != NULL) { if (sticky_key != NULL) {

6
app/src/ext_power_generic.c

@ -57,7 +57,7 @@ int ext_power_save_state() {
static int ext_power_generic_enable(struct device *dev) { 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->driver_data;
const struct ext_power_generic_config *config = dev->config_info; const struct ext_power_generic_config *config = dev->config;
if (gpio_pin_set(data->gpio, config->pin, 1)) { if (gpio_pin_set(data->gpio, config->pin, 1)) {
LOG_WRN("Failed to set ext-power control pin"); LOG_WRN("Failed to set ext-power control pin");
@ -69,7 +69,7 @@ static int ext_power_generic_enable(struct device *dev) {
static int ext_power_generic_disable(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->driver_data;
const struct ext_power_generic_config *config = dev->config_info; const struct ext_power_generic_config *config = dev->config;
if (gpio_pin_set(data->gpio, config->pin, 0)) { if (gpio_pin_set(data->gpio, config->pin, 0)) {
LOG_WRN("Failed to clear ext-power control pin"); LOG_WRN("Failed to clear ext-power control pin");
@ -126,7 +126,7 @@ struct settings_handler ext_power_conf = {.name = "ext_power/state",
static int ext_power_generic_init(struct device *dev) { 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->driver_data;
const struct ext_power_generic_config *config = dev->config_info; const struct ext_power_generic_config *config = dev->config;
data->gpio = device_get_binding(config->label); data->gpio = device_get_binding(config->label);
if (data->gpio == NULL) { if (data->gpio == NULL) {

Loading…
Cancel
Save