wigig_sensing: fix driver state machine

Allow mode change from INITIALIZED to READY_STOPPED only after SPI has been
initialized. This change will prevent mode change before SPI is ready for
operation.

Change-Id: I12b52bb9c9726c2d8e615fa0c504d01c7b1e26e3
Signed-off-by: Gidon Studinski <gidons@codeaurora.org>
Signed-off-by: Alexei Avshalom Lazar <ailizaro@codeaurora.org>
This commit is contained in:
Gidon Studinski 2019-12-26 14:51:47 +02:00 • committed by Gerrit - the friendly Code Review server
commit f92a7e7195
2 changed files with 8 additions and 2 deletions

View file

@ -454,9 +454,11 @@ static int wigig_sensing_change_state(struct wigig_sensing_ctx *ctx,
/*
* Moving from INITIALIZED state is allowed only to READY_STOPPED state
* and only when spi_ready is set
*/
else if (curr_state == WIGIG_SENSING_STATE_INITIALIZED &&
new_state != WIGIG_SENSING_STATE_READY_STOPPED) {
(new_state != WIGIG_SENSING_STATE_READY_STOPPED ||
!ctx->stm.spi_ready)) {
transition_allowed = false;
rc = -EFAULT;
}
@ -1255,9 +1257,11 @@ static irqreturn_t wigig_sensing_dri_isr_thread(int irq, void *cookie)
}
ctx->stm.spi_malfunction = false;
if (ctx->stm.state == WIGIG_SENSING_STATE_INITIALIZED)
if (ctx->stm.state == WIGIG_SENSING_STATE_INITIALIZED) {
wigig_sensing_change_state(ctx, &ctx->stm,
WIGIG_SENSING_STATE_READY_STOPPED);
ctx->stm.spi_ready = true;
}
}
pr_debug("Reading SANITY register\n");
@ -1313,6 +1317,7 @@ static irqreturn_t wigig_sensing_dri_isr_thread(int irq, void *cookie)
WIGIG_SENSING_EVENT_RESET);
ctx->stm.spi_malfunction = true;
ctx->stm.spi_ready = false;
memset(&ctx->inb_cmd, 0, sizeof(ctx->inb_cmd));
spi_status.v &= ~INT_SYSASSERT;
goto deassert_and_bail_out;

View file

@ -146,6 +146,7 @@ struct wigig_sensing_stm {
bool auto_recovery;
bool fw_is_ready;
bool spi_malfunction;
bool spi_ready;
bool waiting_for_deep_sleep_exit;
bool waiting_for_deep_sleep_exit_first_pass;
bool burst_size_ready;