pm: device: move device busy APIs to pm subsystem
The following device busy APIs: - device_busy_set() - device_busy_clear() - device_busy_check() - device_any_busy_check() were used for device PM, so they have been moved to the pm subsystem. This means they are now prefixed with `pm_` and are defined in `pm/device.h`. If device PM is not enabled dummy functions are now provided that do nothing or return `-ENOSYS`, meaning that the functionality is not available. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
775cf55d92
commit
70322853a8
11 changed files with 112 additions and 119 deletions
|
@ -612,52 +612,6 @@ static inline bool device_is_ready(const struct device *dev)
|
|||
return device_usable_check(dev) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate that the device is in the middle of a transaction
|
||||
*
|
||||
* Called by a device driver to indicate that it is in the middle of a
|
||||
* transaction.
|
||||
*
|
||||
* @param dev Pointer to device structure of the driver instance.
|
||||
*/
|
||||
void device_busy_set(const struct device *dev);
|
||||
|
||||
/**
|
||||
* @brief Indicate that the device has completed its transaction
|
||||
*
|
||||
* Called by a device driver to indicate the end of a transaction.
|
||||
*
|
||||
* @param dev Pointer to device structure of the driver instance.
|
||||
*/
|
||||
void device_busy_clear(const struct device *dev);
|
||||
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
/**
|
||||
* @brief Check if any device is in the middle of a transaction
|
||||
*
|
||||
* Called by an application to see if any device is in the middle
|
||||
* of a critical transaction that cannot be interrupted.
|
||||
*
|
||||
* @retval 0 if no device is busy
|
||||
* @retval -EBUSY if any device is busy
|
||||
*/
|
||||
int device_any_busy_check(void);
|
||||
|
||||
/**
|
||||
* @brief Check if a specific device is in the middle of a transaction
|
||||
*
|
||||
* Called by an application to see if a particular device is in the
|
||||
* middle of a critical transaction that cannot be interrupted.
|
||||
*
|
||||
* @param chk_dev Pointer to device structure of the specific device driver
|
||||
* the caller is interested in.
|
||||
* @retval 0 if the device is not busy
|
||||
* @retval -EBUSY if the device is busy
|
||||
*/
|
||||
int device_busy_check(const struct device *chk_dev);
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -133,6 +133,56 @@ int pm_device_state_set(const struct device *dev,
|
|||
int pm_device_state_get(const struct device *dev,
|
||||
enum pm_device_state *device_power_state);
|
||||
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
/**
|
||||
* @brief Indicate that the device is in the middle of a transaction
|
||||
*
|
||||
* Called by a device driver to indicate that it is in the middle of a
|
||||
* transaction.
|
||||
*
|
||||
* @param dev Pointer to device structure of the driver instance.
|
||||
*/
|
||||
void pm_device_busy_set(const struct device *dev);
|
||||
|
||||
/**
|
||||
* @brief Indicate that the device has completed its transaction
|
||||
*
|
||||
* Called by a device driver to indicate the end of a transaction.
|
||||
*
|
||||
* @param dev Pointer to device structure of the driver instance.
|
||||
*/
|
||||
void pm_device_busy_clear(const struct device *dev);
|
||||
|
||||
/**
|
||||
* @brief Check if any device is in the middle of a transaction
|
||||
*
|
||||
* Called by an application to see if any device is in the middle
|
||||
* of a critical transaction that cannot be interrupted.
|
||||
*
|
||||
* @retval 0 if no device is busy
|
||||
* @retval -EBUSY if any device is busy
|
||||
*/
|
||||
int pm_device_any_busy_check(void);
|
||||
|
||||
/**
|
||||
* @brief Check if a specific device is in the middle of a transaction
|
||||
*
|
||||
* Called by an application to see if a particular device is in the
|
||||
* middle of a critical transaction that cannot be interrupted.
|
||||
*
|
||||
* @param chk_dev Pointer to device structure of the specific device driver
|
||||
* the caller is interested in.
|
||||
* @retval 0 if the device is not busy
|
||||
* @retval -EBUSY if the device is busy
|
||||
*/
|
||||
int pm_device_busy_check(const struct device *chk_dev);
|
||||
#else
|
||||
static inline void pm_device_busy_set(const struct device *dev) {}
|
||||
static inline void pm_device_busy_clear(const struct device *dev) {}
|
||||
static inline int pm_device_any_busy_check(void) { return -ENOSYS; }
|
||||
static inline int pm_device_busy_check(const struct device *chk_dev) { return -ENOSYS; }
|
||||
#endif
|
||||
|
||||
/** Alias for legacy use of device_pm_control_nop */
|
||||
#define device_pm_control_nop __DEPRECATED_MACRO NULL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue