Skip to content

Commit 9712271

Browse files
xyzzy42nashif
authored andcommitted
drivers/sensor: si7006: Switch to undef DT_DRV_COMPAT
This style is used in sensor drivers. It's more complicated than the other way, which is used in different drivers that are not sensor drivers. Signed-off-by: Trent Piepho <[email protected]>
1 parent 0f219e1 commit 9712271

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

drivers/sensor/silabs/si7006/si7006.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,23 @@ static int si7006_init(const struct device *dev)
197197
return 0;
198198
}
199199

200-
#define SI7006_DEFINE(inst, temp_cmd) \
201-
static struct si7006_data si7006_data_##inst; \
200+
#define SI7006_DEFINE(inst, name, temp_cmd) \
201+
static struct si7006_data si7006_data_##name##_##inst; \
202202
\
203-
static const struct si7006_config si7006_config_##inst = { \
204-
.i2c = I2C_DT_SPEC_GET(inst), \
203+
static const struct si7006_config si7006_config_##name##_##inst = { \
204+
.i2c = I2C_DT_SPEC_INST_GET(inst), \
205205
.read_temp_cmd = temp_cmd, \
206206
}; \
207207
\
208-
SENSOR_DEVICE_DT_DEFINE(inst, si7006_init, NULL, \
209-
&si7006_data_##inst, &si7006_config_##inst, \
210-
POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, &si7006_api); \
211-
212-
DT_FOREACH_STATUS_OKAY_VARGS(silabs_si7006, SI7006_DEFINE, SI7006_READ_OLD_TEMP);
213-
DT_FOREACH_STATUS_OKAY_VARGS(sensirion_sht21, SI7006_DEFINE, SI7006_MEAS_TEMP_MASTER_MODE);
208+
SENSOR_DEVICE_DT_INST_DEFINE(inst, si7006_init, NULL, \
209+
&si7006_data_##name##_##inst, \
210+
&si7006_config_##name##_##inst, \
211+
POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, \
212+
&si7006_api);
213+
214+
#define DT_DRV_COMPAT silabs_si7006
215+
DT_INST_FOREACH_STATUS_OKAY_VARGS(SI7006_DEFINE, DT_DRV_COMPAT, SI7006_READ_OLD_TEMP);
216+
217+
#undef DT_DRV_COMPAT
218+
#define DT_DRV_COMPAT sensirion_sht21
219+
DT_INST_FOREACH_STATUS_OKAY_VARGS(SI7006_DEFINE, DT_DRV_COMPAT, SI7006_MEAS_TEMP_MASTER_MODE);

0 commit comments

Comments
 (0)