]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sysfs: constify bin_attribute argument of bin_attribute::read/write()
authorThomas Weißschuh <linux@weissschuh.net>
Thu, 13 Mar 2025 15:57:45 +0000 (16:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Apr 2025 16:45:32 +0000 (18:45 +0200)
All callback implementers have been moved to the const variant of the
callbacks. The signature of the original callbacks can now be changed.
Also remove the now unnecessary transition machinery inside __BIN_ATTR().

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20250313-sysfs-const-bin_attr-final-v2-1-96284e1e88ce@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/sysfs.h

index 18f7e1fd093c9179a86aaa16f3f8851338778b0b..576b8b3c60afb382e4ce18247fd5a3d50f08d579 100644 (file)
@@ -306,11 +306,11 @@ struct bin_attribute {
        size_t                  size;
        void                    *private;
        struct address_space *(*f_mapping)(void);
-       ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *,
+       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 *, struct bin_attribute *,
+       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);
@@ -332,28 +332,11 @@ struct bin_attribute {
  */
 #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr)
 
-typedef ssize_t __sysfs_bin_rw_handler_new(struct file *, struct kobject *,
-                                          const struct bin_attribute *, char *, loff_t, size_t);
-
 /* macros to create static binary attributes easier */
 #define __BIN_ATTR(_name, _mode, _read, _write, _size) {               \
        .attr = { .name = __stringify(_name), .mode = _mode },          \
-       .read = _Generic(_read,                                         \
-               __sysfs_bin_rw_handler_new * : NULL,                    \
-               default : _read                                         \
-       ),                                                              \
-       .read_new = _Generic(_read,                                     \
-               __sysfs_bin_rw_handler_new * : _read,                   \
-               default : NULL                                          \
-       ),                                                              \
-       .write = _Generic(_write,                                       \
-               __sysfs_bin_rw_handler_new * : NULL,                    \
-               default : _write                                        \
-       ),                                                              \
-       .write_new = _Generic(_write,                                   \
-               __sysfs_bin_rw_handler_new * : _write,                  \
-               default : NULL                                          \
-       ),                                                              \
+       .read = _read,                                                  \
+       .write = _write,                                                \
        .size   = _size,                                                \
 }