drivers/sensor: stmemsc: make use of spi_dt_spec and i2c_dt_spec

Make use of the new DT facilities that introduced two new
bus structures, spi_dt_spec and i2c_dt_spec, as well as the
macros, SPI_DT_SPEC_INST_GET and I2C_DT_SPEC_INST_GET, to
retrieve info from DT.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
Armando Visconti 2021-09-07 10:27:49 +02:00 committed by Maureen Helm
commit dabaaa1e5d
13 changed files with 42 additions and 62 deletions

View file

@ -888,9 +888,8 @@ static int lsm6dso_init(const struct device *dev)
.handle = \
(void *)&lsm6dso_config_##inst.stmemsc_cfg, \
}, \
.stmemsc_cfg.spi = { \
.bus = DEVICE_DT_GET(DT_INST_BUS(inst)), \
.spi_cfg = SPI_CONFIG_DT_INST(inst, \
.stmemsc_cfg = { \
.spi = SPI_DT_SPEC_INST_GET(inst, \
LSM6DSO_SPI_OP, \
0), \
}, \
@ -912,9 +911,8 @@ static int lsm6dso_init(const struct device *dev)
.handle = \
(void *)&lsm6dso_config_##inst.stmemsc_cfg, \
}, \
.stmemsc_cfg.i2c = { \
.bus = DEVICE_DT_GET(DT_INST_BUS(inst)), \
.i2c_slv_addr = DT_INST_REG_ADDR(inst), \
.stmemsc_cfg = { \
.i2c = I2C_DT_SPEC_INST_GET(inst), \
}, \
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
(LSM6DSO_CFG_IRQ(inst)), ()) \

View file

@ -94,10 +94,10 @@ struct lsm6dso_config {
stmdev_ctx_t ctx;
union {
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
const struct stmemsc_cfg_i2c i2c;
const struct i2c_dt_spec i2c;
#endif
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
const struct stmemsc_cfg_spi spi;
const struct spi_dt_spec spi;
#endif
} stmemsc_cfg;
#ifdef CONFIG_LSM6DSO_TRIGGER