* [PATCH RFC 01/10] IB/core: Prepare for immutable device groups
2026-02-17 22:24 [PATCH RFC 00/10] driver core: constify groups arrays in several structs Heiner Kallweit
@ 2026-02-17 22:25 ` Heiner Kallweit
2026-02-18 8:54 ` Leon Romanovsky
2026-02-17 22:26 ` [PATCH RFC 02/10] rtc: prepare for struct device member groups becoming a constant array Heiner Kallweit
` (8 subsequent siblings)
9 siblings, 1 reply; 18+ messages in thread
From: Heiner Kallweit @ 2026-02-17 22:25 UTC (permalink / raw)
To: Thomas Weißschuh, Greg Kroah-Hartman, Rafael J. Wysocki,
Danilo Krummrich, Jason Gunthorpe, Leon Romanovsky,
Alexandre Belloni
Cc: driver-core, Linux Kernel Mailing List, linux-rdma, linux-rtc
This prepares for making struct device member groups a constant array.
No functional change intended.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/infiniband/core/device.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 1174ab7da62..f967ad534fc 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -565,15 +565,14 @@ static void rdma_init_coredev(struct ib_core_device *coredev,
*/
BUILD_BUG_ON(offsetof(struct ib_device, coredev.dev) !=
offsetof(struct ib_device, dev));
-
- coredev->dev.class = &ib_class;
- coredev->dev.groups = dev->groups;
-
/*
* Don't expose hw counters outside of the init namespace.
*/
if (!is_full_dev && dev->hw_stats_attr_index)
- coredev->dev.groups[dev->hw_stats_attr_index] = NULL;
+ dev->groups[dev->hw_stats_attr_index] = NULL;
+
+ coredev->dev.class = &ib_class;
+ coredev->dev.groups = dev->groups;
device_initialize(&coredev->dev);
coredev->owner = dev;
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH RFC 01/10] IB/core: Prepare for immutable device groups
2026-02-17 22:25 ` [PATCH RFC 01/10] IB/core: Prepare for immutable device groups Heiner Kallweit
@ 2026-02-18 8:54 ` Leon Romanovsky
0 siblings, 0 replies; 18+ messages in thread
From: Leon Romanovsky @ 2026-02-18 8:54 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Thomas Weißschuh, Greg Kroah-Hartman, Rafael J. Wysocki,
Danilo Krummrich, Jason Gunthorpe, Alexandre Belloni, driver-core,
Linux Kernel Mailing List, linux-rdma, linux-rtc
On Tue, Feb 17, 2026 at 11:25:20PM +0100, Heiner Kallweit wrote:
> This prepares for making struct device member groups a constant array.
> No functional change intended.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/infiniband/core/device.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
Thanks,
Acked-by: Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH RFC 02/10] rtc: prepare for struct device member groups becoming a constant array
2026-02-17 22:24 [PATCH RFC 00/10] driver core: constify groups arrays in several structs Heiner Kallweit
2026-02-17 22:25 ` [PATCH RFC 01/10] IB/core: Prepare for immutable device groups Heiner Kallweit
@ 2026-02-17 22:26 ` Heiner Kallweit
2026-02-19 0:53 ` yanjun.zhu
2026-02-17 22:27 ` [PATCH RFC 03/10] sysfs: constify group arrays in function arguments Heiner Kallweit
` (7 subsequent siblings)
9 siblings, 1 reply; 18+ messages in thread
From: Heiner Kallweit @ 2026-02-17 22:26 UTC (permalink / raw)
To: Thomas Weißschuh, Greg Kroah-Hartman, Rafael J. Wysocki,
Danilo Krummrich, Jason Gunthorpe, Leon Romanovsky,
Alexandre Belloni
Cc: driver-core, Linux Kernel Mailing List, linux-rdma, linux-rtc
This prepares for making struct device member groups a constant array.
The assignment groups = rtc->dev.groups would result in a "discarding
const qualifier" warning with this change.
No functional change intended.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/rtc/sysfs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/sysfs.c b/drivers/rtc/sysfs.c
index 4ab05e105a7..ae5e1252b4c 100644
--- a/drivers/rtc/sysfs.c
+++ b/drivers/rtc/sysfs.c
@@ -308,7 +308,7 @@ const struct attribute_group **rtc_get_dev_attribute_groups(void)
int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps)
{
size_t old_cnt = 0, add_cnt = 0, new_cnt;
- const struct attribute_group **groups, **old;
+ const struct attribute_group **groups, *const *old;
if (grps) {
for (groups = grps; *groups; groups++)
@@ -320,9 +320,9 @@ int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps)
return -EINVAL;
}
- groups = rtc->dev.groups;
- if (groups)
- for (; *groups; groups++)
+ old = rtc->dev.groups;
+ if (old)
+ while (*old++)
old_cnt++;
new_cnt = old_cnt + add_cnt + 1;
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH RFC 02/10] rtc: prepare for struct device member groups becoming a constant array
2026-02-17 22:26 ` [PATCH RFC 02/10] rtc: prepare for struct device member groups becoming a constant array Heiner Kallweit
@ 2026-02-19 0:53 ` yanjun.zhu
2026-02-20 14:38 ` Alexandre Belloni
0 siblings, 1 reply; 18+ messages in thread
From: yanjun.zhu @ 2026-02-19 0:53 UTC (permalink / raw)
To: Heiner Kallweit, Thomas Weißschuh, Greg Kroah-Hartman,
Rafael J. Wysocki, Danilo Krummrich, Jason Gunthorpe,
Leon Romanovsky, Alexandre Belloni
Cc: driver-core, Linux Kernel Mailing List, linux-rdma, linux-rtc
On 2/17/26 2:26 PM, Heiner Kallweit wrote:
> This prepares for making struct device member groups a constant array.
> The assignment groups = rtc->dev.groups would result in a "discarding
> const qualifier" warning with this change.
> No functional change intended.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/rtc/sysfs.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/rtc/sysfs.c b/drivers/rtc/sysfs.c
> index 4ab05e105a7..ae5e1252b4c 100644
> --- a/drivers/rtc/sysfs.c
> +++ b/drivers/rtc/sysfs.c
> @@ -308,7 +308,7 @@ const struct attribute_group **rtc_get_dev_attribute_groups(void)
> int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps)
> {
> size_t old_cnt = 0, add_cnt = 0, new_cnt;
> - const struct attribute_group **groups, **old;
> + const struct attribute_group **groups, *const *old;
>
> if (grps) {
> for (groups = grps; *groups; groups++)
> @@ -320,9 +320,9 @@ int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps)
> return -EINVAL;
> }
>
> - groups = rtc->dev.groups;
> - if (groups)
> - for (; *groups; groups++)
> + old = rtc->dev.groups;
> + if (old)
> + while (*old++)
> old_cnt++;
The change from for (; *groups; groups++) to while (*old++) is not
functionally equivalent. In the while version, the post-increment old++
executes even when *old is NULL. This leaves the pointer old pointing
one element past the NULL terminator. While old_cnt remains correct,
this is a side-effect-heavy idiom that differs from standard kernel
patterns and could be fragile if old is used later in the function.
Best Regards,
Zhu Yanjun
>
> new_cnt = old_cnt + add_cnt + 1;
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH RFC 02/10] rtc: prepare for struct device member groups becoming a constant array
2026-02-19 0:53 ` yanjun.zhu
@ 2026-02-20 14:38 ` Alexandre Belloni
0 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2026-02-20 14:38 UTC (permalink / raw)
To: yanjun.zhu
Cc: Heiner Kallweit, Thomas Weißschuh, Greg Kroah-Hartman,
Rafael J. Wysocki, Danilo Krummrich, Jason Gunthorpe,
Leon Romanovsky, driver-core, Linux Kernel Mailing List,
linux-rdma, linux-rtc
On 18/02/2026 16:53:00-0800, yanjun.zhu wrote:
> On 2/17/26 2:26 PM, Heiner Kallweit wrote:
> > This prepares for making struct device member groups a constant array.
> > The assignment groups = rtc->dev.groups would result in a "discarding
> > const qualifier" warning with this change.
> > No functional change intended.
> >
> > Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> > ---
> > drivers/rtc/sysfs.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/rtc/sysfs.c b/drivers/rtc/sysfs.c
> > index 4ab05e105a7..ae5e1252b4c 100644
> > --- a/drivers/rtc/sysfs.c
> > +++ b/drivers/rtc/sysfs.c
> > @@ -308,7 +308,7 @@ const struct attribute_group **rtc_get_dev_attribute_groups(void)
> > int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps)
> > {
> > size_t old_cnt = 0, add_cnt = 0, new_cnt;
> > - const struct attribute_group **groups, **old;
> > + const struct attribute_group **groups, *const *old;
> > if (grps) {
> > for (groups = grps; *groups; groups++)
> > @@ -320,9 +320,9 @@ int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps)
> > return -EINVAL;
> > }
> > - groups = rtc->dev.groups;
> > - if (groups)
> > - for (; *groups; groups++)
> > + old = rtc->dev.groups;
> > + if (old)
> > + while (*old++)
> > old_cnt++;
>
> The change from for (; *groups; groups++) to while (*old++) is not
> functionally equivalent. In the while version, the post-increment old++
> executes even when *old is NULL. This leaves the pointer old pointing one
> element past the NULL terminator. While old_cnt remains correct, this is a
> side-effect-heavy idiom that differs from standard kernel patterns and could
> be fragile if old is used later in the function.
>
Thanks for pointing this out, I agree we should keep the original for
loop.
With that change,
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Best Regards,
> Zhu Yanjun
>
> > new_cnt = old_cnt + add_cnt + 1;
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH RFC 03/10] sysfs: constify group arrays in function arguments
2026-02-17 22:24 [PATCH RFC 00/10] driver core: constify groups arrays in several structs Heiner Kallweit
2026-02-17 22:25 ` [PATCH RFC 01/10] IB/core: Prepare for immutable device groups Heiner Kallweit
2026-02-17 22:26 ` [PATCH RFC 02/10] rtc: prepare for struct device member groups becoming a constant array Heiner Kallweit
@ 2026-02-17 22:27 ` Heiner Kallweit
2026-02-17 22:28 ` [PATCH RFC 04/10] driver: core: constify groups array argument in device_add_groups and device_remove_groups Heiner Kallweit
` (6 subsequent siblings)
9 siblings, 0 replies; 18+ messages in thread
From: Heiner Kallweit @ 2026-02-17 22:27 UTC (permalink / raw)
To: Thomas Weißschuh, Greg Kroah-Hartman, Rafael J. Wysocki,
Danilo Krummrich, Jason Gunthorpe, Leon Romanovsky,
Alexandre Belloni
Cc: driver-core, Linux Kernel Mailing List, linux-rdma, linux-rtc
Constify the groups array argument where applicable. This allows to
pass constant arrays as arguments.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
fs/sysfs/group.c | 10 +++++-----
include/linux/sysfs.h | 16 ++++++++--------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index e1e639f515a..b3edae0578c 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -217,7 +217,7 @@ int sysfs_create_group(struct kobject *kobj,
EXPORT_SYMBOL_GPL(sysfs_create_group);
static int internal_create_groups(struct kobject *kobj, int update,
- const struct attribute_group **groups)
+ const struct attribute_group *const *groups)
{
int error = 0;
int i;
@@ -250,7 +250,7 @@ static int internal_create_groups(struct kobject *kobj, int update,
* Returns 0 on success or error code from sysfs_create_group on failure.
*/
int sysfs_create_groups(struct kobject *kobj,
- const struct attribute_group **groups)
+ const struct attribute_group *const *groups)
{
return internal_create_groups(kobj, 0, groups);
}
@@ -268,7 +268,7 @@ EXPORT_SYMBOL_GPL(sysfs_create_groups);
* Returns 0 on success or error code from sysfs_update_group on failure.
*/
int sysfs_update_groups(struct kobject *kobj,
- const struct attribute_group **groups)
+ const struct attribute_group *const *groups)
{
return internal_create_groups(kobj, 1, groups);
}
@@ -342,7 +342,7 @@ EXPORT_SYMBOL_GPL(sysfs_remove_group);
* If groups is not NULL, remove the specified groups from the kobject.
*/
void sysfs_remove_groups(struct kobject *kobj,
- const struct attribute_group **groups)
+ const struct attribute_group *const *groups)
{
int i;
@@ -613,7 +613,7 @@ EXPORT_SYMBOL_GPL(sysfs_group_change_owner);
* Returns 0 on success or error code on failure.
*/
int sysfs_groups_change_owner(struct kobject *kobj,
- const struct attribute_group **groups,
+ const struct attribute_group *const *groups,
kuid_t kuid, kgid_t kgid)
{
int error = 0, i;
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index c33a96b7391..445869ce0f4 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -445,15 +445,15 @@ void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
int __must_check sysfs_create_group(struct kobject *kobj,
const struct attribute_group *grp);
int __must_check sysfs_create_groups(struct kobject *kobj,
- const struct attribute_group **groups);
+ const struct attribute_group *const *groups);
int __must_check sysfs_update_groups(struct kobject *kobj,
- const struct attribute_group **groups);
+ const struct attribute_group *const *groups);
int sysfs_update_group(struct kobject *kobj,
const struct attribute_group *grp);
void sysfs_remove_group(struct kobject *kobj,
const struct attribute_group *grp);
void sysfs_remove_groups(struct kobject *kobj,
- const struct attribute_group **groups);
+ const struct attribute_group *const *groups);
int sysfs_add_file_to_group(struct kobject *kobj,
const struct attribute *attr, const char *group);
void sysfs_remove_file_from_group(struct kobject *kobj,
@@ -486,7 +486,7 @@ int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid);
int sysfs_link_change_owner(struct kobject *kobj, struct kobject *targ,
const char *name, kuid_t kuid, kgid_t kgid);
int sysfs_groups_change_owner(struct kobject *kobj,
- const struct attribute_group **groups,
+ const struct attribute_group *const *groups,
kuid_t kuid, kgid_t kgid);
int sysfs_group_change_owner(struct kobject *kobj,
const struct attribute_group *groups, kuid_t kuid,
@@ -629,13 +629,13 @@ static inline int sysfs_create_group(struct kobject *kobj,
}
static inline int sysfs_create_groups(struct kobject *kobj,
- const struct attribute_group **groups)
+ const struct attribute_group *const *groups)
{
return 0;
}
static inline int sysfs_update_groups(struct kobject *kobj,
- const struct attribute_group **groups)
+ const struct attribute_group *const *groups)
{
return 0;
}
@@ -652,7 +652,7 @@ static inline void sysfs_remove_group(struct kobject *kobj,
}
static inline void sysfs_remove_groups(struct kobject *kobj,
- const struct attribute_group **groups)
+ const struct attribute_group *const *groups)
{
}
@@ -733,7 +733,7 @@ static inline int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t k
}
static inline int sysfs_groups_change_owner(struct kobject *kobj,
- const struct attribute_group **groups,
+ const struct attribute_group *const *groups,
kuid_t kuid, kgid_t kgid)
{
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC 04/10] driver: core: constify groups array argument in device_add_groups and device_remove_groups
2026-02-17 22:24 [PATCH RFC 00/10] driver core: constify groups arrays in several structs Heiner Kallweit
` (2 preceding siblings ...)
2026-02-17 22:27 ` [PATCH RFC 03/10] sysfs: constify group arrays in function arguments Heiner Kallweit
@ 2026-02-17 22:28 ` Heiner Kallweit
2026-02-17 22:28 ` [PATCH RFC 05/10] driver core: make struct device member groups a constant array Heiner Kallweit
` (5 subsequent siblings)
9 siblings, 0 replies; 18+ messages in thread
From: Heiner Kallweit @ 2026-02-17 22:28 UTC (permalink / raw)
To: Thomas Weißschuh, Greg Kroah-Hartman, Rafael J. Wysocki,
Danilo Krummrich, Jason Gunthorpe, Leon Romanovsky,
Alexandre Belloni
Cc: driver-core, Linux Kernel Mailing List, linux-rdma, linux-rtc
Now that sysfs_create_groups() and sysfs_remove_groups() allow to
pass constant groups arrays, we can constify the groups array argument
also here.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/base/core.c | 5 +++--
include/linux/device.h | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index f599a1384ee..4db63b2603c 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2831,14 +2831,15 @@ static ssize_t removable_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RO(removable);
-int device_add_groups(struct device *dev, const struct attribute_group **groups)
+int device_add_groups(struct device *dev,
+ const struct attribute_group *const *groups)
{
return sysfs_create_groups(&dev->kobj, groups);
}
EXPORT_SYMBOL_GPL(device_add_groups);
void device_remove_groups(struct device *dev,
- const struct attribute_group **groups)
+ const struct attribute_group *const *groups)
{
sysfs_remove_groups(&dev->kobj, groups);
}
diff --git a/include/linux/device.h b/include/linux/device.h
index 0be95294b6e..48a0444ccc1 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1131,9 +1131,9 @@ device_create_with_groups(const struct class *cls, struct device *parent, dev_t
void device_destroy(const struct class *cls, dev_t devt);
int __must_check device_add_groups(struct device *dev,
- const struct attribute_group **groups);
+ const struct attribute_group *const *groups);
void device_remove_groups(struct device *dev,
- const struct attribute_group **groups);
+ const struct attribute_group *const *groups);
static inline int __must_check device_add_group(struct device *dev,
const struct attribute_group *grp)
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC 05/10] driver core: make struct device member groups a constant array
2026-02-17 22:24 [PATCH RFC 00/10] driver core: constify groups arrays in several structs Heiner Kallweit
` (3 preceding siblings ...)
2026-02-17 22:28 ` [PATCH RFC 04/10] driver: core: constify groups array argument in device_add_groups and device_remove_groups Heiner Kallweit
@ 2026-02-17 22:28 ` Heiner Kallweit
2026-02-18 20:14 ` kernel test robot
2026-02-17 22:29 ` [PATCH RFC 06/10] driver core: make struct device_type " Heiner Kallweit
` (4 subsequent siblings)
9 siblings, 1 reply; 18+ messages in thread
From: Heiner Kallweit @ 2026-02-17 22:28 UTC (permalink / raw)
To: Thomas Weißschuh, Greg Kroah-Hartman, Rafael J. Wysocki,
Danilo Krummrich, Jason Gunthorpe, Leon Romanovsky,
Alexandre Belloni
Cc: driver-core, Linux Kernel Mailing List, linux-rdma, linux-rtc
Constify the groups array, allowing to assign constant arrays.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
include/linux/device.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/device.h b/include/linux/device.h
index 48a0444ccc1..bfa2ca603c2 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -640,7 +640,7 @@ struct device {
struct list_head devres_head;
const struct class *class;
- const struct attribute_group **groups; /* optional groups */
+ const struct attribute_group *const *groups; /* optional groups */
void (*release)(struct device *dev);
struct iommu_group *iommu_group;
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH RFC 05/10] driver core: make struct device member groups a constant array
2026-02-17 22:28 ` [PATCH RFC 05/10] driver core: make struct device member groups a constant array Heiner Kallweit
@ 2026-02-18 20:14 ` kernel test robot
0 siblings, 0 replies; 18+ messages in thread
From: kernel test robot @ 2026-02-18 20:14 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: llvm, oe-kbuild-all
Hi Heiner,
[This is a private test report for your RFC patch.]
kernel test robot noticed the following build errors:
[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on driver-core/driver-core-next driver-core/driver-core-linus abelloni/rtc-next rdma/for-next linus/master v6.19 next-20260218]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Heiner-Kallweit/IB-core-Prepare-for-immutable-device-groups/20260218-063407
base: driver-core/driver-core-testing
patch link: https://lore.kernel.org/r/ca6222be-1380-4a1e-a8d0-330caf3748f6%40kernel.org
patch subject: [PATCH RFC 05/10] driver core: make struct device member groups a constant array
config: sparc64-allmodconfig (https://download.01.org/0day-ci/archive/20260219/202602190438.KpXZA9Vu-lkp@intel.com/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project e86750b29fa0ff207cd43213d66dabe565417638)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260219/202602190438.KpXZA9Vu-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602190438.KpXZA9Vu-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/counter/counter-sysfs.c:1172:18: error: read-only variable is not assignable
1172 | dev->groups[i] = &groups[i];
| ~~~~~~~~~~~~~~ ^
1 error generated.
vim +1172 drivers/counter/counter-sysfs.c
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1107
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1108 /**
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1109 * counter_sysfs_add - Adds Counter sysfs attributes to the device structure
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1110 * @counter: Pointer to the Counter device structure
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1111 *
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1112 * Counter sysfs attributes are created and added to the respective device
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1113 * structure for later registration to the system. Resource-managed memory
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1114 * allocation is performed by this function, and this memory should be freed
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1115 * when no longer needed (automatically by a device_unregister call, or
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1116 * manually by a devres_release_all call).
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1117 */
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1118 int counter_sysfs_add(struct counter_device *const counter)
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1119 {
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1120 struct device *const dev = &counter->dev;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1121 const size_t num_groups = counter->num_signals + counter->num_counts + 1;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1122 struct counter_attribute_group *cattr_groups;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1123 size_t i, j;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1124 int err;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1125 struct attribute_group *groups;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1126 struct counter_attribute *p;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1127
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1128 /* Allocate space for attribute groups (signals, counts, and ext) */
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1129 cattr_groups = devm_kcalloc(dev, num_groups, sizeof(*cattr_groups),
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1130 GFP_KERNEL);
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1131 if (!cattr_groups)
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1132 return -ENOMEM;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1133
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1134 /* Initialize attribute lists */
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1135 for (i = 0; i < num_groups; i++)
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1136 INIT_LIST_HEAD(&cattr_groups[i].attr_list);
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1137
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1138 /* Add Counter device sysfs attributes */
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1139 err = counter_sysfs_attr_add(counter, cattr_groups);
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1140 if (err < 0)
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1141 return err;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1142
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1143 /* Allocate attribute group pointers for association with device */
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1144 dev->groups = devm_kcalloc(dev, num_groups + 1, sizeof(*dev->groups),
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1145 GFP_KERNEL);
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1146 if (!dev->groups)
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1147 return -ENOMEM;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1148
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1149 /* Allocate space for attribute groups */
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1150 groups = devm_kcalloc(dev, num_groups, sizeof(*groups), GFP_KERNEL);
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1151 if (!groups)
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1152 return -ENOMEM;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1153
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1154 /* Prepare each group of attributes for association */
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1155 for (i = 0; i < num_groups; i++) {
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1156 groups[i].name = cattr_groups[i].name;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1157
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1158 /* Allocate space for attribute pointers */
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1159 groups[i].attrs = devm_kcalloc(dev,
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1160 cattr_groups[i].num_attr + 1,
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1161 sizeof(*groups[i].attrs),
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1162 GFP_KERNEL);
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1163 if (!groups[i].attrs)
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1164 return -ENOMEM;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1165
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1166 /* Add attribute pointers to attribute group */
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1167 j = 0;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1168 list_for_each_entry(p, &cattr_groups[i].attr_list, l)
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1169 groups[i].attrs[j++] = &p->dev_attr.attr;
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1170
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 1171 /* Associate attribute group */
aaec1a0f76ec25f William Breathitt Gray 2021-08-27 @1172 dev->groups[i] = &groups[i];
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH RFC 06/10] driver core: make struct device_type member groups a constant array
2026-02-17 22:24 [PATCH RFC 00/10] driver core: constify groups arrays in several structs Heiner Kallweit
` (4 preceding siblings ...)
2026-02-17 22:28 ` [PATCH RFC 05/10] driver core: make struct device member groups a constant array Heiner Kallweit
@ 2026-02-17 22:29 ` Heiner Kallweit
2026-02-18 17:39 ` kernel test robot
2026-02-17 22:30 ` [PATCH RFC 07/10] driver core: make struct bus_type groups members constant arrays Heiner Kallweit
` (3 subsequent siblings)
9 siblings, 1 reply; 18+ messages in thread
From: Heiner Kallweit @ 2026-02-17 22:29 UTC (permalink / raw)
To: Thomas Weißschuh, Greg Kroah-Hartman, Rafael J. Wysocki,
Danilo Krummrich, Jason Gunthorpe, Leon Romanovsky,
Alexandre Belloni
Cc: driver-core, Linux Kernel Mailing List, linux-rdma, linux-rtc
Constify the groups array, allowing to assign constant arrays.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
include/linux/device.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/device.h b/include/linux/device.h
index bfa2ca603c2..808f723bbcf 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -87,7 +87,7 @@ int subsys_virtual_register(const struct bus_type *subsys,
*/
struct device_type {
const char *name;
- const struct attribute_group **groups;
+ const struct attribute_group *const *groups;
int (*uevent)(const struct device *dev, struct kobj_uevent_env *env);
char *(*devnode)(const struct device *dev, umode_t *mode,
kuid_t *uid, kgid_t *gid);
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH RFC 06/10] driver core: make struct device_type member groups a constant array
2026-02-17 22:29 ` [PATCH RFC 06/10] driver core: make struct device_type " Heiner Kallweit
@ 2026-02-18 17:39 ` kernel test robot
0 siblings, 0 replies; 18+ messages in thread
From: kernel test robot @ 2026-02-18 17:39 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: oe-kbuild-all
Hi Heiner,
[This is a private test report for your RFC patch.]
kernel test robot noticed the following build errors:
[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on driver-core/driver-core-next driver-core/driver-core-linus abelloni/rtc-next rdma/for-next linus/master v6.19 next-20260218]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Heiner-Kallweit/IB-core-Prepare-for-immutable-device-groups/20260218-063407
base: driver-core/driver-core-testing
patch link: https://lore.kernel.org/r/66a78ec0-2980-4376-96fb-3193b6cbe943%40kernel.org
patch subject: [PATCH RFC 06/10] driver core: make struct device_type member groups a constant array
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20260219/202602190133.MGHdZxXo-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260219/202602190133.MGHdZxXo-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602190133.MGHdZxXo-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/extcon/extcon.c: In function 'extcon_alloc_groups':
>> drivers/extcon/extcon.c:1223:53: error: assignment of read-only location '*(edev->extcon_dev_type.groups + (sizetype)((long unsigned int)index * 8))'
1223 | edev->extcon_dev_type.groups[index] = &edev->cables[index].attr_g;
| ^
drivers/extcon/extcon.c:1226:53: error: assignment of read-only location '*(edev->extcon_dev_type.groups + (sizetype)((long unsigned int)index * 8))'
1226 | edev->extcon_dev_type.groups[index] = &edev->attr_g_muex;
| ^
vim +1223 drivers/extcon/extcon.c
3e70a014abcdf7 Bumwoo Lee 2023-03-20 1196
04151575c507e7 Bumwoo Lee 2023-03-20 1197 /**
04151575c507e7 Bumwoo Lee 2023-03-20 1198 * extcon_alloc_groups() - alloc the groups for extcon device
04151575c507e7 Bumwoo Lee 2023-03-20 1199 * @edev: extcon device
04151575c507e7 Bumwoo Lee 2023-03-20 1200 *
04151575c507e7 Bumwoo Lee 2023-03-20 1201 * Returns 0 if success or error number if fail.
04151575c507e7 Bumwoo Lee 2023-03-20 1202 */
04151575c507e7 Bumwoo Lee 2023-03-20 1203 static int extcon_alloc_groups(struct extcon_dev *edev)
04151575c507e7 Bumwoo Lee 2023-03-20 1204 {
04151575c507e7 Bumwoo Lee 2023-03-20 1205 int index;
04151575c507e7 Bumwoo Lee 2023-03-20 1206
04151575c507e7 Bumwoo Lee 2023-03-20 1207 if (!edev)
04151575c507e7 Bumwoo Lee 2023-03-20 1208 return -EINVAL;
04151575c507e7 Bumwoo Lee 2023-03-20 1209
04151575c507e7 Bumwoo Lee 2023-03-20 1210 if (!edev->max_supported)
04151575c507e7 Bumwoo Lee 2023-03-20 1211 return 0;
04151575c507e7 Bumwoo Lee 2023-03-20 1212
04151575c507e7 Bumwoo Lee 2023-03-20 1213 edev->extcon_dev_type.groups = kcalloc(edev->max_supported + 2,
ef753fb4e86607 Andy Shevchenko 2023-04-11 1214 sizeof(*edev->extcon_dev_type.groups),
04151575c507e7 Bumwoo Lee 2023-03-20 1215 GFP_KERNEL);
04151575c507e7 Bumwoo Lee 2023-03-20 1216 if (!edev->extcon_dev_type.groups)
04151575c507e7 Bumwoo Lee 2023-03-20 1217 return -ENOMEM;
04151575c507e7 Bumwoo Lee 2023-03-20 1218
04151575c507e7 Bumwoo Lee 2023-03-20 1219 edev->extcon_dev_type.name = dev_name(&edev->dev);
04151575c507e7 Bumwoo Lee 2023-03-20 1220 edev->extcon_dev_type.release = dummy_sysfs_dev_release;
04151575c507e7 Bumwoo Lee 2023-03-20 1221
04151575c507e7 Bumwoo Lee 2023-03-20 1222 for (index = 0; index < edev->max_supported; index++)
04151575c507e7 Bumwoo Lee 2023-03-20 @1223 edev->extcon_dev_type.groups[index] = &edev->cables[index].attr_g;
04151575c507e7 Bumwoo Lee 2023-03-20 1224
04151575c507e7 Bumwoo Lee 2023-03-20 1225 if (edev->mutually_exclusive)
04151575c507e7 Bumwoo Lee 2023-03-20 1226 edev->extcon_dev_type.groups[index] = &edev->attr_g_muex;
04151575c507e7 Bumwoo Lee 2023-03-20 1227
04151575c507e7 Bumwoo Lee 2023-03-20 1228 edev->dev.type = &edev->extcon_dev_type;
04151575c507e7 Bumwoo Lee 2023-03-20 1229
04151575c507e7 Bumwoo Lee 2023-03-20 1230 return 0;
04151575c507e7 Bumwoo Lee 2023-03-20 1231 }
04151575c507e7 Bumwoo Lee 2023-03-20 1232
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH RFC 07/10] driver core: make struct bus_type groups members constant arrays
2026-02-17 22:24 [PATCH RFC 00/10] driver core: constify groups arrays in several structs Heiner Kallweit
` (5 preceding siblings ...)
2026-02-17 22:29 ` [PATCH RFC 06/10] driver core: make struct device_type " Heiner Kallweit
@ 2026-02-17 22:30 ` Heiner Kallweit
2026-02-17 22:30 ` [PATCH RFC 08/10] driver core: make struct class " Heiner Kallweit
` (2 subsequent siblings)
9 siblings, 0 replies; 18+ messages in thread
From: Heiner Kallweit @ 2026-02-17 22:30 UTC (permalink / raw)
To: Thomas Weißschuh, Greg Kroah-Hartman, Rafael J. Wysocki,
Danilo Krummrich, Jason Gunthorpe, Leon Romanovsky,
Alexandre Belloni
Cc: driver-core, Linux Kernel Mailing List, linux-rdma, linux-rtc
Constify the groupss arrays, allowing to assign constant arrays.
As a prerequisite this requires to constify the groups array argument
in few functions.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/base/base.h | 6 ++++--
drivers/base/driver.c | 4 ++--
include/linux/device/bus.h | 6 +++---
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 8c2175820da..b6852ba45cd 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -202,8 +202,10 @@ static inline void dev_sync_state(struct device *dev)
dev->driver->sync_state(dev);
}
-int driver_add_groups(const struct device_driver *drv, const struct attribute_group **groups);
-void driver_remove_groups(const struct device_driver *drv, const struct attribute_group **groups);
+int driver_add_groups(const struct device_driver *drv,
+ const struct attribute_group *const *groups);
+void driver_remove_groups(const struct device_driver *drv,
+ const struct attribute_group *const *groups);
void device_driver_detach(struct device *dev);
static inline void device_set_driver(struct device *dev, const struct device_driver *drv)
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 8ab010ddf70..c5ebf1fdad7 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -203,13 +203,13 @@ void driver_remove_file(const struct device_driver *drv,
EXPORT_SYMBOL_GPL(driver_remove_file);
int driver_add_groups(const struct device_driver *drv,
- const struct attribute_group **groups)
+ const struct attribute_group *const *groups)
{
return sysfs_create_groups(&drv->p->kobj, groups);
}
void driver_remove_groups(const struct device_driver *drv,
- const struct attribute_group **groups)
+ const struct attribute_group *const *groups)
{
sysfs_remove_groups(&drv->p->kobj, groups);
}
diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
index 99c3c83ea52..00d8a080f93 100644
--- a/include/linux/device/bus.h
+++ b/include/linux/device/bus.h
@@ -78,9 +78,9 @@ struct fwnode_handle;
struct bus_type {
const char *name;
const char *dev_name;
- const struct attribute_group **bus_groups;
- const struct attribute_group **dev_groups;
- const struct attribute_group **drv_groups;
+ const struct attribute_group *const *bus_groups;
+ const struct attribute_group *const *dev_groups;
+ const struct attribute_group *const *drv_groups;
int (*match)(struct device *dev, const struct device_driver *drv);
int (*uevent)(const struct device *dev, struct kobj_uevent_env *env);
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC 08/10] driver core: make struct class groups members constant arrays
2026-02-17 22:24 [PATCH RFC 00/10] driver core: constify groups arrays in several structs Heiner Kallweit
` (6 preceding siblings ...)
2026-02-17 22:30 ` [PATCH RFC 07/10] driver core: make struct bus_type groups members constant arrays Heiner Kallweit
@ 2026-02-17 22:30 ` Heiner Kallweit
2026-02-17 22:31 ` [PATCH RFC 09/10] driver core: make struct device_driver groups members contact arrays Heiner Kallweit
2026-02-17 22:32 ` [PATCH RFC 10/10] kobject: make struct kobject member default_groups a constant array Heiner Kallweit
9 siblings, 0 replies; 18+ messages in thread
From: Heiner Kallweit @ 2026-02-17 22:30 UTC (permalink / raw)
To: Thomas Weißschuh, Greg Kroah-Hartman, Rafael J. Wysocki,
Danilo Krummrich, Jason Gunthorpe, Leon Romanovsky,
Alexandre Belloni
Cc: driver-core, Linux Kernel Mailing List, linux-rdma, linux-rtc
Constify the groups arrays, allowing to assign constant arrays.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
include/linux/device/class.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/device/class.h b/include/linux/device/class.h
index 65880e60c72..2079239a5aa 100644
--- a/include/linux/device/class.h
+++ b/include/linux/device/class.h
@@ -50,8 +50,8 @@ struct fwnode_handle;
struct class {
const char *name;
- const struct attribute_group **class_groups;
- const struct attribute_group **dev_groups;
+ const struct attribute_group *const *class_groups;
+ const struct attribute_group *const *dev_groups;
int (*dev_uevent)(const struct device *dev, struct kobj_uevent_env *env);
char *(*devnode)(const struct device *dev, umode_t *mode);
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC 09/10] driver core: make struct device_driver groups members contact arrays
2026-02-17 22:24 [PATCH RFC 00/10] driver core: constify groups arrays in several structs Heiner Kallweit
` (7 preceding siblings ...)
2026-02-17 22:30 ` [PATCH RFC 08/10] driver core: make struct class " Heiner Kallweit
@ 2026-02-17 22:31 ` Heiner Kallweit
2026-02-17 22:32 ` [PATCH RFC 10/10] kobject: make struct kobject member default_groups a constant array Heiner Kallweit
9 siblings, 0 replies; 18+ messages in thread
From: Heiner Kallweit @ 2026-02-17 22:31 UTC (permalink / raw)
To: Thomas Weißschuh, Greg Kroah-Hartman, Rafael J. Wysocki,
Danilo Krummrich, Jason Gunthorpe, Leon Romanovsky,
Alexandre Belloni
Cc: driver-core, Linux Kernel Mailing List, linux-rdma, linux-rtc
Constify the groups arrays, allowing to assign constant arrays.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
include/linux/device/driver.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h
index bbc67ec513e..c882daaef01 100644
--- a/include/linux/device/driver.h
+++ b/include/linux/device/driver.h
@@ -114,8 +114,8 @@ struct device_driver {
void (*shutdown) (struct device *dev);
int (*suspend) (struct device *dev, pm_message_t state);
int (*resume) (struct device *dev);
- const struct attribute_group **groups;
- const struct attribute_group **dev_groups;
+ const struct attribute_group *const *groups;
+ const struct attribute_group *const *dev_groups;
const struct dev_pm_ops *pm;
void (*coredump) (struct device *dev);
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH RFC 10/10] kobject: make struct kobject member default_groups a constant array
2026-02-17 22:24 [PATCH RFC 00/10] driver core: constify groups arrays in several structs Heiner Kallweit
` (8 preceding siblings ...)
2026-02-17 22:31 ` [PATCH RFC 09/10] driver core: make struct device_driver groups members contact arrays Heiner Kallweit
@ 2026-02-17 22:32 ` Heiner Kallweit
2026-02-21 13:27 ` Thomas Weißschuh
9 siblings, 1 reply; 18+ messages in thread
From: Heiner Kallweit @ 2026-02-17 22:32 UTC (permalink / raw)
To: Thomas Weißschuh, Greg Kroah-Hartman, Rafael J. Wysocki,
Danilo Krummrich, Jason Gunthorpe, Leon Romanovsky,
Alexandre Belloni
Cc: driver-core, Linux Kernel Mailing List, linux-rdma, linux-rtc
Constify the default_groups array, allowing to assign constant arrays.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
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;
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);
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH RFC 10/10] kobject: make struct kobject member default_groups a constant array
2026-02-17 22:32 ` [PATCH RFC 10/10] kobject: make struct kobject member default_groups a constant array Heiner Kallweit
@ 2026-02-21 13:27 ` Thomas Weißschuh
2026-02-21 14:04 ` Heiner Kallweit
0 siblings, 1 reply; 18+ messages in thread
From: Thomas Weißschuh @ 2026-02-21 13:27 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
Jason Gunthorpe, Leon Romanovsky, Alexandre Belloni, driver-core,
Linux Kernel Mailing List, linux-rdma, linux-rtc
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@gmail.com>
(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);
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH RFC 10/10] kobject: make struct kobject member default_groups a constant array
2026-02-21 13:27 ` Thomas Weißschuh
@ 2026-02-21 14:04 ` Heiner Kallweit
0 siblings, 0 replies; 18+ messages in thread
From: Heiner Kallweit @ 2026-02-21 14:04 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
Jason Gunthorpe, Leon Romanovsky, Alexandre Belloni, driver-core,
Linux Kernel Mailing List, linux-rdma, linux-rtc
On 21.02.2026 14:27, Thomas Weißschuh wrote:
> 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@gmail.com>
>
> (The patch author/From header and Signed-off-by line do not match)
>
Right, have to fix this once series is out of RFC state.
>> ---
>> 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.
>
I think we have to be precise what exactly gets constified:
In the series here it's about arrays of pointers to attribute groups.
Just these arrays can't be modified any longer. This includes no change
to whether data in the attribute groups and attributes can be modified.
These arrays of pointers to attribute groups are used in calls to
sysfs_create_groups() and device_add_groups(), e.g. from create_dir()
for kobject's, and from device_add_attrs().
And sysfs_create_groups() and device_add_groups() are changed accordingly
in this series.
Does this answer your question?
>
> 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);
^ permalink raw reply [flat|nested] 18+ messages in thread