]> www.infradead.org Git - users/jedix/linux-maple.git/commit
sysfs: bin_attribute: add const read/write callback variants
authorThomas Weißschuh <linux@weissschuh.net>
Sun, 3 Nov 2024 17:03:38 +0000 (17:03 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 Nov 2024 13:00:28 +0000 (14:00 +0100)
commiteb2e6c3a8d66ff37b2ee26cd32334ae0e05fd596
tree72b99b7824ff5928bb6ea7bc29f7139c4736a1fd
parentae587a509903cca138e910445d8c21fe73b45c80
sysfs: bin_attribute: add const read/write callback variants

To make it possible to put struct bin_attribute into read-only memory,
the sysfs core has to stop passing mutable pointers to the read() and
write() callbacks.
As there are numerous implementors of these callbacks throughout the
tree it's not possible to change all of them at once.
To enable a step-by-step transition, add new variants of the read() and
write() callbacks which differ only in the constness of the struct
bin_attribute argument.

As most binary attributes are defined through macros, extend these
macros to transparently handle both variants of callbacks to minimize
the churn during the transition.
As soon as all handlers are switch to the const variant, the non-const
one can be removed together with the transition machinery.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Krzysztof Wilczyński <kw@linux.com>
Link: https://lore.kernel.org/r/20241103-sysfs-const-bin_attr-v2-9-71110628844c@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/sysfs/file.c
include/linux/sysfs.h