Change device power mode
#include <sys/pm.h>
int pmd_setmode(pmd_attr_t *pmd,
pm_power_mode_t mode,
unsigned flags);
- pmd
- Pointer to the driver pmd_attr_t's structure for the
device.
- mode
- Power mode to set.
- flags
- Control the behavior of power mode change.
libpm
The pmd_setmode() function is
used to synchronously change the power mode within
device driver code.
The pmd_attr_t must be locked
using pmd_lock_shared() before calling
pmd_setmode().
The pmd_setmode() essentially performs the following steps:
- Convert the shared lock to an exclusive lock using
pmd_lock_upgrade().
This blocks until all other existing shared locks are released.
- Request permission from the power manager to change to the new mode.
If this request is denied, the mode change is aborted with an error.
- Call pmd->setpower() to change the device power mode.
- Convert the exclusive lock to a shared lock using
pmd_lock_downgrade().
- EOK
- Power mode has been changed.
- EINPROGRESS
- Power mode change was initiated, but will complete later.
- EAGAIN
- the Power mode was denied by the power manager policy.
- EINVAL
- mode is not a valid power mode or flags
contains invalid flags.
For more information, see the device driver chapter.
Neutrino
| Safety: | |
| Cancellation point |
Yes |
| Interrupt handler |
No |
| Signal handler |
Yes |
| Thread |
Yes |
pmd_attr_setmodes(),
pmd_lock_shared(),
pmd_lock_upgrade(),
pmd_lock_downgrade()