From 978560a8022c65cea640f8165e6fead47e08fc38 Mon Sep 17 00:00:00 2001 From: Mayank Narang Date: Wed, 22 Jan 2025 22:50:43 +0530 Subject: [PATCH] drivers: sensor: lis2de12: add length check in spi write incr routine Added a length check in the spi write incr routine to handle both single and multi byte write operations properly. Signed-off-by: Mayank Narang (cherry picked from commit cb608812cfae2702bf244a77d945af07424cef2f) --- drivers/sensor/st/stmemsc/stmemsc_spi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/sensor/st/stmemsc/stmemsc_spi.c b/drivers/sensor/st/stmemsc/stmemsc_spi.c index 568c3a84aae5..66421f17ca00 100644 --- a/drivers/sensor/st/stmemsc/stmemsc_spi.c +++ b/drivers/sensor/st/stmemsc/stmemsc_spi.c @@ -73,6 +73,9 @@ int stmemsc_spi_read_incr(const struct spi_dt_spec *stmemsc, int stmemsc_spi_write_incr(const struct spi_dt_spec *stmemsc, uint8_t reg_addr, uint8_t *value, uint8_t len) { - reg_addr |= STMEMSC_SPI_ADDR_AUTO_INCR; + if (len > 1) { + reg_addr |= STMEMSC_SPI_ADDR_AUTO_INCR; + } + return stmemsc_spi_write(stmemsc, reg_addr, value, len); }