diff options
author | Lukas Wunner <lukas@wunner.de> | 2024-04-06 16:52:01 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-04-11 17:02:25 +0300 |
commit | d48c03198a92edf41e89477dab4f602df15165ee (patch) | |
tree | c5b246c1c27d1914859f3ff26c5a80979c127083 /crypto/ansi_cprng.c | |
parent | 85d2b0aa170351380be39fe4ff7973df1427fe76 (diff) | |
download | linux-d48c03198a92edf41e89477dab4f602df15165ee.tar.xz |
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>
Diffstat (limited to 'crypto/ansi_cprng.c')
0 files changed, 0 insertions, 0 deletions