From 3528e1b49775f1ed0a59847640f6710e18d351f8 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Fri, 5 Nov 2021 04:18:03 +0000 Subject: [PATCH] refactor: Move to newer API for IO channels. See: https://docs.zephyrproject.org/latest/releases/release-notes-2.6.html#api-changes --- app/drivers/sensor/battery/battery_voltage_divider.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/drivers/sensor/battery/battery_voltage_divider.c b/app/drivers/sensor/battery/battery_voltage_divider.c index 8981fb3a..484ca4fc 100644 --- a/app/drivers/sensor/battery/battery_voltage_divider.c +++ b/app/drivers/sensor/battery/battery_voltage_divider.c @@ -18,7 +18,6 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct io_channel_config { - const char *label; uint8_t channel; }; @@ -119,10 +118,8 @@ static int bvd_init(const struct device *dev) { 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); - if (drv_data->adc == NULL) { - LOG_ERR("ADC %s failed to retrieve", drv_cfg->io_channel.label); + LOG_ERR("ADC failed to retrieve ADC driver"); return -ENODEV; } @@ -170,12 +167,12 @@ static int bvd_init(const struct device *dev) { return rc; } -static struct bvd_data bvd_data; +static struct bvd_data bvd_data = {.adc = DEVICE_DT_GET(DT_IO_CHANNELS_CTLR(DT_DRV_INST(0)))}; + static const struct bvd_config bvd_cfg = { .io_channel = { - DT_INST_IO_CHANNELS_LABEL(0), - DT_INST_IO_CHANNELS_INPUT(0), + DT_IO_CHANNELS_INPUT(DT_DRV_INST(0)), }, #if DT_INST_NODE_HAS_PROP(0, power_gpios) .power_gpios =