Register driver with the power manager
#include <sys/pm.h>
int pmd_attach(const char *name,
pmd_attr_t *attr,
const struct sigevent *event,
mode_t mode);
- name
- Name of the power managed object the driver is responsible for.
- pmd
- The pmd_attr_t structure used to manage the device power
attributes.
- event
- The event the power manager should use to communicate with the driver.
- mode
- The type and access permission to use if name doesn't yet exist.
libpm
The pmd_attach() is used by a device driver to register with the
power manager.
Before calling pmd_attach(), the driver must initialize the following:
- use pmd_attr_init() to initialize the pmd with default values
- use pmd_attr_setmodes() to specify the device's supported power modes
- use pmd_attr_setpower() to specify the driver's power mode function
- initialize event (typically a pulse).
On return from pmd_attach(), pmd is updated with
initialization
information from the power manager:
- pmd->new_attr specifies the initial power mode the device should be set to.
- pmd->pmm_flags specifies what persistent storage actions the driver is
expected to perform:
- PMD_NO_PSTORE
- if this is set, the driver does not need to use any
persistent storage services. If this flag is NOT set,
the driver must create persistent storage objects for any
driver or device state that must be preserved when the
device is set to a PM_MODE_STANDBY mode.
- PMD_NO_PSTORE_INIT
- if this is set, the driver should not initialize
itself from its persistent storage object. If this flags
is NOT set, the driver should restore the driver or device
state from the state it saved in its persistent storage object.
The power manager delivers the specified event to initiate power mode changes.
This is typically a pulse, and the driver's pulse handler should use
pmd_handler() to perform the necessary interaction with the Power Manager to
co-ordinate the power mode change. pmd_handler() will call the driver's
setpower() function to perform the requested power mode change.
pmd_attach() doesn't return an error if there's no power manager running,
in order to allow drivers to run as normal (except that there will be no
system wide power management policy applied to them).
In this case:
- pmd->hdl is an invalid handle
- pmd->new_attr is set to the device's default PM_MODE_ACTIVE mode
- pmd->pmm_flags have both PMD_NO_PSTORE and PMD_NO_PSTORE_INIT set
- 0
- Success.
- -1
- An error occurred (errno is set)
- EINVAL
- pmd hasn't been correctly initialized.
- EINVAL
- event is not a valid sigevent.
- ENOMEM
- insufficient memory to allocate power manager resources.
For more information, see the device driver chapter.
Neutrino
Safety: | |
Cancellation point |
Yes |
Interrupt handler |
No |
Signal handler |
No |
Thread |
Yes |
pmd_attr_t,
pmd_attr_init(),
pmd_attr_setmodes(),
pmd_attr_setpower()