linux/fs/sysfs
Lukas Wunner d48c03198a sysfs: Add sysfs_bin_attr_simple_read() helper
When drivers expose a bin_attribute in sysfs which is backed by a buffer
in memory, a common pattern is to set the @private and @size members in
struct bin_attribute to the buffer's location and size.

The ->read() callback then merely consists of a single memcpy() call.
It's not even necessary to perform bounds checks as these are already
handled by sysfs_kf_bin_read().

However each driver is so far providing its own ->read() implementation.
The pattern is sufficiently frequent to merit a public helper, so add
sysfs_bin_attr_simple_read() as well as BIN_ATTR_SIMPLE_RO() and
BIN_ATTR_SIMPLE_ADMIN_RO() macros to ease declaration of such
bin_attributes and reduce LoC and .text section size.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/5ed62b197a442ec6db53d8746d9d806dd0576e2d.1712410202.git.lukas@wunner.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-11 16:02:25 +02:00
..
dir.c fs/sysfs/dir.c : Fix typo in comment 2023-12-07 11:35:23 +09:00
file.c sysfs: Add sysfs_bin_attr_simple_read() helper 2024-04-11 16:02:25 +02:00
group.c sysfs:Addresses documentation in sysfs_merge_group and sysfs_unmerge_group. 2024-03-07 22:04:50 +00:00
Kconfig
Makefile
mount.c kernfs: move struct kernfs_root out of the public view. 2022-02-23 15:46:34 +01:00
symlink.c docs: filesystems: fix renamed references 2020-04-20 15:45:22 -06:00
sysfs.h sysfs: split out binary attribute handling from sysfs_add_file_mode_ns 2021-09-14 16:59:46 +02:00