From e5f82cb5dc84e8cf116c3b1596f4467ee387122f Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Wed, 14 Jun 2023 12:20:56 +0200 Subject: [PATCH] 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 --- include/zephyr/device.h | 62 +++++++++++++++++--------------- scripts/build/gen_device_deps.py | 6 ++-- subsys/pm/device.c | 4 +-- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/include/zephyr/device.h b/include/zephyr/device.h index 0b48744991..7dc154dd3e 100644 --- a/include/zephyr/device.h +++ b/include/zephyr/device.h @@ -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. * @@ -44,22 +64,6 @@ extern "C" { */ 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. */ #define DEVICE_HANDLE_NULL 0 @@ -500,8 +504,8 @@ device_required_handles_get(const struct device *dev, size_t *count) if (rv != NULL) { size_t i = 0; - while ((rv[i] != DEVICE_HANDLE_ENDS) && - (rv[i] != DEVICE_HANDLE_SEP)) { + while ((rv[i] != Z_DEVICE_HANDLE_ENDS) && + (rv[i] != Z_DEVICE_HANDLE_SEP)) { ++i; } *count = i; @@ -538,13 +542,13 @@ device_injected_handles_get(const struct device *dev, size_t *count) if (rv != NULL) { /* Fast forward to injected devices */ while (region != 1) { - if (*rv == DEVICE_HANDLE_SEP) { + if (*rv == Z_DEVICE_HANDLE_SEP) { region++; } rv++; } - while ((rv[i] != DEVICE_HANDLE_ENDS) && - (rv[i] != DEVICE_HANDLE_SEP)) { + while ((rv[i] != Z_DEVICE_HANDLE_ENDS) && + (rv[i] != Z_DEVICE_HANDLE_SEP)) { ++i; } *count = i; @@ -582,7 +586,7 @@ device_supported_handles_get(const struct device *dev, size_t *count) if (rv != NULL) { /* Fast forward to supporting devices */ while (region != 2) { - if (*rv == DEVICE_HANDLE_SEP) { + if (*rv == Z_DEVICE_HANDLE_SEP) { region++; } 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 * 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)) { ++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), * List of devicetree dependency ordinals (if any), - * DEVICE_HANDLE_SEP, + * Z_DEVICE_HANDLE_SEP, * List of injected dependency ordinals (if any), - * DEVICE_HANDLE_SEP, + * Z_DEVICE_HANDLE_SEP, * List of devicetree supporting ordinals (if any), * } * * After processing in gen_device_deps.py, the format is updated to: * { * List of existing devicetree dependency handles (if any), - * DEVICE_HANDLE_SEP, + * Z_DEVICE_HANDLE_SEP, * List of injected devicetree dependency handles (if any), - * DEVICE_HANDLE_SEP, + * Z_DEVICE_HANDLE_SEP, * List of existing devicetree support handles (if any), * 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_DEP_ORD(node_id), DT_REQUIRES_DEP_ORDS(node_id)), \ (DEVICE_HANDLE_NULL,)) /**/ \ - DEVICE_HANDLE_SEP, \ + Z_DEVICE_HANDLE_SEP, \ Z_DEVICE_EXTRA_HANDLES(__VA_ARGS__) /**/ \ - DEVICE_HANDLE_SEP, \ + Z_DEVICE_HANDLE_SEP, \ COND_CODE_1(DT_NODE_EXISTS(node_id), \ (DT_SUPPORTS_DEP_ORDS(node_id)), ()) /**/ \ } diff --git a/scripts/build/gen_device_deps.py b/scripts/build/gen_device_deps.py index bbebb554dd..b26e9ef38e 100755 --- a/scripts/build/gen_device_deps.py +++ b/scripts/build/gen_device_deps.py @@ -98,12 +98,12 @@ def c_handle_comment(dev, handles): def c_handle_array(dev, handles, dynamic_handles, extra_support_handles=0): handles = [ *[str(d.handle) for d in handles["depends"]], - 'DEVICE_HANDLE_SEP', + 'Z_DEVICE_HANDLE_SEP', *[str(d.handle) for d in handles["injected"]], - 'DEVICE_HANDLE_SEP', + 'Z_DEVICE_HANDLE_SEP', *[str(d.handle) for d in handles["supports"]], *(extra_support_handles * ['DEVICE_HANDLE_NULL']), - 'DEVICE_HANDLE_ENDS', + 'Z_DEVICE_HANDLE_ENDS', ] ctype = ( '{:s}Z_DECL_ALIGN(device_handle_t) ' diff --git a/subsys/pm/device.c b/subsys/pm/device.c index 9b89a43ee2..f978d20889 100644 --- a/subsys/pm/device.c +++ b/subsys/pm/device.c @@ -128,14 +128,14 @@ static int power_domain_add_or_remove(const struct device *dev, * with the device handle. */ while (region != 2) { - if (*rv == DEVICE_HANDLE_SEP) { + if (*rv == Z_DEVICE_HANDLE_SEP) { region++; } rv++; } i = 0; - while (rv[i] != DEVICE_HANDLE_ENDS) { + while (rv[i] != Z_DEVICE_HANDLE_ENDS) { if (add == false) { if (rv[i] == dev_handle) { dev->pm->domain = NULL;