Skip to content

Commit eb15f30

Browse files
vladislav-pejicnashif
authored andcommitted
driver: sensor: adxl367: Fix for SPI
Fix for SPI communication when RTIO is used in SPI driver. When in adxl367_bus_access, const struct spi_buf buf[3] is used, spi_rtio_copy function won't set correct buffers and length for buf[2] and that will cause exception when that buffer is processed. Signed-off-by: Vladislav Pejic <[email protected]>
1 parent 1a4085a commit eb15f30

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

drivers/sensor/adi/adxl367/adxl367_spi.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ static int adxl367_bus_access(const struct device *dev, uint8_t reg,
3232

3333
addr_reg = ADXL367_TO_REG(reg);
3434

35-
const struct spi_buf buf[3] = {
35+
uint8_t access[2] = {rw_reg, addr_reg};
36+
37+
const struct spi_buf buf[2] = {
3638
{
37-
.buf = &rw_reg,
38-
.len = 1
39-
}, {
40-
.buf = &addr_reg,
41-
.len = 1
39+
.buf = access,
40+
.len = 2
4241
}, {
4342
.buf = data,
4443
.len = length
@@ -52,15 +51,15 @@ static int adxl367_bus_access(const struct device *dev, uint8_t reg,
5251
if ((reg & ADXL367_READ) != 0) {
5352
const struct spi_buf_set rx = {
5453
.buffers = buf,
55-
.count = 3
54+
.count = 2
5655
};
5756

58-
tx.count = 2;
57+
tx.count = 1;
5958

6059
return spi_transceive_dt(&config->spi, &tx, &rx);
6160
}
6261

63-
tx.count = 3;
62+
tx.count = 2;
6463

6564
return spi_write_dt(&config->spi, &tx);
6665
}

0 commit comments

Comments
 (0)