Skip to content

Commit

Permalink
device: remove support for deprecated init levels
Browse files Browse the repository at this point in the history
EARLY, APPLICATION and SMP levels are no longer support for device
drivers as 2 releases have happened since its deprecation. Add a
validation macro so that compilation fails if the given level is not
valid.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
  • Loading branch information
gmarull authored and nashif committed Aug 19, 2024
1 parent 07f3ac9 commit cfe5bd9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
3 changes: 3 additions & 0 deletions doc/releases/release-notes-4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ API Changes
* Removed deprecated ``ceiling_fraction`` macro. :c:macro:`DIV_ROUND_UP` needs
to be used now.

* Deprecated ``EARLY``, ``APPLICATION`` and ``SMP`` init levels can no longer be
used for devices.

Removed APIs in this release
============================

Expand Down
22 changes: 7 additions & 15 deletions include/zephyr/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -1075,24 +1075,16 @@ device_get_dt_nodelabels(const struct device *dev)
Z_DEVICE_SECTION_NAME(level, prio), DEVICE_NAME_GET(dev_id)) = \
Z_DEVICE_INIT(name, pm, data, config, api, state, deps, node_id, dev_id)

/* deprecated device initialization levels */
#define Z_DEVICE_LEVEL_DEPRECATED_EARLY \
__WARN("EARLY device driver level is deprecated")
#define Z_DEVICE_LEVEL_DEPRECATED_PRE_KERNEL_1
#define Z_DEVICE_LEVEL_DEPRECATED_PRE_KERNEL_2
#define Z_DEVICE_LEVEL_DEPRECATED_POST_KERNEL
#define Z_DEVICE_LEVEL_DEPRECATED_APPLICATION \
__WARN("APPLICATION device driver level is deprecated")
#define Z_DEVICE_LEVEL_DEPRECATED_SMP \
__WARN("SMP device driver level is deprecated")

/**
* @brief Issue a warning if the given init level is deprecated.
* @brief Issue an error if the given init level is not supported.
*
* @param level Init level
*/
#define Z_DEVICE_LEVEL_CHECK_DEPRECATED_LEVEL(level) \
Z_DEVICE_LEVEL_DEPRECATED_##level
#define Z_DEVICE_CHECK_INIT_LEVEL(level) \
COND_CODE_1(Z_INIT_PRE_KERNEL_1_##level, (), \
(COND_CODE_1(Z_INIT_PRE_KERNEL_2_##level, (), \
(COND_CODE_1(Z_INIT_POST_KERNEL_##level, (), \
(ZERO_OR_COMPILE_ERROR(0)))))))

/**
* @brief Define the init entry for a device.
Expand All @@ -1105,7 +1097,7 @@ device_get_dt_nodelabels(const struct device *dev)
* @param prio Initialization priority.
*/
#define Z_DEVICE_INIT_ENTRY_DEFINE(node_id, dev_id, init_fn_, level, prio) \
Z_DEVICE_LEVEL_CHECK_DEPRECATED_LEVEL(level) \
Z_DEVICE_CHECK_INIT_LEVEL(level) \
\
static const Z_DECL_ALIGN(struct init_entry) __used __noasan Z_INIT_ENTRY_SECTION( \
level, prio, Z_DEVICE_INIT_SUB_PRIO(node_id)) \
Expand Down

0 comments on commit cfe5bd9

Please sign in to comment.