mgmt: ec_host_cmd: stm32_spi: fix cs interrupt configuration

Move enabling CS interrupt at the end of the backend configuration,
when everything is ready.

It prevents handling the interrupt, when something is not prepared e.g.
DMA is not configured.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
This commit is contained in:
Dawid Niedzwiecki 2024-11-22 13:55:56 +01:00 committed by Benjamin Cabé
commit 21c12786ec

View file

@ -706,10 +706,6 @@ static int ec_host_cmd_spi_init(const struct ec_host_cmd_backend *backend,
return -EIO; return -EIO;
} }
gpio_init_callback(&hc_spi->cs_callback, gpio_cb_nss, BIT(hc_spi->cs.pin));
gpio_add_callback(hc_spi->cs.port, &hc_spi->cs_callback);
gpio_pin_interrupt_configure(hc_spi->cs.port, hc_spi->cs.pin, GPIO_INT_EDGE_BOTH);
hc_spi->rx_ctx = rx_ctx; hc_spi->rx_ctx = rx_ctx;
hc_spi->rx_ctx->len = 0; hc_spi->rx_ctx->len = 0;
@ -746,6 +742,11 @@ static int ec_host_cmd_spi_init(const struct ec_host_cmd_backend *backend,
tx_status(spi, EC_SPI_RX_READY); tx_status(spi, EC_SPI_RX_READY);
hc_spi->state = SPI_HOST_CMD_STATE_READY_TO_RX; hc_spi->state = SPI_HOST_CMD_STATE_READY_TO_RX;
/* Configure CS interrupt once everything is ready. */
gpio_init_callback(&hc_spi->cs_callback, gpio_cb_nss, BIT(hc_spi->cs.pin));
gpio_add_callback(hc_spi->cs.port, &hc_spi->cs_callback);
gpio_pin_interrupt_configure(hc_spi->cs.port, hc_spi->cs.pin, GPIO_INT_EDGE_BOTH);
return ret; return ret;
} }