diff --git a/drivers/sensor/voltage_divider/voltage.c b/drivers/sensor/voltage_divider/voltage.c index ef2b34c74b3..47569b005d5 100644 --- a/drivers/sensor/voltage_divider/voltage.c +++ b/drivers/sensor/voltage_divider/voltage.c @@ -17,9 +17,7 @@ LOG_MODULE_REGISTER(voltage, CONFIG_SENSOR_LOG_LEVEL); struct voltage_config { struct voltage_divider_dt_spec voltage; -#ifdef CONFIG_PM_DEVICE struct gpio_dt_spec gpio_power; -#endif }; struct voltage_data { @@ -90,8 +88,8 @@ static int pm_action(const struct device *dev, enum pm_device_action action) int ret; if (config->gpio_power.port == NULL) { - LOG_ERR("PM not supported"); - return -ENOTSUP; + /* No work to do */ + return 0; } switch (action) { @@ -126,7 +124,6 @@ static int voltage_init(const struct device *dev) return -ENODEV; } -#ifdef CONFIG_PM_DEVICE if (config->gpio_power.port != NULL) { if (!gpio_is_ready_dt(&config->gpio_power)) { LOG_ERR("Power GPIO is not ready"); @@ -138,7 +135,6 @@ static int voltage_init(const struct device *dev) LOG_ERR("failed to initialize GPIO for reset"); } } -#endif ret = adc_channel_setup_dt(&config->voltage.port); if (ret != 0) { @@ -158,18 +154,12 @@ static int voltage_init(const struct device *dev) return 0; } -#ifdef CONFIG_PM_DEVICE -#define POWER_GPIOS(inst) .gpio_power = GPIO_DT_SPEC_INST_GET_OR(inst, power_gpios, {0}), -#else -#define POWER_GPIOS(inst) -#endif - #define VOLTAGE_INIT(inst) \ static struct voltage_data voltage_##inst##_data; \ \ static const struct voltage_config voltage_##inst##_config = { \ .voltage = VOLTAGE_DIVIDER_DT_SPEC_GET(DT_DRV_INST(inst)), \ - POWER_GPIOS(inst) \ + .gpio_power = GPIO_DT_SPEC_INST_GET_OR(inst, power_gpios, {0}), \ }; \ \ PM_DEVICE_DT_INST_DEFINE(inst, pm_action); \