Re: [PATCH RFC 10/10] kobject: make struct kobject member default_groups a constant array

From: Thomas Weißschuh

Date: Sat Feb 21 2026 - 08:27:25 EST


Hello Heiner,

On 2026-02-17 23:32:46+0100, Heiner Kallweit wrote:
> Constify the default_groups array, allowing to assign constant arrays.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@xxxxxxxxx>

(The patch author/From header and Signed-off-by line do not match)

> ---
> include/linux/kobject.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/kobject.h b/include/linux/kobject.h
> index c8219505a79..e45ee843931 100644
> --- a/include/linux/kobject.h
> +++ b/include/linux/kobject.h
> @@ -116,7 +116,7 @@ char *kobject_get_path(const struct kobject *kobj, gfp_t flag);
> struct kobj_type {
> void (*release)(struct kobject *kobj);
> const struct sysfs_ops *sysfs_ops;
> - const struct attribute_group **default_groups;
> + const struct attribute_group *const *default_groups;

Thanks for working on this!

Personally I try to constify the attribute structures together with
their corresponding callbacks. This ensures that no structure is
constified which its callback then tries to modify.
Currently there is no support for const arguments to the callbacks of
'struct kobj_attribute' and 'struct device_attribute'. I am wondering
if the changes to kobject and device groups should be kept out for now
and be added together with the support for their const callback arguments.


Thomas

> const struct kobj_ns_type_operations *(*child_ns_type)(const struct kobject *kobj);
> const void *(*namespace)(const struct kobject *kobj);
> void (*get_ownership)(const struct kobject *kobj, kuid_t *uid, kgid_t *gid);