[PATCH 1/2] configfs: Constify ct_group_ops in struct config_item_type

Christophe JAILLET posted 2 patches 3 months, 2 weeks ago
[PATCH 1/2] configfs: Constify ct_group_ops in struct config_item_type
Posted by Christophe JAILLET 3 months, 2 weeks ago
Make 'ct_group_ops' const in struct config_item_type.
This allows constification of many structures which hold some function
pointers.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only files that explicitly use ct_group_ops.

The script used for that is:
  while IFS= read -r -d '' file; do
    obj="${file%.c}.o" ; echo -e "\nCompiling $file" ; make "$obj"
  done < <(git grep --name-only -z ct_group_ops '*.c')
---
 fs/configfs/dir.c        | 2 +-
 include/linux/configfs.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 81f4f06bc87e..4bcd14b3434c 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -598,7 +598,7 @@ static void detach_attrs(struct config_item * item)
 static int populate_attrs(struct config_item *item)
 {
 	const struct config_item_type *t = item->ci_type;
-	struct configfs_group_operations *ops;
+	const struct configfs_group_operations *ops;
 	struct configfs_attribute *attr;
 	struct configfs_bin_attribute *bin_attr;
 	int error = 0;
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 698520b1bfdb..31a7d7124460 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -65,7 +65,7 @@ extern void config_item_put(struct config_item *);
 struct config_item_type {
 	struct module				*ct_owner;
 	struct configfs_item_operations		*ct_item_ops;
-	struct configfs_group_operations	*ct_group_ops;
+	const struct configfs_group_operations	*ct_group_ops;
 	struct configfs_attribute		**ct_attrs;
 	struct configfs_bin_attribute		**ct_bin_attrs;
 };
-- 
2.51.0
Re: [PATCH 1/2] configfs: Constify ct_group_ops in struct config_item_type
Posted by Breno Leitao 3 months ago
On Sat, Oct 25, 2025 at 01:15:37PM +0200, Christophe JAILLET wrote:
> Make 'ct_group_ops' const in struct config_item_type.
> This allows constification of many structures which hold some function
> pointers.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Breno Leitao <leitao@debian.org>