aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/group.c
diff options
context:
space:
mode:
authorThomas Weißschuh <[email protected]>2024-11-03 17:03:31 +0000
committerGreg Kroah-Hartman <[email protected]>2024-11-05 13:00:28 +0000
commitbebf29b18f34620e25f7e2bd9e4e4d8e34a8977d (patch)
treec18a29612d16c0c23471702f3023e093c1f9c100 /fs/sysfs/group.c
parentsysfs: explicitly pass size to sysfs_add_bin_file_mode_ns() (diff)
downloadkernel-bebf29b18f34620e25f7e2bd9e4e4d8e34a8977d.tar.gz
kernel-bebf29b18f34620e25f7e2bd9e4e4d8e34a8977d.zip
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 <[email protected]> Acked-by: Krzysztof Wilczyński <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
Diffstat (limited to 'fs/sysfs/group.c')
-rw-r--r--fs/sysfs/group.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 45b2e92941da..8b01a7eda5fb 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -98,6 +98,8 @@ static int create_files(struct kernfs_node *parent, struct kobject *kobj,
if (!mode)
continue;
}
+ if (grp->bin_size)
+ size = grp->bin_size(kobj, *bin_attr, i);
WARN(mode & ~(SYSFS_PREALLOC | 0664),
"Attribute %s: Invalid permissions 0%o\n",