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 21, 2024
1 parent 71b7101 commit c44bcd6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions drivers/sensor/lm75/lm75.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down

0 comments on commit c44bcd6

Please sign in to comment.