Skip to content

Commit 022bc83

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

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

drivers/sensor/ms5607/ms5607.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ static const struct sensor_driver_api ms5607_api_funcs = {
325325
{ \
326326
.bus = DEVICE_DT_GET(DT_INST_BUS(inst)), \
327327
.tf = &ms5607_spi_transfer_function, \
328-
.bus_cfg.spi_cfg = \
329-
SPI_CONFIG_DT_INST(inst, \
328+
.bus_cfg.spi_bus = \
329+
SPI_DT_SPEC_INST_GET(inst, \
330330
MS5607_SPI_OPERATION, \
331331
0), \
332332
}

drivers/sensor/ms5607/ms5607.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ struct ms5607_config {
9595
uint16_t i2c_addr;
9696
#endif
9797
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
98-
struct spi_config spi_cfg;
98+
struct spi_dt_spec spi_bus;
9999
#endif
100100
} bus_cfg;
101101
};

drivers/sensor/ms5607/ms5607_spi.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static int ms5607_spi_raw_cmd(const struct ms5607_config *config, uint8_t cmd)
2929
.count = 1,
3030
};
3131

32-
return spi_write(config->bus, &config->bus_cfg.spi_cfg, &buf_set);
32+
return spi_write_dt(&config->bus_cfg.spi_bus, &buf_set);
3333
}
3434

3535
static int ms5607_spi_reset(const struct ms5607_config *config)
@@ -79,8 +79,7 @@ static int ms5607_spi_read_prom(const struct ms5607_config *config, uint8_t cmd,
7979
.count = 1,
8080
};
8181

82-
err = spi_transceive(config->bus,
83-
&config->bus_cfg.spi_cfg,
82+
err = spi_transceive_dt(&config->bus_cfg.spi_bus,
8483
&tx_buf_set,
8584
&rx_buf_set);
8685
if (err < 0) {
@@ -130,8 +129,7 @@ static int ms5607_spi_read_adc(const struct ms5607_config *config, uint32_t *val
130129
.count = 1,
131130
};
132131

133-
err = spi_transceive(config->bus,
134-
&config->bus_cfg.spi_cfg,
132+
err = spi_transceive_dt(&config->bus_cfg.spi_bus,
135133
&tx_buf_set,
136134
&rx_buf_set);
137135
if (err < 0) {
@@ -145,21 +143,11 @@ static int ms5607_spi_read_adc(const struct ms5607_config *config, uint32_t *val
145143

146144
static int ms5607_spi_check(const struct ms5607_config *config)
147145
{
148-
const struct spi_cs_control *cs = config->bus_cfg.spi_cfg.cs;
149-
150-
if (!device_is_ready(config->bus)) {
146+
if (!spi_is_ready(&config->bus_cfg.spi_bus)) {
151147
LOG_DBG("SPI bus %s not ready", config->bus->name);
152148
return -ENODEV;
153149
}
154150

155-
if (cs) {
156-
if (!device_is_ready(cs->gpio_dev)) {
157-
LOG_DBG("SPI CS GPIO controller %s not ready", cs->gpio_dev->name);
158-
return -ENODEV;
159-
}
160-
LOG_DBG("SPI GPIO CS configured on %s:%u", cs->gpio_dev->name, cs->gpio_pin);
161-
}
162-
163151
return 0;
164152
}
165153

0 commit comments

Comments
 (0)