power: remove device_pm_control_nop function
Devices that do not require PM should just use NULL. `device_pm_control_nop` is still kept as an alias to NULL untill all in-tree usage is replaced with NULL. Code relying on device_pm_control function now returns -ENOTSUP (equivalent to calling device_pm_control_nop). Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
5dced184b8
commit
bfce935caf
3 changed files with 20 additions and 50 deletions
|
@ -141,7 +141,7 @@ typedef int16_t device_handle_t;
|
|||
* @param init_fn Address to the init function of the driver.
|
||||
*
|
||||
* @param pm_control_fn Pointer to device_pm_control function.
|
||||
* Can be empty function (device_pm_control_nop) if not implemented.
|
||||
* Can be NULL if not implemented.
|
||||
*
|
||||
* @param data_ptr Pointer to the device's private data.
|
||||
*
|
||||
|
@ -199,7 +199,7 @@ typedef int16_t device_handle_t;
|
|||
* @param init_fn Address to the init function of the driver.
|
||||
*
|
||||
* @param pm_control_fn Pointer to device_pm_control function.
|
||||
* Can be empty function (device_pm_control_nop) if not implemented.
|
||||
* Can be NULL if not implemented.
|
||||
*
|
||||
* @param data_ptr Pointer to the device's private data.
|
||||
*
|
||||
|
@ -744,25 +744,6 @@ void device_busy_clear(const struct device *dev);
|
|||
* Device PM functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief No-op function to initialize unimplemented hook
|
||||
*
|
||||
* This function should be used to initialize device hook
|
||||
* for which a device has no PM operations.
|
||||
*
|
||||
* @param unused_device Unused
|
||||
* @param unused_ctrl_command Unused
|
||||
* @param unused_context Unused
|
||||
* @param cb Unused
|
||||
* @param unused_arg Unused
|
||||
*
|
||||
* @retval -ENOTSUP for all operations.
|
||||
*/
|
||||
int device_pm_control_nop(const struct device *unused_device,
|
||||
uint32_t unused_ctrl_command,
|
||||
void *unused_context,
|
||||
device_pm_cb cb,
|
||||
void *unused_arg);
|
||||
/**
|
||||
* @brief Call the set power state function of a device
|
||||
*
|
||||
|
@ -781,15 +762,12 @@ static inline int device_set_power_state(const struct device *dev,
|
|||
uint32_t device_power_state,
|
||||
device_pm_cb cb, void *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);
|
||||
if (dev->device_pm_control == NULL) {
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
return dev->device_pm_control(dev, DEVICE_PM_SET_POWER_STATE,
|
||||
&device_power_state, cb, arg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -808,15 +786,12 @@ 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)
|
||||
{
|
||||
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);
|
||||
if (dev->device_pm_control == NULL) {
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
return dev->device_pm_control(dev, DEVICE_PM_GET_POWER_STATE,
|
||||
device_power_state, NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -945,10 +920,15 @@ static inline int device_pm_get_sync(const struct device *dev) { return -ENOTSUP
|
|||
static inline int device_pm_put(const struct device *dev) { return -ENOTSUP; }
|
||||
static inline int device_pm_put_sync(const struct device *dev) { return -ENOTSUP; }
|
||||
#endif
|
||||
#else
|
||||
#define device_pm_control_nop(...) NULL
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Alias for legacy use of device_pm_control_nop.
|
||||
*
|
||||
* @note Usage of NULL is preferred, this alias will eventually be removed.
|
||||
*/
|
||||
#define device_pm_control_nop NULL
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -193,15 +193,6 @@ int device_required_foreach(const struct device *dev,
|
|||
}
|
||||
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
int device_pm_control_nop(const struct device *unused_device,
|
||||
uint32_t unused_ctrl_command,
|
||||
void *unused_context,
|
||||
device_pm_cb cb,
|
||||
void *unused_arg)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
int device_any_busy_check(void)
|
||||
{
|
||||
const struct device *dev = __device_start;
|
||||
|
|
|
@ -142,8 +142,7 @@ void 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 == NULL) ||
|
||||
(dev->device_pm_control == device_pm_control_nop)) {
|
||||
if (dev->device_pm_control == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue