Skip to content

Commit 8bbbf1d

Browse files
narangmayanknashif
authored andcommitted
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 <[email protected]> (cherry picked from commit cb60881)
1 parent ba7c85d commit 8bbbf1d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/sensor/st/stmemsc/stmemsc_spi.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ int stmemsc_spi_read_incr(const struct spi_dt_spec *stmemsc,
7373
int stmemsc_spi_write_incr(const struct spi_dt_spec *stmemsc,
7474
uint8_t reg_addr, uint8_t *value, uint8_t len)
7575
{
76-
reg_addr |= STMEMSC_SPI_ADDR_AUTO_INCR;
76+
if (len > 1) {
77+
reg_addr |= STMEMSC_SPI_ADDR_AUTO_INCR;
78+
}
79+
7780
return stmemsc_spi_write(stmemsc, reg_addr, value, len);
7881
}

0 commit comments

Comments
 (0)