device: treat a NULL device_pm_control as device_pm_control_nop
This is a step towards phasing out DEVICE_INIT and just having DEVICE_DEFINE. To make it a little easier on users or DEVICE_DEFINE if they don't care about PM, they can just pass NULL for the pm_control_fn paramater. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
7f0d5ba652
commit
d439478805
|
@ -68,8 +68,7 @@ extern "C" {
|
|||
*/
|
||||
#define DEVICE_INIT(dev_name, drv_name, init_fn, \
|
||||
data_ptr, cfg_ptr, level, prio) \
|
||||
DEVICE_DEFINE(dev_name, drv_name, init_fn, \
|
||||
device_pm_control_nop, \
|
||||
DEVICE_DEFINE(dev_name, drv_name, init_fn, NULL, \
|
||||
data_ptr, cfg_ptr, level, prio, NULL)
|
||||
|
||||
/**
|
||||
|
@ -81,7 +80,7 @@ extern "C" {
|
|||
#define DEVICE_AND_API_INIT(dev_name, drv_name, init_fn, \
|
||||
data_ptr, cfg_ptr, level, prio, api_ptr) \
|
||||
DEVICE_DEFINE(dev_name, drv_name, init_fn, \
|
||||
device_pm_control_nop, \
|
||||
NULL, \
|
||||
data_ptr, cfg_ptr, level, prio, api_ptr)
|
||||
|
||||
/**
|
||||
|
@ -383,9 +382,15 @@ static inline int device_set_power_state(const struct device *dev,
|
|||
uint32_t device_power_state,
|
||||
device_pm_cb cb, void *arg)
|
||||
{
|
||||
return dev->device_pm_control(dev,
|
||||
DEVICE_PM_SET_POWER_STATE,
|
||||
&device_power_state, cb, arg);
|
||||
if (dev->device_pm_control) {
|
||||
return dev->device_pm_control(dev,
|
||||
DEVICE_PM_SET_POWER_STATE,
|
||||
&device_power_state, cb, arg);
|
||||
} else {
|
||||
return device_pm_control_nop(dev,
|
||||
DEVICE_PM_SET_POWER_STATE,
|
||||
&device_power_state, cb, arg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -404,10 +409,15 @@ static inline int device_set_power_state(const struct device *dev,
|
|||
static inline int device_get_power_state(const struct device *dev,
|
||||
uint32_t *device_power_state)
|
||||
{
|
||||
return dev->device_pm_control(dev,
|
||||
DEVICE_PM_GET_POWER_STATE,
|
||||
device_power_state,
|
||||
NULL, NULL);
|
||||
if (dev->device_pm_control) {
|
||||
return dev->device_pm_control(dev,
|
||||
DEVICE_PM_GET_POWER_STATE,
|
||||
device_power_state, NULL, NULL);
|
||||
} else {
|
||||
return device_pm_control_nop(dev,
|
||||
DEVICE_PM_GET_POWER_STATE,
|
||||
device_power_state, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -160,7 +160,8 @@ void sys_pm_create_device_list(void)
|
|||
const struct device *dev = &all_devices[pmi];
|
||||
|
||||
/* Ignore "device"s that don't support PM */
|
||||
if (dev->device_pm_control == device_pm_control_nop) {
|
||||
if ((dev->device_pm_control == NULL) ||
|
||||
(dev->device_pm_control == device_pm_control_nop)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue