Skip to content

Commit 97d0680

Browse files
t-8chgregkh
authored andcommitted
sysfs: constify bin_attribute argument of bin_attribute::read/write()
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 <[email protected]> Link: https://lore.kernel.org/r/20250313-sysfs-const-bin_attr-final-v2-1-96284e1e88ce@weissschuh.net Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 31e4e12 commit 97d0680

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

include/linux/sysfs.h

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@ struct bin_attribute {
306306
size_t size;
307307
void *private;
308308
struct address_space *(*f_mapping)(void);
309-
ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *,
309+
ssize_t (*read)(struct file *, struct kobject *, const struct bin_attribute *,
310310
char *, loff_t, size_t);
311311
ssize_t (*read_new)(struct file *, struct kobject *, const struct bin_attribute *,
312312
char *, loff_t, size_t);
313-
ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *,
313+
ssize_t (*write)(struct file *, struct kobject *, const struct bin_attribute *,
314314
char *, loff_t, size_t);
315315
ssize_t (*write_new)(struct file *, struct kobject *,
316316
const struct bin_attribute *, char *, loff_t, size_t);
@@ -332,28 +332,11 @@ struct bin_attribute {
332332
*/
333333
#define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr)
334334

335-
typedef ssize_t __sysfs_bin_rw_handler_new(struct file *, struct kobject *,
336-
const struct bin_attribute *, char *, loff_t, size_t);
337-
338335
/* macros to create static binary attributes easier */
339336
#define __BIN_ATTR(_name, _mode, _read, _write, _size) { \
340337
.attr = { .name = __stringify(_name), .mode = _mode }, \
341-
.read = _Generic(_read, \
342-
__sysfs_bin_rw_handler_new * : NULL, \
343-
default : _read \
344-
), \
345-
.read_new = _Generic(_read, \
346-
__sysfs_bin_rw_handler_new * : _read, \
347-
default : NULL \
348-
), \
349-
.write = _Generic(_write, \
350-
__sysfs_bin_rw_handler_new * : NULL, \
351-
default : _write \
352-
), \
353-
.write_new = _Generic(_write, \
354-
__sysfs_bin_rw_handler_new * : _write, \
355-
default : NULL \
356-
), \
338+
.read = _read, \
339+
.write = _write, \
357340
.size = _size, \
358341
}
359342

0 commit comments

Comments
 (0)