pm: device: runtime: remove pm_device_wait

After the removal of pm_device_get_async, the pm_device_wait API has
become redundant. Its usage after pm_device_put_async should not be
considered a valid usecase, since after that call what will happen is a
pm_device_get (which is blocking).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2021-10-21 18:30:15 +02:00 committed by Christopher Friedt
parent 30d217aa28
commit e3fece5241
5 changed files with 1 additions and 41 deletions

View file

@ -474,9 +474,6 @@ Releases a device. This API asynchronously puts the device to suspend
state if not already in suspend state if the usage count of this device
reaches 0.
Device drivers can monitor this operation to finish calling
:c:func:`pm_device_wait`.
Suspend Device synchronously API
--------------------------------

View file

@ -910,7 +910,7 @@ Libraries / Subsystems
* Multiple threads can wait an operation (``pm_device_get_async`` and
:c:func:`pm_device_put_async`) to finish.
* A new API :c:func:`pm_device_wait` was added so that drivers can easily
* A new API ``pm_device_wait`` was added so that drivers can easily
wait for an async request to finish.
* The API can be used in :ref:`pre-kernel <api_term_pre-kernel-ok>` stages.
* Several concurrence issues related with atomics access and the usage

View file

@ -100,22 +100,6 @@ int pm_device_put_async(const struct device *dev);
*/
int pm_device_put(const struct device *dev);
/**
* @brief Wait on a device to finish an operation.
*
* The calling thread blocks until the device finishes a
* @ref pm_device_put_async or @ref pm_device_get_async operation. If there is
* no operation in progress this function will return immediately.
*
* @param dev Pointer to device structure of the specific device driver
* the caller is interested in.
* @param timeout The timeout passed to k_condvar_wait. If a timeout happens
* this function will return immediately.
* @retval 0 If successful.
* @retval Errno Negative errno code if failure.
*/
int pm_device_wait(const struct device *dev, k_timeout_t timeout);
#else
static inline void pm_device_enable(const struct device *dev) { }
static inline void pm_device_disable(const struct device *dev) { }

View file

@ -24,8 +24,6 @@ static int dummy_open(const struct device *dev)
return ret;
}
(void) pm_device_wait(dev, K_FOREVER);
(void)pm_device_state_get(dev, &state);
if (state == PM_DEVICE_STATE_ACTIVE) {
printk("Dummy device resumed\n");

View file

@ -224,22 +224,3 @@ void pm_device_disable(const struct device *dev)
(void)k_mutex_unlock(&pm->lock);
SYS_PORT_TRACING_FUNC_EXIT(pm, device_disable, dev);
}
int pm_device_wait(const struct device *dev, k_timeout_t timeout)
{
int ret = 0;
struct pm_device *pm = dev->pm;
k_mutex_lock(&pm->lock, K_FOREVER);
while ((k_work_delayable_is_pending(&pm->work)) ||
atomic_test_bit(&pm->flags, PM_DEVICE_FLAG_TRANSITIONING)) {
ret = k_condvar_wait(&pm->condvar, &pm->lock,
timeout);
if (ret != 0) {
break;
}
}
k_mutex_unlock(&pm->lock);
return ret;
}