Skip to content

Commit 86e98f0

Browse files
committed
device: deprecate DEVICE_AND_API_INIT
Make DEVICE_AND_API_INIT deprecated in favor of DEVICE_DT_INST_DEFINE or DEVICE_DEFINE. Signed-off-by: Kumar Gala <[email protected]>
1 parent d1665d3 commit 86e98f0

File tree

7 files changed

+15
-17
lines changed

7 files changed

+15
-17
lines changed

doc/guides/dts/howtos.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,9 @@ using instance numbers. Do this after defining ``my_api_funcs``.
431431
static const struct my_dev_cfg my_cfg_##inst = { \
432432
/* initialize ROM values as needed. */ \
433433
}; \
434-
DEVICE_AND_API_INIT(my_dev_##inst, \
435-
DT_INST_LABEL(inst), \
434+
DEVICE_DT_INST_DEFINE(inst, \
436435
my_dev_init_function, \
436+
device_pm_control_nop, \
437437
&my_data_##inst, \
438438
&my_cfg_##inst, \
439439
MY_DEV_INIT_LEVEL, MY_DEV_INIT_PRIORITY, \
@@ -508,9 +508,9 @@ devicetree to operate on specific device nodes:
508508
.freq = DT_PROP(MYDEV(idx), clock_frequency), \
509509
}; \
510510
static const struct my_dev_cfg my_cfg_##idx = { /* ... */ }; \
511-
DEVICE_AND_API_INIT(my_dev_##idx, \
512-
DT_LABEL(MYDEV(idx)), \
511+
DEVICE_DT_INST_DEFINE(idx, \
513512
my_dev_init_function, \
513+
device_pm_control_nop, \
514514
&my_data_##idx, \
515515
&my_cfg_##idx, \
516516
MY_DEV_INIT_LEVEL, MY_DEV_INIT_PRIORITY, \

doc/reference/drivers/index.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ applications.
7272
Create device object and related data structures including setting it
7373
up for boot-time initialization.
7474

75-
:c:func:`DEVICE_AND_API_INIT()`
76-
Like :c:func:`DEVICE_DEFINE()` but without support for device power
77-
management.
78-
7975
:c:func:`DEVICE_NAME_GET()`
8076
Converts a device identifier to the global identifier for a device
8177
object.
@@ -175,7 +171,7 @@ of these APIs, and populate an instance of subsystem_api structure:
175171
};
176172
177173
The driver would then pass ``my_driver_api_funcs`` as the ``api`` argument to
178-
``DEVICE_AND_API_INIT()``.
174+
``DEVICE_DEFINE()``.
179175

180176
.. note::
181177

@@ -329,9 +325,9 @@ Then when the particular instance is declared:
329325
330326
static struct my_data_0;
331327
332-
DEVICE_AND_API_INIT(my_driver_0, MY_DRIVER_0_NAME, my_driver_init,
333-
&my_data_0, &my_driver_config_0, POST_KERNEL,
334-
MY_DRIVER_0_PRIORITY, &my_api_funcs);
328+
DEVICE_DEFINE(my_driver_0, MY_DRIVER_0_NAME, my_driver_init,
329+
device_pm_control_nop, &my_data_0, &my_driver_config_0,
330+
POST_KERNEL, MY_DRIVER_0_PRIORITY, &my_api_funcs);
335331
336332
#endif /* CONFIG_MY_DRIVER_0 */
337333

doc/reference/networking/net_l2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ There are, however, two differences:
7474

7575
- The network device driver must use :c:macro:`NET_DEVICE_INIT_INSTANCE()`
7676
or :c:macro:`ETH_NET_DEVICE_INIT()` for Ethernet devices. These
77-
macros will call the :c:macro:`DEVICE_AND_API_INIT()` macro, and also
77+
macros will call the :c:macro:`DEVICE_DEFINE()` macro, and also
7878
instantiate a unique :c:struct:`net_if` related to the created
7979
device driver instance.
8080

doc/releases/release-notes-2.5.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ Deprecated in this release
6262

6363
* DEVICE_INIT was deprecated in favor of utilizing DEVICE_DEFINE directly.
6464

65+
* DEVICE_AND_API_INIT was deprecated in favor of DEVICE_DT_INST_DEFINE and
66+
DEVICE_DEFINE.
67+
6568
Removed APIs in this release
6669
============================
6770

doc/zephyr.doxyfile.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1997,7 +1997,6 @@ PREDEFINED = "CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT" \
19971997
"CONFIG_USE_SWITCH" \
19981998
"NET_MGMT_DEFINE_REQUEST_HANDLER(x)=" \
19991999
"DEVICE_DEFINE()=" \
2000-
"DEVICE_AND_API_INIT()=" \
20012000
"BUILD_ASSERT_MSG()=" \
20022001
"BUILD_ASSERT()=" \
20032002
"__deprecated=" \

include/device.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ extern "C" {
8080
*/
8181
#define DEVICE_AND_API_INIT(dev_name, drv_name, init_fn, \
8282
data_ptr, cfg_ptr, level, prio, api_ptr) \
83+
__DEPRECATED_MACRO \
8384
DEVICE_DEFINE(dev_name, drv_name, init_fn, \
8485
NULL, \
8586
data_ptr, cfg_ptr, level, prio, api_ptr)
@@ -95,8 +96,7 @@ extern "C" {
9596
* @details This macro defines a device object that is automatically
9697
* configured by the kernel during system initialization. Note that
9798
* devices set up with this macro will not be accessible from user mode
98-
* since the API is not specified; whenever possible, use DEVICE_AND_API_INIT
99-
* instead.
99+
* since the API is not specified;
100100
*
101101
* @param dev_name Device name. This must be less than Z_DEVICE_MAX_NAME_LEN
102102
* characters in order to be looked up from user mode with device_get_binding().

include/init.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void z_sys_init_run_level(int32_t _level);
6767
* configured by the kernel during system initialization. Note that
6868
* init entries will not be accessible from user mode. Also this macro should
6969
* not be used directly, use relevant macro such as SYS_INIT() or
70-
* DEVICE_AND_API_INIT() instead.
70+
* DEVICE_DEFINE() instead.
7171
*
7272
* @param _entry_name Init entry name. It is the name this instance exposes to
7373
* the system.

0 commit comments

Comments
 (0)