samples: pm: device_pm: Get the device before use it

The open function should resume the device, not only its parent.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2022-02-20 23:19:10 -08:00 committed by Anas Nashif
parent c124f40f14
commit 8fdb0117eb

View file

@ -25,6 +25,12 @@ static int dummy_open(const struct device *dev)
return ret;
}
ret = pm_device_runtime_get(dev);
if (ret < 0) {
(void)pm_device_runtime_put(parent);
return ret;
}
(void)pm_device_state_get(dev, &state);
if (state == PM_DEVICE_STATE_ACTIVE) {
printk("Dummy device resumed\n");