Linux ACPI
 help / color / mirror / Atom feed
* [PATCH 0/6] configfs: Allow the registration of const struct configfs_attribute
@ 2026-07-16 17:09 Thomas Weißschuh
  2026-07-16 17:09 ` [PATCH 1/6] rust: configfs: remove mutability from some field initializers Thomas Weißschuh
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2026-07-16 17:09 UTC (permalink / raw)
  To: Andreas Hindborg, Breno Leitao, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	Dan Williams, Rafael J. Wysocki, Len Brown
  Cc: rust-for-linux, linux-kernel, intel-xe, dri-devel, linux-coco,
	linux-acpi, Thomas Weißschuh

The attribute structure defined in driver code never need to be
modified. Allow them to be marked as const.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Thomas Weißschuh (6):
      rust: configfs: remove mutability from some field initializers
      configfs: Constify is_visible/is_visible_bin in configfs_group_operations
      configfs: Treat attribute structures as const internally
      configfs: Constify configfs_bin_attribute
      configfs: Allow the registration of const struct configfs_attribute
      samples: configfs: constify the configfs_attribute structures

 drivers/acpi/acpi_configfs.c       |  2 +-
 drivers/gpu/drm/xe/xe_configfs.c   |  4 +--
 drivers/virt/coco/guest/report.c   |  6 ++--
 fs/configfs/configfs_internal.h    | 10 +++---
 fs/configfs/dir.c                  | 10 +++---
 fs/configfs/file.c                 |  6 ++--
 fs/configfs/inode.c                |  2 +-
 include/linux/configfs.h           | 73 ++++++++++++++++++++------------------
 rust/kernel/configfs.rs            | 20 ++++++-----
 samples/configfs/configfs_sample.c | 16 ++++-----
 10 files changed, 78 insertions(+), 71 deletions(-)
---
base-commit: c8d07eca6270b3f41c0e528a470895f1bd42e2b7
change-id: 20260716-configfs-const-base-6955b043560b

Best regards,
--  
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/6] rust: configfs: remove mutability from some field initializers
  2026-07-16 17:09 [PATCH 0/6] configfs: Allow the registration of const struct configfs_attribute Thomas Weißschuh
@ 2026-07-16 17:09 ` Thomas Weißschuh
  2026-07-16 17:09 ` [PATCH 2/6] configfs: Constify is_visible/is_visible_bin in configfs_group_operations Thomas Weißschuh
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2026-07-16 17:09 UTC (permalink / raw)
  To: Andreas Hindborg, Breno Leitao, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	Dan Williams, Rafael J. Wysocki, Len Brown
  Cc: rust-for-linux, linux-kernel, intel-xe, dri-devel, linux-coco,
	linux-acpi, Thomas Weißschuh

These fields do not require mutable pointers.

Use regular immutable ones.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 rust/kernel/configfs.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/rust/kernel/configfs.rs b/rust/kernel/configfs.rs
index 2339c6467325..b33fb2e9adf1 100644
--- a/rust/kernel/configfs.rs
+++ b/rust/kernel/configfs.rs
@@ -754,8 +754,8 @@ pub const fn new_with_child_ctor<const N: usize, Child>(
                 Self {
                     item_type: Opaque::new(bindings::config_item_type {
                         ct_owner: owner.as_ptr(),
-                        ct_group_ops: GroupOperationsVTable::<Data, Child>::vtable_ptr().cast_mut(),
-                        ct_item_ops: ItemOperationsVTable::<$tpe, Data>::vtable_ptr().cast_mut(),
+                        ct_group_ops: GroupOperationsVTable::<Data, Child>::vtable_ptr(),
+                        ct_item_ops: ItemOperationsVTable::<$tpe, Data>::vtable_ptr(),
                         ct_attrs: core::ptr::from_ref(attributes).cast_mut().cast(),
                         ct_bin_attrs: core::ptr::null_mut(),
                     }),
@@ -771,8 +771,8 @@ pub const fn new<const N: usize>(
                 Self {
                     item_type: Opaque::new(bindings::config_item_type {
                         ct_owner: owner.as_ptr(),
-                        ct_group_ops: core::ptr::null_mut(),
-                        ct_item_ops: ItemOperationsVTable::<$tpe, Data>::vtable_ptr().cast_mut(),
+                        ct_group_ops: core::ptr::null(),
+                        ct_item_ops: ItemOperationsVTable::<$tpe, Data>::vtable_ptr(),
                         ct_attrs: core::ptr::from_ref(attributes).cast_mut().cast(),
                         ct_bin_attrs: core::ptr::null_mut(),
                     }),

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/6] configfs: Constify is_visible/is_visible_bin in configfs_group_operations
  2026-07-16 17:09 [PATCH 0/6] configfs: Allow the registration of const struct configfs_attribute Thomas Weißschuh
  2026-07-16 17:09 ` [PATCH 1/6] rust: configfs: remove mutability from some field initializers Thomas Weißschuh
@ 2026-07-16 17:09 ` Thomas Weißschuh
  2026-07-17  8:12   ` Breno Leitao
  2026-07-16 17:09 ` [PATCH 3/6] configfs: Treat attribute structures as const internally Thomas Weißschuh
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Thomas Weißschuh @ 2026-07-16 17:09 UTC (permalink / raw)
  To: Andreas Hindborg, Breno Leitao, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	Dan Williams, Rafael J. Wysocki, Len Brown
  Cc: rust-for-linux, linux-kernel, intel-xe, dri-devel, linux-coco,
	linux-acpi, Thomas Weißschuh

These callbacks are never meant to modify their configfs_attribute
structure. Enforce this in the type system.

As there are only two implementers of these callbacks, adapt them right
away, avoiding a phased transition.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 drivers/gpu/drm/xe/xe_configfs.c | 4 ++--
 drivers/virt/coco/guest/report.c | 4 ++--
 include/linux/configfs.h         | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
index 32102600a148..a5f696e7b329 100644
--- a/drivers/gpu/drm/xe/xe_configfs.c
+++ b/drivers/gpu/drm/xe/xe_configfs.c
@@ -843,7 +843,7 @@ static struct configfs_item_operations xe_config_device_ops = {
 };
 
 static bool xe_config_device_is_visible(struct config_item *item,
-					struct configfs_attribute *attr, int n)
+					const struct configfs_attribute *attr, int n)
 {
 	struct xe_config_group_device *dev = to_xe_config_group_device(item);
 
@@ -938,7 +938,7 @@ static struct configfs_attribute *xe_config_sriov_attrs[] = {
 };
 
 static bool xe_config_sriov_is_visible(struct config_item *item,
-				       struct configfs_attribute *attr, int n)
+				       const struct configfs_attribute *attr, int n)
 {
 	struct xe_config_group_device *dev = to_xe_config_group_device(item->ci_parent);
 
diff --git a/drivers/virt/coco/guest/report.c b/drivers/virt/coco/guest/report.c
index b254a1416286..96e89ddf4989 100644
--- a/drivers/virt/coco/guest/report.c
+++ b/drivers/virt/coco/guest/report.c
@@ -381,7 +381,7 @@ static struct configfs_item_operations tsm_report_item_ops = {
 };
 
 static bool tsm_report_is_visible(struct config_item *item,
-				  struct configfs_attribute *attr, int n)
+				  const struct configfs_attribute *attr, int n)
 {
 	guard(rwsem_read)(&tsm_rwsem);
 	if (!provider.ops)
@@ -394,7 +394,7 @@ static bool tsm_report_is_visible(struct config_item *item,
 }
 
 static bool tsm_report_is_bin_visible(struct config_item *item,
-				      struct configfs_bin_attribute *attr, int n)
+				      const struct configfs_bin_attribute *attr, int n)
 {
 	guard(rwsem_read)(&tsm_rwsem);
 	if (!provider.ops)
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index ef65c75beeaa..5d3fc8822a1d 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -220,8 +220,8 @@ struct configfs_group_operations {
 	struct config_group *(*make_group)(struct config_group *group, const char *name);
 	void (*disconnect_notify)(struct config_group *group, struct config_item *item);
 	void (*drop_item)(struct config_group *group, struct config_item *item);
-	bool (*is_visible)(struct config_item *item, struct configfs_attribute *attr, int n);
-	bool (*is_bin_visible)(struct config_item *item, struct configfs_bin_attribute *attr,
+	bool (*is_visible)(struct config_item *item, const struct configfs_attribute *attr, int n);
+	bool (*is_bin_visible)(struct config_item *item, const struct configfs_bin_attribute *attr,
 			       int n);
 };
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/6] configfs: Treat attribute structures as const internally
  2026-07-16 17:09 [PATCH 0/6] configfs: Allow the registration of const struct configfs_attribute Thomas Weißschuh
  2026-07-16 17:09 ` [PATCH 1/6] rust: configfs: remove mutability from some field initializers Thomas Weißschuh
  2026-07-16 17:09 ` [PATCH 2/6] configfs: Constify is_visible/is_visible_bin in configfs_group_operations Thomas Weißschuh
@ 2026-07-16 17:09 ` Thomas Weißschuh
  2026-07-16 17:09 ` [PATCH 4/6] configfs: Constify configfs_bin_attribute Thomas Weißschuh
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2026-07-16 17:09 UTC (permalink / raw)
  To: Andreas Hindborg, Breno Leitao, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	Dan Williams, Rafael J. Wysocki, Len Brown
  Cc: rust-for-linux, linux-kernel, intel-xe, dri-devel, linux-coco,
	linux-acpi, Thomas Weißschuh

The configfs core never modifies the attribute structures defined in
driver core.

Reflect this in the types used internally in the configfs core.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 fs/configfs/configfs_internal.h | 10 +++++-----
 fs/configfs/dir.c               |  6 +++---
 fs/configfs/file.c              |  6 +++---
 fs/configfs/inode.c             |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h
index acdeea8e2d69..4bc19cd8d666 100644
--- a/fs/configfs/configfs_internal.h
+++ b/fs/configfs/configfs_internal.h
@@ -104,17 +104,17 @@ static inline struct config_item * to_item(struct dentry * dentry)
 	return ((struct config_item *) sd->s_element);
 }
 
-static inline struct configfs_attribute * to_attr(struct dentry * dentry)
+static inline const struct configfs_attribute * to_attr(struct dentry * dentry)
 {
 	struct configfs_dirent * sd = dentry->d_fsdata;
-	return ((struct configfs_attribute *) sd->s_element);
+	return ((const struct configfs_attribute *) sd->s_element);
 }
 
-static inline struct configfs_bin_attribute *to_bin_attr(struct dentry *dentry)
+static inline const struct configfs_bin_attribute *to_bin_attr(struct dentry *dentry)
 {
-	struct configfs_attribute *attr = to_attr(dentry);
+	const struct configfs_attribute *attr = to_attr(dentry);
 
-	return container_of(attr, struct configfs_bin_attribute, cb_attr);
+	return container_of_const(attr, struct configfs_bin_attribute, cb_attr);
 }
 
 static inline struct config_item *configfs_get_config_item(struct dentry *dentry)
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 3c88f13f1ca2..9a5c2bc4065d 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -461,7 +461,7 @@ static struct dentry * configfs_lookup(struct inode *dir,
 		 */
 		if ((sd->s_type & CONFIGFS_NOT_PINNED) &&
 		    !strcmp(configfs_get_name(sd), dentry->d_name.name)) {
-			struct configfs_attribute *attr = sd->s_element;
+			const struct configfs_attribute *attr = sd->s_element;
 			umode_t mode = (attr->ca_mode & S_IALLUGO) | S_IFREG;
 
 			dentry->d_fsdata = configfs_get(sd);
@@ -622,8 +622,8 @@ static int populate_attrs(struct config_item *item)
 {
 	const struct config_item_type *t = item->ci_type;
 	const struct configfs_group_operations *ops;
-	struct configfs_attribute *attr;
-	struct configfs_bin_attribute *bin_attr;
+	const struct configfs_attribute *attr;
+	const struct configfs_bin_attribute *bin_attr;
 	int error = 0;
 	int i;
 
diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index a48cece775a3..6460b000c593 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -41,8 +41,8 @@ struct configfs_buffer {
 	struct config_item	*item;
 	struct module		*owner;
 	union {
-		struct configfs_attribute	*attr;
-		struct configfs_bin_attribute	*bin_attr;
+		const struct configfs_attribute		*attr;
+		const struct configfs_bin_attribute	*bin_attr;
 	};
 };
 
@@ -291,7 +291,7 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type
 {
 	struct dentry *dentry = file->f_path.dentry;
 	struct configfs_fragment *frag = to_frag(file);
-	struct configfs_attribute *attr;
+	const struct configfs_attribute *attr;
 	struct configfs_buffer *buffer;
 	int error;
 
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index 68290fe0e374..69f1f24e890f 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -178,7 +178,7 @@ struct inode *configfs_create(struct dentry *dentry, umode_t mode)
  */
 const unsigned char * configfs_get_name(struct configfs_dirent *sd)
 {
-	struct configfs_attribute *attr;
+	const struct configfs_attribute *attr;
 
 	BUG_ON(!sd || !sd->s_element);
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/6] configfs: Constify configfs_bin_attribute
  2026-07-16 17:09 [PATCH 0/6] configfs: Allow the registration of const struct configfs_attribute Thomas Weißschuh
                   ` (2 preceding siblings ...)
  2026-07-16 17:09 ` [PATCH 3/6] configfs: Treat attribute structures as const internally Thomas Weißschuh
@ 2026-07-16 17:09 ` Thomas Weißschuh
  2026-07-16 17:09 ` [PATCH 5/6] configfs: Allow the registration of const struct configfs_attribute Thomas Weißschuh
  2026-07-16 17:09 ` [PATCH 6/6] samples: configfs: constify the configfs_attribute structures Thomas Weißschuh
  5 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2026-07-16 17:09 UTC (permalink / raw)
  To: Andreas Hindborg, Breno Leitao, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	Dan Williams, Rafael J. Wysocki, Len Brown
  Cc: rust-for-linux, linux-kernel, intel-xe, dri-devel, linux-coco,
	linux-acpi, Thomas Weißschuh

The configfs_bin_attribute structures defined by driver are never
modified. Make them const.

As there are only two users of these attributes, adapt them in the same
commit to avoid a phased transition.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 drivers/acpi/acpi_configfs.c     |  2 +-
 drivers/virt/coco/guest/report.c |  2 +-
 include/linux/configfs.h         | 64 ++++++++++++++++++++--------------------
 rust/kernel/configfs.rs          |  4 +--
 4 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/drivers/acpi/acpi_configfs.c b/drivers/acpi/acpi_configfs.c
index 12ffec795803..6071699c7165 100644
--- a/drivers/acpi/acpi_configfs.c
+++ b/drivers/acpi/acpi_configfs.c
@@ -91,7 +91,7 @@ static ssize_t acpi_table_aml_read(struct config_item *cfg,
 
 CONFIGFS_BIN_ATTR(acpi_table_, aml, NULL, MAX_ACPI_TABLE_SIZE);
 
-static struct configfs_bin_attribute *acpi_table_bin_attrs[] = {
+static const struct configfs_bin_attribute *const acpi_table_bin_attrs[] = {
 	&acpi_table_attr_aml,
 	NULL,
 };
diff --git a/drivers/virt/coco/guest/report.c b/drivers/virt/coco/guest/report.c
index 96e89ddf4989..ad400fbe53f0 100644
--- a/drivers/virt/coco/guest/report.c
+++ b/drivers/virt/coco/guest/report.c
@@ -356,7 +356,7 @@ static struct configfs_attribute *tsm_report_attrs[] = {
 	NULL,
 };
 
-static struct configfs_bin_attribute *tsm_report_bin_attrs[] = {
+static const struct configfs_bin_attribute *const tsm_report_bin_attrs[] = {
 	[TSM_REPORT_INBLOB] = &tsm_report_attr_inblob,
 	[TSM_REPORT_OUTBLOB] = &tsm_report_attr_outblob,
 	[TSM_REPORT_AUXBLOB] = &tsm_report_attr_auxblob,
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 5d3fc8822a1d..eff2fb22ab70 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -67,7 +67,7 @@ struct config_item_type {
 	const struct configfs_item_operations	*ct_item_ops;
 	const struct configfs_group_operations	*ct_group_ops;
 	struct configfs_attribute		**ct_attrs;
-	struct configfs_bin_attribute		**ct_bin_attrs;
+	const struct configfs_bin_attribute	*const *ct_bin_attrs;
 };
 
 /**
@@ -160,41 +160,41 @@ struct configfs_bin_attribute {
 	ssize_t (*write)(struct config_item *, const void *, size_t);
 };
 
-#define CONFIGFS_BIN_ATTR(_pfx, _name, _priv, _maxsz)		\
-static struct configfs_bin_attribute _pfx##attr_##_name = {	\
-	.cb_attr = {						\
-		.ca_name	= __stringify(_name),		\
-		.ca_mode	= S_IRUGO | S_IWUSR,		\
-		.ca_owner	= THIS_MODULE,			\
-	},							\
-	.cb_private	= _priv,				\
-	.cb_max_size	= _maxsz,				\
-	.read		= _pfx##_name##_read,			\
-	.write		= _pfx##_name##_write,			\
+#define CONFIGFS_BIN_ATTR(_pfx, _name, _priv, _maxsz)			\
+static const struct configfs_bin_attribute _pfx##attr_##_name = {	\
+	.cb_attr = {							\
+		.ca_name	= __stringify(_name),			\
+		.ca_mode	= S_IRUGO | S_IWUSR,			\
+		.ca_owner	= THIS_MODULE,				\
+	},								\
+	.cb_private	= _priv,					\
+	.cb_max_size	= _maxsz,					\
+	.read		= _pfx##_name##_read,				\
+	.write		= _pfx##_name##_write,				\
 }
 
-#define CONFIGFS_BIN_ATTR_RO(_pfx, _name, _priv, _maxsz)	\
-static struct configfs_bin_attribute _pfx##attr_##_name = {	\
-	.cb_attr = {						\
-		.ca_name	= __stringify(_name),		\
-		.ca_mode	= S_IRUGO,			\
-		.ca_owner	= THIS_MODULE,			\
-	},							\
-	.cb_private	= _priv,				\
-	.cb_max_size	= _maxsz,				\
-	.read		= _pfx##_name##_read,			\
+#define CONFIGFS_BIN_ATTR_RO(_pfx, _name, _priv, _maxsz)		\
+static const struct configfs_bin_attribute _pfx##attr_##_name = {	\
+	.cb_attr = {							\
+		.ca_name	= __stringify(_name),			\
+		.ca_mode	= S_IRUGO,				\
+		.ca_owner	= THIS_MODULE,				\
+	},								\
+	.cb_private	= _priv,					\
+	.cb_max_size	= _maxsz,					\
+	.read		= _pfx##_name##_read,				\
 }
 
-#define CONFIGFS_BIN_ATTR_WO(_pfx, _name, _priv, _maxsz)	\
-static struct configfs_bin_attribute _pfx##attr_##_name = {	\
-	.cb_attr = {						\
-		.ca_name	= __stringify(_name),		\
-		.ca_mode	= S_IWUSR,			\
-		.ca_owner	= THIS_MODULE,			\
-	},							\
-	.cb_private	= _priv,				\
-	.cb_max_size	= _maxsz,				\
-	.write		= _pfx##_name##_write,			\
+#define CONFIGFS_BIN_ATTR_WO(_pfx, _name, _priv, _maxsz)		\
+static const struct configfs_bin_attribute _pfx##attr_##_name = {	\
+	.cb_attr = {							\
+		.ca_name	= __stringify(_name),			\
+		.ca_mode	= S_IWUSR,				\
+		.ca_owner	= THIS_MODULE,				\
+	},								\
+	.cb_private	= _priv,					\
+	.cb_max_size	= _maxsz,					\
+	.write		= _pfx##_name##_write,				\
 }
 
 /*
diff --git a/rust/kernel/configfs.rs b/rust/kernel/configfs.rs
index b33fb2e9adf1..f99a6e376fa3 100644
--- a/rust/kernel/configfs.rs
+++ b/rust/kernel/configfs.rs
@@ -757,7 +757,7 @@ pub const fn new_with_child_ctor<const N: usize, Child>(
                         ct_group_ops: GroupOperationsVTable::<Data, Child>::vtable_ptr(),
                         ct_item_ops: ItemOperationsVTable::<$tpe, Data>::vtable_ptr(),
                         ct_attrs: core::ptr::from_ref(attributes).cast_mut().cast(),
-                        ct_bin_attrs: core::ptr::null_mut(),
+                        ct_bin_attrs: core::ptr::null(),
                     }),
                     _p: PhantomData,
                 }
@@ -774,7 +774,7 @@ pub const fn new<const N: usize>(
                         ct_group_ops: core::ptr::null(),
                         ct_item_ops: ItemOperationsVTable::<$tpe, Data>::vtable_ptr(),
                         ct_attrs: core::ptr::from_ref(attributes).cast_mut().cast(),
-                        ct_bin_attrs: core::ptr::null_mut(),
+                        ct_bin_attrs: core::ptr::null(),
                     }),
                     _p: PhantomData,
                 }

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/6] configfs: Allow the registration of const struct configfs_attribute
  2026-07-16 17:09 [PATCH 0/6] configfs: Allow the registration of const struct configfs_attribute Thomas Weißschuh
                   ` (3 preceding siblings ...)
  2026-07-16 17:09 ` [PATCH 4/6] configfs: Constify configfs_bin_attribute Thomas Weißschuh
@ 2026-07-16 17:09 ` Thomas Weißschuh
  2026-07-17  8:43   ` Breno Leitao
  2026-07-16 17:09 ` [PATCH 6/6] samples: configfs: constify the configfs_attribute structures Thomas Weißschuh
  5 siblings, 1 reply; 11+ messages in thread
From: Thomas Weißschuh @ 2026-07-16 17:09 UTC (permalink / raw)
  To: Andreas Hindborg, Breno Leitao, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	Dan Williams, Rafael J. Wysocki, Len Brown
  Cc: rust-for-linux, linux-kernel, intel-xe, dri-devel, linux-coco,
	linux-acpi, Thomas Weißschuh

The attribute structure defined in driver code never need to be
modified. Allow them to be marked as const.

As there are many drivers which use these attributes, prepare for a
phased transition by using a union of const and non-const attributes.

After all drivers have been migrated to the const variant, the non-const
one can be replaced by the const one and the transition machinery will
be removed again.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 fs/configfs/dir.c        | 4 ++--
 include/linux/configfs.h | 5 ++++-
 rust/kernel/configfs.rs  | 8 ++++++--
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 9a5c2bc4065d..c2152288517c 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -632,8 +632,8 @@ static int populate_attrs(struct config_item *item)
 
 	ops = t->ct_group_ops;
 
-	if (t->ct_attrs) {
-		for (i = 0; (attr = t->ct_attrs[i]) != NULL; i++) {
+	if (t->ct_attrs_const) {
+		for (i = 0; (attr = t->ct_attrs_const[i]) != NULL; i++) {
 			if (ops && ops->is_visible && !ops->is_visible(item, attr, i))
 				continue;
 
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index eff2fb22ab70..5bead9173ec1 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -66,7 +66,10 @@ struct config_item_type {
 	struct module				*ct_owner;
 	const struct configfs_item_operations	*ct_item_ops;
 	const struct configfs_group_operations	*ct_group_ops;
-	struct configfs_attribute		**ct_attrs;
+	union {
+		struct configfs_attribute		**ct_attrs;
+		const struct configfs_attribute		*const *ct_attrs_const;
+	};
 	const struct configfs_bin_attribute	*const *ct_bin_attrs;
 };
 
diff --git a/rust/kernel/configfs.rs b/rust/kernel/configfs.rs
index f99a6e376fa3..2ef9cce693b9 100644
--- a/rust/kernel/configfs.rs
+++ b/rust/kernel/configfs.rs
@@ -756,7 +756,9 @@ pub const fn new_with_child_ctor<const N: usize, Child>(
                         ct_owner: owner.as_ptr(),
                         ct_group_ops: GroupOperationsVTable::<Data, Child>::vtable_ptr(),
                         ct_item_ops: ItemOperationsVTable::<$tpe, Data>::vtable_ptr(),
-                        ct_attrs: core::ptr::from_ref(attributes).cast_mut().cast(),
+                        __bindgen_anon_1: bindings::config_item_type__bindgen_ty_1 {
+                            ct_attrs_const: core::ptr::from_ref(attributes).cast(),
+                        },
                         ct_bin_attrs: core::ptr::null(),
                     }),
                     _p: PhantomData,
@@ -773,7 +775,9 @@ pub const fn new<const N: usize>(
                         ct_owner: owner.as_ptr(),
                         ct_group_ops: core::ptr::null(),
                         ct_item_ops: ItemOperationsVTable::<$tpe, Data>::vtable_ptr(),
-                        ct_attrs: core::ptr::from_ref(attributes).cast_mut().cast(),
+                        __bindgen_anon_1: bindings::config_item_type__bindgen_ty_1 {
+                            ct_attrs_const: core::ptr::from_ref(attributes).cast(),
+                        },
                         ct_bin_attrs: core::ptr::null(),
                     }),
                     _p: PhantomData,

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 6/6] samples: configfs: constify the configfs_attribute structures
  2026-07-16 17:09 [PATCH 0/6] configfs: Allow the registration of const struct configfs_attribute Thomas Weißschuh
                   ` (4 preceding siblings ...)
  2026-07-16 17:09 ` [PATCH 5/6] configfs: Allow the registration of const struct configfs_attribute Thomas Weißschuh
@ 2026-07-16 17:09 ` Thomas Weißschuh
  2026-07-17  8:42   ` Breno Leitao
  5 siblings, 1 reply; 11+ messages in thread
From: Thomas Weißschuh @ 2026-07-16 17:09 UTC (permalink / raw)
  To: Andreas Hindborg, Breno Leitao, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	Dan Williams, Rafael J. Wysocki, Len Brown
  Cc: rust-for-linux, linux-kernel, intel-xe, dri-devel, linux-coco,
	linux-acpi, Thomas Weißschuh

To show that the transition machinery works, constify the sample code.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 samples/configfs/configfs_sample.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/samples/configfs/configfs_sample.c b/samples/configfs/configfs_sample.c
index c1b108ec4ea0..9788ec9b8e30 100644
--- a/samples/configfs/configfs_sample.c
+++ b/samples/configfs/configfs_sample.c
@@ -84,7 +84,7 @@ CONFIGFS_ATTR_RO(childless_, showme);
 CONFIGFS_ATTR(childless_, storeme);
 CONFIGFS_ATTR_RO(childless_, description);
 
-static struct configfs_attribute *childless_attrs[] = {
+static const struct configfs_attribute *const childless_attrs[] = {
 	&childless_attr_showme,
 	&childless_attr_storeme,
 	&childless_attr_description,
@@ -92,7 +92,7 @@ static struct configfs_attribute *childless_attrs[] = {
 };
 
 static const struct config_item_type childless_type = {
-	.ct_attrs	= childless_attrs,
+	.ct_attrs_const	= childless_attrs,
 	.ct_owner	= THIS_MODULE,
 };
 
@@ -148,7 +148,7 @@ static ssize_t simple_child_storeme_store(struct config_item *item,
 
 CONFIGFS_ATTR(simple_child_, storeme);
 
-static struct configfs_attribute *simple_child_attrs[] = {
+static const struct configfs_attribute *const simple_child_attrs[] = {
 	&simple_child_attr_storeme,
 	NULL,
 };
@@ -164,7 +164,7 @@ static const struct configfs_item_operations simple_child_item_ops = {
 
 static const struct config_item_type simple_child_type = {
 	.ct_item_ops	= &simple_child_item_ops,
-	.ct_attrs	= simple_child_attrs,
+	.ct_attrs_const	= simple_child_attrs,
 	.ct_owner	= THIS_MODULE,
 };
 
@@ -205,7 +205,7 @@ static ssize_t simple_children_description_show(struct config_item *item,
 
 CONFIGFS_ATTR_RO(simple_children_, description);
 
-static struct configfs_attribute *simple_children_attrs[] = {
+static const struct configfs_attribute *const simple_children_attrs[] = {
 	&simple_children_attr_description,
 	NULL,
 };
@@ -230,7 +230,7 @@ static const struct configfs_group_operations simple_children_group_ops = {
 static const struct config_item_type simple_children_type = {
 	.ct_item_ops	= &simple_children_item_ops,
 	.ct_group_ops	= &simple_children_group_ops,
-	.ct_attrs	= simple_children_attrs,
+	.ct_attrs_const	= simple_children_attrs,
 	.ct_owner	= THIS_MODULE,
 };
 
@@ -283,7 +283,7 @@ static ssize_t group_children_description_show(struct config_item *item,
 
 CONFIGFS_ATTR_RO(group_children_, description);
 
-static struct configfs_attribute *group_children_attrs[] = {
+static const struct configfs_attribute *const group_children_attrs[] = {
 	&group_children_attr_description,
 	NULL,
 };
@@ -298,7 +298,7 @@ static const struct configfs_group_operations group_children_group_ops = {
 
 static const struct config_item_type group_children_type = {
 	.ct_group_ops	= &group_children_group_ops,
-	.ct_attrs	= group_children_attrs,
+	.ct_attrs_const	= group_children_attrs,
 	.ct_owner	= THIS_MODULE,
 };
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/6] configfs: Constify is_visible/is_visible_bin in configfs_group_operations
  2026-07-16 17:09 ` [PATCH 2/6] configfs: Constify is_visible/is_visible_bin in configfs_group_operations Thomas Weißschuh
@ 2026-07-17  8:12   ` Breno Leitao
  0 siblings, 0 replies; 11+ messages in thread
From: Breno Leitao @ 2026-07-17  8:12 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Andreas Hindborg, Miguel Ojeda, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	Dan Williams, Rafael J. Wysocki, Len Brown, rust-for-linux,
	linux-kernel, intel-xe, dri-devel, linux-coco, linux-acpi

On Thu, Jul 16, 2026 at 07:09:27PM +0200, Thomas Weißschuh wrote:
> These callbacks are never meant to modify their configfs_attribute
> structure. Enforce this in the type system.
> 
> As there are only two implementers of these callbacks, adapt them right
> away, avoiding a phased transition.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 6/6] samples: configfs: constify the configfs_attribute structures
  2026-07-16 17:09 ` [PATCH 6/6] samples: configfs: constify the configfs_attribute structures Thomas Weißschuh
@ 2026-07-17  8:42   ` Breno Leitao
  0 siblings, 0 replies; 11+ messages in thread
From: Breno Leitao @ 2026-07-17  8:42 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Andreas Hindborg, Miguel Ojeda, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	Dan Williams, Rafael J. Wysocki, Len Brown, rust-for-linux,
	linux-kernel, intel-xe, dri-devel, linux-coco, linux-acpi

On Thu, Jul 16, 2026 at 07:09:31PM +0200, Thomas Weißschuh wrote:
> To show that the transition machinery works, constify the sample code.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 5/6] configfs: Allow the registration of const struct configfs_attribute
  2026-07-16 17:09 ` [PATCH 5/6] configfs: Allow the registration of const struct configfs_attribute Thomas Weißschuh
@ 2026-07-17  8:43   ` Breno Leitao
  2026-07-17 15:35     ` Thomas Weißschuh
  0 siblings, 1 reply; 11+ messages in thread
From: Breno Leitao @ 2026-07-17  8:43 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Andreas Hindborg, Miguel Ojeda, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	Dan Williams, Rafael J. Wysocki, Len Brown, rust-for-linux,
	linux-kernel, intel-xe, dri-devel, linux-coco, linux-acpi

On Thu, Jul 16, 2026 at 07:09:30PM +0200, Thomas Weißschuh wrote:
> The attribute structure defined in driver code never need to be
> modified. Allow them to be marked as const.
> 
> As there are many drivers which use these attributes, prepare for a
> phased transition by using a union of const and non-const attributes.

How many drivers need to be migrated? Isn't this a mechanism move?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 5/6] configfs: Allow the registration of const struct configfs_attribute
  2026-07-17  8:43   ` Breno Leitao
@ 2026-07-17 15:35     ` Thomas Weißschuh
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2026-07-17 15:35 UTC (permalink / raw)
  To: Breno Leitao
  Cc: Andreas Hindborg, Miguel Ojeda, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	Dan Williams, Rafael J. Wysocki, Len Brown, rust-for-linux,
	linux-kernel, intel-xe, dri-devel, linux-coco, linux-acpi

On 2026-07-17 01:43:36-0700, Breno Leitao wrote:
> On Thu, Jul 16, 2026 at 07:09:30PM +0200, Thomas Weißschuh wrote:
> > The attribute structure defined in driver code never need to be
> > modified. Allow them to be marked as const.
> > 
> > As there are many drivers which use these attributes, prepare for a
> > phased transition by using a union of const and non-const attributes.
> 
> How many drivers need to be migrated? Isn't this a mechanism move?

The actual constification of the attribute will happen with a central
change to the CONFIGFS_ATTR* macros. But all users of the macro
will need to be prepared to handle the constness.

I have a branch with the full conversion here:

https://git.kernel.org/pub/scm/linux/kernel/git/thomas.weissschuh/linux.git/log/?h=b4/configfs-const

 73 files changed, 241 insertions(+), 248 deletions(-)

 Most driver changes are really trivial. But a few do more interesting
 things. My goal is to heavily reduce the amount of patches in this
 branch by merging patches to the same subsystem.

 The last four patches will be the finalization going again through
 the configfs tree.


 Thomas

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-07-17 15:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16 17:09 [PATCH 0/6] configfs: Allow the registration of const struct configfs_attribute Thomas Weißschuh
2026-07-16 17:09 ` [PATCH 1/6] rust: configfs: remove mutability from some field initializers Thomas Weißschuh
2026-07-16 17:09 ` [PATCH 2/6] configfs: Constify is_visible/is_visible_bin in configfs_group_operations Thomas Weißschuh
2026-07-17  8:12   ` Breno Leitao
2026-07-16 17:09 ` [PATCH 3/6] configfs: Treat attribute structures as const internally Thomas Weißschuh
2026-07-16 17:09 ` [PATCH 4/6] configfs: Constify configfs_bin_attribute Thomas Weißschuh
2026-07-16 17:09 ` [PATCH 5/6] configfs: Allow the registration of const struct configfs_attribute Thomas Weißschuh
2026-07-17  8:43   ` Breno Leitao
2026-07-17 15:35     ` Thomas Weißschuh
2026-07-16 17:09 ` [PATCH 6/6] samples: configfs: constify the configfs_attribute structures Thomas Weißschuh
2026-07-17  8:42   ` Breno Leitao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox