Skip to content

Commit 5ab5a37

Browse files
t-8chgregkh
authored andcommitted
kheaders: Simplify attribute through __BIN_ATTR_SIMPLE_RO()
The utility macro from the sysfs core is sufficient to implement this attribute. Make use of it. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20241221-sysfs-const-bin_attr-kheaders-v2-1-8205538aa012@weissschuh.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e62fede commit 5ab5a37

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

kernel/kheaders.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,12 @@ asm (
2929
extern char kernel_headers_data[];
3030
extern char kernel_headers_data_end[];
3131

32-
static ssize_t
33-
ikheaders_read(struct file *file, struct kobject *kobj,
34-
struct bin_attribute *bin_attr,
35-
char *buf, loff_t off, size_t len)
36-
{
37-
memcpy(buf, &kernel_headers_data[off], len);
38-
return len;
39-
}
40-
41-
static struct bin_attribute kheaders_attr __ro_after_init = {
42-
.attr = {
43-
.name = "kheaders.tar.xz",
44-
.mode = 0444,
45-
},
46-
.read = &ikheaders_read,
47-
};
32+
static struct bin_attribute kheaders_attr __ro_after_init =
33+
__BIN_ATTR_SIMPLE_RO(kheaders.tar.xz, 0444);
4834

4935
static int __init ikheaders_init(void)
5036
{
37+
kheaders_attr.private = kernel_headers_data;
5138
kheaders_attr.size = (kernel_headers_data_end -
5239
kernel_headers_data);
5340
return sysfs_create_bin_file(kernel_kobj, &kheaders_attr);

0 commit comments

Comments
 (0)