Skip to content

Commit

Permalink
drivers: flash: nrf_qspi_nor: Mark device as busy when locked
Browse files Browse the repository at this point in the history
Mark the device as busy when it is locked to perform a flash operation
so that the PM subsystem does not try to suspend it. Also refuse to run
a PM action when the device is busy (in case `qspi_nor_pm_action()` is
called directly, not by the PM subsystem).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
  • Loading branch information
anangl authored and MaureenHelm committed Apr 25, 2023
1 parent ce339e3 commit 7b8170d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/flash/nrf_qspi_nor.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ static inline void qspi_lock(const struct device *dev)
{
struct qspi_nor_data *dev_data = dev->data;

pm_device_busy_set(dev);

#ifdef CONFIG_MULTITHREADING
k_sem_take(&dev_data->sem, K_FOREVER);
#else /* CONFIG_MULTITHREADING */
Expand Down Expand Up @@ -283,6 +285,8 @@ static inline void qspi_unlock(const struct device *dev)
#else
ARG_UNUSED(dev_data);
#endif

pm_device_busy_clear(dev);
}

static inline void qspi_trans_lock(const struct device *dev)
Expand Down Expand Up @@ -1350,6 +1354,10 @@ static int qspi_nor_pm_action(const struct device *dev,
int ret;
nrfx_err_t err;

if (pm_device_is_busy(dev)) {
return -EBUSY;
}

switch (action) {
case PM_DEVICE_ACTION_SUSPEND:
#ifndef CONFIG_PM_DEVICE_RUNTIME
Expand Down

0 comments on commit 7b8170d

Please sign in to comment.