samples: device_pm: Fix condvar usage
Use pm_device_wait() to properly wait an operation to finish. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
4c16d391c7
commit
ff1613c80f
1 changed files with 1 additions and 5 deletions
|
@ -15,7 +15,6 @@ static const struct device *parent;
|
|||
static int dummy_open(const struct device *dev)
|
||||
{
|
||||
int ret;
|
||||
struct k_mutex wait_mutex;
|
||||
|
||||
printk("open()\n");
|
||||
|
||||
|
@ -32,10 +31,7 @@ static int dummy_open(const struct device *dev)
|
|||
|
||||
printk("Async wakeup request queued\n");
|
||||
|
||||
k_mutex_init(&wait_mutex);
|
||||
k_mutex_lock(&wait_mutex, K_FOREVER);
|
||||
(void) k_condvar_wait(&dev->pm->condvar, &wait_mutex, K_FOREVER);
|
||||
k_mutex_unlock(&wait_mutex);
|
||||
(void) pm_device_wait(dev, K_FOREVER);
|
||||
|
||||
if (atomic_get(&dev->pm->state) == PM_DEVICE_STATE_ACTIVE) {
|
||||
printk("Dummy device resumed\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue