Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Thomas Weißschuh and committed by
Greg Kroah-Hartman
5ab5a377 e62fedef

+3 -16
+3 -16
kernel/kheaders.c
··· 29 29 extern char kernel_headers_data[]; 30 30 extern char kernel_headers_data_end[]; 31 31 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); 48 34 49 35 static int __init ikheaders_init(void) 50 36 { 37 + kheaders_attr.private = kernel_headers_data; 51 38 kheaders_attr.size = (kernel_headers_data_end - 52 39 kernel_headers_data); 53 40 return sysfs_create_bin_file(kernel_kobj, &kheaders_attr);