fix(drivers): Proper static/const for data/config (#2769)

Save a tiny bit of RAM by properly marking our device config
struct instances const consistently, and also add missing static
modifiers to properly isolate config/data for drivers.
This commit is contained in:
Pete Johanson
2025-01-15 10:35:35 -07:00
committed by GitHub
parent 700e9b264f
commit 6941abc2af
9 changed files with 14 additions and 17 deletions

View File

@@ -148,8 +148,8 @@ int ec11_init(const struct device *dev) {
}
#define EC11_INST(n) \
struct ec11_data ec11_data_##n; \
const struct ec11_config ec11_cfg_##n = { \
static struct ec11_data ec11_data_##n; \
static const struct ec11_config ec11_cfg_##n = { \
.a = GPIO_DT_SPEC_INST_GET(n, a_gpios), \
.b = GPIO_DT_SPEC_INST_GET(n, b_gpios), \
.resolution = DT_INST_PROP_OR(n, resolution, 1), \

View File

@@ -205,8 +205,8 @@ static const struct sensor_driver_api max17048_api_table = {.sample_fetch = max1
.channel_get = max17048_channel_get};
#define MAX17048_INIT(inst) \
static struct max17048_config max17048_##inst##_config = {.i2c_bus = \
I2C_DT_SPEC_INST_GET(inst)}; \
static const struct max17048_config max17048_##inst##_config = { \
.i2c_bus = I2C_DT_SPEC_INST_GET(inst)}; \
\
static struct max17048_drv_data max17048_##inst##_drvdata = { \
.raw_state_of_charge = 0, \