pm: device_runtime: Check busy status in runtime_enable

We can't enable device runtime power management in a device that is
set busy since it may suspend this device.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2024-04-22 15:40:40 -07:00 committed by Alberto Escolar
parent 9320907fdf
commit a458d892e6
2 changed files with 6 additions and 0 deletions

View file

@ -49,6 +49,7 @@ int pm_device_runtime_auto_enable(const struct device *dev);
*
* @retval 0 If the device runtime PM is enabled successfully.
* @retval -EPERM If device has power state locked.
* @retval -EBUSY If device is busy.
* @retval -ENOTSUP If the device does not support PM.
* @retval -errno Other negative errno, result of suspending the device.
*

View file

@ -422,6 +422,11 @@ int pm_device_runtime_enable(const struct device *dev)
goto end;
}
if (pm_device_is_busy(dev)) {
ret = -EBUSY;
goto end;
}
if (atomic_test_bit(&dev->pm_base->flags, PM_DEVICE_FLAG_ISR_SAFE)) {
ret = runtime_enable_sync(dev);
goto end;