diff options
author | Thomas Weißschuh <linux@weissschuh.net> | 2024-12-21 15:09:34 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-12-24 09:46:49 +0100 |
commit | 5ab5a3778dd1745bafa426e5d6f7c71bf9e14d84 (patch) | |
tree | cef251881b1bf9faf896992ea5073fd05630e17f /kernel/kheaders.c | |
parent | e62fedef0aa51134b6848951dcd007fd9338705a (diff) | |
download | linux-5ab5a3778dd1745bafa426e5d6f7c71bf9e14d84.tar.gz linux-5ab5a3778dd1745bafa426e5d6f7c71bf9e14d84.tar.bz2 linux-5ab5a3778dd1745bafa426e5d6f7c71bf9e14d84.zip |
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>
Diffstat (limited to 'kernel/kheaders.c')
-rw-r--r-- | kernel/kheaders.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/kernel/kheaders.c b/kernel/kheaders.c index 42163c9e94e5..378088b07f46 100644 --- a/kernel/kheaders.c +++ b/kernel/kheaders.c @@ -29,25 +29,12 @@ asm ( extern char kernel_headers_data[]; extern char kernel_headers_data_end[]; -static ssize_t -ikheaders_read(struct file *file, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t len) -{ - memcpy(buf, &kernel_headers_data[off], len); - return len; -} - -static struct bin_attribute kheaders_attr __ro_after_init = { - .attr = { - .name = "kheaders.tar.xz", - .mode = 0444, - }, - .read = &ikheaders_read, -}; +static struct bin_attribute kheaders_attr __ro_after_init = + __BIN_ATTR_SIMPLE_RO(kheaders.tar.xz, 0444); static int __init ikheaders_init(void) { + kheaders_attr.private = kernel_headers_data; kheaders_attr.size = (kernel_headers_data_end - kernel_headers_data); return sysfs_create_bin_file(kernel_kobj, &kheaders_attr); |