Skip to content

Commit 281b931

Browse files
committed
[nrf fromtree] drivers: flash_mspi_nor: Add support for CONFIG_MULTITHREADING=n
Add possibility to use the driver in configurations with disabled multithreading. It may be useful in bootloaders, for example. Signed-off-by: Andrzej Głąbek <[email protected]> (cherry picked from commit 828bde8)
1 parent a699574 commit 281b931

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

drivers/flash/flash_mspi_nor.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ static int acquire(const struct device *dev)
237237
struct flash_mspi_nor_data *dev_data = dev->data;
238238
int rc;
239239

240+
#if defined(CONFIG_MULTITHREADING)
240241
k_sem_take(&dev_data->acquired, K_FOREVER);
242+
#endif
241243

242244
rc = pm_device_runtime_get(dev_config->bus);
243245
if (rc < 0) {
@@ -269,21 +271,27 @@ static int acquire(const struct device *dev)
269271
(void)pm_device_runtime_put(dev_config->bus);
270272
}
271273

274+
#if defined(CONFIG_MULTITHREADING)
272275
k_sem_give(&dev_data->acquired);
276+
#endif
277+
273278
return rc;
274279
}
275280

276281
static void release(const struct device *dev)
277282
{
278283
const struct flash_mspi_nor_config *dev_config = dev->config;
279-
struct flash_mspi_nor_data *dev_data = dev->data;
280284

281285
/* This releases the MSPI controller. */
282286
(void)mspi_get_channel_status(dev_config->bus, 0);
283287

284288
(void)pm_device_runtime_put(dev_config->bus);
285289

290+
#if defined(CONFIG_MULTITHREADING)
291+
struct flash_mspi_nor_data *dev_data = dev->data;
292+
286293
k_sem_give(&dev_data->acquired);
294+
#endif
287295
}
288296

289297
static inline uint32_t dev_flash_size(const struct device *dev)
@@ -1215,7 +1223,9 @@ static int drv_init(const struct device *dev)
12151223
}
12161224
}
12171225

1226+
#if defined(CONFIG_MULTITHREADING)
12181227
k_sem_init(&dev_data->acquired, 1, K_SEM_MAX_LIMIT);
1228+
#endif
12191229

12201230
return pm_device_driver_init(dev, dev_pm_action_cb);
12211231
}

drivers/flash/flash_mspi_nor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ struct flash_mspi_nor_config {
104104
};
105105

106106
struct flash_mspi_nor_data {
107+
#if defined(CONFIG_MULTITHREADING)
107108
struct k_sem acquired;
109+
#endif
108110
struct mspi_xfer_packet packet;
109111
struct mspi_xfer xfer;
110112
struct jesd216_erase_type erase_types[JESD216_NUM_ERASE_TYPES];

0 commit comments

Comments
 (0)