Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <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>

authored by

Thomas Weißschuh and committed by
Greg Kroah-Hartman
97d06802 31e4e12e

+4 -21
+4 -21
include/linux/sysfs.h
··· 306 306 size_t size; 307 307 void *private; 308 308 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 *, 310 310 char *, loff_t, size_t); 311 311 ssize_t (*read_new)(struct file *, struct kobject *, const struct bin_attribute *, 312 312 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 *, 314 314 char *, loff_t, size_t); 315 315 ssize_t (*write_new)(struct file *, struct kobject *, 316 316 const struct bin_attribute *, char *, loff_t, size_t); ··· 332 332 */ 333 333 #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) 334 334 335 - typedef ssize_t __sysfs_bin_rw_handler_new(struct file *, struct kobject *, 336 - const struct bin_attribute *, char *, loff_t, size_t); 337 - 338 335 /* macros to create static binary attributes easier */ 339 336 #define __BIN_ATTR(_name, _mode, _read, _write, _size) { \ 340 337 .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, \ 357 340 .size = _size, \ 358 341 } 359 342