Skip to content

Commit

Permalink
drivers: sensor: scd4x: Fix to allow the use of multiple models
Browse files Browse the repository at this point in the history
Compilation will fail if multiple models are used at the same time.
Changing to define different unique names for the symbols
to avoid conflicts.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
  • Loading branch information
soburi authored and kartben committed Dec 11, 2024
1 parent f41195f commit 0e978fb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/sensor/sensirion/scd4x/scd4x.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,14 +889,14 @@ static DEVICE_API(sensor, scd4x_api_funcs) = {
};

#define SCD4X_INIT(inst, scd4x_model) \
static struct scd4x_data scd4x_data_##inst; \
static const struct scd4x_config scd4x_config_##inst = { \
static struct scd4x_data scd4x_data_##scd4x_model##_##inst; \
static const struct scd4x_config scd4x_config_##scd4x_model##_##inst = { \
.bus = I2C_DT_SPEC_INST_GET(inst), \
.model = scd4x_model, \
.mode = DT_INST_ENUM_IDX_OR(inst, mode, SCD4X_MODE_NORMAL), \
}; \
SENSOR_DEVICE_DT_INST_DEFINE(inst, scd4x_init, NULL, &scd4x_data_##inst, \
&scd4x_config_##inst, POST_KERNEL, \
SENSOR_DEVICE_DT_INST_DEFINE(inst, scd4x_init, NULL, &scd4x_data_##scd4x_model##_##inst, \
&scd4x_config_##scd4x_model##_##inst, POST_KERNEL, \
CONFIG_SENSOR_INIT_PRIORITY, &scd4x_api_funcs);

#define DT_DRV_COMPAT sensirion_scd40
Expand Down

0 comments on commit 0e978fb

Please sign in to comment.