The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v4 0/2] sysfs: finalize the constification of 'struct bin_attribute'
@ 2025-08-11  9:13 Thomas Weißschuh
  2025-08-11  9:13 ` [PATCH v4 1/2] sysfs: remove bin_attribute::read_new/write_new() Thomas Weißschuh
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2025-08-11  9:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich
  Cc: linux-kernel, Thomas Weißschuh

All users have been migrated to the new const types and variables.
Get rid of the transition machinery.

After applying, make sure no leftovers are left:
$ git grep bin_attrs_new
$ git grep read_new ':!drivers/block/swim_asm.S'
$ git grep write_new ':!drivers/cpufreq/powernow-k8.c' ':!drivers/s390/char/monwriter.c'

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Changes in v4:
- Drop already applied patches
- Rebase on v6.17-rc1
- Link to v3: https://lore.kernel.org/r/20250530-sysfs-const-bin_attr-final-v3-0-724bfcf05b99@weissschuh.net

Changes in v3:
- Drop already applied patches
- Constify internal references in fs/sysfs/file.c
- Update const_structs.checkpatch
- Rebase on linux-next/master
- Link to v2: https://lore.kernel.org/r/20250313-sysfs-const-bin_attr-final-v2-0-96284e1e88ce@weissschuh.net

Changes in v2:
- Rebase onto current driver-core-next.
- Remove prerequisites list from cover letter.
- Link to v1: https://lore.kernel.org/r/20250219-sysfs-const-bin_attr-final-v1-0-02828d86af3c@weissschuh.net

---
Thomas Weißschuh (2):
      sysfs: remove bin_attribute::read_new/write_new()
      sysfs: remove attribute_group::bin_attrs_new

 fs/sysfs/file.c       | 22 +++++-----------------
 include/linux/sysfs.h | 11 ++---------
 2 files changed, 7 insertions(+), 26 deletions(-)
---
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250217-sysfs-const-bin_attr-final-d9e4d0cf8a1d

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


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

* [PATCH v4 1/2] sysfs: remove bin_attribute::read_new/write_new()
  2025-08-11  9:13 [PATCH v4 0/2] sysfs: finalize the constification of 'struct bin_attribute' Thomas Weißschuh
@ 2025-08-11  9:13 ` Thomas Weißschuh
  2025-08-11  9:13 ` [PATCH v4 2/2] sysfs: remove attribute_group::bin_attrs_new Thomas Weißschuh
  2025-08-19 11:12 ` [PATCH v4 0/2] sysfs: finalize the constification of 'struct bin_attribute' Greg Kroah-Hartman
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2025-08-11  9:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich
  Cc: linux-kernel, Thomas Weißschuh

These transitional fields are now unused and unnecessary.
Remove them and their logic in the sysfs core.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 fs/sysfs/file.c       | 22 +++++-----------------
 include/linux/sysfs.h |  4 ----
 2 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 1ca143d2f22ad2d6b0b74b261514f8bc3cb5153c..3825e780cc580df4a1a511d12b3ee3fa2e6bdb37 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -97,12 +97,9 @@ static ssize_t sysfs_kf_bin_read(struct kernfs_open_file *of, char *buf,
 			count = size - pos;
 	}
 
-	if (!battr->read && !battr->read_new)
+	if (!battr->read)
 		return -EIO;
 
-	if (battr->read_new)
-		return battr->read_new(of->file, kobj, battr, buf, pos, count);
-
 	return battr->read(of->file, kobj, battr, buf, pos, count);
 }
 
@@ -161,12 +158,9 @@ static ssize_t sysfs_kf_bin_write(struct kernfs_open_file *of, char *buf,
 	if (!count)
 		return 0;
 
-	if (!battr->write && !battr->write_new)
+	if (!battr->write)
 		return -EIO;
 
-	if (battr->write_new)
-		return battr->write_new(of->file, kobj, battr, buf, pos, count);
-
 	return battr->write(of->file, kobj, battr, buf, pos, count);
 }
 
@@ -335,19 +329,13 @@ int sysfs_add_bin_file_mode_ns(struct kernfs_node *parent,
 	const struct kernfs_ops *ops;
 	struct kernfs_node *kn;
 
-	if (battr->read && battr->read_new)
-		return -EINVAL;
-
-	if (battr->write && battr->write_new)
-		return -EINVAL;
-
 	if (battr->mmap)
 		ops = &sysfs_bin_kfops_mmap;
-	else if ((battr->read || battr->read_new) && (battr->write || battr->write_new))
+	else if (battr->read && battr->write)
 		ops = &sysfs_bin_kfops_rw;
-	else if (battr->read || battr->read_new)
+	else if (battr->read)
 		ops = &sysfs_bin_kfops_ro;
-	else if (battr->write || battr->write_new)
+	else if (battr->write)
 		ops = &sysfs_bin_kfops_wo;
 	else
 		ops = &sysfs_file_kfops_empty;
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index f418aae4f1134f8126783d9e8eb575ba4278e927..7544f6d81c05982b5d168624f376cd647127ab51 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -308,12 +308,8 @@ struct bin_attribute {
 	struct address_space *(*f_mapping)(void);
 	ssize_t (*read)(struct file *, struct kobject *, const struct bin_attribute *,
 			char *, loff_t, size_t);
-	ssize_t (*read_new)(struct file *, struct kobject *, const struct bin_attribute *,
-			    char *, loff_t, size_t);
 	ssize_t (*write)(struct file *, struct kobject *, const struct bin_attribute *,
 			 char *, loff_t, size_t);
-	ssize_t (*write_new)(struct file *, struct kobject *,
-			     const struct bin_attribute *, char *, loff_t, size_t);
 	loff_t (*llseek)(struct file *, struct kobject *, const struct bin_attribute *,
 			 loff_t, int);
 	int (*mmap)(struct file *, struct kobject *, const struct bin_attribute *attr,

-- 
2.50.1


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

* [PATCH v4 2/2] sysfs: remove attribute_group::bin_attrs_new
  2025-08-11  9:13 [PATCH v4 0/2] sysfs: finalize the constification of 'struct bin_attribute' Thomas Weißschuh
  2025-08-11  9:13 ` [PATCH v4 1/2] sysfs: remove bin_attribute::read_new/write_new() Thomas Weißschuh
@ 2025-08-11  9:13 ` Thomas Weißschuh
  2025-08-19 11:12 ` [PATCH v4 0/2] sysfs: finalize the constification of 'struct bin_attribute' Greg Kroah-Hartman
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2025-08-11  9:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich
  Cc: linux-kernel, Thomas Weißschuh

This transitional field is now unused and unnecessary.
Remove it.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 include/linux/sysfs.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 7544f6d81c05982b5d168624f376cd647127ab51..9a25a29116528fab77d667390dd3ef5957b86554 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -106,10 +106,7 @@ struct attribute_group {
 					    const struct bin_attribute *,
 					    int);
 	struct attribute	**attrs;
-	union {
-		const struct bin_attribute	*const *bin_attrs;
-		const struct bin_attribute	*const *bin_attrs_new;
-	};
+	const struct bin_attribute	*const *bin_attrs;
 };
 
 #define SYSFS_PREALLOC		010000
@@ -293,7 +290,7 @@ __ATTRIBUTE_GROUPS(_name)
 
 #define BIN_ATTRIBUTE_GROUPS(_name)				\
 static const struct attribute_group _name##_group = {		\
-	.bin_attrs_new = _name##_attrs,				\
+	.bin_attrs = _name##_attrs,				\
 };								\
 __ATTRIBUTE_GROUPS(_name)
 

-- 
2.50.1


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

* Re: [PATCH v4 0/2] sysfs: finalize the constification of 'struct bin_attribute'
  2025-08-11  9:13 [PATCH v4 0/2] sysfs: finalize the constification of 'struct bin_attribute' Thomas Weißschuh
  2025-08-11  9:13 ` [PATCH v4 1/2] sysfs: remove bin_attribute::read_new/write_new() Thomas Weißschuh
  2025-08-11  9:13 ` [PATCH v4 2/2] sysfs: remove attribute_group::bin_attrs_new Thomas Weißschuh
@ 2025-08-19 11:12 ` Greg Kroah-Hartman
  2 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2025-08-19 11:12 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: Rafael J. Wysocki, Danilo Krummrich, linux-kernel

On Mon, Aug 11, 2025 at 11:13:34AM +0200, Thomas Weißschuh wrote:
> All users have been migrated to the new const types and variables.
> Get rid of the transition machinery.
> 
> After applying, make sure no leftovers are left:
> $ git grep bin_attrs_new
> $ git grep read_new ':!drivers/block/swim_asm.S'
> $ git grep write_new ':!drivers/cpufreq/powernow-k8.c' ':!drivers/s390/char/monwriter.c'

Looks good, thanks!

Finally queued up, sorry for the delay.

greg k-h

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

end of thread, other threads:[~2025-08-19 11:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-11  9:13 [PATCH v4 0/2] sysfs: finalize the constification of 'struct bin_attribute' Thomas Weißschuh
2025-08-11  9:13 ` [PATCH v4 1/2] sysfs: remove bin_attribute::read_new/write_new() Thomas Weißschuh
2025-08-11  9:13 ` [PATCH v4 2/2] sysfs: remove attribute_group::bin_attrs_new Thomas Weißschuh
2025-08-19 11:12 ` [PATCH v4 0/2] sysfs: finalize the constification of 'struct bin_attribute' Greg Kroah-Hartman

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