Skip to content
14 changes: 7 additions & 7 deletions applications/nrf_desktop/src/hw_interface/wheel.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/pm/device.h>
#include <zephyr/pm/device_runtime.h>
#include <pinctrl_soc.h>

#include <app_event_manager.h>
Expand Down Expand Up @@ -262,13 +262,13 @@ static int enable_qdec(enum state next_state)

int err = 0;

/* QDEC device driver starts in PM_DEVICE_STATE_ACTIVE state. */
if (state != STATE_DISABLED) {
err = pm_device_action_run(qdec_dev, PM_DEVICE_ACTION_RESUME);
/* QDEC device driver starts in PM_DEVICE_STATE_SUSPENDED state. */
if (state == STATE_DISABLED) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the check here should be removed. Now we should always call pm_device_runtime_get here (also after we return from the suspended state), right?

err = pm_device_runtime_get(qdec_dev);
}

if (err) {
LOG_ERR("Cannot resume QDEC");
LOG_ERR("Cannot get QDEC");
return err;
}

Expand Down Expand Up @@ -304,9 +304,9 @@ static int disable_qdec(enum state next_state)
return err;
}

err = pm_device_action_run(qdec_dev, PM_DEVICE_ACTION_SUSPEND);
err = pm_device_runtime_put(qdec_dev);
if (err) {
LOG_ERR("Cannot suspend QDEC");
LOG_ERR("Cannot put QDEC");
} else {
err = setup_wakeup();
if (!err) {
Expand Down