Skip to content

Commit

Permalink
drivers: sensor: fix PM Implementation for LM75 temperature sensor
Browse files Browse the repository at this point in the history
fixes the driver always returning -EIO  if PM_DEVICE_RUNTIME is enabled.

Signed-off-by: Jonas Woerner <[email protected]>
  • Loading branch information
CodingGhost committed May 14, 2024
1 parent 71b7101 commit aafa76b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/sensor/lm75/lm75.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit aafa76b

Please sign in to comment.