Skip to content

Commit a36c2bd

Browse files
committed
driver: sensor: fix tmp108 build (#158)
Fixed tmp108 build when device_pm is not enabled Signed-off-by: Jared Baumann <jared.baumann8@t-mobile.com>
1 parent 1b042f8 commit a36c2bd

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

drivers/sensor/tmp108/tmp108.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,9 @@ static int tmp108_pm_action(const struct device *dev,
418418

419419
return ret;
420420
}
421-
#endif
421+
#endif /* CONFIG_PM_DEVICE */
422422

423+
#ifdef CONFIG_PM_DEVICE
423424
#define TMP108_DEFINE(inst, t) \
424425
static struct tmp108_data tmp108_prv_data_##inst##t; \
425426
static const struct tmp108_config tmp108_config_##inst##t = { \
@@ -437,6 +438,24 @@ static int tmp108_pm_action(const struct device *dev,
437438
POST_KERNEL, \
438439
CONFIG_SENSOR_INIT_PRIORITY, \
439440
&tmp108_driver_api);
441+
#else
442+
#define TMP108_DEFINE(inst, t) \
443+
static struct tmp108_data tmp108_prv_data_##inst##t; \
444+
static const struct tmp108_config tmp108_config_##inst##t = { \
445+
.i2c_spec = I2C_DT_SPEC_INST_GET(inst), \
446+
.alert_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, \
447+
alert_gpios, { 0 }),\
448+
.reg_def = t##_CONF \
449+
}; \
450+
SENSOR_DEVICE_DT_INST_DEFINE(inst, \
451+
&tmp108_init, \
452+
NULL, \
453+
&tmp108_prv_data_##inst##t, \
454+
&tmp108_config_##inst##t, \
455+
POST_KERNEL, \
456+
CONFIG_SENSOR_INIT_PRIORITY, \
457+
&tmp108_driver_api);
458+
#endif /* CONFIG_PM_DEVICE */
440459

441460
#define TMP108_INIT(n) TMP108_DEFINE(n, TI_TMP108)
442461
#undef DT_DRV_COMPAT

0 commit comments

Comments
 (0)