devicetree: allow access to all nodes
Usually, we want to operate only on "available" device nodes ("available" means "status is okay and a matching binding is found"), but that's not true in all cases. Sometimes we want to operate on special nodes without matching bindings, such as those describing memory. To handle the distinction, change various additional devicetree APIs making it clear that they operate only on available device nodes, adjusting gen_defines and devicetree.h implementation details accordingly: - emit macros for all existing nodes in gen_defines.py, regardless of status or matching binding - rename DT_NUM_INST to DT_NUM_INST_STATUS_OKAY - rename DT_NODE_HAS_COMPAT to DT_NODE_HAS_COMPAT_STATUS_OKAY - rename DT_INST_FOREACH to DT_INST_FOREACH_STATUS_OKAY - rename DT_ANY_INST_ON_BUS to DT_ANY_INST_ON_BUS_STATUS_OKAY - rewrite DT_HAS_NODE_STATUS_OKAY in terms of a new DT_NODE_HAS_STATUS - resurrect DT_HAS_NODE in the form of DT_NODE_EXISTS - remove DT_COMPAT_ON_BUS as a public API - use the new default_prop_types edtlib parameter Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
e96ca54fd8
commit
7e0eed9235
171 changed files with 496 additions and 433 deletions
|
@ -752,7 +752,7 @@ static struct lsm6dso_data lsm6dso_data;
|
|||
|
||||
static const struct lsm6dso_config lsm6dso_config = {
|
||||
.bus_name = DT_INST_BUS_LABEL(0),
|
||||
#if DT_ANY_INST_ON_BUS(spi)
|
||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
|
||||
.bus_init = lsm6dso_spi_init,
|
||||
.spi_conf.frequency = DT_INST_PROP(0, spi_max_frequency),
|
||||
.spi_conf.operation = (SPI_OP_MODE_MASTER | SPI_MODE_CPOL |
|
||||
|
@ -767,7 +767,7 @@ static const struct lsm6dso_config lsm6dso_config = {
|
|||
#else
|
||||
.spi_conf.cs = NULL,
|
||||
#endif
|
||||
#elif DT_ANY_INST_ON_BUS(i2c)
|
||||
#elif DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
|
||||
.bus_init = lsm6dso_i2c_init,
|
||||
.i2c_slv_addr = DT_INST_REG_ADDR(0),
|
||||
#else
|
||||
|
|
|
@ -100,15 +100,15 @@ struct lsm6dso_config {
|
|||
u8_t int_gpio_flags;
|
||||
u8_t int_pin;
|
||||
#endif /* CONFIG_LSM6DSO_TRIGGER */
|
||||
#if DT_ANY_INST_ON_BUS(i2c)
|
||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
|
||||
u16_t i2c_slv_addr;
|
||||
#elif DT_ANY_INST_ON_BUS(spi)
|
||||
#elif DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
|
||||
struct spi_config spi_conf;
|
||||
#if DT_INST_SPI_DEV_HAS_CS_GPIOS(0)
|
||||
const char *gpio_cs_port;
|
||||
u8_t cs_gpio;
|
||||
#endif /* DT_INST_SPI_DEV_HAS_CS_GPIOS(0) */
|
||||
#endif /* DT_ANY_INST_ON_BUS(i2c) */
|
||||
#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) */
|
||||
};
|
||||
|
||||
union samples {
|
||||
|
@ -159,9 +159,9 @@ struct lsm6dso_data {
|
|||
|
||||
stmdev_ctx_t *ctx;
|
||||
|
||||
#if DT_ANY_INST_ON_BUS(i2c)
|
||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
|
||||
stmdev_ctx_t ctx_i2c;
|
||||
#elif DT_ANY_INST_ON_BUS(spi)
|
||||
#elif DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
|
||||
stmdev_ctx_t ctx_spi;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include "lsm6dso.h"
|
||||
|
||||
#if DT_ANY_INST_ON_BUS(i2c)
|
||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
|
||||
|
||||
LOG_MODULE_DECLARE(LSM6DSO, CONFIG_SENSOR_LOG_LEVEL);
|
||||
|
||||
|
@ -52,4 +52,4 @@ int lsm6dso_i2c_init(struct device *dev)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif /* DT_ANY_INST_ON_BUS(i2c) */
|
||||
#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) */
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "lsm6dso.h"
|
||||
#include <logging/log.h>
|
||||
|
||||
#if DT_ANY_INST_ON_BUS(spi)
|
||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
|
||||
|
||||
#define LSM6DSO_SPI_READ (1 << 7)
|
||||
|
||||
|
@ -125,4 +125,4 @@ int lsm6dso_spi_init(struct device *dev)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif /* DT_ANY_INST_ON_BUS(spi) */
|
||||
#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue