From c44bcd69f2fb2df3826a9f7a5d48a83cd284a9ea Mon Sep 17 00:00:00 2001 From: Jonas Woerner Date: Tue, 14 May 2024 14:09:51 +0200 Subject: [PATCH] drivers: sensor: fix PM Implementation for LM75 temperature sensor fixes the driver always returning -EIO if PM_DEVICE_RUNTIME is enabled. Signed-off-by: Jonas Woerner --- drivers/sensor/lm75/lm75.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/sensor/lm75/lm75.c b/drivers/sensor/lm75/lm75.c index e01a691a58e6d83..729c4c99249a710 100644 --- a/drivers/sensor/lm75/lm75.c +++ b/drivers/sensor/lm75/lm75.c @@ -66,11 +66,12 @@ static int lm75_sample_fetch(const struct device *dev, const struct lm75_config *cfg = dev->config; enum pm_device_state pm_state; int ret; + int pm_ret; - (void)pm_device_state_get(dev, &pm_state); - if (pm_state != PM_DEVICE_STATE_ACTIVE) { - ret = -EIO; - return ret; + pm_ret = pm_device_runtime_get(dev); + if (pm_ret < 0) { + LOG_ERR("pm_device_runtime_get failed with error %i", pm_ret); + return pm_ret; } switch (chan) { @@ -83,6 +84,11 @@ static int lm75_sample_fetch(const struct device *dev, break; } + pm_ret = pm_device_runtime_put(dev); + if (pm_ret < 0) { + LOG_ERR("pm_device_runtime_put failed with error %i", pm_ret); + } + return ret; }