pm: device_runtime: Return possible error on enable
Change the function pm_device_runtime_enable() to return 0 on success or an error code in case of error. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
0a32eadd13
commit
18b932f10d
13 changed files with 29 additions and 22 deletions
|
@ -154,7 +154,10 @@ must perform the necessary operations to suspend the device.
|
|||
...
|
||||
/* make sure the device physically is suspended */
|
||||
/* enable device runtime power management */
|
||||
pm_device_runtime_enable(dev);
|
||||
ret = pm_device_runtime_enable(dev);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
...
|
||||
}
|
||||
|
||||
|
|
|
@ -612,9 +612,7 @@ static int gpio_stm32_init(const struct device *dev)
|
|||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_DEVICE_RUNTIME
|
||||
pm_device_runtime_enable(dev);
|
||||
|
||||
return 0;
|
||||
return pm_device_runtime_enable(dev);
|
||||
#else
|
||||
return gpio_stm32_clock_request(dev, true);
|
||||
#endif
|
||||
|
|
|
@ -28,8 +28,12 @@ extern "C" {
|
|||
* @funcprops \pre_kernel_ok
|
||||
*
|
||||
* @param dev Device instance.
|
||||
*
|
||||
* @retval 0 If the device runtime PM is enabled successfully.
|
||||
* @retval -EPERM If device has power state locked.
|
||||
* @retval -ENOSYS If the functionality is not available.
|
||||
*/
|
||||
void pm_device_runtime_enable(const struct device *dev);
|
||||
int pm_device_runtime_enable(const struct device *dev);
|
||||
|
||||
/**
|
||||
* @brief Disable device runtime PM
|
||||
|
@ -131,7 +135,7 @@ int pm_device_runtime_put_async(const struct device *dev);
|
|||
bool pm_device_runtime_is_enabled(const struct device *dev);
|
||||
|
||||
#else
|
||||
static inline void pm_device_runtime_enable(const struct device *dev) { }
|
||||
static inline int pm_device_runtime_enable(const struct device *dev) { return -ENOSYS; }
|
||||
static inline int pm_device_runtime_disable(const struct device *dev) { return -ENOSYS; }
|
||||
static inline int pm_device_runtime_get(const struct device *dev) { return -ENOSYS; }
|
||||
static inline int pm_device_runtime_put(const struct device *dev) { return -ENOSYS; }
|
||||
|
|
|
@ -1985,8 +1985,9 @@ void sys_trace_idle(void);
|
|||
/**
|
||||
* @brief Trace enabling device runtime PM call exit.
|
||||
* @param dev Device instance.
|
||||
* @param ret Return value.
|
||||
*/
|
||||
#define sys_port_trace_pm_device_runtime_enable_exit(dev)
|
||||
#define sys_port_trace_pm_device_runtime_enable_exit(dev, ret)
|
||||
|
||||
/**
|
||||
* @brief Trace disabling device runtime PM call entry.
|
||||
|
|
|
@ -109,9 +109,7 @@ int dummy_init(const struct device *dev)
|
|||
printk("parent not found\n");
|
||||
}
|
||||
|
||||
pm_device_runtime_enable(dev);
|
||||
|
||||
return 0;
|
||||
return pm_device_runtime_enable(dev);
|
||||
}
|
||||
|
||||
PM_DEVICE_DEFINE(dummy_driver, dummy_device_pm_action);
|
||||
|
|
|
@ -48,8 +48,7 @@ static const struct dummy_parent_api funcs = {
|
|||
|
||||
int dummy_parent_init(const struct device *dev)
|
||||
{
|
||||
pm_device_runtime_enable(dev);
|
||||
return 0;
|
||||
return pm_device_runtime_enable(dev);
|
||||
}
|
||||
|
||||
PM_DEVICE_DEFINE(dummy_parent, dummy_parent_pm_action);
|
||||
|
|
|
@ -166,13 +166,15 @@ int pm_device_runtime_put_async(const struct device *dev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void pm_device_runtime_enable(const struct device *dev)
|
||||
int pm_device_runtime_enable(const struct device *dev)
|
||||
{
|
||||
int ret = 0;
|
||||
struct pm_device *pm = dev->pm;
|
||||
|
||||
SYS_PORT_TRACING_FUNC_ENTER(pm, device_runtime_enable, dev);
|
||||
|
||||
if (pm_device_state_is_locked(dev)) {
|
||||
ret = -EPERM;
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -200,7 +202,8 @@ unlock:
|
|||
}
|
||||
|
||||
end:
|
||||
SYS_PORT_TRACING_FUNC_EXIT(pm, device_runtime_enable, dev);
|
||||
SYS_PORT_TRACING_FUNC_EXIT(pm, device_runtime_enable, dev, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pm_device_runtime_disable(const struct device *dev)
|
||||
|
|
|
@ -331,7 +331,7 @@ extern "C" {
|
|||
#define sys_port_trace_pm_device_runtime_put_async_enter(dev)
|
||||
#define sys_port_trace_pm_device_runtime_put_async_exit(dev, ret)
|
||||
#define sys_port_trace_pm_device_runtime_enable_enter(dev)
|
||||
#define sys_port_trace_pm_device_runtime_enable_exit(dev)
|
||||
#define sys_port_trace_pm_device_runtime_enable_exit(dev, ret)
|
||||
#define sys_port_trace_pm_device_runtime_disable_enter(dev)
|
||||
#define sys_port_trace_pm_device_runtime_disable_exit(dev, ret)
|
||||
|
||||
|
|
|
@ -166,5 +166,5 @@ TaskState 0xBF 1=dummy, 2=Waiting, 4=New, 8=Terminated, 16=Suspended, 32=Termina
|
|||
156 pm_device_runtime_get dev=%I | Returns %u
|
||||
157 pm_device_runtime_put dev=%I | Returns %u
|
||||
158 pm_device_runtime_put_async dev=%I | Returns %u
|
||||
159 pm_device_runtime_enable dev=%I
|
||||
159 pm_device_runtime_enable dev=%I | Returns %u
|
||||
160 pm_device_runtime_disable dev=%I | Returns %u
|
||||
|
|
|
@ -639,8 +639,9 @@ void sys_trace_k_thread_info(struct k_thread *thread);
|
|||
#define sys_port_trace_pm_device_runtime_enable_enter(dev) \
|
||||
SEGGER_SYSVIEW_RecordU32(TID_PM_DEVICE_RUNTIME_ENABLE, \
|
||||
(uint32_t)(uintptr_t)dev)
|
||||
#define sys_port_trace_pm_device_runtime_enable_exit(dev) \
|
||||
SEGGER_SYSVIEW_RecordEndCall(TID_PM_DEVICE_RUNTIME_ENABLE)
|
||||
#define sys_port_trace_pm_device_runtime_enable_exit(dev, ret) \
|
||||
SEGGER_SYSVIEW_RecordEndCall(TID_PM_DEVICE_RUNTIME_ENABLE, \
|
||||
(uint32_t)ret)
|
||||
#define sys_port_trace_pm_device_runtime_disable_enter(dev) \
|
||||
SEGGER_SYSVIEW_RecordU32(TID_PM_DEVICE_RUNTIME_DISABLE, \
|
||||
(uint32_t)(uintptr_t)dev)
|
||||
|
|
|
@ -439,7 +439,7 @@
|
|||
#define sys_port_trace_pm_device_runtime_put_async_enter(dev)
|
||||
#define sys_port_trace_pm_device_runtime_put_async_exit(dev, ret)
|
||||
#define sys_port_trace_pm_device_runtime_enable_enter(dev)
|
||||
#define sys_port_trace_pm_device_runtime_enable_exit(dev)
|
||||
#define sys_port_trace_pm_device_runtime_enable_exit(dev, ret)
|
||||
#define sys_port_trace_pm_device_runtime_disable_enter(dev)
|
||||
#define sys_port_trace_pm_device_runtime_disable_exit(dev, ret)
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ static const struct dummy_driver_api funcs = {
|
|||
|
||||
int dummy_init(const struct device *dev)
|
||||
{
|
||||
pm_device_runtime_enable(dev);
|
||||
return 0;
|
||||
return pm_device_runtime_enable(dev);
|
||||
}
|
||||
|
||||
PM_DEVICE_DEFINE(dummy_driver, dummy_device_pm_action);
|
||||
|
|
|
@ -304,7 +304,8 @@ void test_power_state_trans(void)
|
|||
k_sleep(SLEEP_TIMEOUT);
|
||||
zassert_true(leave_idle, NULL);
|
||||
|
||||
pm_device_runtime_enable(device_dummy);
|
||||
ret = pm_device_runtime_enable(device_dummy);
|
||||
zassert_true(ret == 0, "Failed to enable device runtime PM");
|
||||
|
||||
pm_notifier_unregister(¬ifier);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue