pm: device: allow optional support of TURN_ON action
Some devices, e.g. SoC level devices like I2C peripheral, can never be powerd off as they are always energized. Such devices can only go from an active state or to a low power state (suspended). Allow them to simply return -ENOTSUP when called with TURN_ON (or TURN_OFF). Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
parent
f8bac1ac1b
commit
740eba1341
2 changed files with 4 additions and 3 deletions
|
|
@ -625,7 +625,8 @@ bool pm_device_is_powered(const struct device *dev);
|
|||
* This helper function is intended to be called at the end of a driver
|
||||
* init function to automatically setup the device into the lowest power
|
||||
* mode. It assumes that the device has been configured as if it is in
|
||||
* @ref PM_DEVICE_STATE_OFF.
|
||||
* @ref PM_DEVICE_STATE_OFF, or @ref PM_DEVICE_STATE_SUSPENDED if device can
|
||||
* never be powered off.
|
||||
*
|
||||
* @param dev Device instance.
|
||||
* @param action_cb Device PM control callback function.
|
||||
|
|
@ -718,7 +719,7 @@ static inline int pm_device_driver_init(const struct device *dev, pm_device_acti
|
|||
|
||||
/* When power management is not enabled, all drivers should initialise to active state */
|
||||
rc = action_cb(dev, PM_DEVICE_ACTION_TURN_ON);
|
||||
if (rc < 0) {
|
||||
if ((rc < 0) && (rc != -ENOTSUP)) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ int pm_device_driver_init(const struct device *dev,
|
|||
|
||||
/* Run power-up logic */
|
||||
rc = action_cb(dev, PM_DEVICE_ACTION_TURN_ON);
|
||||
if (rc != 0) {
|
||||
if ((rc < 0) && (rc != -ENOTSUP)) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue