userspace: update k_object API to support immutable objects
The k_object API associates mutable state structures with known kernel
objects to support userspace. The kernel objects themselves are not
modified by the API, and in some cases (e.g. device structures) may be
const-qualified. Update the API so that pointers to these const
kernel objects can be passed without casting away the const qualifier.
Fixes #27399
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
diff --git a/scripts/gen_kobject_list.py b/scripts/gen_kobject_list.py
index 7b472c9..0a3ae69 100755
--- a/scripts/gen_kobject_list.py
+++ b/scripts/gen_kobject_list.py
@@ -711,7 +711,7 @@
# turned into a string, we told gperf to expect binary strings that are not
# NULL-terminated.
footer = """%%
-struct z_object *z_object_gperf_find(void *obj)
+struct z_object *z_object_gperf_find(const void *obj)
{
return z_object_lookup((const char *)obj, sizeof(void *));
}
@@ -728,7 +728,7 @@
}
#ifndef CONFIG_DYNAMIC_OBJECTS
-struct z_object *z_object_find(void *obj)
+struct z_object *z_object_find(const void *obj)
ALIAS_OF(z_object_gperf_find);
void z_object_wordlist_foreach(_wordlist_cb_func_t func, void *context)