]> www.infradead.org Git - users/jedix/linux-maple.git/commit
sysfs: introduce callback attribute_group::bin_size
authorThomas Weißschuh <linux@weissschuh.net>
Sun, 3 Nov 2024 17:03:31 +0000 (17:03 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 Nov 2024 13:00:28 +0000 (14:00 +0100)
commitbebf29b18f34620e25f7e2bd9e4e4d8e34a8977d
treec18a29612d16c0c23471702f3023e093c1f9c100
parent0afcee132bbc9d7ef9c5bb4da9b6fe014a9afaa9
sysfs: introduce callback attribute_group::bin_size

Several drivers need to dynamically calculate the size of an binary
attribute. Currently this is done by assigning attr->size from the
is_bin_visible() callback.

This has drawbacks:
* It is not documented.
* A single attribute can be instantiated multiple times, overwriting the
  shared size field.
* It prevents the structure to be moved to read-only memory.

Introduce a new dedicated callback to calculate the size of the
attribute.

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-2-71110628844c@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/sysfs/group.c
include/linux/sysfs.h