spi: context: update state when already locked
Update the context state parameters when the context is already locked. This allows changing the callback information for asynchronous operations while the context is locked. Signed-off-by: Jordan Yates <jordan@embeint.com>
This commit is contained in:
parent
ebc2ca59e3
commit
13df3b9f62
1 changed files with 3 additions and 5 deletions
|
|
@ -96,13 +96,11 @@ static inline void spi_context_lock(struct spi_context *ctx,
|
||||||
(k_sem_count_get(&ctx->lock) == 0) &&
|
(k_sem_count_get(&ctx->lock) == 0) &&
|
||||||
(ctx->owner == spi_cfg);
|
(ctx->owner == spi_cfg);
|
||||||
|
|
||||||
if (already_locked) {
|
if (!already_locked) {
|
||||||
return;
|
k_sem_take(&ctx->lock, K_FOREVER);
|
||||||
|
ctx->owner = spi_cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_sem_take(&ctx->lock, K_FOREVER);
|
|
||||||
ctx->owner = spi_cfg;
|
|
||||||
|
|
||||||
#ifdef CONFIG_SPI_ASYNC
|
#ifdef CONFIG_SPI_ASYNC
|
||||||
ctx->asynchronous = asynchronous;
|
ctx->asynchronous = asynchronous;
|
||||||
ctx->callback = callback;
|
ctx->callback = callback;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue