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 init_fn Address to the init function of the driver.
|
||||||
*
|
*
|
||||||
* @param pm_control_fn Pointer to device_pm_control function.
|
* @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.
|
* @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 init_fn Address to the init function of the driver.
|
||||||
*
|
*
|
||||||
* @param pm_control_fn Pointer to device_pm_control function.
|
* @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.
|
* @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
|
* 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
|
* @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,
|
uint32_t device_power_state,
|
||||||
device_pm_cb cb, void *arg)
|
device_pm_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
if (dev->device_pm_control) {
|
if (dev->device_pm_control == NULL) {
|
||||||
return dev->device_pm_control(dev,
|
return -ENOSYS;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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,
|
static inline int device_get_power_state(const struct device *dev,
|
||||||
uint32_t *device_power_state)
|
uint32_t *device_power_state)
|
||||||
{
|
{
|
||||||
if (dev->device_pm_control) {
|
if (dev->device_pm_control == NULL) {
|
||||||
return dev->device_pm_control(dev,
|
return -ENOSYS;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(const struct device *dev) { return -ENOTSUP; }
|
||||||
static inline int device_pm_put_sync(const struct device *dev) { return -ENOTSUP; }
|
static inline int device_pm_put_sync(const struct device *dev) { return -ENOTSUP; }
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
#define device_pm_control_nop(...) NULL
|
|
||||||
#endif
|
#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
|
#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)
|
int device_any_busy_check(void)
|
||||||
{
|
{
|
||||||
const struct device *dev = __device_start;
|
const struct device *dev = __device_start;
|
||||||
|
|
|
@ -142,8 +142,7 @@ void pm_create_device_list(void)
|
||||||
const struct device *dev = &all_devices[pmi];
|
const struct device *dev = &all_devices[pmi];
|
||||||
|
|
||||||
/* Ignore "device"s that don't support PM */
|
/* Ignore "device"s that don't support PM */
|
||||||
if ((dev->device_pm_control == NULL) ||
|
if (dev->device_pm_control == NULL) {
|
||||||
(dev->device_pm_control == device_pm_control_nop)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue