mirror of https://github.com/zmkfirmware/zmk.git
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:
parent
700e9b264f
commit
6941abc2af
|
|
@ -371,14 +371,14 @@ static int il0323_init(const struct device *dev) {
|
||||||
return il0323_controller_init(dev);
|
return il0323_controller_init(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct il0323_cfg il0323_config = {
|
static const struct il0323_cfg il0323_config = {
|
||||||
.spi = SPI_DT_SPEC_INST_GET(0, SPI_OP_MODE_MASTER | SPI_WORD_SET(8), 0),
|
.spi = SPI_DT_SPEC_INST_GET(0, SPI_OP_MODE_MASTER | SPI_WORD_SET(8), 0),
|
||||||
.reset = GPIO_DT_SPEC_INST_GET(0, reset_gpios),
|
.reset = GPIO_DT_SPEC_INST_GET(0, reset_gpios),
|
||||||
.busy = GPIO_DT_SPEC_INST_GET(0, busy_gpios),
|
.busy = GPIO_DT_SPEC_INST_GET(0, busy_gpios),
|
||||||
.dc = GPIO_DT_SPEC_INST_GET(0, dc_gpios),
|
.dc = GPIO_DT_SPEC_INST_GET(0, dc_gpios),
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct display_driver_api il0323_driver_api = {
|
static const struct display_driver_api il0323_driver_api = {
|
||||||
.blanking_on = il0323_blanking_on,
|
.blanking_on = il0323_blanking_on,
|
||||||
.blanking_off = il0323_blanking_off,
|
.blanking_off = il0323_blanking_off,
|
||||||
.write = il0323_write,
|
.write = il0323_write,
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ static int reg_595_init(const struct device *dev) {
|
||||||
GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_PROP(inst, ngpios))
|
GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_PROP(inst, ngpios))
|
||||||
|
|
||||||
#define REG_595_INIT(n) \
|
#define REG_595_INIT(n) \
|
||||||
static struct reg_595_config reg_595_##n##_config = { \
|
static const struct reg_595_config reg_595_##n##_config = { \
|
||||||
.common = \
|
.common = \
|
||||||
{ \
|
{ \
|
||||||
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(n), \
|
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(n), \
|
||||||
|
|
|
||||||
|
|
@ -322,7 +322,7 @@ static int max7318_init(const struct device *dev) {
|
||||||
GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_PROP(inst, ngpios))
|
GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_PROP(inst, ngpios))
|
||||||
|
|
||||||
#define MAX7318_INIT(inst) \
|
#define MAX7318_INIT(inst) \
|
||||||
static struct max7318_config max7318_##inst##_config = { \
|
static const struct max7318_config max7318_##inst##_config = { \
|
||||||
.common = {.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(inst)}, \
|
.common = {.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(inst)}, \
|
||||||
.i2c_bus = I2C_DT_SPEC_INST_GET(inst)}; \
|
.i2c_bus = I2C_DT_SPEC_INST_GET(inst)}; \
|
||||||
\
|
\
|
||||||
|
|
|
||||||
|
|
@ -68,13 +68,10 @@ int input_mock_init(const struct device *dev) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GET_EVENT(n, inst) \
|
|
||||||
{}
|
|
||||||
|
|
||||||
#define INPUT_MOCK_INST(n) \
|
#define INPUT_MOCK_INST(n) \
|
||||||
struct input_mock_data input_mock_data_##n = {}; \
|
static struct input_mock_data input_mock_data_##n = {}; \
|
||||||
const uint32_t mock_data_##n[] = DT_INST_PROP(n, events); \
|
static const uint32_t mock_data_##n[] = DT_INST_PROP(n, events); \
|
||||||
const struct input_mock_config input_mock_cfg_##n = { \
|
static const struct input_mock_config input_mock_cfg_##n = { \
|
||||||
.events = mock_data_##n, \
|
.events = mock_data_##n, \
|
||||||
.events_len = DT_INST_PROP_LEN(n, events), \
|
.events_len = DT_INST_PROP_LEN(n, events), \
|
||||||
.startup_delay = DT_INST_PROP(n, event_startup_delay), \
|
.startup_delay = DT_INST_PROP(n, event_startup_delay), \
|
||||||
|
|
|
||||||
|
|
@ -445,7 +445,7 @@ static const struct kscan_driver_api kscan_charlieplex_api = {
|
||||||
.charlieplex_state = kscan_charlieplex_state_##n, \
|
.charlieplex_state = kscan_charlieplex_state_##n, \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
static struct kscan_charlieplex_config kscan_charlieplex_config_##n = { \
|
static const struct kscan_charlieplex_config kscan_charlieplex_config_##n = { \
|
||||||
.cells = KSCAN_GPIO_LIST(kscan_charlieplex_cells_##n), \
|
.cells = KSCAN_GPIO_LIST(kscan_charlieplex_cells_##n), \
|
||||||
.debounce_config = \
|
.debounce_config = \
|
||||||
{ \
|
{ \
|
||||||
|
|
|
||||||
|
|
@ -397,7 +397,7 @@ static const struct kscan_driver_api kscan_direct_api = {
|
||||||
.pin_state = kscan_direct_state_##n, \
|
.pin_state = kscan_direct_state_##n, \
|
||||||
COND_INTERRUPTS((.irqs = kscan_direct_irqs_##n, ))}; \
|
COND_INTERRUPTS((.irqs = kscan_direct_irqs_##n, ))}; \
|
||||||
\
|
\
|
||||||
static struct kscan_direct_config kscan_direct_config_##n = { \
|
static const struct kscan_direct_config kscan_direct_config_##n = { \
|
||||||
.debounce_config = \
|
.debounce_config = \
|
||||||
{ \
|
{ \
|
||||||
.debounce_press_ms = INST_DEBOUNCE_PRESS_MS(n), \
|
.debounce_press_ms = INST_DEBOUNCE_PRESS_MS(n), \
|
||||||
|
|
|
||||||
|
|
@ -515,7 +515,7 @@ static const struct kscan_driver_api kscan_matrix_api = {
|
||||||
.matrix_state = kscan_matrix_state_##n, \
|
.matrix_state = kscan_matrix_state_##n, \
|
||||||
COND_INTERRUPTS((.irqs = kscan_matrix_irqs_##n, ))}; \
|
COND_INTERRUPTS((.irqs = kscan_matrix_irqs_##n, ))}; \
|
||||||
\
|
\
|
||||||
static struct kscan_matrix_config kscan_matrix_config_##n = { \
|
static const struct kscan_matrix_config kscan_matrix_config_##n = { \
|
||||||
.rows = ARRAY_SIZE(kscan_matrix_rows_##n), \
|
.rows = ARRAY_SIZE(kscan_matrix_rows_##n), \
|
||||||
.cols = ARRAY_SIZE(kscan_matrix_cols_##n), \
|
.cols = ARRAY_SIZE(kscan_matrix_cols_##n), \
|
||||||
.outputs = \
|
.outputs = \
|
||||||
|
|
|
||||||
|
|
@ -148,8 +148,8 @@ int ec11_init(const struct device *dev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EC11_INST(n) \
|
#define EC11_INST(n) \
|
||||||
struct ec11_data ec11_data_##n; \
|
static struct ec11_data ec11_data_##n; \
|
||||||
const struct ec11_config ec11_cfg_##n = { \
|
static const struct ec11_config ec11_cfg_##n = { \
|
||||||
.a = GPIO_DT_SPEC_INST_GET(n, a_gpios), \
|
.a = GPIO_DT_SPEC_INST_GET(n, a_gpios), \
|
||||||
.b = GPIO_DT_SPEC_INST_GET(n, b_gpios), \
|
.b = GPIO_DT_SPEC_INST_GET(n, b_gpios), \
|
||||||
.resolution = DT_INST_PROP_OR(n, resolution, 1), \
|
.resolution = DT_INST_PROP_OR(n, resolution, 1), \
|
||||||
|
|
|
||||||
|
|
@ -205,8 +205,8 @@ static const struct sensor_driver_api max17048_api_table = {.sample_fetch = max1
|
||||||
.channel_get = max17048_channel_get};
|
.channel_get = max17048_channel_get};
|
||||||
|
|
||||||
#define MAX17048_INIT(inst) \
|
#define MAX17048_INIT(inst) \
|
||||||
static struct max17048_config max17048_##inst##_config = {.i2c_bus = \
|
static const struct max17048_config max17048_##inst##_config = { \
|
||||||
I2C_DT_SPEC_INST_GET(inst)}; \
|
.i2c_bus = I2C_DT_SPEC_INST_GET(inst)}; \
|
||||||
\
|
\
|
||||||
static struct max17048_drv_data max17048_##inst##_drvdata = { \
|
static struct max17048_drv_data max17048_##inst##_drvdata = { \
|
||||||
.raw_state_of_charge = 0, \
|
.raw_state_of_charge = 0, \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue