Skip to content

[DNM][WIP][do not review yet]Service and Device initialization: automatic priorities #79340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
90785f3
scripts/edtlib: Add the same accessor as chosen but for aliases
tbursztyka Apr 23, 2024
a7fb150
scripts: Add Zephyr initalization object script
tbursztyka Sep 10, 2024
f243140
cmake: Add a gen_init_priorties module
tbursztyka Apr 12, 2024
7a428a7
CMakeLists.txt: call zephyr_generate_init_priorities() where relevant
tbursztyka Sep 12, 2024
e4af5ac
include: Add init utility macro specific header
tbursztyka Apr 12, 2024
040da09
init: Adapt init entry section generation
tbursztyka Apr 12, 2024
ac25636
linker: Add an extra number to check for sorting levels sections
tbursztyka Jun 3, 2024
2129def
init: Add an extra '_' between level names and priority in sections
tbursztyka Jun 3, 2024
573c457
service: Introduce software service instanciation macros
tbursztyka Sep 11, 2024
21a4bfe
device: Add new macros to instanciate device objects
tbursztyka Sep 12, 2024
e4b5930
drivers: Switching DEVICE_<DT/DT_INST>_DEFINE macros to new ones
tbursztyka Sep 20, 2024
cc698fb
modules: Switching DEVICE_<DT/DT_INST>_DEFINE macros to new ones
tbursztyka Oct 22, 2024
a1d188a
soc: Switching DEVICE_<DT/DT_INST>_DEFINE macros to new ones
tbursztyka Oct 22, 2024
582fdf7
tests: Switching DEVICE_<DT/DT_INST>_DEFINE macros to new ones
tbursztyka Sep 20, 2024
394c058
subsys: Switching DEVICE_<DT/DT_INST>_DEFINE macros to new ones
tbursztyka Sep 20, 2024
b5d7b4e
boards: Switching DEVICE_<DT/DT_INST>_DEFINE macros to new ones
tbursztyka Sep 20, 2024
55d1d4f
sensor: Provide new device instantiation macros
tbursztyka Sep 19, 2024
1cab0e3
sensors: Switching SENSOR_DEVICE_<DT/DT_INST>_DEFINE macros to new ones
tbursztyka Sep 20, 2024
16d6965
net: Provide new device instantiation macros
tbursztyka Sep 23, 2024
3b63406
drivers: Switching NET_DEVICE_<INIT/DT_DEFINE>... macros to new ones
tbursztyka Sep 25, 2024
cf4ae2f
net/ethernet: Provide new device instantiation macro
tbursztyka Sep 25, 2024
11a3899
ethernet: Switching ETH_NET_DEVICE_<INIT/DT_INSTANCE>... to new ones
tbursztyka Sep 25, 2024
fa57ff1
tests: Switching NET_DEVICE_<INIT/DT_DEFINE>... macros to new ones
tbursztyka Sep 26, 2024
4dc46c5
can: Provide new device instantiation macro
tbursztyka Sep 26, 2024
ce5f327
drivers/can: Switching CAN_DEVICE_DT_DEFINE macros to new ones
tbursztyka Sep 26, 2024
a7dd9ee
smbus: Provide new device instantiation macro
tbursztyka Sep 26, 2024
5c0422c
drivers/smbus: Switching SMBUS_DEVICE_DT_DEFINE macros to new ones
tbursztyka Sep 26, 2024
2697cfb
include/drivers: Switching specific headers to new device macros
tbursztyka Sep 26, 2024
5c6ac50
i2c: Provide new device instantiation macro
tbursztyka Sep 26, 2024
8015d1a
drivers/i2c: Switching I2C_DEVICE_DT_DEFINE macros to new ones
tbursztyka Sep 26, 2024
cbf4c1c
spi: Provide new device instantiation macro
tbursztyka Sep 26, 2024
9f34701
firmware: Provide new device instantiation macro
tbursztyka Sep 26, 2024
d5578fd
tests and samples: Add relevant service and device init modifiers
tbursztyka Oct 2, 2024
94cc451
drivers: Add relevant changes for dependency resolution
tbursztyka Oct 7, 2024
ae8913a
tests: Fix DTS overlay for build_all/input
tbursztyka Oct 7, 2024
d99415a
devicetree: Define DT_NODE_HAS_STATUS if not ZTEST_UNITTEST
tbursztyka Jun 7, 2024
82530d6
tests: Change check_init_priorities fake device's priorities relevantly
tbursztyka Nov 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ set(DRIVER_VALIDATION_H_TARGET driver_validation_h_target)
set(KOBJ_TYPES_H_TARGET kobj_types_h_target)
set(PARSE_SYSCALLS_TARGET parse_syscalls_target)

include(${ZEPHYR_BASE}/cmake/modules/init_priorities.cmake)

define_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT BRIEF_DOCS " " FULL_DOCS " ")
set_property( GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-little${ARCH}) # BFD format

Expand Down Expand Up @@ -976,6 +978,9 @@ else()
set(NO_WHOLE_ARCHIVE_LIBS kernel)
endif()

# Generating priorities
zephyr_generate_init_priorities()

get_property(OUTPUT_FORMAT GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT)

if (CONFIG_CODE_DATA_RELOCATION)
Expand Down
4 changes: 2 additions & 2 deletions boards/beagle/beagleconnect_freedom/board_antenna.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = {
};

PINCTRL_DT_INST_DEFINE(0);
DEVICE_DT_INST_DEFINE(0, board_antenna_init, NULL, NULL, NULL, POST_KERNEL,
CONFIG_BOARD_ANTENNA_INIT_PRIO, NULL);
DEVICE_INSTANCE_FROM_DT_INST(0, board_antenna_init, NULL, NULL, NULL, POST_KERNEL,
NULL);

static const struct pinctrl_dev_config *ant_pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0);
static const struct gpio_dt_spec ant_gpios[] = {
Expand Down
4 changes: 2 additions & 2 deletions boards/ti/common/board_antenna.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = {
};

PINCTRL_DT_INST_DEFINE(0);
DEVICE_DT_INST_DEFINE(0, board_antenna_init, NULL, NULL, NULL, POST_KERNEL,
CONFIG_BOARD_ANTENNA_INIT_PRIO, NULL);
DEVICE_INSTANCE_FROM_DT_INST(0, board_antenna_init, NULL, NULL, NULL, POST_KERNEL,
NULL);

static const struct pinctrl_dev_config *ant_pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0);
static const struct gpio_dt_spec ant_gpios[] = {
Expand Down
13 changes: 9 additions & 4 deletions cmake/modules/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5172,8 +5172,8 @@ endfunction()
# This is useful content such as struct devices.
#
# For example: zephyr_linker_section_obj_level(SECTION init LEVEL PRE_KERNEL_1)
# will create an input section matching `.z_init_PRE_KERNEL_1?_` and
# `.z_init_PRE_KERNEL_1??_`.
# will create an input section matching `.z_init_PRE_KERNEL_1?_`,
# `.z_init_PRE_KERNEL_1??_` and `.z_init_PRE_KERNEL_1???_`
#
# SECTION <section>: Section in which the objects shall be placed
# LEVEL <level> : Priority level, all input sections matching the level
Expand All @@ -5197,13 +5197,18 @@ function(zephyr_linker_section_obj_level)

zephyr_linker_section_configure(
SECTION ${OBJ_SECTION}
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}?_*"
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}_?_*"
SYMBOLS __${OBJ_SECTION}_${OBJ_LEVEL}_start
KEEP SORT NAME
)
zephyr_linker_section_configure(
SECTION ${OBJ_SECTION}
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}??_*"
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}_??_*"
KEEP SORT NAME
)
zephyr_linker_section_configure(
SECTION ${OBJ_SECTION}
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}_???_*"
KEEP SORT NAME
)
endfunction()
Expand Down
110 changes: 110 additions & 0 deletions cmake/modules/init_priorities.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright (c) 2024, Tomasz Bursztyka
#
# SPDX-License-Identifier: Apache-2.0

include_guard(GLOBAL)
include(boards)

function(zephyr_add_service service_file)
set(service_full_path ${CMAKE_CURRENT_SOURCE_DIR}/${service_file})
set_property(TARGET zephyr_interface APPEND PROPERTY ZEPHYR_SERVICE_FILES ${service_full_path})
endfunction()

function(zephyr_add_service_ifdef feature_toggle service_file)
if(${${feature_toggle}})
zephyr_add_service(${service_file})
endif()
endfunction()

function(zephyr_add_device_init dev_init_file)
set(dev_init_full_path ${CMAKE_CURRENT_SOURCE_DIR}/${dev_init_file})
set_property(TARGET zephyr_interface APPEND PROPERTY ZEPHYR_DEVICE_INIT_FILES ${dev_init_full_path})
endfunction()

function(zephyr_add_device_init_ifdef feature_toggle dev_init_file)
if(${${feature_toggle}})
zephyr_add_device_init(${dev_init_file})
endif()
endfunction()

function(zephyr_generate_init_priorities)
if(NOT (ARGC EQUAL 0))
messasge(FATAL_ERROR "zephyr_generate_init_priorities takes no arguments")
endif()

# The directory containing gen_init_priorities.py script and files.
set(GIP_BASE ${ZEPHYR_BASE}/scripts/gen_init_priorities)

# gen_init_priorities script that will generate a header about soft/hard
# init nodes priority and - whene relevant - levels too.
set(GIP_SCRIPT ${GIP_BASE}/gen_init_priorities.py)

# The edtlib.EDT object in pickle format.
set(EDT_PICKLE ${PROJECT_BINARY_DIR}/edt.pickle)

# The .config file generated by Kconfig
set(DOTCONFIG ${PROJECT_BINARY_DIR}/.config)

# The generated C header needed by <zephyr/init.h>
set(GIP_INIT_H ${BINARY_DIR_INCLUDE_GENERATED}/zinit.h)

set(init_files)
# Recovering services files, if any
get_property(service_files TARGET zephyr_interface PROPERTY ZEPHYR_SERVICE_FILES)
if (NOT (service_files EQUAL 0))
list(APPEND init_files ${service_files})
endif()

# Recovering device init files, if any
get_property(dev_init_files TARGET zephyr_interface PROPERTY ZEPHYR_DEVICE_INIT_FILES)
if (NOT (dev_init_files EQUAL 0))
list(APPEND init_files ${dev_init_files})
endif()

# Recovering application overlays
zephyr_build_string(board_string SHORT shortened_board_string
BOARD ${BOARD} BOARD_QUALIFIERS ${BOARD_QUALIFIERS}
)

set(gip_board_strings
${board_string}
${shortened_board_string}
)

foreach(str ${gip_board_strings})
if (EXISTS ${APPLICATION_CONFIG_DIR}/boards/${str}_service_and_device_init.yaml)
list(APPEND init_files ${APPLICATION_CONFIG_DIR}/boards/${str}_service_and_device_init.yaml)
endif()
endforeach()

if (EXISTS ${APPLICATION_CONFIG_DIR}/service_and_device_init.yaml)
list(APPEND init_files ${APPLICATION_CONFIG_DIR}/service_and_device_init.yaml)
endif()

set(INIT_OPT)
list(LENGTH init_files found_init_files)
if (NOT (found_init_files EQUAL 0))
message(STATUS "Found initialization object files: ${init_files}")
list(APPEND INIT_OPT --init-files ${init_files})
endif()

#
# Run GIP_SCRIPT
#
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${GIP_SCRIPT}
--dotconfig-file ${DOTCONFIG}
--edt-pickle ${EDT_PICKLE}
${INIT_OPT}
--header-out ${GIP_INIT_H}
OUTPUT_QUIET # Discard stdout
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
RESULT_VARIABLE ret
)

if(NOT "${ret}" STREQUAL "0")
message(FATAL_ERROR "command failed with return code: ${ret}")
else()
message(STATUS "Generated initialization header file ${GIP_INIT_H}")
endif()
endfunction()
5 changes: 2 additions & 3 deletions drivers/adc/adc_ad559x.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@ static int adc_ad559x_init(const struct device *dev)
\
static struct adc_ad559x_data adc_ad559x_data##inst; \
\
DEVICE_DT_INST_DEFINE(inst, adc_ad559x_init, NULL, &adc_ad559x_data##inst, \
&adc_ad559x_config##inst, POST_KERNEL, CONFIG_MFD_INIT_PRIORITY, \
&adc_ad559x_api##inst);
DEVICE_INSTANCE_FROM_DT_INST(inst, adc_ad559x_init, NULL, &adc_ad559x_data##inst, \
&adc_ad559x_config##inst, POST_KERNEL, &adc_ad559x_api##inst);

DT_INST_FOREACH_STATUS_OKAY(ADC_AD559X_DEFINE)
4 changes: 2 additions & 2 deletions drivers/adc/adc_ads1112.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ static const struct adc_driver_api api = {
#define ADC_ADS1112_INST_DEFINE(n) \
static const struct ads1112_config config_##n = {.bus = I2C_DT_SPEC_INST_GET(n)}; \
static struct ads1112_data data_##n; \
DEVICE_DT_INST_DEFINE(n, ads1112_init, NULL, &data_##n, &config_##n, POST_KERNEL, \
CONFIG_ADC_INIT_PRIORITY, &api);
DEVICE_INSTANCE_FROM_DT_INST(n, ads1112_init, NULL, &data_##n, &config_##n, POST_KERNEL, \
&api);

DT_INST_FOREACH_STATUS_OKAY(ADC_ADS1112_INST_DEFINE);
7 changes: 3 additions & 4 deletions drivers/adc/adc_ads1119.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,8 @@ static const struct adc_driver_api api = {
IF_ENABLED(CONFIG_ADC_ASYNC, (.stack = thread_stack_##n)) \
}; \
static struct ads1119_data data_##n; \
DEVICE_DT_INST_DEFINE(n, ads1119_init, \
NULL, &data_##n, &config_##n, \
POST_KERNEL, CONFIG_ADC_INIT_PRIORITY, \
&api);
DEVICE_INSTANCE_FROM_DT_INST(n, ads1119_init, \
NULL, &data_##n, &config_##n, \
POST_KERNEL, &api);

DT_INST_FOREACH_STATUS_OKAY(ADC_ADS1119_INST_DEFINE);
4 changes: 2 additions & 2 deletions drivers/adc/adc_ads114s0x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ BUILD_ASSERT(CONFIG_ADC_INIT_PRIORITY > CONFIG_SPI_INIT_PRIORITY,
.vbias_level = DT_INST_PROP(n, vbias_level), \
}; \
static struct ads114s0x_data data_##n; \
DEVICE_DT_INST_DEFINE(n, ads114s0x_init, NULL, &data_##n, &config_##n, POST_KERNEL, \
CONFIG_ADC_INIT_PRIORITY, &api);
DEVICE_INSTANCE_FROM_DT_INST(n, ads114s0x_init, NULL, &data_##n, &config_##n, POST_KERNEL, \
&api);

DT_INST_FOREACH_STATUS_OKAY(ADC_ADS114S0X_INST_DEFINE);
5 changes: 2 additions & 3 deletions drivers/adc/adc_ads1x1x.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,8 @@ static const struct adc_driver_api ads1x1x_api = {
ADC_CONTEXT_INIT_TIMER(ads##t##_data_##n, ctx), \
ADC_CONTEXT_INIT_SYNC(ads##t##_data_##n, ctx), \
}; \
DEVICE_DT_DEFINE(DT_INST_ADS1X1X(n, t), ads1x1x_init, NULL, &ads##t##_data_##n, \
&ads##t##_config_##n, POST_KERNEL, CONFIG_ADC_ADS1X1X_INIT_PRIORITY, \
&ads1x1x_api);
DEVICE_INSTANCE(DT_INST_ADS1X1X(n, t), ads1x1x_init, NULL, &ads##t##_data_##n, \
&ads##t##_config_##n, POST_KERNEL, &ads1x1x_api);

/* The ADS111X provides 16 bits of data in binary two's complement format
* A positive full-scale (+FS) input produces an output code of 7FFFh and a
Expand Down
4 changes: 2 additions & 2 deletions drivers/adc/adc_ads7052.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static const struct adc_driver_api ads7052_api = {
ADC_CONTEXT_INIT_SYNC(ads7052_data_##n, ctx), \
}; \
\
DEVICE_DT_INST_DEFINE(n, adc_ads7052_init, NULL, &ads7052_data_##n, &ads7052_cfg_##n, \
POST_KERNEL, CONFIG_ADC_ADS7052_INIT_PRIORITY, &ads7052_api);
DEVICE_INSTANCE_FROM_DT_INST(n, adc_ads7052_init, NULL, &ads7052_data_##n, &ads7052_cfg_##n,\
POST_KERNEL, &ads7052_api);

DT_INST_FOREACH_STATUS_OKAY(ADC_ADS7052_INIT)
5 changes: 2 additions & 3 deletions drivers/adc/adc_ambiq.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,7 @@ static int adc_ambiq_pm_action(const struct device *dev, enum pm_device_action a
.pwr_func = pwr_on_ambiq_adc_##n, \
}; \
PM_DEVICE_DT_INST_DEFINE(n, adc_ambiq_pm_action); \
DEVICE_DT_INST_DEFINE(n, &adc_ambiq_init, PM_DEVICE_DT_INST_GET(n), &adc_ambiq_data_##n, \
&adc_ambiq_config_##n, POST_KERNEL, CONFIG_ADC_INIT_PRIORITY, \
&adc_ambiq_driver_api_##n);
DEVICE_INSTANCE_FROM_DT_INST(n, &adc_ambiq_init, PM_DEVICE_DT_INST_GET(n), &adc_ambiq_data_##n,\
&adc_ambiq_config_##n, POST_KERNEL, &adc_ambiq_driver_api_##n);

DT_INST_FOREACH_STATUS_OKAY(ADC_AMBIQ_INIT)
3 changes: 1 addition & 2 deletions drivers/adc/adc_b91.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,7 @@ static const struct adc_driver_api adc_b91_driver_api = {
.ref_internal = cfg_0.vref_internal_mv,
};

DEVICE_DT_INST_DEFINE(0, adc_b91_init, NULL,
DEVICE_INSTANCE_FROM_DT_INST(0, adc_b91_init, NULL,
&data_0, &cfg_0,
POST_KERNEL,
CONFIG_ADC_INIT_PRIORITY,
&adc_b91_driver_api);
3 changes: 1 addition & 2 deletions drivers/adc/adc_cc13xx_cc26xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,10 @@ static const struct adc_driver_api cc13xx_cc26xx_driver_api = {
ADC_CONTEXT_INIT_LOCK(adc_cc13xx_cc26xx_data_##index, ctx), \
ADC_CONTEXT_INIT_SYNC(adc_cc13xx_cc26xx_data_##index, ctx), \
}; \
DEVICE_DT_INST_DEFINE(index, \
DEVICE_INSTANCE_FROM_DT_INST(index, \
&adc_cc13xx_cc26xx_init, NULL, \
&adc_cc13xx_cc26xx_data_##index, \
&adc_cc13xx_cc26xx_cfg_##index, POST_KERNEL, \
CONFIG_ADC_INIT_PRIORITY, \
&cc13xx_cc26xx_driver_api); \
\
static void adc_cc13xx_cc26xx_cfg_func_##index(void) \
Expand Down
3 changes: 1 addition & 2 deletions drivers/adc/adc_cc32xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,9 @@ static const struct adc_driver_api cc32xx_driver_api = {
ADC_CONTEXT_INIT_SYNC(adc_cc32xx_data_##index, ctx), \
}; \
\
DEVICE_DT_INST_DEFINE(index, \
DEVICE_INSTANCE_FROM_DT_INST(index, \
&adc_cc32xx_init, NULL, &adc_cc32xx_data_##index, \
&adc_cc32xx_cfg_##index, POST_KERNEL, \
CONFIG_ADC_INIT_PRIORITY, \
&cc32xx_driver_api); \
\
static void adc_cc32xx_cfg_func_##index(void) \
Expand Down
3 changes: 1 addition & 2 deletions drivers/adc/adc_emul.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,9 @@ static int adc_emul_init(const struct device *dev)
.ref_int = DT_INST_PROP(_num, ref_internal_mv), \
}; \
\
DEVICE_DT_INST_DEFINE(_num, adc_emul_init, NULL, \
DEVICE_INSTANCE_FROM_DT_INST(_num, adc_emul_init, NULL, \
&adc_emul_data_##_num, \
&adc_emul_config_##_num, POST_KERNEL, \
CONFIG_ADC_INIT_PRIORITY, \
&adc_emul_api_##_num);

DT_INST_FOREACH_STATUS_OKAY(ADC_EMUL_INIT)
4 changes: 2 additions & 2 deletions drivers/adc/adc_ene_kb1200.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ static int adc_kb1200_init(const struct device *dev)
.adc = (struct adc_regs *)DT_INST_REG_ADDR(inst), \
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
}; \
DEVICE_DT_INST_DEFINE(inst, &adc_kb1200_init, NULL, &adc_kb1200_data_##inst, \
DEVICE_INSTANCE_FROM_DT_INST(inst, &adc_kb1200_init, NULL, &adc_kb1200_data_##inst, \
&adc_kb1200_config_##inst, PRE_KERNEL_1, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &adc_kb1200_api);
&adc_kb1200_api);

DT_INST_FOREACH_STATUS_OKAY(ADC_KB1200_DEVICE)
3 changes: 1 addition & 2 deletions drivers/adc/adc_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,11 +744,10 @@ static const struct adc_driver_api api_esp32_driver_api = {
static struct adc_esp32_data adc_esp32_data_##inst = { \
}; \
\
DEVICE_DT_INST_DEFINE(inst, &adc_esp32_init, NULL, \
DEVICE_INSTANCE_FROM_DT_INST(inst, &adc_esp32_init, NULL, \
&adc_esp32_data_##inst, \
&adc_esp32_conf_##inst, \
POST_KERNEL, \
CONFIG_ADC_INIT_PRIORITY, \
&api_esp32_driver_api);

DT_INST_FOREACH_STATUS_OKAY(ESP32_ADC_INIT)
5 changes: 2 additions & 3 deletions drivers/adc/adc_gd32.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,9 @@ static void adc_gd32_global_irq_cfg(void)
.irq_config_func = adc_gd32_global_irq_cfg, \
ADC_CLOCK_SOURCE(n) \
}; \
DEVICE_DT_INST_DEFINE(n, \
DEVICE_INSTANCE_FROM_DT_INST(n, \
&adc_gd32_init, NULL, \
&adc_gd32_data_##n, &adc_gd32_config_##n, \
POST_KERNEL, CONFIG_ADC_INIT_PRIORITY, \
&adc_gd32_driver_api); \
POST_KERNEL, &adc_gd32_driver_api); \

DT_INST_FOREACH_STATUS_OKAY(ADC_GD32_INIT)
7 changes: 3 additions & 4 deletions drivers/adc/adc_gecko.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,9 @@ static const struct adc_driver_api api_gecko_adc_driver_api = {
adc_gecko_isr, DEVICE_DT_INST_GET(n), 0); \
irq_enable(DT_INST_IRQN(n)); \
}; \
DEVICE_DT_INST_DEFINE(n, \
DEVICE_INSTANCE_FROM_DT_INST(n, \
&adc_gecko_init, NULL, \
&adc_gecko_data_##n, &adc_gecko_config_##n,\
POST_KERNEL, CONFIG_ADC_INIT_PRIORITY, \
&api_gecko_adc_driver_api);
&adc_gecko_data_##n, &adc_gecko_config_##n, \
POST_KERNEL, &api_gecko_adc_driver_api);

DT_INST_FOREACH_STATUS_OKAY(GECKO_ADC_INIT)
9 changes: 4 additions & 5 deletions drivers/adc/adc_ifx_cat1.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,9 @@ static const struct adc_driver_api adc_cat1_driver_api = {
.irq_priority = DT_INST_IRQ(n, priority), \
}; \
\
DEVICE_DT_INST_DEFINE(n, ifx_cat1_adc_init, \
NULL, &ifx_cat1_adc_data##n, \
&adc_cat1_cfg_##n, \
POST_KERNEL, CONFIG_ADC_INIT_PRIORITY, \
&adc_cat1_driver_api);
DEVICE_INSTANCE_FROM_DT_INST(n, ifx_cat1_adc_init, \
NULL, &ifx_cat1_adc_data##n, \
&adc_cat1_cfg_##n, \
POST_KERNEL, &adc_cat1_driver_api);

DT_INST_FOREACH_STATUS_OKAY(INFINEON_CAT1_ADC_INIT)
3 changes: 1 addition & 2 deletions drivers/adc/adc_ite_it8xxx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,8 @@ static const struct adc_it8xxx2_cfg adc_it8xxx2_cfg_0 = {
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
};

DEVICE_DT_INST_DEFINE(0, adc_it8xxx2_init,
DEVICE_INSTANCE_FROM_DT_INST(0, adc_it8xxx2_init,
NULL,
&adc_it8xxx2_data_0,
&adc_it8xxx2_cfg_0, PRE_KERNEL_1,
CONFIG_ADC_INIT_PRIORITY,
&api_it8xxx2_driver_api);
Loading
Loading