refactor: Move away from deprecated label usages.

* Move away from DT_LABEL.
* Move to DEVICE_DT_GET for non-behavior device access.
* Move various drivers to `gpio_spec_dt` and `DT` related macros.
* Remove mcp23017 while at it, since better upstream driver is
  available.
This commit is contained in:
Peter Johanson
2023-01-17 20:40:44 -05:00
committed by Pete Johanson
parent 062f94d014
commit 09ed79a867
41 changed files with 199 additions and 828 deletions

View File

@@ -20,18 +20,15 @@ extern struct ec11_data ec11_driver;
LOG_MODULE_DECLARE(EC11, CONFIG_SENSOR_LOG_LEVEL);
static inline void setup_int(const struct device *dev, bool enable) {
struct ec11_data *data = dev->data;
const struct ec11_config *cfg = dev->config;
LOG_DBG("enabled %s", (enable ? "true" : "false"));
if (gpio_pin_interrupt_configure(data->a, cfg->a_pin,
enable ? GPIO_INT_EDGE_BOTH : GPIO_INT_DISABLE)) {
if (gpio_pin_interrupt_configure_dt(&cfg->a, enable ? GPIO_INT_EDGE_BOTH : GPIO_INT_DISABLE)) {
LOG_WRN("Unable to set A pin GPIO interrupt");
}
if (gpio_pin_interrupt_configure(data->b, cfg->b_pin,
enable ? GPIO_INT_EDGE_BOTH : GPIO_INT_DISABLE)) {
if (gpio_pin_interrupt_configure_dt(&cfg->b, enable ? GPIO_INT_EDGE_BOTH : GPIO_INT_DISABLE)) {
LOG_WRN("Unable to set A pin GPIO interrupt");
}
}
@@ -121,16 +118,16 @@ int ec11_init_interrupt(const struct device *dev) {
drv_data->dev = dev;
/* setup gpio interrupt */
gpio_init_callback(&drv_data->a_gpio_cb, ec11_a_gpio_callback, BIT(drv_cfg->a_pin));
gpio_init_callback(&drv_data->a_gpio_cb, ec11_a_gpio_callback, BIT(drv_cfg->a.pin));
if (gpio_add_callback(drv_data->a, &drv_data->a_gpio_cb) < 0) {
if (gpio_add_callback(drv_cfg->a.port, &drv_data->a_gpio_cb) < 0) {
LOG_DBG("Failed to set A callback!");
return -EIO;
}
gpio_init_callback(&drv_data->b_gpio_cb, ec11_b_gpio_callback, BIT(drv_cfg->b_pin));
gpio_init_callback(&drv_data->b_gpio_cb, ec11_b_gpio_callback, BIT(drv_cfg->b.pin));
if (gpio_add_callback(drv_data->b, &drv_data->b_gpio_cb) < 0) {
if (gpio_add_callback(drv_cfg->b.port, &drv_data->b_gpio_cb) < 0) {
LOG_DBG("Failed to set B callback!");
return -EIO;
}