device: hide DEVICE_HANDLE_SEP/ENDS

These macros are used internally by the device dependencies functions.
There's no need to expose them publicly, so prefix them with Z_ and add
them under INTERNAL_HIDDEN docs section.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2023-06-14 12:20:56 +02:00 committed by Carles Cufí
parent 8bee39edff
commit e5f82cb5dc
3 changed files with 38 additions and 34 deletions

View file

@ -27,6 +27,26 @@ extern "C" {
* @{ * @{
*/ */
/** @cond INTERNAL_HIDDEN */
/**
* @brief Flag value used in lists of device handles to separate distinct
* groups.
*
* This is the minimum value for the device_handle_t type.
*/
#define Z_DEVICE_HANDLE_SEP INT16_MIN
/**
* @brief Flag value used in lists of device handles to indicate the end of the
* list.
*
* This is the maximum value for the device_handle_t type.
*/
#define Z_DEVICE_HANDLE_ENDS INT16_MAX
/** @endcond */
/** /**
* @brief Type used to represent a "handle" for a device. * @brief Type used to represent a "handle" for a device.
* *
@ -44,22 +64,6 @@ extern "C" {
*/ */
typedef int16_t device_handle_t; typedef int16_t device_handle_t;
/**
* @brief Flag value used in lists of device handles to separate distinct
* groups.
*
* This is the minimum value for the device_handle_t type.
*/
#define DEVICE_HANDLE_SEP INT16_MIN
/**
* @brief Flag value used in lists of device handles to indicate the end of the
* list.
*
* This is the maximum value for the device_handle_t type.
*/
#define DEVICE_HANDLE_ENDS INT16_MAX
/** @brief Flag value used to identify an unknown device. */ /** @brief Flag value used to identify an unknown device. */
#define DEVICE_HANDLE_NULL 0 #define DEVICE_HANDLE_NULL 0
@ -500,8 +504,8 @@ device_required_handles_get(const struct device *dev, size_t *count)
if (rv != NULL) { if (rv != NULL) {
size_t i = 0; size_t i = 0;
while ((rv[i] != DEVICE_HANDLE_ENDS) && while ((rv[i] != Z_DEVICE_HANDLE_ENDS) &&
(rv[i] != DEVICE_HANDLE_SEP)) { (rv[i] != Z_DEVICE_HANDLE_SEP)) {
++i; ++i;
} }
*count = i; *count = i;
@ -538,13 +542,13 @@ device_injected_handles_get(const struct device *dev, size_t *count)
if (rv != NULL) { if (rv != NULL) {
/* Fast forward to injected devices */ /* Fast forward to injected devices */
while (region != 1) { while (region != 1) {
if (*rv == DEVICE_HANDLE_SEP) { if (*rv == Z_DEVICE_HANDLE_SEP) {
region++; region++;
} }
rv++; rv++;
} }
while ((rv[i] != DEVICE_HANDLE_ENDS) && while ((rv[i] != Z_DEVICE_HANDLE_ENDS) &&
(rv[i] != DEVICE_HANDLE_SEP)) { (rv[i] != Z_DEVICE_HANDLE_SEP)) {
++i; ++i;
} }
*count = i; *count = i;
@ -582,7 +586,7 @@ device_supported_handles_get(const struct device *dev, size_t *count)
if (rv != NULL) { if (rv != NULL) {
/* Fast forward to supporting devices */ /* Fast forward to supporting devices */
while (region != 2) { while (region != 2) {
if (*rv == DEVICE_HANDLE_SEP) { if (*rv == Z_DEVICE_HANDLE_SEP) {
region++; region++;
} }
rv++; rv++;
@ -591,7 +595,7 @@ device_supported_handles_get(const struct device *dev, size_t *count)
* Trailing NULL's can be injected by gen_device_deps.py due to * Trailing NULL's can be injected by gen_device_deps.py due to
* CONFIG_PM_DEVICE_POWER_DOMAIN_DYNAMIC_NUM * CONFIG_PM_DEVICE_POWER_DOMAIN_DYNAMIC_NUM
*/ */
while ((rv[i] != DEVICE_HANDLE_ENDS) && while ((rv[i] != Z_DEVICE_HANDLE_ENDS) &&
(rv[i] != DEVICE_HANDLE_NULL)) { (rv[i] != DEVICE_HANDLE_NULL)) {
++i; ++i;
} }
@ -799,18 +803,18 @@ static inline bool z_impl_device_is_ready(const struct device *dev)
* { * {
* DEVICE_ORDINAL (or DEVICE_HANDLE_NULL if not a devicetree node), * DEVICE_ORDINAL (or DEVICE_HANDLE_NULL if not a devicetree node),
* List of devicetree dependency ordinals (if any), * List of devicetree dependency ordinals (if any),
* DEVICE_HANDLE_SEP, * Z_DEVICE_HANDLE_SEP,
* List of injected dependency ordinals (if any), * List of injected dependency ordinals (if any),
* DEVICE_HANDLE_SEP, * Z_DEVICE_HANDLE_SEP,
* List of devicetree supporting ordinals (if any), * List of devicetree supporting ordinals (if any),
* } * }
* *
* After processing in gen_device_deps.py, the format is updated to: * After processing in gen_device_deps.py, the format is updated to:
* { * {
* List of existing devicetree dependency handles (if any), * List of existing devicetree dependency handles (if any),
* DEVICE_HANDLE_SEP, * Z_DEVICE_HANDLE_SEP,
* List of injected devicetree dependency handles (if any), * List of injected devicetree dependency handles (if any),
* DEVICE_HANDLE_SEP, * Z_DEVICE_HANDLE_SEP,
* List of existing devicetree support handles (if any), * List of existing devicetree support handles (if any),
* DEVICE_HANDLE_NULL * DEVICE_HANDLE_NULL
* } * }
@ -831,9 +835,9 @@ static inline bool z_impl_device_is_ready(const struct device *dev)
DT_NODE_EXISTS(node_id), \ DT_NODE_EXISTS(node_id), \
(DT_DEP_ORD(node_id), DT_REQUIRES_DEP_ORDS(node_id)), \ (DT_DEP_ORD(node_id), DT_REQUIRES_DEP_ORDS(node_id)), \
(DEVICE_HANDLE_NULL,)) /**/ \ (DEVICE_HANDLE_NULL,)) /**/ \
DEVICE_HANDLE_SEP, \ Z_DEVICE_HANDLE_SEP, \
Z_DEVICE_EXTRA_HANDLES(__VA_ARGS__) /**/ \ Z_DEVICE_EXTRA_HANDLES(__VA_ARGS__) /**/ \
DEVICE_HANDLE_SEP, \ Z_DEVICE_HANDLE_SEP, \
COND_CODE_1(DT_NODE_EXISTS(node_id), \ COND_CODE_1(DT_NODE_EXISTS(node_id), \
(DT_SUPPORTS_DEP_ORDS(node_id)), ()) /**/ \ (DT_SUPPORTS_DEP_ORDS(node_id)), ()) /**/ \
} }

View file

@ -98,12 +98,12 @@ def c_handle_comment(dev, handles):
def c_handle_array(dev, handles, dynamic_handles, extra_support_handles=0): def c_handle_array(dev, handles, dynamic_handles, extra_support_handles=0):
handles = [ handles = [
*[str(d.handle) for d in handles["depends"]], *[str(d.handle) for d in handles["depends"]],
'DEVICE_HANDLE_SEP', 'Z_DEVICE_HANDLE_SEP',
*[str(d.handle) for d in handles["injected"]], *[str(d.handle) for d in handles["injected"]],
'DEVICE_HANDLE_SEP', 'Z_DEVICE_HANDLE_SEP',
*[str(d.handle) for d in handles["supports"]], *[str(d.handle) for d in handles["supports"]],
*(extra_support_handles * ['DEVICE_HANDLE_NULL']), *(extra_support_handles * ['DEVICE_HANDLE_NULL']),
'DEVICE_HANDLE_ENDS', 'Z_DEVICE_HANDLE_ENDS',
] ]
ctype = ( ctype = (
'{:s}Z_DECL_ALIGN(device_handle_t) ' '{:s}Z_DECL_ALIGN(device_handle_t) '

View file

@ -128,14 +128,14 @@ static int power_domain_add_or_remove(const struct device *dev,
* with the device handle. * with the device handle.
*/ */
while (region != 2) { while (region != 2) {
if (*rv == DEVICE_HANDLE_SEP) { if (*rv == Z_DEVICE_HANDLE_SEP) {
region++; region++;
} }
rv++; rv++;
} }
i = 0; i = 0;
while (rv[i] != DEVICE_HANDLE_ENDS) { while (rv[i] != Z_DEVICE_HANDLE_ENDS) {
if (add == false) { if (add == false) {
if (rv[i] == dev_handle) { if (rv[i] == dev_handle) {
dev->pm->domain = NULL; dev->pm->domain = NULL;