Skip to content
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

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

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bbd5c17
scripts/edtlib: Add the same accessor as chosen but for aliases
tbursztyka Apr 23, 2024
2616bff
scripts: Add Zephyr initalization object script
tbursztyka Sep 10, 2024
3e81ad2
cmake: Add a gen_init_priorties module
tbursztyka Apr 12, 2024
887d433
CMakeLists.txt: call zephyr_generate_init_priorities() where relevant
tbursztyka Sep 12, 2024
e5889e2
include: Add init utility macro specific header
tbursztyka Apr 12, 2024
22644b3
init: Adapt init entry section generation
tbursztyka Apr 12, 2024
fd5d802
linker: Add an extra number to check for sorting levels sections
tbursztyka Jun 3, 2024
0460552
init: Add an extra '_' between level names and priority in sections
tbursztyka Jun 3, 2024
6098c0f
service: Introduce software service instanciation macros
tbursztyka Sep 11, 2024
82a94b2
device: Add new macros to instanciate device objects
tbursztyka Sep 12, 2024
ac134ba
tests: Switching DEVICE_<DT/DT_INST>_DEFINE macros to new ones
tbursztyka Sep 20, 2024
c280a9c
subsys: Switching DEVICE_<DT/DT_INST>_DEFINE macros to new ones
tbursztyka Sep 20, 2024
dbb4d17
boards: Switching DEVICE_<DT/DT_INST>_DEFINE macros to new ones
tbursztyka Sep 20, 2024
9fd64ca
sensor: Provide new device instantiation macros
tbursztyka Sep 19, 2024
c2c0bfd
sensors: Switching SENSOR_DEVICE_<DT/DT_INST>_DEFINE macros to new ones
tbursztyka Sep 20, 2024
1f0d042
net: Provide new device instantiation macros
tbursztyka Sep 23, 2024
c1da4e1
drivers: Switching NET_DEVICE_<INIT/DT_DEFINE>... macros to new ones
tbursztyka Sep 25, 2024
e950a45
net/ethernet: Provide new device instantiation macro
tbursztyka Sep 25, 2024
5417073
ethernet: Switching ETH_NET_DEVICE_<INIT/DT_INSTANCE>... to new ones
tbursztyka Sep 25, 2024
77d1905
tests: Switching NET_DEVICE_<INIT/DT_DEFINE>... macros to new ones
tbursztyka Sep 26, 2024
64869e3
can: Provide new device instantiation macro
tbursztyka Sep 26, 2024
778f07e
drivers/can: Switching CAN_DEVICE_DT_DEFINE macros to new ones
tbursztyka Sep 26, 2024
a8ec0c4
smbus: Provide new device instantiation macro
tbursztyka Sep 26, 2024
397140c
drivers/smbus: Switching SMBUS_DEVICE_DT_DEFINE macros to new ones
tbursztyka Sep 26, 2024
97b5122
include/drivers: Switching specific headers to new device macros
tbursztyka Sep 26, 2024
f31342c
i2c: Provide new device instantiation macro
tbursztyka Sep 26, 2024
213522b
drivers/i2c: Switching I2C_DEVICE_DT_DEFINE macros to new ones
tbursztyka Sep 26, 2024
4b2e3bd
spi: Provide new device instantiation macro
tbursztyka Sep 26, 2024
bac8763
firmware: Provide new device instantiation macro
tbursztyka Sep 26, 2024
4f3db92
drivers: Switching DEVICE_<DT/DT_INST>_DEFINE macros to new ones
tbursztyka Sep 20, 2024
2892bda
tests and samples: Add relevant service and device init modifiers
tbursztyka Oct 2, 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 @@ -972,6 +974,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,9 +43,9 @@
};

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);

Check notice on line 48 in boards/beagle/beagleconnect_freedom/board_antenna.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

boards/beagle/beagleconnect_freedom/board_antenna.c:48 -DEVICE_INSTANCE_FROM_DT_INST(0, board_antenna_init, NULL, NULL, NULL, POST_KERNEL, - 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[] = {
DT_FOREACH_PROP_ELEM_SEP(DT_NODELABEL(antenna_mux0), gpios, GPIO_DT_SPEC_GET_BY_IDX, (,))};
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,9 +44,9 @@
};

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);

Check notice on line 49 in boards/ti/common/board_antenna.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

boards/ti/common/board_antenna.c:49 -DEVICE_INSTANCE_FROM_DT_INST(0, board_antenna_init, NULL, NULL, NULL, POST_KERNEL, - 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[] = {
DT_FOREACH_PROP_ELEM_SEP(DT_NODELABEL(antenna_mux0), gpios, GPIO_DT_SPEC_GET_BY_IDX, (,))};
Expand Down
13 changes: 9 additions & 4 deletions cmake/modules/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5029,8 +5029,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 @@ -5054,13 +5054,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(${ARGN})
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(${ARGN})
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 @@ -288,8 +288,7 @@
\
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);
DEVICE_INSTANCE_FROM_DT_INST(inst, adc_ad559x_init, NULL, &adc_ad559x_data##inst, \
&adc_ad559x_config##inst, POST_KERNEL, &adc_ad559x_api);

Check notice on line 293 in drivers/adc/adc_ad559x.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/adc/adc_ad559x.c:293 - &adc_ad559x_config##inst, POST_KERNEL, &adc_ad559x_api); + &adc_ad559x_config##inst, POST_KERNEL, &adc_ad559x_api);
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 @@
#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);

Check notice on line 392 in drivers/adc/adc_ads1112.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/adc/adc_ads1112.c:392 - static const struct ads1112_config config_##n = {.bus = I2C_DT_SPEC_INST_GET(n)}; \ + static const struct ads1112_config config_##n = {.bus = I2C_DT_SPEC_INST_GET(n)}; \ static struct ads1112_data data_##n; \ DEVICE_INSTANCE_FROM_DT_INST(n, ads1112_init, NULL, &data_##n, &config_##n, POST_KERNEL, \ - &api); + &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 @@
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);

Check notice on line 505 in drivers/adc/adc_ads1119.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/adc/adc_ads1119.c:505 -#define ADC_ADS1119_INST_DEFINE(n) \ +#define ADC_ADS1119_INST_DEFINE(n) \ IF_ENABLED(CONFIG_ADC_ASYNC, \ (static \ K_KERNEL_STACK_DEFINE(thread_stack_##n, \ - CONFIG_ADC_ADS1119_ACQUISITION_THREAD_STACK_SIZE);)) \ - static const struct ads1119_config config_##n = { \ - .bus = I2C_DT_SPEC_GET(DT_DRV_INST(n)), \ - IF_ENABLED(CONFIG_ADC_ASYNC, (.stack = thread_stack_##n)) \ - }; \ - static struct ads1119_data data_##n; \ - DEVICE_INSTANCE_FROM_DT_INST(n, ads1119_init, \ - NULL, &data_##n, &config_##n, \ - POST_KERNEL, &api); + CONFIG_ADC_ADS1119_ACQUISITION_THREAD_STACK_SIZE);)) \ + static const struct ads1119_config config_##n = { \ + .bus = I2C_DT_SPEC_GET(DT_DRV_INST(n)), \ + IF_ENABLED(CONFIG_ADC_ASYNC, (.stack = thread_stack_##n)) }; \ + static struct ads1119_data data_##n; \ + 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 @@
.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);

Check notice on line 1507 in drivers/adc/adc_ads114s0x.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/adc/adc_ads114s0x.c:1507 -#define ADC_ADS114S0X_INST_DEFINE(n) \ +#define ADC_ADS114S0X_INST_DEFINE(n) \ IF_ENABLED( \ CONFIG_ADC_ASYNC, \ (static K_KERNEL_STACK_DEFINE( \ - thread_stack_##n, CONFIG_ADC_ADS114S0X_ACQUISITION_THREAD_STACK_SIZE);)) \ - static const struct ads114s0x_config config_##n = { \ - .bus = SPI_DT_SPEC_INST_GET( \ - n, SPI_OP_MODE_MASTER | SPI_MODE_CPHA | SPI_WORD_SET(8), 0), \ - IF_ENABLED(CONFIG_ADC_ASYNC, (.stack = thread_stack_##n,)) \ - .gpio_reset = GPIO_DT_SPEC_INST_GET_OR(n, reset_gpios, {0}), \ - .gpio_data_ready = GPIO_DT_SPEC_INST_GET(n, drdy_gpios), \ - .gpio_start_sync = GPIO_DT_SPEC_INST_GET_OR(n, start_sync_gpios, {0}), \ - .idac_current = DT_INST_PROP(n, idac_current), \ - .vbias_level = DT_INST_PROP(n, vbias_level), \ - }; \ - static struct ads114s0x_data data_##n; \ - DEVICE_INSTANCE_FROM_DT_INST(n, ads114s0x_init, NULL, &data_##n, &config_##n, POST_KERNEL, \ - &api); + thread_stack_##n, CONFIG_ADC_ADS114S0X_ACQUISITION_THREAD_STACK_SIZE);)) \ + static const struct ads114s0x_config config_##n = { \ + .bus = SPI_DT_SPEC_INST_GET( \ + n, SPI_OP_MODE_MASTER | SPI_MODE_CPHA | SPI_WORD_SET(8), 0), \ + IF_ENABLED(CONFIG_ADC_ASYNC, (.stack = thread_stack_##n,)) .gpio_reset = \ + GPIO_DT_SPEC_INST_GET_OR(n, reset_gpios, {0}), \ + .gpio_data_ready = GPIO_DT_SPEC_INST_GET(n, drdy_gpios), \ + .gpio_start_sync = GPIO_DT_SPEC_INST_GET_OR(n, start_sync_gpios, {0}), \ + .idac_current = DT_INST_PROP(n, idac_current), \ + .vbias_level = DT_INST_PROP(n, vbias_level), \ + }; \ + static struct ads114s0x_data data_##n; \ + 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);
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 @@
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,\

Check warning on line 311 in drivers/adc/adc_ads7052.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE

drivers/adc/adc_ads7052.c:311 line length of 101 exceeds 100 columns
POST_KERNEL, &ads7052_api);

Check notice on line 313 in drivers/adc/adc_ads7052.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/adc/adc_ads7052.c:313 - DEVICE_INSTANCE_FROM_DT_INST(n, adc_ads7052_init, NULL, &ads7052_data_##n, &ads7052_cfg_##n,\ - POST_KERNEL, &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 @@
.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,\

Check warning on line 435 in drivers/adc/adc_ambiq.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE

drivers/adc/adc_ambiq.c:435 line length of 104 exceeds 100 columns
&adc_ambiq_config_##n, POST_KERNEL, &adc_ambiq_driver_api_##n);

Check notice on line 437 in drivers/adc/adc_ambiq.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/adc/adc_ambiq.c:437 - 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); + 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 @@
.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 @@
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 All @@ -306,6 +305,6 @@
IRQ_CONNECT(DT_INST_IRQN(index), DT_INST_IRQ(index, priority), \
adc_cc13xx_cc26xx_isr, DEVICE_DT_INST_GET(index), 0); \
irq_enable(DT_INST_IRQN(index)); \
}

Check notice on line 308 in drivers/adc/adc_cc13xx_cc26xx.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/adc/adc_cc13xx_cc26xx.c:308 -#define CC13XX_CC26XX_ADC_INIT(index) \ - static void adc_cc13xx_cc26xx_cfg_func_##index(void); \ - static const struct adc_cc13xx_cc26xx_cfg adc_cc13xx_cc26xx_cfg_##index = { \ - .base = DT_INST_REG_ADDR(index), \ - .irq_cfg_func = adc_cc13xx_cc26xx_cfg_func_##index, \ - }; \ - static struct adc_cc13xx_cc26xx_data adc_cc13xx_cc26xx_data_##index = { \ - ADC_CONTEXT_INIT_TIMER(adc_cc13xx_cc26xx_data_##index, ctx), \ - ADC_CONTEXT_INIT_LOCK(adc_cc13xx_cc26xx_data_##index, ctx), \ - ADC_CONTEXT_INIT_SYNC(adc_cc13xx_cc26xx_data_##index, ctx), \ - }; \ - DEVICE_INSTANCE_FROM_DT_INST(index, \ - &adc_cc13xx_cc26xx_init, NULL, \ - &adc_cc13xx_cc26xx_data_##index, \ - &adc_cc13xx_cc26xx_cfg_##index, POST_KERNEL, \ - &cc13xx_cc26xx_driver_api); \ - \ - static void adc_cc13xx_cc26xx_cfg_func_##index(void) \ - { \ - IRQ_CONNECT(DT_INST_IRQN(index), DT_INST_IRQ(index, priority), \ - adc_cc13xx_cc26xx_isr, DEVICE_DT_INST_GET(index), 0); \ - irq_enable(DT_INST_IRQN(index)); \ +#define CC13XX_CC26XX_ADC_INIT(index) \ + static void adc_cc13xx_cc26xx_cfg_func_##index(void); \ + static const struct adc_cc13xx_cc26xx_cfg adc_cc13xx_cc26xx_cfg_##index = { \ + .base = DT_INST_REG_ADDR(index), \ + .irq_cfg_func = adc_cc13xx_cc26xx_cfg_func_##index, \ + }; \ + static struct adc_cc13xx_cc26xx_data adc_cc13xx_cc26xx_data_##index = { \ + ADC_CONTEXT_INIT_TIMER(adc_cc13xx_cc26xx_data_##index, ctx), \ + ADC_CONTEXT_INIT_LOCK(adc_cc13xx_cc26xx_data_##index, ctx), \ + ADC_CONTEXT_INIT_SYNC(adc_cc13xx_cc26xx_data_##index, ctx), \ + }; \ + DEVICE_INSTANCE_FROM_DT_INST( \ + index, &adc_cc13xx_cc26xx_init, NULL, &adc_cc13xx_cc26xx_data_##index, \ + &adc_cc13xx_cc26xx_cfg_##index, POST_KERNEL, &cc13xx_cc26xx_driver_api); \ + \ + static void adc_cc13xx_cc26xx_cfg_func_##index(void) \ + { \ + IRQ_CONNECT(DT_INST_IRQN(index), DT_INST_IRQ(index, priority), \ + adc_cc13xx_cc26xx_isr, DEVICE_DT_INST_GET(index), 0); \ + irq_enable(DT_INST_IRQN(index)); \

DT_INST_FOREACH_STATUS_OKAY(CC13XX_CC26XX_ADC_INIT)
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 @@ -738,11 +738,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);
5 changes: 2 additions & 3 deletions drivers/adc/adc_ltc2451.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ static const struct adc_driver_api ltc2451_api = {
.conversion_speed = DT_INST_PROP(index, conversion_speed), \
}; \
\
DEVICE_DT_INST_DEFINE(index, &ltc2451_init, NULL, NULL, \
&ltc2451_cfg_##index, POST_KERNEL, CONFIG_ADC_INIT_PRIORITY, \
&ltc2451_api);
DEVICE_INSTANCE_FROM_DT_INST(index, &ltc2451_init, NULL, NULL,\
&ltc2451_cfg_##index, POST_KERNEL, &ltc2451_api);

DT_INST_FOREACH_STATUS_OKAY(LTC2451_DEFINE)
5 changes: 2 additions & 3 deletions drivers/adc/adc_max11102_17.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,8 @@ BUILD_ASSERT(CONFIG_ADC_INIT_PRIORITY > CONFIG_SPI_INIT_PRIORITY,
.channel_count = channels, \
}; \
static struct max11102_17_data data_##name##_##index; \
DEVICE_DT_INST_DEFINE(index, max11102_17_init, NULL, &data_##name##_##index, \
&config_##name##_##index, POST_KERNEL, CONFIG_ADC_INIT_PRIORITY, \
&api);
DEVICE_INSTANCE_FROM_DT_INST(index, max11102_17_init, NULL, &data_##name##_##index, \
&config_##name##_##index, POST_KERNEL, &api);

#define DT_DRV_COMPAT maxim_max11102
#define ADC_MAX11102_RESOLUTION 12
Expand Down
Loading
Loading