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.

sysfs: constify bin_attribute argument of sysfs_bin_attr_simple_read()

Most users use this function through the BIN_ATTR_SIMPLE* macros,
they can handle the switch transparently.
Also adapt the two non-macro users in the same change.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Reviewed-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Tested-by: Aditya Gupta <adityag@linux.ibm.com>
Link: https://lore.kernel.org/r/20241228-sysfs-const-bin_attr-simple-v2-1-7c6f3f1767a3@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Thomas Weißschuh and committed by
Greg Kroah-Hartman
3675a926 92d6254f

+5 -5
+1 -1
arch/powerpc/platforms/powernv/opal.c
··· 818 818 sysfs_bin_attr_init(attr); 819 819 attr->attr.name = name; 820 820 attr->attr.mode = 0400; 821 - attr->read = sysfs_bin_attr_simple_read; 821 + attr->read_new = sysfs_bin_attr_simple_read; 822 822 attr->private = __va(vals[0]); 823 823 attr->size = vals[1]; 824 824
+1 -1
fs/sysfs/file.c
··· 817 817 * Returns number of bytes written to @buf. 818 818 */ 819 819 ssize_t sysfs_bin_attr_simple_read(struct file *file, struct kobject *kobj, 820 - struct bin_attribute *attr, char *buf, 820 + const struct bin_attribute *attr, char *buf, 821 821 loff_t off, size_t count) 822 822 { 823 823 memcpy(buf, attr->private + off, count);
+2 -2
include/linux/sysfs.h
··· 511 511 int sysfs_emit_at(char *buf, int at, const char *fmt, ...); 512 512 513 513 ssize_t sysfs_bin_attr_simple_read(struct file *file, struct kobject *kobj, 514 - struct bin_attribute *attr, char *buf, 514 + const struct bin_attribute *attr, char *buf, 515 515 loff_t off, size_t count); 516 516 517 517 #else /* CONFIG_SYSFS */ ··· 774 774 775 775 static inline ssize_t sysfs_bin_attr_simple_read(struct file *file, 776 776 struct kobject *kobj, 777 - struct bin_attribute *attr, 777 + const struct bin_attribute *attr, 778 778 char *buf, loff_t off, 779 779 size_t count) 780 780 {
+1 -1
kernel/module/sysfs.c
··· 196 196 nattr->attr.mode = 0444; 197 197 nattr->size = info->sechdrs[i].sh_size; 198 198 nattr->private = (void *)info->sechdrs[i].sh_addr; 199 - nattr->read = sysfs_bin_attr_simple_read; 199 + nattr->read_new = sysfs_bin_attr_simple_read; 200 200 ++nattr; 201 201 } 202 202 ++loaded;