Skip to content

Commit 0a7d8d4

Browse files
bbilasMaureenHelm
authored andcommitted
drivers: sensor: bmp388: convert to spi_dt_spec
Convert bmp388 driver to use spi_dt_spec helpers. Signed-off-by: Bartosz Bilas <[email protected]>
1 parent 022bc83 commit 0a7d8d4

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

drivers/sensor/bmp388/bmp388.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static int bmp388_transceive(const struct device *dev,
5252
const struct spi_buf buf = { .buf = data, .len = length };
5353
const struct spi_buf_set s = { .buffers = &buf, .count = 1 };
5454

55-
return spi_transceive(cfg->bus, &cfg->spi_cfg, &s, &s);
55+
return spi_transceive_dt(&cfg->spi_bus, &s, &s);
5656
}
5757

5858
static int bmp388_read_spi(const struct device *dev,
@@ -71,7 +71,7 @@ static int bmp388_read_spi(const struct device *dev,
7171
const struct spi_buf_set tx = { .buffers = buf, .count = 1 };
7272
const struct spi_buf_set rx = { .buffers = buf, .count = 2 };
7373

74-
return spi_transceive(cfg->bus, &cfg->spi_cfg, &tx, &rx);
74+
return spi_transceive_dt(&cfg->spi_bus, &tx, &rx);
7575
}
7676

7777
static int bmp388_byte_read_spi(const struct device *dev,
@@ -602,10 +602,10 @@ static int bmp388_init(const struct device *dev)
602602
}
603603

604604
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
605-
/* Verify that the CS device is ready if it is set in the DT. */
606-
if (is_spi && (cfg->spi_cfg.cs != NULL)) {
607-
if (!device_is_ready(cfg->spi_cfg.cs->gpio_dev)) {
608-
LOG_ERR("SPI CS device is not ready");
605+
/* Verify the SPI bus */
606+
if (is_spi) {
607+
if (!spi_is_ready(&cfg->spi_bus)) {
608+
LOG_ERR("SPI bus is not ready");
609609
return -ENODEV;
610610
}
611611
}
@@ -694,7 +694,7 @@ static int bmp388_init(const struct device *dev)
694694

695695
#define BMP388_BUS_CFG_SPI(inst) \
696696
.ops = &bmp388_spi_ops, \
697-
.spi_cfg = SPI_CONFIG_DT_INST(inst, SPI_OP_MODE_MASTER | SPI_WORD_SET(8), 0)
697+
.spi_bus = SPI_DT_SPEC_INST_GET(inst, SPI_OP_MODE_MASTER | SPI_WORD_SET(8), 0)
698698

699699
#define BMP388_BUS_CFG(inst) \
700700
COND_CODE_1(DT_INST_ON_BUS(inst, i2c), \

drivers/sensor/bmp388/bmp388.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ struct bmp388_config {
143143
const struct bmp388_io_ops *ops;
144144
union {
145145
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
146-
struct spi_config spi_cfg;
146+
struct spi_dt_spec spi_bus;
147147
#endif
148148
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
149149
uint16_t bus_addr;

0 commit comments

Comments
 (0)