From bc087b5c27be53e35b319578e159d5a1f0d19bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ju=C5=99ena?= Date: Sun, 8 Dec 2024 21:22:34 +0100 Subject: [PATCH] drivers: sensor: ti: ina230: Fix shared data between instances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- drivers/sensor/ti/ina23x/ina230.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/sensor/ti/ina23x/ina230.c b/drivers/sensor/ti/ina23x/ina230.c index c65d5b80d97f24..1e496a400ff064 100644 --- a/drivers/sensor/ti/ina23x/ina230.c +++ b/drivers/sensor/ti/ina23x/ina230.c @@ -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) | \ @@ -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);