From aafa76bb9f2b0f15c43ce8475541928c2f656835 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/sensor/lm75/lm75.c b/drivers/sensor/lm75/lm75.c index e01a691a58e6d83..6f3917503274c4a 100644 --- a/drivers/sensor/lm75/lm75.c +++ b/drivers/sensor/lm75/lm75.c @@ -67,6 +67,13 @@ static int lm75_sample_fetch(const struct device *dev, enum pm_device_state pm_state; int ret; +#ifdef CONFIG_PM_DEVICE_RUNTIME + ret = pm_device_runtime_get(dev); + if (ret < 0) { + LOG_ERR("pm_device_runtime_get failed with error %i", ret); + return ret; + } +#endif (void)pm_device_state_get(dev, &pm_state); if (pm_state != PM_DEVICE_STATE_ACTIVE) { ret = -EIO; @@ -82,7 +89,13 @@ static int lm75_sample_fetch(const struct device *dev, ret = -ENOTSUP; break; } +#ifdef CONFIG_PM_DEVICE_RUNTIME + int ret2 = pm_device_runtime_put(dev); + if (ret2 < 0) { + LOG_ERR("pm_device_runtime_put failed with error %i", ret2); + } +#endif return ret; }