Skip to content

Commit

Permalink
drivers: sensor: ti: ina230: Fix shared data between instances
Browse files Browse the repository at this point in the history
This commit fixes a shared context between multiple instances of the
INA230 and INA236 driver. The issue is the naming of the instance data in
`INA230_DRIVER_INIT` macro when we have one instance of INA230 and one
of INA236 the name of the data variable will be `drv_data_0`. This
variable will then be passed to both instances.

Signed-off-by: Tomáš Juřena <[email protected]>
  • Loading branch information
jurenat committed Dec 8, 2024
1 parent bea5fc7 commit bc087b5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/sensor/ti/ina23x/ina230.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static DEVICE_API(sensor, ina230_driver_api) = {
#endif /* CONFIG_INA230_TRIGGER */

#define INA230_DRIVER_INIT(inst, type) \
static struct ina230_data drv_data_##inst; \
static struct ina230_data drv_data_##type##inst; \
static const struct ina230_config drv_config_##type##inst = { \
.bus = I2C_DT_SPEC_INST_GET(inst), \
.config = (DT_INST_PROP_OR(inst, high_precision, 0) << 12) | \
Expand All @@ -266,7 +266,7 @@ static DEVICE_API(sensor, ina230_driver_api) = {
(DT_INST_PROP_OR(inst, high_precision, 0) << 1)), \
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, alert_gpios), (INA230_CFG_IRQ(inst)), \
())}; \
SENSOR_DEVICE_DT_INST_DEFINE(inst, &ina230_init, NULL, &drv_data_##inst, \
SENSOR_DEVICE_DT_INST_DEFINE(inst, &ina230_init, NULL, &drv_data_##type##inst, \
&drv_config_##type##inst, POST_KERNEL, \
CONFIG_SENSOR_INIT_PRIORITY, &ina230_driver_api);

Expand Down

0 comments on commit bc087b5

Please sign in to comment.