mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-14 17:53:39 +00:00
kernel/ksysfs.c: simplify bin_attribute definition
The notes attribute can be implemented in terms of BIN_ATTR_SIMPLE(). This saves memory at runtime and is a preparation for the constification of struct bin_attribute. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20241121-sysfs-const-bin_attr-ksysfs-v1-1-972faced149d@weissschuh.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e1a51c2bf4
commit
0f9e1f3a6e
@ -239,21 +239,7 @@ extern const void __start_notes;
|
||||
extern const void __stop_notes;
|
||||
#define notes_size (&__stop_notes - &__start_notes)
|
||||
|
||||
static ssize_t notes_read(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *bin_attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
memcpy(buf, &__start_notes + off, count);
|
||||
return count;
|
||||
}
|
||||
|
||||
static struct bin_attribute notes_attr __ro_after_init = {
|
||||
.attr = {
|
||||
.name = "notes",
|
||||
.mode = S_IRUGO,
|
||||
},
|
||||
.read = ¬es_read,
|
||||
};
|
||||
static __ro_after_init BIN_ATTR_SIMPLE_RO(notes);
|
||||
|
||||
struct kobject *kernel_kobj;
|
||||
EXPORT_SYMBOL_GPL(kernel_kobj);
|
||||
@ -307,8 +293,9 @@ static int __init ksysfs_init(void)
|
||||
goto kset_exit;
|
||||
|
||||
if (notes_size > 0) {
|
||||
notes_attr.size = notes_size;
|
||||
error = sysfs_create_bin_file(kernel_kobj, ¬es_attr);
|
||||
bin_attr_notes.private = (void *)&__start_notes;
|
||||
bin_attr_notes.size = notes_size;
|
||||
error = sysfs_create_bin_file(kernel_kobj, &bin_attr_notes);
|
||||
if (error)
|
||||
goto group_exit;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user